Structured Text Code Generation Limitations
The Simulink® PLC Coder™ software does not support:
Complex data types
String data types
Model reference blocks
Stateflow® machine-parented data and events
Stateflow empty chart output functions.
Limited support for math functions
Signal and state storage classes
Shared state variables between subsystems
For Each Subsystem block
Variable-size signals and parameters
MATLAB System block or system objects
Identifiername property with
Code generation for Simulink signals that do not resolve to a
Simulink.Signaldata store memory object.
Code generation when
The use of
enumdatatype numeric values for comparison inside model subsystem blocks. Use a data type conversion block to perform an enum to integer conversion, to perform the numeric comparison.
The use of special characters in comments. This could lead to errors when importing the generated code.
Signal lines named using
Half precision fixed-point data types.
Testbench generation for models using software-in-the-loop (SIL) simulation mode.
Testbench generation for models using processor-in-the-loop (PIL) simulation mode.
Non top-level Stateflow function call output events that call Simulink subsystems.
Half-precision data types.
Code generation inside subsystem reference blocks.
Code generation for nested subsystem reference blocks.
Code generation in folders that have the
Folder is ready for archivingoption enabled on the Windows® system prior to R2022a.
The structured text language has inherent restrictions. As a result, the Simulink PLC Coder software has these restrictions:
Supports code generation only for atomic subsystems.
Supports automatic, inline, or reusable function packaging for code generation. Nonreusable function packaging is not supported.
Does not support blocks that require continuous time semantics. This restriction includes integrator blocks, zero-crossing detection blocks, physical blocks, such as Simscape™ library blocks and so on.
Does not support pointer data types.
Does not support recursion (including recursive events).
Does not support nonfinite data, for example
Does not support MATLAB 64-bit integer data types.
In a floating-point data type, the value
0 has either a
positive sign or a negative sign. Arithmetically,
0 is equal to
-0, but some operations are sensitive to the sign of a 0
input. Examples include
angle. Division by
Inf, but division by
atan2d (-0,-1) produces
PLC Coder stores
0 because there is
no representation of
-0 in IEC61131.This leads to division by
-Inf in Simulink, but
Inf in PLC IDE. Similarly,
-180 in Simulink, but
180 in PLC IDE
-0 is converted to
Divide by Zero
In Simulink, division by zero produces either
Inf or the
largest number for the data type. In the Codesys target IDE, division by zero
results in a
-1. Code generation by using a testbench might
result in testbench verification failures due to a difference in results from divide
by zero operations.
Fixed-Point Data Type Multiword Operations
Simulink PLC Coder does not support code generation for block parameter settings
that require fixed-point data type multiword operations. For example, the square
root block that has int32 integer data type as input and output data type setting of
Inherit via internal rule is not supported for code
Inplace Variables Code Generation
Inplace argument semantics could be broken if the datatypes between inputs and
outputs differ in the number of dimensions. To fix the problem, set the input
variable size to
-1. For more information, see Declare Variable-Size MATLAB Function Block Variables.
Simulink Data Dictionary
Simulink PLC Coder does not support:
The mixed use of the base workspace and Simulink Data Dictionary (SLDD) files. Use the Simulink migration utility to migrate your entire base workspace to SLDD files.
Model workspace parameters and signals for code generation.
MATLAB variables in SLDD files for code generation. To generate code convert these variables to
Simulink.parameter types that have
StorageClass options other than
ImportedExtern are auto
StorageClass during code generation.