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

  • Stateflow empty chart output functions.

  • Limited support for math functions

  • Step block

  • Clock block

  • Signal and state storage classes

  • Shared state variables between subsystems

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

  • Code generation in folders that have the Folder is ready for archiving option enabled on the Windows® system prior to R2022a.

  • Execution of callback functions during code generation. Before code generation, you must compile or simulate the model to execute the callback functions.

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

Simulink.parameter types that have StorageClass options other than ExportedGlobal and ImportedExtern are auto converted to ExportedGlobal StorageClass during code generation.

MITSUBISHI Data Type Limitations

When you generate code for the MITSUBISHI ELECTRIC MELSOFT GX Works3 target IDE and your model contains int8 or uint8 data types, Simulink PLC Coder converts int8 to int16, and uint8 to uint16. This data type conversion could lead to a difference between simulation results and run-time results. Simulink PLC Coder recommends that you do not use these unsupported data types in your model.