Why do I get an error regarding tunable parameter and real32_T/real_T when generating PLC code?
21 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 18 Juil 2019
Modifié(e) : MathWorks Support Team
le 9 Août 2022
I encounter the following error in my model when generating PLC code using MATLAB R2018b through R2019b:
Simulink block 'MyModel/TestBlock' that consumes tunable parameter Param1 has datatype real32_T, however
the values it contains are of type real_T.
Or from R2020a:
Invalid data type. The 'MyModel/TestBlock' block that consumes tunable parameter Param1 expects real32_T
datatype. However the parameter values are of type real_T. Use a typed expression, such as single(21.1)
to set the value property of the parameter.
My parameter 'Param1' already has been defined to have 'single' data type.
Réponse acceptée
MathWorks Support Team
le 9 Août 2022
Modifié(e) : MathWorks Support Team
le 9 Août 2022
This is an expected conformance check performed by Simulink PLC Coder. It occurs because there is a mismatch between the specified data type 'single' (real32_T) and the provided value which defaults to 'double' (real_T) in MATLAB/Simulink.
If the parameter is a Simulink.Parameter, define the value as shown below and verify the data type of the value:
>> testVariable.Value=single(1.234)
>> class(testVariable.Value)
ans =
'single'
If the parameter is defined in a Data Dictionary, make sure to explicitly cast the value of the parameter to single as shown below:
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Simulink PLC Coder dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!