Main Content

Structured Text Code Generation Limitations

General 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 messages

  • Limited support for math functions

  • Merge block

  • Step block

  • Clock block

  • 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

  • MATLAB® classes.

  • The Simulink.CoderInfo Identifier name property with Simulink.Parameter and Simulink.Signal objects.

  • The Simulink.LookupTable, Simulink.Breakpoint, and Simulink.DualScaledParameter objects.

  • Code generation for Simulink signals that do not resolve to a Simulink.Signal data store memory object.

  • Code generation when UseRowMajorAlgorithm='on'.

  • The use of enum datatype 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 Simulink.Signal mappings.

  • 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.

Restrictions

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 NaN or Inf.

  • Does not support MATLAB 64-bit integer data types.

Negative Zero

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 rdivide, atan2, atan2d, and angle. Division by 0 produces Inf, but division by -0 produces -Inf. Similarly, atan2d(0,-1) produces 180, but atan2d (-0,-1) produces -180.

Simulink PLC Coder stores -0 as 0 because there is no representation of -0 in IEC61131.This leads to division by -0 producing -Inf in Simulink, but Inf in PLC IDE. Similarly, atan2d(-0,-1) produces -180 in Simulink, but 180 in PLC IDE as the -0 is converted to 0.

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 generation.

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 Inputs and Outputs.