Parameter and constant management for embedded coder

24 ビュー (過去 30 日間)
Brice Balleux
Brice Balleux 2022 年 9 月 26 日
コメント済み: Benjamin Thompson 2022 年 10 月 4 日
Hello,
I'm currently working on Simulink model & embedded coder. In my model I have several submodules. I would like to use them as function in a C++ code. To do so I have selected "treat as atomic unit" & function packaging as "reusable function". In my model I have parameters (variable stored in my workspace) and I set the default parameter behavior as "tunable" because I want to be able to change them in my code. Functions are well generated but I've noticed that constant values ( for example a gain of 3.6 for km/h to m/s conversion ) are stored in a specific structure and this structure is passed in argument of my function.
I would like to have my parameters to be tunable but those constant to be inlined in order to don't have those constant passed in argument of my function.
How can I do this?

採用された回答

Benjamin Thompson
Benjamin Thompson 2022 年 9 月 26 日
You should look over the examples included for Embedded Coder. There are some dealing with tunable parameters. Usually you need to have a Simulink.Parameter object defined in either the model data dictionary, the model workspace, or the base workspace. The Simulink.Parameter object has a field called "Storage class" that is available if you have a Coder license where you can change it from Auto if you want a certain way to pass the parameter to the model. Then you must use the parameter name on a block somewhere in the model--rather than hard coded numbers.
  2 件のコメント
Brice Balleux
Brice Balleux 2022 年 10 月 4 日
Hello,
Sorry for the late answer and thank you for your answer.
I already use Simulink.Parameter object for my parameters that I want to be tunable so do you mean I must use Simulink.Parameter object even for "constant" numbers (like the number "3.6" for speed unit convertion) to be able to tell embedded coder to inlined those "constant" numbers?
Benjamin Thompson
Benjamin Thompson 2022 年 10 月 4 日
If you use Simulink.Parameter you have many choices in the "Storage class" for how Embedded Coder treats it. You probably want to select "Const" for parameter that you want to be inlined.
But if you always want the parameter inlined and do not care about using Simulink.Parameter, you can just put the number directly into the Simulink block.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDeployment, Integration, and Supported Hardware についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by