Fixed Point Simulink PLC Coder Structured Text Code Generation
Block Parameters
At the MATLAB command prompt, enter:
openExample('plcdemo_fixed_point');
If the block in the subsystem has a Signal Attributes tab, navigate to that tab and jump to step 3.
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.
For the Integer rounding mode parameter, select
Round
.Clear the Saturate on integer overflow check box.
For the Output data type parameter, select a fixed-point data type.
Click the Data Type Assistant button.
For the Word length parameter, enter
8
,16
, or32
.For the Mode parameter, select
Fixed point
.For the Scaling parameter, select
Binary point
.Click OK.
Model Parameters
In the Model Configuration Parameters dialog box, click the
Hardware Implementation
node.For the Device vendor parameter, select
Generic
orCustom Processor
. If you selectCustom Processor
proceed to step 4.For the Device type, select
Custom
.For the Signed integer division rounds to, select
Zero
.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.
If you disable the Saturate on overflow, Wrap on overflow, or Detect precision loss warnings, verification failures the generated structured text code due to overflow or precision loss cannot be identified. For more information, see Data Validity Diagnostics Overview.
You are now ready to: