This step is only required if your Simulink® model contains multi-rate signals. If your Simulink model does not contain multi-rate signals, you may proceed to solver selection.
Simulink PLC Coder™ only generates code for single-tasking subsystems. For multi-rate subsystems, you must first explicitly set the tasking mode to single-tasking before selecting a solver. In the model configuration, on the Solver pane, clear the check box for Treat each discrete rate as a separate task.
Choose a solver for your Simulink PLC Coder model.
|Variable-step||Use a continuous solver. Configure a fixed sample time for the subsystem for which you generate code.|
|Fixed-step||Use a discrete fixed-step solver.|
You must already have a model for which you want to generate and import code to a PLC IDE. Before you use this model, perform the following steps.
In the Command Window, open your model.
Configure the model to use the fixed-step discrete solver. Click the solver link in
the lower-right corner. The Solver information pane opens. In the
pane, click the View solver settings button to open the
Solver pane of the model configuration parameters. Under the
Solver selection, set Type to
Fixed-step and Solver to
If your model uses a continuous solver, has a subsystem, configure a fixed sample time for the subsystem for which you generate code.
Save this model as
Create a subsystem containing the components for which you want to generate Structured Text code.
Y respectively. This operation results in
a subsystem like the following figure:
Save the model with the new subsystem.
In the top-level model, right-click the Subsystem block and select Block Parameters (Subsystem).
In the resulting block dialog box, select Treat as atomic unit.
Simulate your model.
Save your model. In later procedures, you can use either this model, or the
plcdemo_simple_subsystem model that comes with your
You are now ready to:
Set up your subsystem to generate Structured Text code. See Check System Compatibility for Structured Text Code Generation.
Generate Structured Text code for your IDE. See Generate and Examine Structured Text Code.
You must already have a model that you have configured to work with the Simulink PLC Coder software.
In your model, navigate to the subsystem for which you want to generate code.
Right-click that Subsystem block and select PLC Code > Check Subsystem Compatibility.
The coder checks whether your model satisfies the Simulink PLC Coder criteria. When the checking is complete, a View diagnostics hyperlink appears at the bottom of the model window. Click this hyperlink to open the Diagnostic Viewer window.
If the subsystem is not atomic, right-click the Subsystem block and select PLC Code, which prompts Enable “Treat as atomic unit” to generate code.
This command opens the block parameter dialog box. Select Treat as atomic unit.
You are now ready to generate Structured Text code for your IDE. See Generate and Examine Structured Text Code.