Tunable parameters in Simulink code generation

9 visualizaciones (últimos 30 días)
Itservices
Itservices el 13 de Abr. de 2018
Respondida: Akshat Dalal el 7 de Oct. de 2024
I am making an S-Function with mask parameters and want to generate C code for this block. All S-Function parameters should be tunable. Currently I declared the parameters as tunable via ssSetSFcnParamTunable(S, PARAM_P0_IDX, SS_PRM_TUNABLE); and ssRegAllTunableParamsAsRunTimeParams. I also verified that the parameters show up in the model.rtw file. However, in code generation the parameters are still inlined (i.e., I see 1.0f instead of myDataStruct.myParam).
I tried the sfcndemo_runtime example and see the same behavior. Only when the mask parameters are declared in the base workspace, they become tunable. The S-Function I am making will be used in a library block and I expect there to be multiple instances of this block. Therefore declaring the workspace variables automatically will be error-prone. The generated code will not be functional when (some) parameters are inlined, and I don't want to make the user responsible for declaring these workspace variables.
Is there a way to get tunable parameters in the generated code without declaring corresponding variables in the base workspace?

Respuestas (1)

Akshat Dalal
Akshat Dalal el 7 de Oct. de 2024
Hi,
You can declare the variales in Model Workspace of the library block. This way, it will be distinct for each instance of the block. You can have a look the following docuementation for more information: https://www.mathworks.com/help/rtw/ug/configure-data-accessibility-for-rapid-prototyping.html

Categorías

Más información sobre Simulink Coder en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by