Real time, Matlab, SpeedGoat, Simulink, read write data, Solution?

7 views (last 30 days)
Hi,I'm using Simulink connected to speedgoat in a real time status. The simulink model includes a user defined block in which along with the main code, there are commands open, close fprintf, fscanf, in order to write/read some numerical data. The model is built correctly, but when the start application button is clicked the following error pops up "external mode open protocol start command failed". So, is there any other way by which we can enjoy write and read data while connected to speedgoat online. Mathwork expers, do you know how to solve this issue?
  4 Comments
Bonyadi Arezoo
Bonyadi Arezoo on 14 Jul 2022
There is no problem in the code generation process and C++ code can be generated correctly. Nevertheless, when the speedgoat is supposed to work, the connection is lost because I have used fopen, fprintf, suchlike commands to store and read data. The speedgoat does not support them. So, how to use similink while connected to speedgoat and we want to read/write data online? No one could solve this problem yet? It seems a high level of knowledge of Matlab and simulink is needed for addressing this issue.
Bonyadi Arezoo
Bonyadi Arezoo on 14 Jul 2022
Dear Walter, Let's make the issue simple and easy to understand. Assume that there is a simulink model where there is a user defined block. In this block an array is built, e.g. A=zeros(5,1), Now we want to store this array somewhere and whenever we needed it, it can be read, modified and then stored. An example of modification: A= A+1; So, as a whole the block is something like this,
% Initialization A=zeros(5,1); Store A If t==3 Read A A=A+1; Store A end
This is while our simulink model is connected to a speedgoat machine and the machine is supposed to work online.

Sign in to comment.

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 14 Jul 2022
Edited: Fangjun Jiang on 14 Jul 2022
To store runtime data like "A" in your example, use "Data Store Memory" block in your Simulink model. Use "Data Store Read" and "Data Store Write" block to read and write the data.
To log data for offline use, use "To Workspace" block or utilize signal logging.
  7 Comments
Fangjun Jiang
Fangjun Jiang on 14 Jul 2022
Data Store Memory block does not support variable size signal. See doc
You could declare the maximum size and fill the un-used with zeros.
Bonyadi Arezoo
Bonyadi Arezoo on 15 Jul 2022
Dear Jiang, Thanks to your advice, My issue was solved completely.

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!