Using Simulink to run a portion of a model on hardware in external mode

10 views (last 30 days)
I am trying to use a raspberry pi to run only a section of a Simulink model. It is now running in an external mode simulation on the raspberry pi but this runs all of the model on the hardware. I am trying to figure out the best way to have the hardware run a portion of the code and have this send information to a second Simulink simulation, and vice versa, in real time.
Some of what I have tried is saving to the base workspace from the external mode simulation but it seems like in external mode the Simulation can not save to the workspace in real time using a MATLAB function block with the assignin() function. Can you use the base workspace as a way to share values between the model on the hardware and the model on the computer as they are running?
I tried using a referenced model but it did not have external mode as a simulation mode. It did have PIL and SIL but with these there is an error that says the model is not derived from an ERT or GRT system target file. Can you run a referenced model in external mode on a raspberry pi?
  2 Comments
Ned
Ned on 8 Apr 2021
Hi Michael,
PIL will be suitable solution for you.
Can you please provide more info regarding the error message in your PIL workflow?
-Reeno
Michael Ciriacy
Michael Ciriacy on 30 Apr 2021
I was trying use a referenced model in PIL simulation mode to run a section of a larger model on the hardware. Using the way in that example I was able to run only a section of the model on the raspberry pi. Would there be any reason to use a referenced model instead of the way that the example makes the PIL block from the model?
The start of the error that I get when trying to use a referenced model is:
An error occurred while calling into the SIL or PIL target connectivity implementation.
Caused by:
  • Error executing command "touch -c /home/pi/MATLAB_ws/R2020b/C/Users/Mike/MATLAB/Projects/Project/Hardware_Testing/raspi_full_CPmodel/PIL_error/slprj/ert/control_sub/pil/*.*;make -f control_sub.mk all MATLAB_WORKSPACE="/home/pi/MATLAB_ws/R2020b" -C /home/pi/MATLAB_ws/R2020b/C/Users/Mike/MATLAB/Projects/Project/Hardware_Testing/raspi_full_CPmodel/PIL_error/slprj/ert/control_sub/pil". Details: STDERR: /home/pi/MATLAB_ws/R2020b/C/Users/Mike/MATLAB/Projects/Project/Hardware_Testing/raspi_full_CPmodel/PIL_error/slprj/ert/control_sub/pil/xil_interface.c: In function ‘xilInitialize’: /home/pi/MATLAB_ws/R2020b/C/Users/Mike/MATLAB/Projects/Project/Hardware_Testing/raspi_full_CPmodel/PIL_error/slprj/ert/control_sub/pil/xil_interface.c:434:44: error: incompatible type for argument 2 of ‘control_sub_initialize’ control_sub_initialize(rt_errorStatus, rt_solverInfo, timingBridge,
The model also does run slowly when it is running with the PIL method that the example shows. Is there any way that you know of to try and speed up a model that is using PIIL?
My goal is to run part of the model on the hardware and have it interface with the rest of the model on a computer or on other hardware. It does not matter if it is done using PIL if there is a better or faster way to have only a section of the Simulink model running on the hardware.

Sign in to comment.

Answers (0)

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!