Can I change variables directly in the C-Code I generated with Simulink Coder?

3 ビュー (過去 30 日間)
Nils Henke
Nils Henke 2015 年 8 月 5 日
回答済み: Eshwar 2016 年 7 月 19 日
I generated C-Code from a Simulink model using Simulink Coder to run as a standalone on Raspberry Pi. Now I would like to change some of the constants I used for example in my gain blocks. To do that I need to find the constants in my C-Code, but I haven't yet. In my gain blocks are variables which normally reference to values in a .m-file when I simulate it with my PC. Is there any chance to find these variables in my C-Code? If yes, I expect that they don't have the same name I gave them in my Simulink-file.

採用された回答

Sebastian Castro
Sebastian Castro 2015 年 8 月 5 日
Assuming you're using default settings, you should be able to find all your parameter values in the modelName_data.c file in the source directory.
Note: If you don't see anything there, or you don't have that file, you should also make sure that in Configuration Parameters -> Optimization -> Signals and Parameters, you have "Inline Parameters" disabled.
- Sebastian
  2 件のコメント
Nils Henke
Nils Henke 2015 年 8 月 6 日
Thanks for your answer so far! I disabled "Inline Parameters" and generated the code again. I still have no modelName_data.c but found my variables declared in the modelName.h. Due to the fact that I haven't coded my .m-file where I reference values to my variables, should I code my .m-file with the Matlab Coder or can I just reference values to my varialbes directly in the modelName.c?
Sebastian Castro
Sebastian Castro 2015 年 8 月 6 日
That all seems fine -- the data probably just gets placed somewhere differently when you switch from the standard Simulink Coder target to the Raspberry Pi target. So, you can change the data declarations in the .h file and then recompile the code.
And no, you do not need to generate code from the MATLAB file containing parameters. When you generate code from a Simulink model, all the necessary data that it requires also becomes part of that code.
- Sebastiab

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

その他の回答 (1 件)

Eshwar
Eshwar 2016 年 7 月 19 日
hello, I am facing some problems in editing the generated C code from simulink coder. So, is there any book or some other source that you would like to recommend to help me with understanding and editing the C code.
P.S: I am trying to perform the HiL test for a certain Plant.
-- Eshwar

カテゴリ

Help Center および File ExchangeRaspberry Pi Hardware についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by