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

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 件のコメント

Walter Roberson
Walter Roberson 2022 年 7 月 14 日
Are the file operations coded in terms of coder.ceval() ? File operations at the MATLAB level are not supported for deployment.
Bonyadi Arezoo
Bonyadi Arezoo 2022 年 7 月 14 日
Hi Walter, To your question, I should say, no, nothing. It's a very simple simulink model, I just want to write an array numerical data and then read it, while the speedgoat is connected to the simulink and giving output.
Bonyadi Arezoo
Bonyadi Arezoo 2022 年 7 月 14 日
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 2022 年 7 月 14 日
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.

サインインしてコメントする。

 採用された回答

Fangjun Jiang
Fangjun Jiang 2022 年 7 月 14 日
編集済み: Fangjun Jiang 2022 年 7 月 14 日

1 投票

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 件のコメント

Bonyadi Arezoo
Bonyadi Arezoo 2022 年 7 月 14 日
Dear F. Jiang,
thank you for your swift reply. So, just for sure, "Data Store Memory" block works online, yes?
Fangjun Jiang
Fangjun Jiang 2022 年 7 月 14 日
Change your MATLAB Function block code to remove those fprtinf() and fscanf() lines.
Implement your algorithm using the Data Store Memory/Read/Write block and try it on Speedgoat.
Sebastian K
Sebastian K 2022 年 7 月 14 日
Just a small correction: Speedgoat target machines are actually computers equipped with hard drives and other perhiperals.
Otherwise, I agree that Data Store Memory would be the best way to achieve what the asker is trying to do.
Bonyadi Arezoo
Bonyadi Arezoo 2022 年 7 月 14 日
Dear Jiang, and Sebastian,
I cannot thank you enough.
I am very near to get the goal based on your great suggestion. Just please let me know how I can configure the variable defined in a data store memory, with a variable size. Because the size of some of the variables changes. for instance, the array A size may change from (1,1) to the array (5,1) (Five rows, one column).
I could not find the setting location to do it.
Bonyadi Arezoo
Bonyadi Arezoo 2022 年 7 月 14 日
Indeed, I know the upper bound of the size. they are all five rows in one culomn. But perhaps they change to three rows in one column. only the rows change from 1 to 5.
Fangjun Jiang
Fangjun Jiang 2022 年 7 月 14 日
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 2022 年 7 月 15 日
Dear Jiang, Thanks to your advice, My issue was solved completely.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by