Main Content

Configure Model Parameter for Tuning and State Data for Measurement During Run Time

By default, code generation optimizations eliminate storage for model parameters and most data store, signal, and state data that do not participate in the entry-point function interface. In this case, in the model code mappings, the service interface for the element is listed as Not tunable or Not measurable. To make parameters tunable and data store, signal, and state data measurable during run time, configure them to use a named parameter tuning or measurement service interface.

To enable parameter tuning and measurement of state data, use the code mappings for model ComponentDeploymentFcn to configure service interfaces for:

  • The state data for the Discrete-Time Integrator block in the Integrator subsystem.

  • The gain parameter for the Gain block in the Accumulator subsystem.

  • The state data for the Unit Delay block in the Accumulator subsystem.

The code mappings for the state data also specify identifiers that the code generator uses for naming the variables representing that data. To see the identifier specifications, in the Code Mappings editor, on the Signals/States tab, select a state and click the pencil icon. In the dialog box that appears, note the setting of the Identifier property.

If not already open, in the Embedded Coder app, open example model CompoentDeploymentFcn.

Inspect the code interface settings.

  1. Open the Code Mappings editor.

  2. Click the Parameters tab. Model parameter k is mapped to the default parameter tuning service interface ParameterTuningService. Alternatively, you can select Not tunable.

  3. Click the Signals/States tab. The state data for the Discrete-Time Integrator and Unit Delay blocks is mapped to the default measurement service interface MeasurementService. For each state, alternatively, you can select Not measured.

The storage classes associated with service interfaces ParameterTuningService and MeasurementService, TuningStruct and MeasurementStruct, define structure type and instance variable names for the data in the generated code as CD_tunable_T, CD_tunable.k, CD_measured_T, CD_measured.dti, and CD_measured.delay.

In the Code view:

  1. Search for dti.

  2. In ComponentDeploymentFcn.c, place your cursor over CD_measured in the highlighted code CD_measured.dti.

    Code view display that shows the definition, model elements, and code metrics for variable CD_measured.dti.

  3. To see the variable definition for CD_measured.dti, in the dialog box, click the definition code.

Consider searching for instances of the other data type and variable names: CD_tunable_T, CD_tunable.k, and CD_measured.delay.

Next, learn how you can deploy generated code.