Why do I get an error regarding tunable parameter and real32_T/real_T when generating PLC code?
21 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2019 年 7 月 18 日
編集済み: MathWorks Support Team
2022 年 8 月 9 日
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.
採用された回答
MathWorks Support Team
2022 年 8 月 9 日
編集済み: MathWorks Support Team
2022 年 8 月 9 日
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Simulink PLC Coder についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!