Main Content

Fixed Point Simulink PLC Coder Structured Text Code Generation

Block Parameters

At the MATLAB command prompt type plcdemo_fixed_point. Once the example model opens , follow these instructions to configure the model for Structured Text code generation.

  1. If the block in the subsystem has a Signal Attributes tab, navigate to that tab and jump to step 3.

  2. If there are no blocks in the subsystem with a Signal Attributes tab use the Data Type Conversion block. Add the Data Type Conversionblock to the model and continue to the next step.

  3. For the Integer rounding mode parameter, select Round.

  4. Clear the Saturate on integer overflow check box.

  5. For the Output data type parameter, select a fixed-point data type.

  6. Click the Data Type Assistant button .

  7. For the Word length parameter, enter 8, 16, or 32.

  8. For the Mode parameter, select Fixed point.

  9. For the Scaling parameter, select Binary point.

  10. Click OK.

Model Parameters

  1. In the Model Configuration Parameters dialog box, click the Hardware Implementation node.

  2. For the Device vendor parameter, select Generic or Custom Processor. If you select Custom Processor proceed to step 4.

  3. For the Device type, select Custom.

  4. For the Signed integer division rounds to, select Zero.

  5. For the Number of bits, set char to 16.

Limitations

  • 64 bit fixed-point data type not supported.

  • The data type and value type must match for fixed-point tunable parameters of type Simulink.Parameter.

  • Scaling parameter type Slope and bias is not supported for code generation.

You are now ready to: