How to access model's variables on Raspberry Pi after model has been deployed to target hardware

3 次查看(过去 30 天)
I am using Matlab R2020b and have a Raspberry Pi 4 Model B. I flashed the Pi's SD-card with "mathworks_raspbian_R20.2.3.zip".
I have a model that I can run on the Raspberry Pi by choosing the Raspberry Pi in the Hardware Settings and then either clicking "Build, Deploy & Start" or "Monitor & Tune". Both works fine.
However, I would now like to have more control over the program that is now running on the Pi. For example, I would like to access certain variables' values so that I can send this data to a small LCD-Display connected to the Pi.
My question therefore is: Where do I find and how do I access (on the Raspberry) variables from my Simulink model when it is executed on the Raspberry Pi?
Background to this question ist, that Simulink's library browser has not all the Raspberry Pi blocks that I need. For example, I would like to use a small display but I cannot control it with any of the Simulink blocks because this block just doesn't exist. Apparently, you can build your own block (S-Function) and then integrate it to your Simulink Model. However, I am not very experienced with that and would like to find an alternative way. As the alternative, I would like to devide my project into two parts:
1) Build & deploy the model on the Raspberry Pi (as usual)
2) Having the Raspberry now run standalone and access variables (with a program on the Raspberry) from the model to send them to other applications
Additionally, the following questions are related to my problem, so if anyone has answers to them, I am sure that would be of great help as well:
  • What exactly happens, when I press "Build, Deploy & Start"? Which file is executed on the Pi and with which program?
  • In case I would already be able to extract a variable from a Simulink model that is running on Raspberry Pi: How could I display it on the Raspberry GUI (like the Scope in Simulink).
Thank you very much for your help!

回答(1 个)

Ashutosh Thakur
Ashutosh Thakur 2023-12-15
Hi Leander,
I undertand that you require some information regarding certain processes of Simulink with Raspberry Pi.
You can find some suggestions regarding your queries below:
  1. Where do I find and how do I access variables from my Simulink model on the Raspberry Pi?
  • When you deploy a Simulink model to the Raspberry Pi, it does not provide an easy way to directly access the internal variables from outside the model. However, you can use the Simulink blocks designed for external communication (like UDP, TCP/IP, MQTT, etc.) to send data from your model to other applications or services running on the Raspberry Pi or elsewhere.
2. What happens when you press "Build, Deploy & Start"?
  • Build option generates C++ code from your model (using Simulink Coder). Deploy option transfers the compiled executable and any necessary files from the Simulink to the Raspberry Pi. Start option runs the executable on the Raspberry Pi.
3. Which file is executed on the Pi and with which program?
  • The executable file that is generated has the same name as your Simulink Model in the location where the model has been built and it is executed on Raspberry Pi Operating System.
The following documentation link would provide more information regrading MATLAB support for Raspberry PI:
I hope the above information helps you in resolving your queries.

类别

Help CenterFile Exchange 中查找有关 Run on Target Hardware 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by