Raspberry Pi Simulink Driver Blocks ADC DAC PWM

バージョン (36.9 KB) 作成者: John Whittington
Driver blocks allowing Simulink models to interface with PWM, MCP3008/ADS1115 ADC, MCP4725 DAC

ダウンロード 3.9K 件

更新 2015/6/18


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:
* 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


John Whittington (2022). 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. 取得済み .

MATLAB リリースの互換性
作成: R2014b
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!