Real-Time Workshop User's Guide    

Storage Classes of Tunable Parameters

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

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 3-3 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 3-3: 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 
    };
    .
    .
    rtb_y = rtB.u * (rtP.Kp);
    
ExportedGlobal
    real_T Kp = 5.0;
    .
    .
    rtb_y = rtB.u * (Kp);
    
ImportedExtern
    extern real_T Kp;
    .
    .
    rtb_y = rtB.u * (Kp);
    
ImporteExternPointer
    extern real_T *Kp; 
    .
    .
    rtb_y = rtB.u * ((*Kp));
    


 Tunable Parameter Storage Using the Model Parameter Configuration Dialog