MATLAB Answers

Can i call Raspberry matlab commands in simulink

2 views (last 30 days)
Abdulkadir Eroglu
Abdulkadir Eroglu on 27 May 2016
Commented: Kurt Stewart on 16 May 2018
Hello,
With the support package for Raspberry Pi come in handy methods to acquire data from the Pi device. So i want to use the putFile, getFile and system methods, that can be used in matlab code in simulink, too. But when i try to instantiate a pi instance in a matlab function in simulink, i get a parsing error.
--------------------------------
The 'matlab.mixin.CustomDisplay' class does not support code generation.
Function 'raspi.m' (#76.3324.7682), line 110, column 9: "function obj = raspi(hostname, username, password, port)"
Launch diagnostic report.
--------------------------------------
I dont see another way than to implement matlab code in simulink, but it wont work. How can i use these methods in simulink?
thanks in advance:)

  0 Comments

Sign in to comment.

Answers (4)

Greg Drayer
Greg Drayer on 28 Feb 2018
Edited: Greg Drayer on 28 Feb 2018
At this time, the answer to the question is that MATLAB Raspberry Pi commands are not compatible for use inside the MATLAB Function block in Simulink. During Normal mode simulation, the APIs are trying to generate the corresponding C code, which is not supported as of today for MATLAB API for Raspberry Pi.
A workaround to this question is to make use of a custom Simulink block based on System Objects as follows:
1) Create a new Simulink System Object script as below:
2) Set the simulation mode to “Interpreted Execution as shown below:
3) Add initialization tasks in “setupImpl” method. Example: Create a raspi object.
4) Add periodic code in “stepImpl” method. Example: Reading the status of GPIO pin using the raspi object created in setup method.
5) Save the script.
6) Create a Simulink block using Simulink Library Browser -> Simulink -> User Defined Functions -> MATLAB System. In the MATLAB System block, point to the created system object.
7) Try running the model in Normal mode Simulation mode.
For additional information about how to create Simulink blocks using system objects, please visit the following documentation page:

  1 Comment

Kurt Stewart
Kurt Stewart on 16 May 2018
Tried this workaround for Beaglebone Black and it doesnt seem to work

Sign in to comment.


wilmer sarango
wilmer sarango on 12 Dec 2017
Hello, did you find a solution for this? I also have the same problem, please help!

  0 Comments

Sign in to comment.


Abdulkadir Eroglu
Abdulkadir Eroglu on 12 Dec 2017
Well, yes and no...
We found a way around the problem, instead of running a simulink model with matlab code in it, we:
1. started a matlab code to access the pi,
2. handed over the accessed to simulink model, that is started by the m-file
3. did our stuff in simulink
4. handed the signals back to matlab
5. then pushed the "new" data onto the pi.
Maybe it helps you:) and good luck with it. Luckily I found our documentation on the issue, its been too long to remember!

  0 Comments

Sign in to comment.


Kurt Stewart
Kurt Stewart on 16 May 2018
this same issue exists with beaglebone black as there are no blocks that run useful peripherals such as SPI

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!