This example shows how to propose data types for a referenced model. To run this example, you must first run the "Log Simulation Minimum and Maximum Values for Referenced Models" example. See Log Simulation Ranges for Referenced Models
In the Fixed-Point Tool, under System
under design, click Change. In the
System Selector, select the
Under Automatic data typing,
specify the Safety margin for simulation min/max (%) parameter
20 and click Apply.
Click Propose data types, .
Because no design minimum and maximum information is supplied, the simulation minimum and maximum data that was collected during the simulation run is used to propose data types. The Safety margin for simulation min/max (%) parameter value multiplies the "raw" simulation values by a factor of 1.2. Setting this parameter to a value greater than 1 decreases the likelihood that an overflow will occur when fixed-point data types are being used.
Because of the nonlinear effects of quantization, a fixed-point simulation will produce results that are different from an idealized, doubles-based simulation. Signals in a fixed-point simulation can cover a larger or smaller range than in a doubles-based simulation. If the range increases enough, overflows or saturations could occur. A safety margin decreases the likelihood of this happening, but it might also decrease the precision of the simulation.
In the Propose Data Types dialog box, select
The Fixed-Point Tool analyzes the scaling of all fixed-point blocks whose Lock output data type setting against changes by the fixed-point tools parameter is not selected.
The Fixed-Point Tool uses the minimum and maximum values stored in the selected run to propose each block's scaling such that the precision is maximized while the full range of simulation values is spanned. The tool displays the proposed scaling in its Contents pane. Now, it displays the Automatic Data Typing View to provide information, such as ProposedDT, ProposedMin, and ProposedMax, which are relevant at this stage of the fixed-point conversion.
Review the scaling that the Fixed-Point Tool proposes. You can choose to accept the scaling proposal for each block by selecting the corresponding Accept check box in the Contents pane. By default, the Fixed-Point Tool accepts all scaling proposals that differ from the current scaling. For this example, verify that the Accept check box associated with the active run is selected for each of the Controller system's blocks.
To view more information about a proposal, select the result and click the Result Details tab.
In the Fixed-Point Tool, click the Apply accepted data types button .
The Fixed-Point Tool applies the scaling proposals that you accepted in the previous step.
Under Configure model settings,
click the Range collection with specified data types button.
Under Range collection, set the run name to
Click Simulate model.
Simulink® simulates the
using the new scaling that you applied. Afterward, the Fixed-Point
Tool displays in its Contents pane information
about blocks that logged fixed-point data.
Use the Simulation Data Inspector to plot the Analog Plant output for the floating-point and fixed-point runs and the difference between them.
The difference plot shows that the difference
between the floating-point signal and the fixed-point signal is within
the specified tolerance of