Main Content

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'))

Image of slrt_ex_osc_cal model

Image showing Scope output

Image showing Scope 1 output

Image showing Scope 2 output

Calibration of parameters reduces the ringing in signals DampedOsc, L_1D, and L_2D.

Initial Setup

Open the model and check for model data.

  1. 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

  2. Set the Default parameter behavior configuration parameter to Tunable.

  3. In the Code Mappings Editor – C in Data Defaults, specify the storage class as PageSwitching for Model parameters under Parameters.

    Image showing Code Mappings Editor

    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.

  1. In slrt_ex_osc_cal, on the Modeling tab, click Design > Model Explorer .

  2. Select Model Workspace in the Model Hierarchy pane.

  3. Make sure that the Kg parameter object exists and has these properties:

    • Value400

    • Data typedouble

  4. If the parameter object does not exist, add it. On the toolbar, click the Add Simulink Parameter button.

  5. Open slrt_ex_osc_cal/Gain1.

  6. 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.

  1. In slrt_ex_osc_cal, on the Modeling tab, click Design > Model Explorer .

  2. Select Model Workspace in the Model Hierarchy pane.

  3. Make sure that the DampedOsc signal object exists and has these properties:

    • Minimum−10

    • Maximum10

    • Data typedouble

  4. Make sure that the SignalGenerator signal object exists and has these properties:

    • Minimum−10

    • Maximum10

    • Data typedouble

  5. Make sure that the L_1D signal object exists and has these properties:

    • Minimum−15

    • Maximum15

    • Data typedouble

  6. Make sure that the L_2D signal object exists and has these properties:

    • Minimum−15

    • Maximum15

    • Data typedouble

  7. If a signal does not exist, add it. On the toolbar, click the Add Simulink Signal button .

  8. For each signal, open its Properties dialog box.

  9. 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.

  1. Open the block parameters for the 1-D Lookup Table block.

  2. In the Table and Breakpoints pane, verify these settings:

    • Number of table dimensions1

    • Data specificationLookup table object

    • NameLUT_1D_obj

  3. Open the block parameters for the 2-D Lookup Table block.

  4. In the Table and Breakpoints pane, check these settings:

    • Number of table dimensions2

    • Data specificationLookup table object

    • NameLUT_2D_obj

To view the contents of the lookup tables, click Edit table and breakpoints, and then click Plot > Mesh.

Generate Data Description File

  1. 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.

  2. To retrieve the A2L file and update target IP address in the A2L file, use extractASAP2 command.

  3. Connect to the target by using a third-party calibration tool.

See Also

Related Topics

External Websites