Main Content

Generating Simulink PLC Coder Structured Text Code for Multirate Models

Multirate Model Requirements for PLC Code Generation

Open the plcdemo_multirate model. To open the model, enter:

Once the demo model opens up follow the instructions below to configure the model for Structured Text code generation:

Model Configuration Parameters

Before generating Structured Text from a multirate model, you must configure the model as follows:

  • Solver options that are recommended or required for PLC code generation:

    • Type:Fixed-step.

    • Solver:Discrete(no continuous states). Other fixed-step solvers could be selected, but this option is usually best for simulating discrete systems.

    • Tasking mode: Must be explicitly set to Single Tasking. Do not set Tasking modeto Auto

  • Change any continuous time input signals in the top level subsystem to use discrete fixed sample times.

  • 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.

When you deploy code generated from a multirate model, you must run the code at the fundamental sample rate.


The B&R Automation Studio® does not support structured text code generation from multirate models.

You are now ready to: