Deploy Structured Text
Using Simulink PLC Coder, you can generate structured text and test bench code, and then import the generated code into the target IDE.
Learning Objectives
In this tutorial you learn how to:
Open the
plcdemo_simple_subsystem
model and prepare the model for code generation.Verify the code that you generated.
Automatically or manually import your generated code into your target IDE.
Prerequisites
Simulink® PLC Coder™
Target IDE folder location (for automatic import).
Workflow
Open the
plcdemo_simple_subsystem
model. To open the model, enter:openExample('plcdemo_simple_subsystem');
Open the model settings and set Solver Selection to
Fixed-step
and Solver todiscrete(no continuous states)
.If your target IDE is in the PLC IDEs for Importing Code Automatically , see Generate and Automatically Import Structured Text Code. Otherwise , see Importing Generated Structured Text Code Manually
Importing Generated Structured Text Code Manually
If your target IDE does not automatically import generated code:
Right-click the Subsystem block and select PLC Code > Options.
The Configuration Parameters dialog box is displayed.
On the PLC Code Generation pane, select an option from the Target IDE list, for example,
CODESYS 2.3
.The default Target IDE list displays the full set of supported IDEs. To see a reduced subset of the target IDEs supported by Simulink PLC Coder, disable the option Show full target list. To customize this list, use the
plccoderpref
function.Click Apply.
Click Generate code.
This button:
Generates Structured Text code (same as the PLC Code > Generate Code for Subsystem option)
Stores generated code in
(for example,model_name
.expplcdemo_simple_subsystem.exp
)
When code generation is complete, a View diagnostics hyperlink appears at the bottom of the model window. Click this hyperlink to open the Diagnostic Viewer window.
This window has links that you can click to open the associated files. For more information, see Files Generated by Simulink PLC Coder.
To import generated code into your target IDE import the generated files manually into your target IDE.