Real-Time Workshop | Search  Help Desk |
Parameter Tuning
Parameter tuning is a method of modifying a block parameter on-the-fly. Clicking the Tunable parameters button opens RTW Tunable Parameters dialog box. You can de-inline any model parameter by placing its name in the Variable field and clicking Add. This effectively negates the Inline parameters check box for the variables you select. All other model parameters remain inlined. The purpose of the parameter tuning feature is two fold. In the generated code, it allows you to:C
Variable Name
Name of a MATLAB workspace variable; this must be a valid C variable.Storage Class
matlabroot
/rtw/c/src/pt_readme.txt
.
Storage Type Qualifier
Prepend any string (for example,const
) to the parameter declaration. Note the Real-Time Workshop does not check the string for syntax errors.
Data Type and Initial Value
A parameter's data type and initial value are inferred from the actual MATLAB workspace variable. For example, assumeKp
is used in a gain block where
Kp = int16(5);
Kp
is a signed 16-bit integer with an initial value of 5.
Implicit Casting Rules
The data type of a tunable parameter is enforced at all times. This includes forcing (typeless)K=5
as double since MATLAB assumes all untyped data is of type double. There are two basic rules for implicit casting
.
.Access to Parameter Tuning Dialog Box via M-code
You can access the Parameter Tuning dialog box using these commands:get_paraThe valid storage class settings are:m(gcs, 'TunableVars')
get_param(gcs, 'TunableVarsStorageClass')
get_param(gcs, 'TunableVarsTypeQualifier')
set_param(gcs, 'TunableVars', str)
set_param(gcs, 'TunableVarsStorageClass', str)
set_param(gcs, 'TunableVarsTypeQualifier', str)
Auto ExportedGlobal ImportedExtern ImportedExternPointerFor example,
set_param(gcs, 'TunableVars', 'k1, k2, k3') set_param(gcs, 'TunableVarsStorageClass', ... 'Auto, ExportedGlobal, ImportedExtern') set_param(gcs, 'TunableVarsTypeQualifier', ... ',,const')Note that the parameter tuning dialog does not refresh automatically for a given
set_param
.
Ada
Storage Class
Change the storage class of the selected variable. The options available in the RTW Tunable Parameters dialog box have C code names that map to Ada concepts. The options in the pull-down menu are as follows:Your_Package
.
Your_variable
.
Storage Type Qualifier
This is only used when specifying the package specification to qualify fully the variable name for theImportedExtern
option. This field is ignored in all other cases.
Data Type and Initial Value
A parameter's data type and initial value are inferred from the actual MATLAB workspace variable. For example, assumeKp
is used in a gain block where
Kp = int16(5);
Kp
is a signed 16-bit integer with an initial value of 5.
Implicit Casting Rules
Since Ada does not support implicit upcasting of data types, all numerical operations in your model must be of homogeneous data types for Ada code generation.