Real-Time Workshop    

Storage Classes of Tunable Parameters

Real-Time Workshop defines four storage classes for tunable parameters. You must declare a tunable parameter to have one of the following storage classes:

The generated code for model.h includes model_private.h in order to make the extern declarations available to subsystem files.

As an example of how the storage class declaration affects the code generated for a parameter, consider the model shown below.

The workspace variable Kp sets the gain of the Gain1 block. Assume that the value of Kp is 5.0. Table 5-2 shows the variable declarations and the code generated for the gain block when Kp is declared as a tunable parameter. An example is shown for each storage class.

Note that the symbolic name Kp is preserved in the variable and field names in the generated code.

Table 5-2: Tunable Parameter Storage Declarations and Code
Storage Class
Generated Variable Declaration and Code
SimulinkGlobal(Auto)
  • typedef struct Parameters_tag {
      real_T Kp;
    } Parameters;
    .
    .
    Parameters rtP = {
      5.0 
    };
    .
    .
    rtY.Out1 = (rtP.Kp * rtb_u);
    
ExportedGlobal
  • extern real_T Kp;
    .
    .
    real_T Kp = 5.0;
    .
    .
    rtY.Out1 = (Kp * rtb_u);
    
ImportedExtern
  • extern real_T Kp;
    .
    .
    rtY.Out1 = (Kp * rtb_u);
    
ImportedExternPointer
  • extern real_T *Kp; 
    .
    .
    rtY.Out1 = ((*Kp) * rtb_u);
    


  Tunable Parameter Storage Using the Model Parameter Configuration Dialog