Prepare ASAP2 Data Description File
This example shows how to configure a Simulink® Real-Time™ model so that the build generates an ASAP2 (A2L) data description file for the real-time application. The real-time application models a damped oscillator that feeds into 1-D and 2-D lookup tables, which invert and rescale the input waveform.
This example uses model slrt_ex_osc_cal
. To open the model, in the
MATLAB® Command Window,
type:
open_system(fullfile(matlabroot, 'toolbox', 'slrealtime', ... 'examples', 'slrt_ex_osc_cal'))
Calibration of parameters reduces the ringing in signals DampedOsc
,
L_1D
, and L_2D
.
Initial Setup
Open the model and check for model data.
Open
slrt_ex_osc_cal
open_system(fullfile(matlabroot,'toolbox','slrealtime', ... 'examples', 'slrt_ex_osc_cal'))
The Model Workspace variables contain these functions:
Kg
— Parameter object for theGain1
blockDampedOsc
,SignalGenerator
,L_1D
,L_2D
— Signal objects for output signalsLUT_1D_obj
,LUT_2D_obj
— 1-D and 2-D lookup tables data respectivelySignalGenerator
— Test input data
Set the Default parameter behavior configuration parameter to
Tunable
.In the Code Mappings Editor – C in Data Defaults, specify the storage class as
PageSwitching
for Model parameters under Parameters.Note
The model default setting for parameters sets the storage class as
PageSwitching
.
Set Up Parameters
Set up parameter tuning by using Simulink parameter objects.
In
slrt_ex_osc_cal
, on the Modeling tab, click Design > Model Explorer.
Select Model Workspace in the Model Hierarchy pane.
Make sure that the
Kg
parameter object exists and has these properties:Value —
400
Data type —
double
If the parameter object does not exist, add it. On the toolbar, click the Add Simulink Parameter button
.
Open
slrt_ex_osc_cal/Gain1
.Make sure that you have set the Gain value to the parameter object
Kg
.
Set Up Signals
As a best practice, set up signal viewing by using Simulink signal objects.
In
slrt_ex_osc_cal
, on the Modeling tab, click Design > Model Explorer.
Select Model Workspace in the Model Hierarchy pane.
Make sure that the
DampedOsc
signal object exists and has these properties:Minimum —
−10
Maximum —
10
Data type —
double
Make sure that the
SignalGenerator
signal object exists and has these properties:Minimum —
−10
Maximum —
10
Data type —
double
Make sure that the
L_1D
signal object exists and has these properties:Minimum —
−15
Maximum —
15
Data type —
double
Make sure that the
L_2D
signal object exists and has these properties:Minimum —
−15
Maximum —
15
Data type —
double
If a signal does not exist, add it. On the toolbar, click the Add Simulink Signal button
.
For each signal, open its Properties dialog box.
Make sure that you selected the Signal name must resolve to Simulink signal object and the Test point check boxes.
Set Up Lookup Tables
The example model contains 1-D and 2-D lookup tables.
Open the block parameters for the 1-D Lookup Table block.
In the Table and Breakpoints pane, verify these settings:
Number of table dimensions —
1
Data specification —
Lookup table object
Name —
LUT_1D_obj
Open the block parameters for the 2-D Lookup Table block.
In the Table and Breakpoints pane, check these settings:
Number of table dimensions —
2
Data specification —
Lookup table object
Name —
LUT_2D_obj
To view the contents of the lookup tables, click Edit table and breakpoints, and then click Plot > Mesh.
Generate Data Description File
On the REAL-TIME tab, select RUN ON TARGET > Build Application.
On the C CODE tab, select Share > Generate Calibration Files. Use the tool to generate the required version of ASAP2 file. For more information about using the tool, see Generate ASAP2 and CDF Calibration Files.
You can perform the same operation by using the
coder.asap2.export
function.coder.asap2.export('slrt_ex_osc_cal','MapFile','slrt_ex_osc_cal_slrealtime_rtw/slrt_ex_osc_cal','Comments',false);
Connect to the target by using a third-party calibration tool.
See Also
n-D Lookup Table | coder.asap2.export
Related Topics
- Generate ASAP2 and CDF Calibration Files
- Calibrate Parameters with Vector CANape
- Calibrate Parameters with ETAS Inca