Configure Model Parameters with Tuning Service Interface Definitions
R2026bA generated-code variable corresponding to a model parameter, can be tuned at during program execution if the parameter is configured as tunable before code generation.
Because the parameter is configured as tunable, the ASAP2 file includes a section that describes its tuning properties. To learn more about generated ASAP2 files, see:
There are five general types of model parameters that can be tuned with ASAP2 files:
Model Parameters Arguments
Model Parameters
Model Variant Control Arguments
Model Variant Controls
Model Variant Variables
For information about model parameters, see Simulink.Parameter,
Simulink.VariantVariable, and Simulink.VariantControl.
Map Model Parameters to Parameter Tuning Service Interface Definitions
This example shows how to map model parameters to tuning service interface definitions for code generation, using the Initial condition of a Unit Delay block and the Initial output of the Merge block.
To allow tuning these model parameters during program execution:
Before generating code, configure the parameter as tunable and specify its tuning properties.
Generate code for the model.
Generate an ASAP2 file.
Open Explore Model
Open the component model ControllerSWC.
soaControlModel = "ControllerSWC";
open_system(soaControlModel);

In the example you,
Create Simulink® Parameter objects using Model Explorer.
Assign the parameter objects to specific block parameters.
Configure these block parameters with tuning service interface definitions.
Generate model code that exports the variables corresponding to those parameters.
Generate ASAP2 files that contain the description of these parameters.
Use Parameters in Model
The Unit Delay block has a configurable Initial condition parameter and the Merge block has a configurable Initial output parameter. Add Simulink parameters to the model workspace and assign them as the values for these block parameters.
Add Parameters to Model:
Open the model workspace: from the Modeling tab of the Simulink editor, in the Design section, click the arrow to open the gallery. Then, in the Design section, click the Model Explorer button
.In the left pane, navigate to the Model Workspace tree branch. Then, click Add in the menu bar, and then select Simulink Parameter.
Add two Simulink parameters with the names UD_Param and MergeParam. Set the value of each of them to 0. Designate MergeParam as an argument by selecting the Argument checkbox.

Assign Model Parameters to Block Parameters:
Double click the Unit Delay and the Merge blocks to open their model parameter dialog boxes. In the Initial condition parameter of the Unit Delay block type UD_Param and in the Initial output parameter of the Merge block type MergeParam. Click OK in both.

Open Service Mappings Editor
Open the Service Mappings editor by pressing Ctrl+Shift+C. Then, select the Parameters tab.

There are five parent entries in the table, each corresponding to one type of model parameters. The Model Parameters and Model Parameter Arguments entries have each one child entry, MergeParam and UD_Param, respectively.
Configure Parameter Tuning Service
The Parameter Tuning Service property determines whether the generated code that represents tunable elements can be tuned during program execution or not. For both MergeParam and UD_Param, set Parameter Tuning Service to Tunable.
Calibration Properties
When the Parameter Tuning Service of a model parameter is set to Tunable, the generated ASAP2 file contains a section that corresponds to the parameter and contains the calibration properties of the parameter. This allows calibration tools to measure and tune the value of the corresponding variable during program execution. To configure calibration properties of a model parameter:
Select the Parameters tab of the Service Mappings editor.
In the table, locate the entry of the model parameter.
Click the pencil icon
at the end of the entry to open a dialog box in which you configure the calibration properties of the model parameter.
The Identifier property of the model parameter is not one of the calibration properties, but you configure it also in the dialog box. Use this property to specify the name of the variable that corresponds to the model parameter, in the code generated from the model. If you leave the value of this property empty, the name of the corresponding variable is the name of the model parameter itself.
When the Calibration Access property of a model parameter is set to NoCalibration, the calibration tool is blocked from modifying the variable value. However, the variable is still exported in the code, and the ASAP2 file contains a section that corresponds to the parameter, and the calibration tool can still read the variable value.
Specify these calibration properties for the parameters UD_Param and MergeParam:
|
| Corresponding Property in ASAP2 File | |
|---|---|---|---|
Identifier |
|
|
|
Calibration Access (Only shown when value is |
|
|
|
Display Identifier |
|
|
|
Format | Leave empty |
|
|
Compu Method | Leave empty |
|
|

Generate Model Code and Calibration Files
Generate code from the model.
evalc("slbuild(soaControlModel,GenerateCodeOnly=true)");
To generate the calibration file, on the Software Component tab of the Simulink Toolstrip, select Share > Generate Calibration Files.

In the Generate Calibration Files dialog box, make sure that Generate ASAP2 switch is set to on and, since you are not using address replacement, make sure the Address replacement is cleared. Then, click Generate.

In the generated file ControllerSWC.a2l, locate the sections that correspond to the model parameters UD_Param and mergeParam. The beginning marker of each of these sections is /begin CHARACTERISTIC and the end marker is /end CHARACTERISTIC. Each section consists of the calibration properties of the model parameter it corresponds to.
/begin CHARACTERISTIC
/* Name */ ControllerSWC_Params.mergeParamID
/* Long Identifier */ ""
/* Type */ VALUE
/* ECU Address */ 0x0000 /* @ECU_Address@ControllerSWC_Params.mergeParamID@ */
/* Record Layout */ Record_BOOLEAN
/* Maximum Difference */ 0
/* Conversion Method */ myCompMethod
/* Lower Limit */ 0
/* Upper Limit */ 1
DISPLAY_IDENTIFIER MergeParamDispID
FORMAT "%2.1"
/end CHARACTERISTIC
/begin CHARACTERISTIC
/* Name */ UD_ParamID
/* Long Identifier */ ""
/* Type */ VALUE
/* ECU Address */ 0x0000 /* @ECU_Address@UD_ParamID@ */
/* Record Layout */ Record_BOOLEAN
/* Maximum Difference */ 0
/* Conversion Method */ CM_boolean
/* Lower Limit */ 0
/* Upper Limit */ 1
CALIBRATION_ACCESS NO_CALIBRATION
DISPLAY_IDENTIFIER UD_ParamDispID
/end CHARACTERISTIC
Note how each of these sections matches the calibration properties of the model parameter it corresponds to.
See Also
Service Mappings Editor | Parameters Service Interface Properties