Raspberry Pi Simulink Driver Blocks ADC DAC PWM

Driver blocks allowing Simulink models to interface with PWM, MCP3008/ADS1115 ADC, MCP4725 DAC
4.1K Downloads
Updated Thu, 18 Jun 2015 11:27:24 +0000

View License

Support for the Raspberry Pi beyond toggling GPIO. Joshua Hurst did some good work creating these blocks: http://uk.mathworks.com/matlabcentral/fileexchange/41529-raspberry-pi-pwm-driver-block-sfunction but there were a number of errors/steps lacking to get them compiling and working on a Raspberry Pi.
Uncomment or copy into another Raspberry Pi model the blocks you wish to use.
# Usage
* You must open the S-Function driver block and click 'Build' to generate the
embedded coder files otherwise you will receive an error 'sfcn\_.... does
not exist'.
* If using the ADS1115 and MCP4725 you will require my fork of wiringPi:
https://github.com/tuna-f1sh/wiringPi-mcp4725 see the README for
installation instructions.
* If using the PWM block, you will need to enable SPI in Raspbian - see: http://uk.mathworks.com/help/supportpkg/raspberrypiio/examples/analog-input-using-spi.html or enable via SSH.
* The scopes work in real-time on the Pi to see the correct data is going
to/coming from blocks.
* The discrete timestep is set to 'Ts' throughout the model. This is
initialised as 1e-3s at model load - it seems to be the sweet spot for
performance/usage. Remember to consider quantisation that this can create
with signals driving the blocks.

# Notes

* wiringPi softPWM:
https://projects.drogon.net/raspberry-pi/wiringpi/software-pwm-library/
* Do not sure both ADC blocks at once without changing the wiringPi 'pin'
assignment - it won't work.
* See the post on my blog explaining how these work: http://wp.me/p2C0Bi-bK

# Install wiringPi Fork

1. Login to the Pi via SSH.
2. `git clone https://github.com/tuna-f1sh/wiringPi-mcp4725`
3. `cd wiringPi-mcp4725`
4. `./build`

www.jbrengineering.co.uk - @j_whittington - 2015

Cite As

John Whittington (2024). Raspberry Pi Simulink Driver Blocks ADC DAC PWM (https://www.mathworks.com/matlabcentral/fileexchange/51232-raspberry-pi-simulink-driver-blocks-adc-dac-pwm), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Simulink Supported Hardware in Help Center and MATLAB Answers
Communities

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

rpi-driver-blocks/

Version Published Release Notes
1.0.0.0

Added link to my blog
Forgot link again....