Simulink Custom Storage Class "Importeddefine"

7 visualizzazioni (ultimi 30 giorni)
Andreas
Andreas il 28 Gen 2011
I have a headerfile (params.h) with some defines (#define test_param 22) and want to use/import this in a Simulink model (ERTW). I add a Simulink.Parameter and assign "ImportedDefine (Custom)" as Storage Class and add "params.h" to the "Custom attributes -> Header file". How can I use this "test_param" in the model (it does not work with a constant / gain block) ?
  2 Commenti
Kaustubha Govind
Kaustubha Govind il 28 Gen 2011
Hi Andreas,
Do you see an error when you use the parameter with a gain block? Could you post the error?
~K
Andreas
Andreas il 31 Gen 2011
I named the Simulink.Parameter "test_param" and put this string in the field "gain" of the gain block. If I assign no value to "test_param" I get the error "Invalid setting in 'mymodel/Gain' for parameter 'Gain'". If I assign a value to "test_param" the model uses this value (without an error) but does not import the value from the #define in the specified header file.
Also same behaviour with a constant block.

Accedi per commentare.

Risposte (1)

MarkB
MarkB il 31 Gen 2011
Basically, Simulink itself doesn't use header files, but compilers do. Thus, in this case the "Simulink.Parameter"'s job is essentially to describe the content of the header file for simulation. As a result, the ".Value" field that you use in your "Simulink.Parameter" object is the number that Simulink will use when you press the "play" button.
However, when you generate code, the data object will cause a "#include" statement to appear in the generated code, and the code will use (but not define or declare) the name "test_param", expecting the header file provide it.
Since the "Simulink.Parameter" is what is used for simulation, it is important to ensure that it accurately reflects what the header file will provide to the generated code (i.e. the numeric values should match).

Categorie

Scopri di più su Simulink Coder in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by