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
.
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 the
Gain1
block
DampedOsc
, SignalGenerator
,
L_1D
, L_2D
— Signal
objects for output signals
LUT_1D_obj
, LUT_2D_obj
— 1-D and 2-D lookup tables data respectively
SignalGenerator
— Test input data
Set the Default parameter behavior configuration
parameter to Tunable
.
In the Code Mappings Editor (Embedded Coder) 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 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
.
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.
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.
On the REAL-TIME tab, select RUN ON TARGET > Build Application. The build produces a file named
slrt_ex_osc_cal_slrt.mldatx
in the working folder
containing A2L file.
To retrieve the A2L file and update target IP address in the A2L file, use
extractASAP2
command.
Connect to the target by using a third-party calibration tool.