Main Content

Generate Structured Text Code for a Simple Simulink® Subsystem

This example shows how to select the target IDE for a Simulink® model, generate code, and view generated files.

1. Open model plcdemo_simple_subsystem and save a copy to a writable location.

2. Open the Simulink PLC Coder app.

3. Open the PLC Code Generation dialog box.. In the Target IDE select 3S CoDeSys 2.3.

Click OK

4. Select the SimpleSubsystem block and click Generate PLC Code. Alternatively, from the command line, enter:

generatedfiles = plcgeneratecode('plcdemo_simple_subsystem/SimpleSubsystem');

5. View the code generation report.

The report includes links to the generated code file plcdemo_simple_subsystem.exp and associated traceability and code metrics reports.

6. This figure contains the generatecode plcdemo_simple_subsystem.exp.