This topic assumes that you have generated Structured Text code from a Simulink® model. If you have not yet done so, see Generate Structured Text from the Model Window.
The example in this topic shows generated code for the CoDeSys Version 2.3 IDE. Generated code for other IDE platforms looks different.
If you do not have the plcdemo_simple_subsystem.exp
file
open, open it in the MATLAB® editor. In the folder that contains
the file, type:
edit plcdemo_simple_subsystem.exp
A file like the following is displayed.
The following figure illustrates the mapping of the generated
code to Structured Text components for a simple Simulink subsystem.
The Simulink subsystem corresponds to the Structured Text function
block, Subsystem
.
The coder maps alias data types to the base data type in the generated code.
Inspect this code as you ordinarily do for PLC code. Check the generated code.
The Simulink model for plcdemo_simple_subsystem
does
not contain signal names at the input or output of the SimpleSubsystem
block.
So the generated code has the port names U
and Y
as
the input and output variable names of the FUNCTION_BLOCK
.
However, even if your model does contain signal names, coder only
uses port names in the generated code.