Main Content

Generate Structured Text Code for Simulink Model That Has Fixed-Point Data Types

This example shows how to generate structured text code for a Simulink® model that has fixed-point data types by using Simulink® PLC Coder™.

Model Description

The model consists of a subsystem block that performs mathematical operations and delays on the inputs to the subsystem block. Open the model:

load_system('plcdemo_fixed_point');
open_system('plcdemo_fixed_point/Subsystem');

fixed_point_subsystem.png

Generate Code

To generate structured text code for the subsystem, do one of the following:

  • Open the PLC Coder app. Select the Subsystem block and click Generate PLC Code.

  • Use the plcgeneratecode function:

plcgeneratecode('plcdemo_fixed_point/Subsystem');
### Generating PLC code for 'plcdemo_fixed_point/Subsystem'.
### Using model settings from 'plcdemo_fixed_point' for PLC code generation parameters.
### Begin code generation for IDE step7.
### Emit PLC code to file.
### Creating PLC code generation report plcdemo_fixed_point_codegen_rpt.html.
### PLC code generation successful for 'plcdemo_fixed_point/Subsystem'.
### Generated files:
plcsrc/plcdemo_fixed_point/plcdemo_fixed_point.scl

See Also