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:

A parameter's storage class and storage type qualifier define how the memory is declared and referenced. Regardless of the attributes, parameters listed in the dialog box collapse to a single memory location.

Conceptually, the meaning of the parameter attributes are the same for C and Ada, however, there are slight differences.

Note that there are current limitations to parameter tuning.

C

Variable Name

Name of a MATLAB workspace variable; this must be a valid C variable.

Storage Class

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, assume Kp is used in a gain block where

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

   1.
An upcast is always performed silently.
   2.
Downcasting is not allowed. This guarantees deterministic behavior between Simulink and the Real-Time Workshop.

Access to Parameter Tuning Dialog Box via M-code

You can access the Parameter Tuning dialog box using these commands:

The valid storage class settings are:

For example,

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:

Storage Type Qualifier

This is only used when specifying the package specification to qualify fully the variable name for the ImportedExtern 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, assume Kp is used in a gain block where

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.



[ Next | Help Desk ]