Raspberry Pi I/O with SIMULINK Model in real-time
31 views (last 30 days)
I have a prototype program written in C that runs on the Raspberry Pi 4B. It reads sensors values from some GPIO pins and writes valve actuation commands to other GPIO pins.
I have created a SIMULINK model of the plant that the software is supposed to control. I'm setting up the connection between the RPi and my computer using the support package provided by MATLAB and SIMULINK.
The question I have is:
How would I make the SIMULINK model interact with the Raspberry Pi in real-time? i.e. Send sensor values to the Pi and accept actuation signal from the Pi.
Any help is appreciated. Thank you!
Prasanth Sunkara on 14 Oct 2020
You can deploy the entire plant software model + Raspberry Pi GPIO blocks to raspberry pi using one of the below two workflows
1) Standalone deployment workflow --> https://www.mathworks.com/help/supportpkg/raspberrypi/ug/create-and-run-an-application-on-raspberry_pi-hardware.html
2) Monitor & Tune workflow --> https://www.mathworks.com/help/supportpkg/raspberrypi/ug/remotely-monitoring-and-controlling-an-application-on-hardware.html
Alternatively, if you just want to check how your algorithm(or plant software model in your case) works with real hw data, you may want to use "Simulink Connected I/O workflow". In this approach, the model does not get deployed onto the hardware, rather Raspberry Pi Simulink blocks communicate with the hw for all I/O needs and brings that data to your host PC which is running your simulink model. This way you can see how your plant behaves with real sensor and actuator data.
For more info on Connected I/O workflow, please see the below page.
You might also find the below image processing example with connected i/o helpful.