model gain-scheduled control systems in simulink
in simulink®, you can model gain-scheduled control systems in which controller gains or coefficients depend on scheduling variables such as time, operating conditions, or model parameters. the library of linear parameter-varying blocks in control system toolbox™ lets you implement common control-system elements with variable gains. use blocks such as lookup tables or matlab function blocks to implement the gain schedule, which gives the dependence of these gains on the scheduling variables.
to model a gain-scheduled control system in simulink:
identify the scheduling variables and the signals that represent them in your model. for instance, if your system is a cruising aircraft, then the scheduling variables might be the incidence angle and the airspeed of the aircraft.
use a lookup table block or a matlab function block to implement a gain or coefficient that depends on the scheduling variables. if you do not have lookup table values or matlab® expressions for gain schedules that meet your performance requirements, you can use
systune
to tune them. see .replace ordinary control elements with gain-scheduled elements. for instance, instead of a fixed-coefficient pid controller, use a varying pid controller block, in which the gain schedules determine the pid gains.
add scheduling logic and safeguards to your model as needed.
model scheduled gains
a gain schedule converts the current values of the scheduling variables into controller gains. there are several ways to implement a gain schedule in simulink.
available blocks for implementing lookup tables include:
lookup tables — a lookup table is a list of breakpoints and corresponding gain values. when the scheduling variables fall between breakpoints, the lookup table interpolates between the corresponding gains. use the following blocks to implement gain schedules as lookup tables.
, , — for a scalar gain that depends on one, two, or more scheduling variables.
— for a matrix-valued gain that depends on one, two, or three scheduling variables. (this block is in the simulink extras library.)
block — when you have a functional expression relating the gains to the scheduling variables, use a matlab function block. if the expression is a smooth function, using a matlab function can result in smoother gain variations than a lookup table. also, if you use a code-generation product such as simulink coder™ to implement the controller in hardware, a matlab function can result in a more memory-efficient implementation than a lookup table.
you can use
systune
to tune gain schedules implement as either lookup tables or
matlab functions. see .
scheduled gain in controller
as an example, the model rct_cstr
includes a pi controller and a
lead compensator in which the controller gains are implemented as lookup tables using
blocks. for more
information on this model, see .
copy the example files and open the rct_cstr
model.
openexample("control/gainscheduledprocessexample",... supportingfile="rct_cstr.slx")
both the concentration controller
and temperature
controller
blocks take the cstr
plant output,
cr
, as an input. this value is both the controlled variable of the
system and the scheduling variable on which the controller action depends. double-click
the concentration controller
block.
this block is a pi controller in which the proportional gain kp
and
integrator gain ki
are determined by feeding the scheduling parameter
cr
into a 1-d lookup table block. similarly, the
temperature controller
block contains three gains implemented as
lookup tables.
gain-scheduled equivalents for commonly used control elements
use the linear parameter varying block library of control system toolbox to implement common control elements with variable parameters or coefficients. these blocks provide common elements in which the gains or parameters are available as external inputs. the following table lists some applications of these blocks.
block | application |
---|---|
| use these blocks to implement a butterworth lowpass filter in which the cutoff frequency varies with scheduling variables. |
| use these blocks to implement a notch filter in which the notch frequency, width, and depth vary with scheduling variables. |
| these blocks are preconfigured versions of the pid controller and pid controller (2dof) blocks. use them to implement pid controllers in which the pid gains vary with scheduling variables. |
| use these blocks to implement a transfer function of any order in which the polynomial coefficients of the numerator and denominator vary with scheduling variables. |
| use these blocks to implement a state-space controller in which the a, b, c, and d matrices vary with the scheduling variables. |
| use these blocks to implement a gain-scheduled observer-form state-space controller, such as an lqg controller. in such a controller, the a, b, c, d matrices and the state-feedback and state-observer gain matrices vary with the scheduling variables. |
caution
when using the block, avoid scheduling the c and d matrices based on the system output y. if you have such dependence, the resulting state-space equation y = c(y)x d(y)u creates an algebraic loop, because computing the output value y requires knowing the output value. this algebraic loop is prone to instability and divergence. instead, try expressing c and d in terms of the time t, the block input u, and the state outputs x.
for similar reasons, avoid scheduling a and b based on the dx output. note that it is safe to for a and b to depend on y when y is a fixed combination of states and inputs, (in other words, when y = cx du where c and d are constant matrices).
similarly, in the block, use xk instead of yk when scheduling c and d, and avoid using xk 1 to schedule a and b. you can use yk to schedule a and b when yk is a fixed combination of states and inputs.
gain-scheduled notch filter
for example, the subsystem in the following illustration uses a varying notch filter block to implement a filter whose notch frequency varies as a function of two scheduling variables. the relationship between the notch frequency and the scheduling variables is implemented in a matlab function.
gain-scheduled pi controller
as another example, the following subsystem is a gain-scheduled discrete-time pi controller in which both the proportional and integral gains depend on the same scheduling variable. this controller uses 1-d lookup table blocks to implement the gain schedules.
matrix-valued gain schedules
you can also implement matrix-valued gain schedules simulink. a matrix-valued gain schedule takes one or more scheduling variables and returns a matrix rather than a scalar value. for instance, suppose that you want to implement a time-varying lqg controller of the form:
where, in general, the state-space matrices a, b, c, and d, the state-feedback matrix k, and the observer-gain matrix l all vary with time. in this case, time is the scheduling variable, and the gain schedule determines the values of the matrices at a given time.
in your simulink model, you can implement matrix-valued gain schedules using:
block — specify a matlab function that takes scheduling variables and returns matrix values.
block — specify a lookup table to associate a matrix value with each scheduling-variable breakpoint. between breakpoints, the block interpolates the matrix elements. (this block is in the simulink extras library.)
for the lqg controller, use either matlab function blocks or matrix interpolation blocks to implement the time-varying matrices as inputs to a varying observer form block. for example:
in this implementation, the time-varying matrices are each implemented as a matlab function block in which the associated function takes the simulation time and returns a matrix of appropriate dimensions.
you can tune
matrix-valued gain schedules implemented as either matlab function blocks
or as matrix interpolation blocks. however, to tune a matrix
interpolation block, you must set simulate using to
interpreted execution
. see the block reference
page for information about simulation modes.
custom gain-scheduled control structures
you can also use the scheduled gains to build your own control elements. for example,
the model rct_cstr
includes a gain-scheduled lead compensator with three
coefficients that depend on the scheduling variable, cr
. to see how this
compensator is implemented, open the model and examine the temperature
controller
subsystem.
here, the overall gain kt
, the zero location a
,
and the pole location b
are each implemented as a 1-d lookup table that
takes the scheduling variable as input. the lookup tables feed directly into product blocks.
tunability of gain schedules
for a lookup table or matlab function block that implements a gain
schedule to be tunable with systune
, it must ultimately feed into
either:
a block in the linear parameter varying block library.
a product block that applies the gain to a given signal. for instance, if the product block takes as inputs a scheduled gain g(α) and a signal u(t), then the output signal of the block is y(t) = g(α)u(t).
there can be one or more of the following blocks between the lookup table or matlab function block and the product block or parameter-varying block:
gain
bias
blocks that are equivalent to a unit gain in the linear domain, including:
transport delay, variable transport delay
saturate, deadzone
rate limiter, rate transition
quantizer, memory, zero-order hold
minmax
data type conversion
signal specification
switch blocks, including:
switch
multiport switch
manual switch
inserting such blocks can be useful, for example, to constrain the gain value to a certain range, or to specify how often the gain schedule is updated.