Why do I get an error regarding tunable parameter and real32_T/real_T when generating PLC code?

조회 수: 22 (최근 30일)
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
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개)

카테고리

Help CenterFile Exchange에서 Simulink PLC Coder에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by