Why do I get an error regarding tunable parameter and real32_T/real_T when generating PLC code?
22 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 18 de Jul. de 2019
Editada: MathWorks Support Team
el 9 de Ag. de 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.
Respuesta aceptada
MathWorks Support Team
el 9 de Ag. de 2022
Editada: MathWorks Support Team
el 9 de Ag. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Simulink PLC 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!