Real-Time Workshop | ![]() ![]() |
Real-Time Workshop supports the use of tunable variables in expressions. An expression that contains one or more tunable parameters is called a tunable expression.
Currently, there are certain limitations on the use of tunable variables in expressions. When an expression described below as not supported is encountered during code generation, a warning is issued and a nontunable expression is generated in the code. The limitations on tunable expressions are:
The rules applying to each category are as follows:
Note The "dot" (structure membership) operator is not supported. This means that expressions that include a structure member are not tunable. |
Tunable Expressions in Masked Subsystems
Tunable expressions are allowed in masked subsystems. You can use tunable parameter names or tunable expressions in a masked subsystem dialog. When referenced in lower-level subsystems, such parameters remain tunable.
As an example, consider the masked subsystem depicted below. The masked dialog variable k
sets the gain parameter of theGain
.
Suppose that the base workspace variable b
is declared tunable with SimulinkGlobal(Auto)
storage class. Figure 5-2 shows the tunable expression b*3
in the subsystem's mask dialog.
Figure 5-2: Tunable Expression in Subsystem Mask Dialog
Real-Time Workshop produces the following output computation for theGain
. The variable b
is represented as a member of the global parameters structure, rtP
. (Note that for clarity in showing the individual Gain block computation, Expression folding was turned off in this example.)
Limitations of Tunable Expressions in Masked Subsystems. Expressions that include variables that were declared or modified in mask initialization code are not tunable.
As an example, consider the subsystem above, modified as follows:
k
of the myGain
block is 4 + t
.
b = 2
. The expression b * 3
is plugged into the mask dialog as in Figure 5-2.
Since the mask initialization code can only run once, k
is evaluated at code generation time as
Real-Time Workshop inlines the result. Therefore, despite the fact that b
was declared tunable, the code generator produces the following output computation for theGain
. (Note that for clarity in showing the individual Gain block computation, Expression folding was turned off in this example.)
![]() | Using the Model Parameter Configuration Dialog | Tunability of Linear Block Parameters | ![]() |