Getting Started Guide: Control System Toolbox™ 9
Getting Started Guide: Control System Toolbox™ 9
www.mathworks.com Web
comp.soft-sys.matlab Newsgroup
www.mathworks.com/contact_TS.html Technical Support
508-647-7000 (Phone)
508-647-7001 (Fax)
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand
names may be trademarks or registered trademarks of their respective holders.
Patents
MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
Revision History
November 2002 First printing New Version 5.0 (Release 12)
June 2001 Second printing Revised for Version 5.1 (Release 12.1)
July 2002 Online only Revised for Version 5.2 (Release 13)
June 2004 Online only Revised for Version 6.0 (Release 14)
March 2005 Online only Revised for Version 6.2 (Release 14SP2)
September 2005 Online only Revised for Version 6.2.1 (Release 14SP3)
March 2006 Online only Revised for Version 7.0 (Release 2006a)
September 2006 Online only Revised for Version 7.1 (Release 2006b)
March 2007 Online only Revised for Version 8.0 (Release 2007a)
September 2007 Online only Revised for Version 8.0.1 (Release 2007b)
March 2008 Online only Revised for Version 8.1 (Release 2008a)
October 2008 Third printing Revised for Version 8.2 (Release 2008b)
March 2009 Online only Revised for Version 8.3 (Release 2009a)
September 2009 Online only Revised for Version 8.4 (Release 2009b)
March 2010 Online only Revised for Version 8.5 (Release 2010a)
September 2010 Online only Revised for Version 9.0 (Release 2010b)
Contents
Product Overview
1
Why Use This Toolbox? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Building Models
2
Linear (LTI) Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
What Is a Plant? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Linear Model Representations . . . . . . . . . . . . . . . . . . . . . . . 2-2
SISO Example: The DC Motor . . . . . . . . . . . . . . . . . . . . . . . 2-3
Building SISO Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
Constructing Discrete Time Systems . . . . . . . . . . . . . . . . . . 2-9
Adding Delays to Linear Models . . . . . . . . . . . . . . . . . . . . . 2-10
LTI Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
v
Arithmetic Operations for Interconnecting Models . . . . . . 2-23
Feedback Interconnections . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24
Analyzing Models
3
Quick Start for Performing Linear Analysis Using the
LTI Viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
vi Contents
Example: Importing Inputs from the Workspace . . . . . . . . 3-29
Designing Input Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-33
Specifying Initial Conditions . . . . . . . . . . . . . . . . . . . . . . . . 3-35
Designing Compensators
4
Designing PID Controllers . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
Designing PID Controllers with the PID Tuner GUI . . . . . 4-2
Designing PID Controllers at the Command Line . . . . . . . 4-14
vii
Adjusting the Bandwidth . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-57
Adding an Integrator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-59
Adding a Lead Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-63
Moving Compensator Poles and Zeros . . . . . . . . . . . . . . . . . 4-68
Adding a Notch Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-71
Modifying a Prefilter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-76
viii Contents
Functions for Compensator Design . . . . . . . . . . . . . . . . . . 4-147
When to Use Functions for Compensator Design . . . . . . . . 4-147
Root Locus Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-147
Pole Placement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-148
Linear-Quadratic-Gaussian (LQG) Design . . . . . . . . . . . . . 4-151
Example — Designing an LQG Regulator . . . . . . . . . . . . . . 4-162
Example — Designing an LQG Servo Controller . . . . . . . . 4-165
Example — Designing an LQR Servo Controller in
Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-168
Index
ix
x Contents
1
Product Overview
This toolbox lets you construct and analyze linear models of dynamic systems.
Use Control System Toolbox functions to model dynamic systems as transfer
functions, in state-space form, or as arrays of frequency response data. Plot
the time and frequency responses of your system to understand how your
system behaves.
You can also use the toolbox to design and tune single-loop or multiple-loop
control systems using various classical and state-space techniques.
1-2
Using the Documentation
This guide also discusses model order reduction and linear quadratic
Gaussian (LQG) control design techniques with examples.
• Release Notes — Highlights new and changed features in the latest product
release.
• Creating and Manipulating Models — In-depth information about creating,
manipulating, and analyzing linear models and linear time-invariant
(LTI) arrays. You can use LTI arrays to store collections of linear models
in one variable.
• Customization — Information about setting plot properties, including
setting preferences that persist from session to session.
• Control System Toolbox Design Case Studies — Worked examples
of control design problems, including Kalman filtering and
Linear-Quadratic-Gaussian design. The examples illustrate
design techniques in both single-input/single-output (SISO) and
multiple-input/multiple-output (MIMO) systems.
• Control System Toolbox Reliable Computations — Discussion of numerical
stability and accuracy in computation
• Using the SISO Design Tool and the LTI Viewer — Complete descriptions
of the LTI Viewer and SISO Design Tool. These tools help you analyze
systems and design SISO compensators.
• Function Reference — Describes the purpose, syntax, and options for each
function.
1-3
1 Product Overview
Related Products
The following table summarizes MathWorks® products that extend and
complement the Control System Toolbox software. For current information
about these products and other MathWorks products, point your Web browser
to:
www.mathworks.com
Product Description
Simulink® Provides blocks for simulating
models you create and analyze
using the Control System Toolbox
software.
Fuzzy Logic Toolbox™ Complements Control System
Toolbox software with tools for
modeling complex systems based on
fuzzy logic.
Model Predictive Control Toolbox™ Helps you design and simulate model
predictive controllers for linear plant
models created using Control System
Toolbox functions.
Robust Control Toolbox™ Helps you design robust control
systems based on plant models
created using the Control System
Toolbox software. Enables you
to assess robustness based on
confidence bounds for your plant
models.
Simulink® Control Design™ Lets you use Control System Toolbox
linear control tools to analyze and
tune Simulink models.
1-4
Related Products
Product Description
Simulink® Design Optimization™ Helps you improve controller
designs by estimating and tuning
model parameters using numerical
optimization.
“System Identification Toolbox™” Helps you estimate linear and
nonlinear mathematical models of
dynamic systems from measured
data. Use the Control System
Toolbox software to analyze and
design controllers for resulting
linear models.
1-5
1 Product Overview
1-6
2
Building Models
What Is a Plant?
Typically, control engineers begin by developing a mathematical description of
the dynamic system that they want to control. The system to be controlled is
called a plant. As an example of a plant, this section uses the DC motor. This
section develops the differential equations that describe the electromechanical
properties of a DC motor with an inertial load. It then shows you how to
use the Control System Toolbox functions to build linear models based on
these equations.
dx
= Ax + Bu
dt
y = Cx + Du
2-2
Linear (LTI) Models
s+2
H (s) = 2
s + s + 10
( z + 1 + j)( z + 1 − j)
H ( z) = 3
( z + 0.2)( z + 0.1)
Note The design of FRD models is a specialized subject that this guide
does not address. See “Creating Frequency Response Data (FRD) Models”
for a discussion of this topic.
2-3
2 Building Models
In this model, the dynamics of the motor itself are idealized; for instance,
the magnetic field is assumed to be constant. The resistance of the circuit
is denoted by R and the self-inductance of the armature by L. If you are
unfamiliar with the basics of DC motor modeling, consult any basic text on
physical modeling. With this simple model and basic laws of physics, it is
possible to develop differential equations that describe the behavior of this
electromechanical system. In this example, the relationships between electric
potential and mechanical force are Faraday’s law of induction and Ampère’s
law for the force on a conductor moving through a magnetic field.
Mathematical Derivation
The torque τ seen at the shaft of the motor is proportional to the current i
induced by the applied voltage,
τ(t) = K m i(t)
where Kb, the emf constant, also depends on certain physical properties
of the motor.
The mechanical part of the motor equations is derived using Newton’s law,
which states that the inertial load J times the derivative of angular rate
equals the sum of all the torques about the motor shaft. The result is this
equation,
dw
J = ∑ τi = − K f ω(t) + K m i(t)
dt
2-4
Linear (LTI) Models
di
υapp (t) − υemf (t) = L + Ri(t)
dt
or, solving for the applied voltage and substituting for the back emf,
di
υapp (t) = L + Ri(t) + K bω(t)
dt
di R K 1
= − i(t) − b ω(t) + υapp (t)
dt L L L
dω 1 1
= − K f ω(t) + K m i(t)
dt J J
⎡ R Kb ⎤
− − ⎡1⎤
d ⎡i⎤ ⎢ L L ⎥ ⎡i⎤ ⎢ ⎥
=⎢ ⎥ ⋅ ⎢ ⎥ + L ⋅ υapp (t)
dt ⎢⎣ω⎥⎦ ⎢ K m K f ⎥ ⎣ ω⎦ ⎢ ⎥
⎢⎣ J − ⎢⎣ 0 ⎥⎦
J ⎥⎦
⎡i⎤
y(t) = [0 1] ⋅ ⎢ ⎥ + [0] ⋅ υapp (t)
⎣ ω⎦
2-5
2 Building Models
R= 2.0 % Ohms
L= 0.5 % Henrys
Km = .015 % torque constant
Kb = .015 % emf constant
Kf = 0.2 % Nms
J= 0.02 % kg.m^2
a =
x1 x2
x1 -4 -0.03
x2 0.75 -10
b =
u1
2-6
Linear (LTI) Models
x1 2
x2 0
c =
x1 x2
y1 0 1
d =
u1
y1 0
sys_tf = tf(sys_dc)
Transfer function:
1.5
------------------
s^2 + 14 s + 40.02
sys_zpk = zpk(sys_dc)
Zero/pole/gain:
1.5
2-7
2 Building Models
-------------------
(s+4.004) (s+9.996)
For example, you can create the transfer function by specifying the numerator
and denominator with this code.
Transfer function:
1.5
------------------
s^2 + 14 s + 40.02
s = tf('s');
sys_tf = 1.5/(s^2+14*s+40.02)
Transfer function:
2-8
Linear (LTI) Models
1.5
--------------------
s^2 + 14 s + 40.02
Zero/pole/gain:
1.5
-------------------
(s+9.996) (s+4.004)
Transfer function:
1
-----
z + 1
2-9
2 Building Models
Transfer function:
1
z^(-5) * -----
z + 1
This command constructs the DC motor transfer function, but adds a 0.05
second delay.
Transfer function:
1.5
exp(-0.05*s) * ------------------
s^2 + 14 s + 40.02
For a complete description of adding time delays to models and closing loops
with time delays, see Time Delays.
LTI Objects
For convenience, the Control System Toolbox software uses custom data
structures called LTI objects to store model-related data. For example, the
variable sys_dc created for the DC motor example is called an SS object.
There are also TF, ZPK, and FRD objects for transfer function, zero/pole/gain,
and frequency data response models respectively. The four LTI objects
encapsulate the model data and enable you to manipulate linear systems as
single entities rather than as collections of vectors or matrices.
To see what LTI objects contain, use the get command. This code describes
the contents of sys_dc from the DC motor example.
2-10
Linear (LTI) Models
get(sys_dc)
a: [2x2 double]
b: [2x1 double]
c: [0 1]
d: 0
e: []
StateName: {2x1 cell}
InternalDelay: [0x1 double]
Ts: 0
InputDelay: 0
OutputDelay: 0
InputName: {''}
OutputName: {''}
InputGroup: [1x1 struct]
OutputGroup: [1x1 struct]
Name: ''
Notes: {}
UserData: []
You can manipulate the data contained in LTI objects using the set command;
see the Control System Toolbox online reference pages for descriptions of
set and get.
sys_dc.a
ans =
-4.0000 -0.0300
0.7500 -10.0000
Similarly, if you want to change the values of the A matrix, you can do so
directly, as this code shows.
2-11
2 Building Models
sys_dc.a = A_new;
2-12
MIMO Models
MIMO Models
In this section...
“MIMO Example: State-Space Model of Jet Transport Aircraft” on page 2-13
“Constructing MIMO Transfer Functions” on page 2-15
“Accessing I/O Pairs in MIMO Systems” on page 2-17
The jet model during cruise flight at MACH = 0.8 and H = 40,000 ft. is
B = [ 0.0073 0
-0.4750 0.0077
0.1530 0.1430
0 0];
C = [0 1 0 0
0 0 0 1];
D = [0 0
0 0];
Use the following commands to specify this state-space model as an LTI object
and attach names to the states, inputs, and outputs.
2-13
2 Building Models
sys_mimo = ss(A,B,C,D,'statename',states,...
'inputname',inputs,...
'outputname',outputs);
sys_mimo
a =
beta yaw roll phi
beta -0.0558 -0.9968 0.0802 0.0415
yaw 0.598 -0.115 -0.0318 0
roll -3.05 0.388 -0.465 0
phi 0 0.0805 1 0
b =
rudder aileron
beta 0.0073 0
yaw -0.475 0.0077
roll 0.153 0.143
phi 0 0
c =
beta yaw roll phi
yaw rate 0 1 0 0
bank angle 0 0 0 1
d =
rudder aileron
yaw rate 0 0
bank angle 0 0
Continuous-time model.
2-14
MIMO Models
The model has two inputs and two outputs. The units are radians for beta
(sideslip angle) and phi (bank angle) and radians/sec for yaw (yaw rate) and
roll (roll rate). The rudder and aileron deflections are in degrees.
tf(sys_mimo)
2-15
2 Building Models
⎡ s −1 ⎤
⎢ s+1 ⎥
H (s) = ⎢ ⎥
⎢ s+2 ⎥
⎢⎣ s2 + 4 s + 5 ⎥⎦
You can specify H(s) by concatenation of its SISO entries. For instance,
or, equivalently,
s = tf('s')
h11 = (s-1)/(s+1);
h21 = (s+2)/(s^2+4*s+5);
H = [h11; h21]
For example, for the rational transfer matrix H(s), the two cell arrays N and D
should contain the row-vector representations of the polynomial entries of
⎡ s −1⎤ ⎡ s+1 ⎤
N (s) = ⎢ D(s) = ⎢ 2 ⎥
⎣ s + 2 ⎥⎦ ⎣ s + 4s + 5 ⎦
2-16
MIMO Models
s + 2
#2: -------------
s^2 + 4 s + 5
Notice that both N and D have the same dimensions as H. For a general MIMO
transfer matrix H(s), the cell array entries N{i,j} and D{i,j} should be
row-vector representations of the numerator and denominator of Hij(s), the
ijth entry of the transfer matrix H(s).
sys_mimo(3,1)
extracts the subsystem, mapping the first input to the third output. Row
indices select the outputs and column indices select the inputs. Similarly,
redefines the transfer function between the first input and third output as
an integrator.
2-17
2 Building Models
The number of inputs and outputs must be the same for all linear models
encapsulated by the LTI array, but the model order (number of states) can
vary from model to model within a single LTI array.
The LTI array sys_lti contains the state-space models for each value of K.
Type sys_lti to see the contents of the LTI array.
Model sys_lti(:,:,1,1)
======================
a =
x1 x2
x1 -4 -0.2
x2 5 -10
.
.
.
Model sys_lti(:,:,2,1)
======================
a =
x1 x2
x1 -4 -0.3
x2 7.5 -10
.
.
2-18
Arrays of Linear Models
.
Model sys_lti(:,:,3,1)
======================
a =
x1 x2
x1 -4 -0.4
x2 10 -10
.
.
.
3x1 array of continuous-time state-space models.
You can manipulate the LTI array like any other object. For example,
step(sys_lti)
produces a plot containing step responses for all three state-space models.
2-19
2 Building Models
LTI arrays are useful for performing batch analysis on an entire set of models.
For more information, see Arrays of LTI Models.
2-20
Model Characteristics
Model Characteristics
You can use the Control System Toolbox commands to query model
characteristics such as the I/O dimensions, poles, zeros, and DC gain.
These commands apply to both continuous- and discrete-time models. Their
LTI-based syntax is summarized in the table below.
Command Description
size(model_name) Number of inputs and outputs
ndims(model_name) Number of dimensions
isct(model_name) Returns 1 for continuous systems
isdt(model_name) Returns 1 for discrete systems
hasdelay(model_name) True if system has delays
pole(model_name) System poles
zero(model_name) System (transmission) zeros
dcgain(model_name) DC gain
norm(model_name) System norms (H2 and L∞)
covar(model_name,W) Covariance of response to white noise
2-21
2 Building Models
Command Description
class(model_name) Create object or return class of object
2-22
Interconnecting Linear Models
Transfer function:
s^2 + 2 s + 2
-------------
s^2 + 2 s
Transfer function:
2 s + 2
---------
s^2 + 2 s
If the operands are models of different types, the resulting model type is
determined by precedence rules; see “Precedence and Property Inheritance”
for more information. State-space models have the highest precedence while
transfer functions have the lowest precedence. Hence the sum of a transfer
function and a state-space model is always a state-space model.
2-23
2 Building Models
You can also use the series and parallel functions as substitutes for
multiplication and addition, respectively.
Feedback Interconnections
You can use the feedback and lft functions to derive closed-loop models.
For example,
computes the closed-loop transfer function from r to y for the feedback loop
shown below. The result is
Transfer function:
s + 2
-------------
s^2 + 3 s + 1
2-24
Interconnecting Linear Models
Feedback Interconnection
You can use the lft function to create more complicated feedback structures.
This function constructs the linear fractional transformation of two systems.
See the reference page for more information.
2-25
2 Building Models
Ts=0.01;
2-26
Converting Between Continuous- and Discrete- Time Systems
sysd=c2d(sys_dc,Ts)
a =
x1 x2
x1 0.96079 -0.00027976
x2 0.006994 0.90484
b =
u1
x1 0.019605
x2 7.1595e-005
c =
x1 x2
y1 0 1
d =
u1
y1 0
To see the discrete-time zero-pole gain for the digital DC motor, use zpk to
convert the model.
fd=zpk(sysd)
Zero/pole/gain:
7.1595e-005 (z+0.9544)
------------------------
(z-0.9608) (z-0.9049)
You can compare the step responses of sys_dc and sysd by typing
2-27
2 Building Models
step(sys_dc,sysd)
2-28
Reducing Model Order
2-29
2 Building Models
load ltiexamples
at the MATLAB prompt; the gasifier example is stored in the variable named
gasf. If you type
size(gasf)
sys35 = gasf(3,5);
Before attempting model order reduction, inspect the pole and zero locations
by typing
pzmap(sys35)
Zoom in near the origin on the resulting plot using the zoom feature or by
typing
2-30
Reducing Model Order
To find a low-order reduction of this SISO model, perform the following steps:
hsvd(sys35)
Changing to log scale using the right-click menu results in the following
plot.
2-31
2 Building Models
Small Hankel singular values indicate that the associated states contribute
little to the I/O behavior. This plot shows that discarding the last 10 states
(associated with the 10 smallest Hankel singular values) has little impact
on the approximation error.
2 To remove the last 10 states and create a 15th order approximation, type
rsys35 = balred(sys35,15);
You can type size(rsys35) to see that your reduced system contains only
15 states.
bode(sys35,'b',rsys35,'r--')
2-32
Reducing Model Order
As the overlap of the curves in the figure shows, the reduced model provides
a good approximation of the original system.
You can try reducing the model order further by repeating this process and
removing more states. Reduce the gasf model to 5th, 10th, and 15th orders
all at once by typing the following command
Plot a bode diagram of these three reduced systems along with the full order
system by typing
bode(sys35,'b',rsys35,'r--')
2-33
2 Building Models
Type
hsvd(gasf)
2-34
Reducing Model Order
Discarding the last 8 states (associated with the 8 smallest Hankel singular
values) should have little impact on the error in the resulting 17th order
system.
2 To remove the last 8 states and create a 17th order MIMO system, type
rsys=balred(gasf,17);
You can type size(gasf) to see that your reduced system contains only
17 states.
sigma(gasf,'b',gasf-rsys,'r')
2-35
2 Building Models
The reduction error is small compared to the original system so the reduced
order model provides a good approximation of the original model.
Acknowledgment
MathWorks thanks ALSTOM® Power UK for permitting use of their gasifier
model for this example. This model was issued as part of the ALSTOM
Benchmark Challenge on Gasifier Control. For more details see Dixon, R.,
(1999), "Advanced Gasifier Control," Computing & Control Engineering
Journal, IEE, Vol. 10, No. 3, pp. 92–96.
2-36
3
Analyzing Models
• “Quick Start for Performing Linear Analysis Using the LTI Viewer” on
page 3-2
• “LTI Viewer” on page 3-7
• “Simulating Models with Arbitrary Inputs and Initial Conditions” on page
3-22
• “Functions for Time and Frequency Response” on page 3-37
3 Analyzing Models
Before you can perform the analysis, you must have already created linear
models in the MATLAB workspace. For information on how to create a model,
see Chapter 2, “Building Models”.
1 Open the LTI Viewer showing one or more models using the following
syntax:
ltiview(model1,model2,...,modelN)
By default, this syntax opens a step response plot of your models, as shown
in the following figure.
3-2
Quick Start for Performing Linear Analysis Using the LTI Viewer
3-3
3 Analyzing Models
b In the Plot Configurations dialog box, select the number of plots to open.
Select the
number of
plots to open
3-4
Quick Start for Performing Linear Analysis Using the LTI Viewer
Right-click
to select
a plot type
3-5
3 Analyzing Models
4 Analyze system performance. For example, you can analyze the peak
response in the Bode plot and settling time in the step response plot.
a Right-click to select performance characteristics.
Right-click to show
performance
characteristics
Click dot to
view value
3-6
LTI Viewer
LTI Viewer
In this section...
“Plot Types Available in the LTI Viewer” on page 3-7
“Example: Time and Frequency Responses of the DC Motor” on page 3-8
“Right-Click Menus” on page 3-10
“Displaying Response Characteristics on a Plot” on page 3-11
“Changing Plot Type” on page 3-14
“Showing Multiple Response Types” on page 3-16
“Comparing Multiple Models” on page 3-17
Note that time responses and pole/zero plots are not available for FRD models.
Note The LTI Viewer displays up to six different plot types simultaneously.
You can also analyze the response plots of several linear models at once.
3-7
3 Analyzing Models
The next section presents an example that shows you how to import a system
into the LTI Viewer and how to customize the viewer to fit your requirements.
load ltiexamples
3-8
LTI Viewer
ltiview
This opens an LTI Viewer with an empty step response plot window by default.
Import System Data Dialog Box with the DC Motor Model Selected
Select sys_dc from the list of available models and click OK to close the
browser. This imports the DC motor model into the LTI Viewer.
3-9
3 Analyzing Models
The figure below shows the LTI Viewer with a step response for the DC
motor example.
Alternatively, you can open the LTI Viewer and import the DC motor example
directly from the MATLAB prompt.
ltiview('step', sys_dc)
Right-Click Menus
The LTI Viewer provides a set of controls and options that you can access by
right-clicking your mouse. Once you have imported a model into the LTI
Viewer, the options you can select include
• Plot Types — Change the plot type. Available types include step, impulse,
Bode, Bode magnitude, Nichols, Nyquist, and singular values plots.
3-10
LTI Viewer
• Systems — Select or clear any models that you included when you created
the response plot.
• Characteristics — Add information about the plot. The characteristics
available change from plot to plot. For example, Bode plots have stability
margins available, but step responses have rise time and steady-state
values available.
• Grid — Add grids to your plots.
• Normalize — Scale responses to fit the view (only available for
time-domain plot types).
• Full View — Use automatic limits to make the entire curve visible.
• Properties — Open the Property Editor.
You can use this editor to customize various attributes of your plot. See
Customizing Plot Properties and Preferences for a full description of the
Property Editor.
Alternatively, you can open the Property Editor by double-clicking in an
empty region of the response plot.
3-11
3 Analyzing Models
Using Right-Click Menus to Display the Rise Time for a Step Response
By default, the rise time is defined as the amount of time it takes the step
response to go from 10% to 90% of the steady-state value. You can change this
range in the options tab of the property editor. For more information on the
property editor, see Customizing Plot Properties and Preferences.
The LTI Viewer calculates and displays the rise time for the step response.
3-12
LTI Viewer
For example, this figure shows the rise time value for the DC motor step
response.
3-13
3 Analyzing Models
Note that you can left-click anywhere on a particular plot line to see the
response values of that plot at that point. You must either place your cursor
over the blue dot or left-click, however, if you want to see the rise time value.
For more information about data markers, see “Data Markers” on page 3-42.
3-14
LTI Viewer
Selecting Bode changes the step response to a Bode plot for the DC motor
model.
3-15
3 Analyzing Models
3-16
LTI Viewer
Using the Plot Configurations Dialog Box to Reconfigure the LTI Viewer
You can select up to six plots in one viewer. Choose the Response type for
each plot area from the right-side menus. There are nine available plot types:
• Step
• Impulse
• Linear Simulation
• Initial Condition
• Bode (magnitude and phase)
• Bode Magnitude (only)
• Nyquist
• Nichols
• Singular Value
• Pole/Zero
• I/O pole/zero
3-17
3 Analyzing Models
load ltiexamples
to load the provided transfer functions. The three closed-loop transfer function
models, Gcl1, Gcl2, and Gcl3, are for a satellite attitude controller.
In this example, you analyze the response plots of the Gcl1 and Gcl2 transfer
functions.
Alternatively, you can open an LTI Viewer with both systems and both the
step responses and Bode plots displayed. To do this, type
ltiview({'step';'bode'},Gcl1,Gcl2)
3-18
LTI Viewer
• Right-click anywhere in the plot region of the step response plots. This
opens the right-click menu list in the plot region.
• Select Characteristics > Settling Time.
To mark the stability margins of the Bode plot in this example, right-click and
select Characteristics > Minimum Stability Margins.
3-19
3 Analyzing Models
The minimum stability margins, meaning the smallest magnitude phase and
gain margins, are displayed as green and blue markers on the Bode phase
diagram. If you want to see all the gain and phase margins of a system,
right-click and select Characteristics > Minimum Stability Margins.
s=tf('s');
sys1=1/(s^2+s+1);
sys2=1/(s^2+s+2);
sys3=1/(s^2+s+3);
3-20
LTI Viewer
This figure shows how to clear the second of the three models using right-click
menu options.
The Systems menu lists all the imported models. A system is selected if a
check mark is visible to the left of the system name.
3-21
3 Analyzing Models
3-22
Simulating Models with Arbitrary Inputs and Initial Conditions
• In the LTI Viewer, right-click the plot area and select Plot Types >
Linear Simulation.
• Use the lsim function at the MATLAB prompt:
lsim(modelname)
After opening the Linear Simulation Tool (as described in “Opening the Linear
Simulation Tool” on page 3-22), follow these steps to simulate your model:
3-23
3 Analyzing Models
2 In the Timing area, specify the simulation time vector by doing one of
the following:
• Import the time vector by clicking Import time.
• Enter the end time and the time interval in seconds. The start time
is set to 0 seconds.
4 If you have a state-space model and want to specify initial conditions, click
the Initial states tab. By default, all initial states are set to zero.
You can either enter state values in the Initial value column, or import
values by clicking Import state vector. For more information about
entering initial states, see “Specifying Initial Conditions” on page 3-35.
3-24
Simulating Models with Arbitrary Inputs and Initial Conditions
6 Click Simulate.
3-25
3 Analyzing Models
For information about creating your own inputs, see “Designing Input
Signals” on page 3-33. For an overview of working with the Linear Simulation
Tool, see “Working with the Linear Simulation Tool” on page 3-23.
1 In the Linear Simulation Tool, click the Input signals tab, if it is not
displayed.
3 Select one or more rows for the input channels you want to import. The
following figure shows an example with two selected channels.
3-26
Simulating Models with Arbitrary Inputs and Initial Conditions
4 Click Import signal to open the Data Import dialog box. The following
figure shows an example of the Data Import dialog box.
3-27
3 Analyzing Models
5 In the Import from list, select the source of the input signals. It can be
one of the following:
• Workspace
• MAT file
• XLS file
• CSV file
• ASCII file
6 Select the data you want to import. The Data Import dialog box contains
different options depending on which source format you selected.
7 Click Import.
1 In the Linear Simulation Tool, click Import signal in the Input signals
tab to open the Data Import dialog box.
3 Click Browse.
4 Select the file you want to import and click Open. This populates the Data
Import dialog box with the data from the Microsoft Excel spreadsheet.
3-28
Simulating Models with Arbitrary Inputs and Initial Conditions
s=tf('s');
ss=(s+2)/(s^2+3*s+2);
lsim(ss,randn(100,1),1:100);
3-29
3 Analyzing Models
This opens the Linear Simulation Tool with default input data.
3-30
Simulating Models with Arbitrary Inputs and Initial Conditions
3 Create an input signal for your system in the MATLAB Command Window,
such as the following:
5 In the Data Import dialog box, click, Assign columns to assign the first
column of the input signal to the selected channel.
3-31
3 Analyzing Models
6 Click Import. This imports the new signal into the Linear Simulation Tool.
3-32
Simulating Models with Arbitrary Inputs and Initial Conditions
For information about importing inputs from the MATLAB workspace or from
a file, see “Importing Input Signals” on page 3-26. For an overview of working
with the Linear Simulation Tool, see “Working with the Linear Simulation
Tool” on page 3-23.
1 In the Linear Simulation Tool, click the Input signals tab (if it is not
displayed).
3-33
3 Analyzing Models
2 Specify the simulation time in the Timing area. The time interval (in
seconds) is used to evaluate the input signal you design in later steps of
this procedure.
3 Select one or more rows for the signal channels you want to design. The
following figure shows an example with two selected channels.
4 Click Design signal to open the Signal Designer dialog box. The following
figure shows an example of the Signal Designer dialog box.
3-34
Simulating Models with Arbitrary Inputs and Initial Conditions
5 In the Signal type list, select the type of signal you want to create. It
can be one of the following:
• Sine wave
• Square wave
• Step function
• White noise
6 Specify the signal characteristics. The Signal Designer dialog box contains
different options depending on which signal type you selected.
7 Click Insert. This brings the new signal into the Linear Simulation Tool.
8 Click Simulate in the Linear Simulation Tool to view the system response.
For an overview of working with the Linear Simulation Tool, see “Working
with the Linear Simulation Tool” on page 3-23.
You can also import initial states from the MATLAB workspace.
3-35
3 Analyzing Models
1 In the Linear Simulation Tool, click the Initial states tab (if it is not
already displayed).
2 In the Selected system list, select the system for which you want to
specify initial conditions.
3 You can either enter state values in the Initial value column, or import
values from the MATLAB workspace by clicking Import state vector.
The following figure shows an example of the import window:
4 After specifying the initial states, click Simulate in the Linear Simulation
Tool to view the system response.
3-36
Functions for Time and Frequency Response
The next sections discuss time and frequency response functions and how to
use these functions to create customized plots of linear model responses.
3-37
3 Analyzing Models
response, and general linear simulations. For example, you can simulate the
response to white noise inputs using lsim and the MATLAB function randn.
In addition to time-domain analysis, you can use the Control System Toolbox
functions for frequency-domain analysis using the following standard plots:
• Bode
• Nichols
• Nyquist
• Singular value
This table lists available time and frequency response functions and their use.
Functions Description
bode Bode plot
evalfr Computes the frequency response at a single complex
frequency (not for FRD models)
freqresp Computes the frequency response for a set of
frequencies
gensig Input signal generator (for lsim)
impulse Impulse response plot
initial Initial condition response plot
iopzmap Pole-zero map for each I/O pair of an LTI model
lsim Simulation of response to arbitrary inputs
margin Computes and plots gain and phase margins
nichols Nichols plot
nyquist Nyquist plot
pzmap Pole-zero map
step Step response plot
3-38
Functions for Time and Frequency Response
Functions Description
hsvd Compute Hankel singular values of LTI model
bodemag Bode magnitude response of LTI models
3-39
3 Analyzing Models
3-40
Functions for Time and Frequency Response
Right-Click Menus
All the time and frequency response functions provide right-click menus
that allow you to customize your plots. For more information on using the
LTI Viewer right-click menus, see “Using the Right-Click Menu in the LTI
Viewer”. This figure shows the plots from Step Responses for a MIMO Model
on page 3-40, with the right-click menu open.
3-41
3 Analyzing Models
• Systems — Select or clear any models that you included when you created
the response plot.
• Characteristics — Add information about the plot. The characteristics
available change from plot to plot. For example, Bode plots have stability
margins available, but step responses have rise time and steady-state
values available.
• Axes Grouping — Change the grouping of your plots. Available options
are All, None, Inputs, and Outputs. You can group all the plots together,
place each in a separate plot region (none), or group the inputs or outputs
together.
• I/O Selector — Open the I/O Selector dialog box.
Use this dialog box to select/clear which inputs and outputs to plot.
• Normalize — Scale responses to fit the view (only available for
time-domain plot types).
• Full View — Use automatic limits to make the entire curve visible.
• Grid — Add grids to your plots.
• Properties — Open the Property Editor, which you can use to customize
various attributes of your plot. See Customization for a full description of
the Property Editor.
Alternatively, you can open the Property Editor by double-clicking in an
empty region of the response plot.
Data Markers
In addition to right-click menus, you can use plot data markers. These allow
you to identify key data points on your plots. This figure, using the same
plot as Step Responses for a MIMO Model on page 3-40, shows markers on
the plots.
3-42
Functions for Time and Frequency Response
The time and amplitude values will change as you move the marker. This
does not apply to markers that display plot characteristics (e.g., peak value or
rise time). In the case of plot characteristic data markers, you can view them
by placing your cursor over the dot that represents the active characteristic.
To make the data marker persistent, left-click the marker.
Note Data markers do not apply to the SISO Design Tool, which displays
data about plot characteristics in the status pane at the bottom of the SISO
Design Tool window.
3-43
3 Analyzing Models
Right-Click Menus
Right-click on any data marker to open a property menu for the marker.
These options work the same as they do for the full right-click menu.
3-44
Functions for Time and Frequency Response
so, invoke the corresponding command-line function using the list sys1,...,
sysN of models as the inputs.
stepplot(sys1,sys2,...,sysN)
impulseplot(sys1,sys2,...,sysN)
...
bodeplot(sys1,sys2,...,sysN)
nicholsplot(sys1,sys2,...,sysN)
...
All models in the argument lists of any of the response plotting functions
(except for sigma) must have the same number of inputs and outputs.
To differentiate the plots easily, you can also specify a distinctive
color/linestyle/marker for each system just as you would with the plot
command. For example,
bodeplot(sys1,'r',sys2,'y--',sys3,'gx')
plots sys1 with solid red lines, sys2 with yellow dashed lines, and sys3 with
green x markers.
You can plot responses of multiple models on the same plot. These models do
not need to be all continuous-time or all discrete-time.
stepplot(sysc,'--',sysd,'-')
% Compare step responses
3-45
3 Analyzing Models
Use this command to compare the Bode plots of the two systems.
bodeplot(sysc,'--',sysd,'-')
% Compare Bode responses
3-46
Functions for Time and Frequency Response
Comparison of Bode Plots for a Continuous Model and Its Discretized Version
3-47
3 Analyzing Models
bodeplot(h)
subplot(222)
stepplot(h)
subplot(223)
pzplot(h)
subplot(224)
plot(rand(1, 100)) % Any data can go here
title('Some noise')
For information about plot, subplot, hold, and other options for plotting
general data, see Basic Plots and Graphs in the MATLAB Function Reference.
These documents are available in the MATLAB online help.
3-48
Functions for Time and Frequency Response
3-49
3 Analyzing Models
3-50
4
Designing Compensators
r
+ u y
C sys
-
r
+ u y
C sys
-
4-2
Designing PID Controllers
The PID Tuner automatically designs a controller for your plant. You specify
the controller type (P, I, PI, PD, PDF, PID, PIDF) and form (parallel or
standard). You can analyze the design using a variety of response plots, and
interactively adjust the design to meet your performance requirements.
pidtool(sys,type)
where sys is a linear model of the plant you want to control, and type is a
string indicating the controller type to design.
Alternatively, enter
pidtool(sys,Cbase)
For more information about sys and Cbase, see the pidtool reference page.
4-3
4 Designing Compensators
If sys is a discrete-time model with sampling time Ts, the PID Tuner designs
a discrete-time pid controller using the ForwardEuler discrete integrator
formula. To design a controller that has different discrete integrator formulas,
use one of the following methods:
4-4
Designing PID Controllers
• After launching the PID Tuner, click the button to open the PID
Tuner Settings dialog box. Select discrete integrator formulas from the
Integral Formula and Derivative Formula menus.
For more information about discrete integrator formulas, see the pid and
pidstd reference pages.
For more information about parallel and standard controller forms, see the
pid and pidstd reference pages.
d1 d2
PID Plant
r + u + +
- C sys y
+ +
4-5
4 Designing Compensators
4-6
Designing PID Controllers
If you provide Cbase, check Show baseline to display the response of the
baseline controller.
1
sys = .
(s + 1)3
The design requirements are for the closed loop system to track a reference
input with a rise time less than 1.5 s, and settling time less than 6 s.
1 Launch the PID Tuner to design a PI controller for a first pass design.
Upon launch, the PID Tuner displays the closed-loop step response of the
system with a PI controller designed for a balance between performance
(response time) and robustness (stability margins).
4-7
4 Designing Compensators
4-8
Designing PID Controllers
4-9
4 Designing Compensators
on the plot, click the Show parameters button . This action expands
the GUI to show performance and robustness metrics. It also displays
the controller gains.
3 Use the Response time slider to try to improve the loop performance.
Slide the slider to the right to make the loop faster. The response plot
automatically updates with the new design.
Moving the slider far enough to meet the rise time requirement of less
than 1.5 s, however, results in unacceptably long settling time. There is
also more oscillation. To achieve the faster response speed, the algorithm
must sacrifice stability.
4-10
Designing PID Controllers
Adding derivative action to the controller gives the PID Tuner more
freedom to achieve adequate phase margin with the desired response speed.
Select PIDF from the Type menu. The PID Tuner designs a new PIDF
controller. (See “PID Controller Type” on page 4-3 for more information
about available controller types.)
4-11
4 Designing Compensators
The rise time and settling time now meet the design requirements. You can
use the Response time slider to make further adjustments to the response.
To revert to the default automated tuning result, click the button.
4-12
Designing PID Controllers
4-13
4 Designing Compensators
See “Analyzing Your Design Using Response Plots” on page 4-5 for more
information about available response plots.
For more examples of controller design using the PID Tuner, see the Control
System Toolbox demo, Designing PID for Disturbance Rejection with PID
Tuner
4-14
SISO Design Tool
To tune parameters:
1 Open the control design GUIs by typing the following in the MATLAB
Command Window:
sisotool
4-15
4 Designing Compensators
This command opens the Control and Estimation Tools Manager and the
SISO Design Tool, as shown in the following figure.
4-16
SISO Design Tool
Select
control
architecture
Specify sign of
summing junctions
as + or -
4-17
4 Designing Compensators
3 Specify the plant model and initial guesses for the compensator elements
in the control architecture.
a In the Architecture tab of the Control and Estimation Tools Manager,
click System Data.
b In the System Data dialog box, browse for a model in the MATLAB
workspace.
Browse for
model in MATLAB
workspace
4-18
SISO Design Tool
Select
automated
tuning method
Specify
tuning options
Tune parameters
4-19
4 Designing Compensators
Select plot
type
4-20
SISO Design Tool
Click dot
to view value
Right-click
to select
performance
characteristics
4-21
4 Designing Compensators
i In the Graphical Tuning tab, select the loop to tune in each plot.
ii Select plot types.
4-22
SISO Design Tool
Right-click to
add dynamic
elements in
controller structure
c Add a new pole, for example, by clicking the pole location on the plot.
4-23
4 Designing Compensators
d Modify the compensator structure by moving the poles, zeros, and other
dynamic elements directly on the plot.
Click and
drag plot
4-24
SISO Design Tool
a In the Control and Estimation Tools Manager, select File > Export.
Select Export to
compensator workspace
4-25
4 Designing Compensators
• SISO Design Task node in the Control and Estimation Tools Manager
is a user interface (UI) that facilitates the design of compensators for
single-input, single-output feedback loops through a series of interactive
tabs.
• The Graphical Tuning window is a graphical user interface (GUI) for
displaying and manipulating the Bode, root locus, and Nichols plots for the
controller currently being designed. This window is titled SISO Design
for Design Name.
• The LTI Viewer associated with the SISO Design Task. For instructions
on how to operate the LTI Viewer, see “LTI Viewer for SISO Design Task
Design Requirements”.
4-26
SISO Design Tool
load ltiexamples
sisotool(sys_dc)
• The SISO Design Task node in the Control and Estimation Tools Manager
• The Graphical Tuning window with the root locus and open-loop Bode
diagrams for the DC motor plotted by default
4-27
4 Designing Compensators
4-28
SISO Design Tool
• Architecture:
- Change the feedback structure and label signals and blocks.
- Configure loops for multi-loop design by opening signals to remove the
effects of other feedback loops.
- Import LTI models or row or column arrays of LTI models into your
system.
4-29
4 Designing Compensators
You can import an LTI model or a row or column array of LTI models by
clicking System Data in the Architecture page, as shown in the following
figure.
4-30
SISO Design Tool
The System Data dialog box opens, as shown in the following figure.
4-31
4 Designing Compensators
Note If you import an array of LTI models for either G or H or both for control
design, you can use the default multimodel options or configure the options by
clicking Multimodel Configuration in the Architecture tab. For more
information, see “Control Design Analysis of Multiple Models” on page 4-132.
1 Select G and click Browse. The Model Import dialog box opens, as shown
in the following figure.
4-32
SISO Design Tool
2 Select sys_dc from the Available Models list. Click Import, and then
click Close.
You can now see sys_dc in the System Data dialog box.
3 Click OK.
The Graphical Tuning window updates with the DC motor model, as shown
in the following figure.
4-33
4 Designing Compensators
Feedback Structure
The SISO Design Tool, by default, assumes that the compensator is in the
forward path, i.e., that the feedback structure looks like this figure.
In this figure:
4-34
SISO Design Tool
The default values for F, H, and C are all 1. You can see the default values in
the System Data dialog box. This means that, by default, the compensator
has unity gain.
You can use the Signs and Blocks and Signals panes to change the sign of
the feedback signal into a summing junction and rename blocks and signals
in the diagram respectively. See “Block Diagram Structure Modifications”
for more details.
On any tab in the SISO Design Task node, click Show Architecture to see
the current architecture and a list of the identifiers and names associated
with the components.
4-35
4 Designing Compensators
4-36
SISO Design Tool
Select the plot types for each plot in the Analysis Plots area. Then select the
plots to appear in the Plots list in the Contents of Plots table, as shown in
the following figure.
4-37
4 Designing Compensators
After you select a plot, the LTI Viewer opens and displays the appropriate
response(s) opens. You can also click Show Analysis Plot to open the LTI
Viewer.
The following figure shows the resulting plot for the closed-loop step response
of the DC motor.
4-38
SISO Design Tool
The settling time of the DC motor is about 1.5 seconds, which is too slow for
many applications. Also, the plot shows a large steady-state error. You can
use Bode diagram techniques to improve the response time and steady-state
error of the DC motor step response, as described in “Bode Diagram Design”
on page 4-55.
For a row or column array of LTI models, the analysis plots show the response
of the nominal model only. To view the responses of the remaining models in
the array, right-click the plot, and select one of the following options:
4-39
4 Designing Compensators
4-40
SISO Design Tool
The plot line in darker shade of blue is the response of the nominal model.
When you design a controller for the nominal plant, you can simultaneously
analyze the controller’s effect on the remaining model responses in the array.
For more information on analyzing control design for multiple models, see
“Control Design Analysis of Multiple Models” on page 4-132.
4-41
4 Designing Compensators
The graphical tuning window shows the plots configured in the Graphical
Tuning tab.
4-42
SISO Design Tool
This topic describes some of the methods you can use to navigate in the
Graphical Tuning window and manipulate the window’s appearance.
• Poles as x’s
• Zeros as o’s
• Gain and phase margins (by default) in the lower-left corners of the Bode
magnitude and phase plots
For the DC motor, the graphical tuning window resembles the following figure.
4-43
4 Designing Compensators
For a row or column arrays of LTI models, the plots show the individual
responses and poles and zeros of all models in the array, as shown in the
following figure.
4-44
SISO Design Tool
The plot line in darker shade of blue represents the response of the nominal
model. This plot also displays the response characteristics of the nominal
model.
You can change the display to view an envelope that encompasses all
individual model responses. To do so, right-click the plot, and select
Multimodel Display > Bounds. The bounds resemble the following figure.
4-45
4 Designing Compensators
As you are designing a controller for the nominal plant, you can
simultaneously analyze the controller’s effect on the remaining models in the
array. The software computes the response for each model and plots them.
This computation is expensive and results in a slower refresh of the plots for:
4-46
SISO Design Tool
To speed up the plot updates, change the display to plot the envelope instead
of individual responses. For more information, see “Control Design Analysis
of Multiple Models” on page 4-132.
4-47
4 Designing Compensators
Use the options on the Units page to make the change. This unit change
persists for the entire session.
Right-Click Menus
The SISO Design Tool has right-click menus available in any of the plot
regions. Open the Bode magnitude menu by right-clicking in the Bode
magnitude plot. The following menu appears.
4-48
SISO Design Tool
Although the menus for each plot generally contain the same options, there
are some options specific to each plot type:
• The Open-Loop Bode Editor has a Gain Target option, the Closed-Loop
Bode Editor has a Select Compensator option instead.
• For arrays of LTI models, the Multimodel Display option for the Root
Locus Editor has an option to show the poles and zeros of the nominal or all
models, instead of Bounds and Individual Responses options.
4-49
4 Designing Compensators
• Select models to export area shows a list of models for the components of
your designs. For a plant or sensor modeled as row or column array of LTI
models, the components are also arrays of LTI models.
• Export As column displays variables with default names or previously
named in the System Data dialog box.
• Select design drop-down list lets you view the components of other
designs.
To select multiple components, use the Shift key if they are all adjacent
and the Ctrl key if they are not.
4-50
SISO Design Tool
who
You can save your models as MAT-files in any folder. The default name
for the MAT-file is the name of your original model. You can also specify a
name for the MAT-file. If you save multiple components, they are stored
in a single MAT-file.
4-51
4 Designing Compensators
If you have any intermediate designs already stored, they will appear on
the Design History page.
Click Store Design to save the current design with the default name Design;
the suffix increments when you store additional compensators without
renaming them. You can rename the design by right-clicking the name under
the node and selecting Rename.
4-52
SISO Design Tool
Click any design name in the Design History to view a snapshot summary of
the design, as shown in the following figure.
4-53
4 Designing Compensators
4-54
Bode Diagram Design
Example: DC Motor
The following topics use the DC motor example to show how to create a
compensator using Bode diagram design techniques. From “SISO Example:
The DC Motor” on page 2-3, the transfer function of the DC motor is
Transfer function:
1.5
------------------
s^2 + 14 s + 40.02
4-55
4 Designing Compensators
3 In the text box to the right of the equal sign in the Compensator area,
enter 38 and press Enter.
4-56
Bode Diagram Design
The SISO Design Tool calculates the compensator gain, and Bode and root
locus graphs in the Graphical Tuning window are updated.
Alternatively, you can set the gain in the Graphical Tuning window by
grabbing the Bode magnitude line and dragging it upward. The gain and poles
change as the closed-loop set point is recomputed, and the new compensator
value is updated in the Compensator Editor page.
4-57
4 Designing Compensators
To make the crossover easier to see, select Grid from the right-click menu.
This creates a grid for the Bode magnitude plot. Left-click the Bode magnitude
plot and drag the curve until you see the curve crossing over the 0 dB line (on
the y axis) at 3 rad/s. This changes both the SISO Design Tool display and
the LTI Viewer step response.
This plot shows the associated closed-loop step response in the LTI Viewer.
4-58
Bode Diagram Design
The step response shows that the steady-state error and rise time have
improved somewhat, but you must design a more sophisticated controller
to meet all the design specifications, in particular, the steady-state error
requirement.
Adding an Integrator
One way to eliminate steady-state error is to add an integrator. To add an
integrator:
2 Right-click anywhere in the Dynamics table for the right-click menu, and
then select Add Pole/Zero > Integrator.
4-59
4 Designing Compensators
4-60
Bode Diagram Design
Notice adding the integrator changed the crossover frequency of the system.
Readjust the compensator gain in the Compensator Editor page to bring
the crossover back to 3 rad/s; the gain should be 99.
After you have added the integrator and readjusted the compensator gain, the
Graphical Tuning window shows a red ‘x’ at the origin of the root locus plot.
4-61
4 Designing Compensators
4-62
Bode Diagram Design
Use the right-click menu to show the peak response and rise time (listed
under the Characteristics). The step response is settling around 1, which
satisfies the steady-state error requirement. This is because the integrator
forces the system to zero steady-state error. The figure shows, however, that
the peak response is 1.3, or about 30% overshoot, and that the rise time is
roughly 0.4 second. So a compensator consisting of an integrator and a gain
is not enough to satisfy the design requirements, which require that the
overshoot be less than 10%.
4-63
4 Designing Compensators
the compensator gain to verify this. The only option left is to add dynamics to
the compensator.
2 In the Dynamics table, right-click and then select Add Pole/Zero > Lead.
The following figures show the process of adding a lead network to your
controller.
4-64
Bode Diagram Design
Editable fields are shown in the Edit Selected Dynamics group box (right
side of page) when an item in the Dynamics table has been selected, as
shown in the following figure.
4-65
4 Designing Compensators
For this example, change Real Zero to -7.38 and change Real Pole to -11.1.
You can also add a lead network using the Graphical Tuning window.
Right-click in the Bode graph, select Add Pole/Zero > Lead, place the ‘x’
on the plot where you want to add the lead network, and then left-click to
place it. The Compensator Editor page is updated to include the new lead
network in the Dynamics table.
Your Graphical Tuning window and LTI Viewer plots should now look similar
to these.
4-66
Bode Diagram Design
Root Locus, Bode, and Step Response Plots for the DC Motor with a Lead
Network
4-67
4 Designing Compensators
The Step Response plot shows that the rise time is now about 0.4 second and
peak response is 1.24 rad/s (i.e., the overshoot is about 25%). Although the rise
time meets the requirement, the overshoot is still too large, and the stability
margins are still unacceptable, so you must tune the lead parameters.
1 Change the value of the lead network zero (Real Zero) to move it closer to
the left-most (slowest) pole of the DC motor plant (denoted by a blue ‘x’).
2 Change the value of the lead network pole (Real Pole) to move it to the
right. Notice how the gain margin increases (as shown in the Graphical
Tuning window) as you do this.
4-68
Bode Diagram Design
As you tune these parameters, look at the LTI Viewer. You will see the
closed-loop step response alter with each parameter change you make.
The following figure shows the final values for a design that meets the
specifications.
Graphical Tuning Window with Final Design Parameters for the DC Motor
Compensator
4-69
4 Designing Compensators
Enter these values directly in the Edit Selected Dynamics group box in the
Compensator Editor page, shown as follows (Integrator is already set to 0).
The following figure shows the step response for the final compensator design.
4-70
Bode Diagram Design
4-71
4 Designing Compensators
4-72
Bode Diagram Design
The following figure shows the result in the Graphical Tuning window.
4-73
4 Designing Compensators
To see the notch filter parameters in more detail, click the Zoom In
icon on the Graphical Tuning window. In the Open-Loop Bode Editor, press
the left mouse button and drag your mouse to draw a box around the notch
filter. When you release the mouse, the Graphical Tuning window will zoom
in on the selected region.
To understand how adjusting the notch filter parameters affects the filter,
consider the notch filter transfer function.
s2 + 21n s + n2
s2 + 22n s + n2
4-74
Bode Diagram Design
The three adjustable parameters are ξ1, ξ2, and ωn. The ratio of ξ2/ξ1 sets the
depth of the notch, and ωn is the natural frequency of the notch.
This diagram shows how moving the red ⊗ and black diamonds changes these
parameters, and hence the transfer function of the notch filter.
In the Dynamics table on the Compensator Editor page, select the row
containing the newly added notch filter. The editable fields appear in the
Edit Selected Dynamics group box, as shown next.
4-75
4 Designing Compensators
Modifying a Prefilter
You can use the SISO Design Tool to modify the prefilter in your design.
Typical prefilter applications include:
A common prefilter is a simple lowpass filter that reduces noise in the input
signal.
4-76
Bode Diagram Design
Open the Bode diagram for the prefilter by opening the right-click menu in
the Closed-Loop Bode Editor in the Graphical Tuning window, and then
selecting Select Compensators > F(F).
For clarity, the previous figure does not show the open-loop Bode diagram for
the compensator (C). To remove the Bode diagram from the Graphical Tuning
window, go to the SISO Design Task node on the Control and Estimation
Tools Manager, click the Graphical Tuning tab, and for Plot 2, Open Loop 1,
select Plot type None.
4-77
4 Designing Compensators
If you haven’t imported a prefilter, the default is a unity gain. You can add
poles and zeros and adjust the gain using the same methods as you did when
designing the compensator (C) on the Compensator Editor page.
4-78
Bode Diagram Design
By default, the damping ratio of the complex pair is 1.0, which means that
there are two real-valued poles at about -50 rad/s. The green curve, which
represents the prefilter Bode response, shows the -3 dB point for the roll-off
is at about 50 rad/s. The magenta curve, which represents the closed-loop
response from the prefilter to the plant output, shows that after the -3 dB
point, the closed-loop gain rolls off at -40 dB/decade to provide some noise
disturbance rejection.
Importing a Prefilter
As an alternative approach, you can design a prefilter using the Control
System Toolbox commands like ss or tf and then import the design directly
into the prefilter. For example, to create the lowpass filter using zpk, try
4-79
4 Designing Compensators
Importing a Prefilter
Select prefilt from the Available Models list and click Import to import
the prefilter model. Click Close to close the Import Model dialog box. After
you have imported the prefilter model, you can modify it using the same
methods as described in this chapter for compensator design.
4-80
Root Locus Design
As system parameter k varies over a continuous range of values, the root locus
diagram shows the trajectories of the closed-loop poles of the feedback system.
Typically, the root locus method is used to tune the loop gain of a SISO control
system by specifying a designed set of closed-loop pole locations.
where P(s) is the plant, H(s) is the sensor dynamics, and k is a scalar gain to
be adjusted. The closed-loop poles are the roots of
4-81
4 Designing Compensators
The root locus technique consists of plotting the closed-loop pole trajectories
in the complex plane as k varies. You can use this plot to identify the gain
value associated with a desired set of closed-loop poles.
The DC motor design example focused on the Bode diagram feature of the
SISO Design Tool. Each of the design options available on the Bode diagram
side of the tool have a counterpart on the root locus side. To demonstrate
these techniques, this example presents an electrohydraulic servomechanism.
The SISO Design Tool’s root locus and Bode diagram design tools provide
complementary perspectives on the same design issues; each perspective
offers insight into the design process. Because the SISO Design Tool shows
both root locus and Bode diagrams, you can also choose to combine elements
of both perspectives in making your design decisions.
4-82
Root Locus Design
Electrohydraulic Servomechanism
The force on the spool is proportional to the current in the electromagnet coil.
As the spool moves, the valve opens, allowing the high-pressure hydraulic
fluid to flow through the chamber. The moving fluid forces the piston to move
in the opposite direction of the spool. Control System Dynamics, by R. N.
Clark, (Cambridge University Press, 1996) derives linearized models for the
electromagnetic amplifier, the valve spool dynamics, and the ram dynamics; it
also provides a detailed description of this type of servomechanism.
If you want to use this servomechanism for position control, you can use
the input voltage to the electromagnet to control the ram position. When
measurements of the ram position are available, you can use feedback for the
ram position control, as shown in the following figure.
4-83
4 Designing Compensators
load ltiexamples
Gservo
Design Specifications
For this example, you want to design a controller so that the step response of
the closed-loop system meets the following specifications:
The remainder of this topic discusses how to use the SISO Design Tool to
design a controller to meet these specifications.
sisotool(Gservo)
at the MATLAB prompt. This opens the SISO Design Task node in the
Control and Estimation Tools Manager and the Graphical Tuning window
with the servomechanism plant imported.
4-84
Root Locus Design
Graphical Tuning Window Showing the Root Locus and Bode Plots for the
Electrohydraulic Servomechanism Plant
Zooming
Click the Zoom In
icon in the Graphical Tuning window. Press and hold the mouse’s left button
and drag the mouse to select a region for zooming. For this example, reduce
the root locus region to about -500 to 500 in both the x- and y-axes. This figure
illustrates the zooming in process.
4-85
4 Designing Compensators
As in the DC motor example, click the Analysis Plots tab to set up loop
responses. Select Plot Type Step for Plot 1, then select plot 1 for Closed-Loop
r to y, shown as follows.
4-86
Root Locus Design
For more information about the Analysis Plots page, see Analysis Plots in
"Using the SISO Design Tool and LTI Viewer."
Selecting the plot for Closed-Loop r to y opens the associated LTI Viewer.
4-87
4 Designing Compensators
The step response plot shows that the rise time is on the order of 2 seconds,
which is much too slow given the system requirements. The following topics
describe how to use frequency design techniques in the SISO Design Tool
to design a compensator that meets the requirements specified in “Design
Specifications” on page 4-84.
4-88
Root Locus Design
Changing the Compensator Gain in the Root Locus Plot with the Compensator
Editor Page
Enter the compensator gain in the text box to the right of the equal sign as
shown in the previous figure. The Graphical Tuning window automatically
replots the graphs with the new gain.
Experiment with different gains and view the closed-loop response in the
associated LTI Viewer.
Alternatively, you can change the gain by grabbing the red squares on the root
locus plot in the Graphical Tuning window and moving them along the curve.
4-89
4 Designing Compensators
Closed-Loop Response
Change the gain to 20 by editing the text box next to the equal sign on the
Compensator Editor page. Notice that the locations of the closed-loop poles
on the root locus are recalculated for the new gain.
This figure shows the associated closed-loop step response for the gain of 20.
4-90
Root Locus Design
There are three sets of parameters that specify the compensator: poles, zeros,
and gain. After you have selected the gain, you can add poles or zeros to
the compensator.
4-91
4 Designing Compensators
You can also add a complex pole pair directly on the root locus plot using the
Graphical Tuning window. Right-click in the root locus plot and select Add
Pole/Zero > Complex Pole. Click in the root locus plot region where you
want to add one of the complex poles.
After you have added the complex pair of poles, the LTI Viewer response plots
change and both the root locus and Bode plots show the new poles.
This figure shows the Graphical Tuning window with the new poles added.
For clarity, you may want to zoom out further, as was done here.
4-92
Root Locus Design
To add the zeros using the Compensator Editor page, click the
Compensator Editor tab, make sure C is selected, and then right click
in the Dynamics table. Select Add Pole/Zero > Complex Zero. Use the
Edit Selected Dynamics group box to modify zero parameters, as shown.
For more about entering zero parameters directly, see “Editing Compensator
Pole and Zero Locations” on page 4-96.
4-93
4 Designing Compensators
You can also add complex zeros directly on the root locus plot using the
Graphical Tuning window by right-clicking in the root locus plot, selecting
Add Pole/Zero > Complex Zero, and then clicking in the root locus plot
region where you want to add one of the zeros.
After you have added the complex zeros, the LTI Viewer response plots change
and both the root locus and Bode plots show the new zeros.
4-94
Root Locus Design
4-95
4 Designing Compensators
If your step response is unstable, lower the gain by grabbing a red box in the
right-side plane and moving it into the left-side plane. In this example, the
resulting step response is stable, but it still doesn’t meet the design criteria
since the 2% settling time is greater than 0.05 second.
As you can see, the compensator design process can involve some trial and
error. You can try dragging the compensator poles, compensator zeros, or the
closed-loop poles around the root locus until you meet the design criteria.
“Editing Compensator Pole and Zero Locations” on page 4-96, shows you
how to modify the placement of poles and zeros by specifying their numerical
values on the Compensator Editor page. It also presents a solution that
meets the design specifications for the servomechanism example.
4-96
Root Locus Design
precise numerical values, however, you should use the Compensator Editor
page in the SISO Design Task node on the Control and Estimation Tools
Manager to change the gain value and the pole and zero locations of your
compensator, as shown.
Using the Compensator Editor Page to Add, Delete, and Move Compensator
Poles and Zeros
4-97
4 Designing Compensators
1 Select the compensator (in this example, C) in the list box to the left of
the equal sign.
3 From the pop-up menu, select Add Pole/Zero > Complex Pole or Add
Pole/Zero > Complex Zero.
4 Use the Edit Selected Dynamics group box to modify pole or zero
parameters.
1 Select the compensator (in this example, C) in the list box to the left of
the equal sign.
2 Select the pole or zero in the Dynamics table that you want to delete.
1 Select the compensator to edit in the list box to the left of the equal sign
in the Compensator area.
2 Enter the gain value in the text box to the right of the equal sign in the
Compensator area.
1 Select the pole or zero you want to edit in the Dynamics table.
4-98
Root Locus Design
For this example, edit the poles to be at −110 ± 140i and the zeros at
−70 ± 270i. Set the compensator gain to 23.3.
Graphical Tuning Window with the Final Values for the Electrohydraulic
Servomechanism Design Example
To see that this design meets the design requirements, look at the step
response of the closed-loop system.
4-99
4 Designing Compensators
The step response looks good. The settling time is less than 0.05 second, and
the overshoot is less than 5%. You have met the design specifications.
4-100
Root Locus Design
Applying damping ratio requirements to the root locus plot results in a pair of
shaded rays at the desired slope, as this figure shows.
4-101
4 Designing Compensators
Try moving the complex pair of poles you added to the design so that they are
on the 0.707 damping ratio line. You can experiment with different damping
ratios to see the effect on the design.
If you want to change the damping ratio, select Design Requirements >
Edit from the right-click menu. This opens the Edit Design Requirements
dialog box.
If you want to add a different set of requirements, for example, a settling time
requirement, again select Design Requirements > New from the right-click
menu to open the New Requirements dialog box and choose Settling time
from the pull-down menu. You can have multiple types of design requirements
in one plot, or more than one instance of any type.
The types of requirements available depend on which view you use for
your design. See Design Requirements for a description of all the design
requirement options available in the SISO Design Tool.
4-102
Nichols Plot Design
You can design compensators with the SISO Design Tool by using Nichols plot
techniques. This topic repeats the DC motor compensator design presented in
“Example: DC Motor” on page 4-55, only this time the focus is on Nichols plot
techniques. The design strategy, however, is the same.
3 Add a lead network to further improve the rise time while minimizing
overshoot.
DC Motor Example
From “SISO Example: The DC Motor” on page 2-3, the transfer function of
the DC motor is
Transfer function:
1.5
------------------
s^2 + 14 s + 40.02
4-103
4 Designing Compensators
load ltiexamples
sisotool({'bode','nichols'},sys_dc)
The SISO Design Task node on the Control and Estimation Tools Manager
opens and the Graphical Tuning window with sys_dc opens.
4-104
Nichols Plot Design
3 In the text box to the right of the equal sign in the Compensator area,
enter the gain amount and press Enter.
4-105
4 Designing Compensators
You can also adjust the compensator gain in the Graphical Tuning window by
moving the Nichols curve up and down with your mouse. To do this, place
your mouse over the curve. The cursor turns into a hand. Left-click and move
the curve up to increase the gain. When you adjust the gain in this manner,
the compensator gain is automatically updated in the Compensator Editor
page.
Click the Analysis Plots tab to set the analysis plots. Select Plot Type
Step for Plot 1, and then select plot 1 for Closed-Loop r to y, as shown in
the following figure, to open a linked LTI Viewer with the closed-loop step
response from reference signal r to output signal y.
4-106
Nichols Plot Design
4-107
4 Designing Compensators
The rise time is quite fast, about 0.15 second, but the overshoot is 18.4%
and the steady-state is about 0.82.
Adding an Integrator
One approach to eliminating the steady-state error is to add an integrator.
To add an integrator:
4-108
Nichols Plot Design
You can also add an integrator by selecting Add Pole/Zero > Integrator
from the right-click menu in the Graphical Tuning window. When you add the
integrator in this manner, it is automatically added to the Dynamics table
on the Compensator Editor page.
Adding an integrator changes the gain margin from infinity to 10.5 dB. Since
the gain and phase margins are now both finite, the Nichols plot shows a
vertical line for the gain margin and a horizontal line for the phase margin.
The linked LTI Viewer automatically updates to show the new response.
4-109
4 Designing Compensators
The steady-state value is now 1, which means the steady-state error has been
eliminated, but the overshoot is 34% and the rise time is about 0.7 second.
You must do more work to create a good design.
2 Right-click in the Dynamics table and select Add Pole/Zero > Lead.
This figure shows the process of adding a lead network on the Compensator
Editor page.
4-110
Nichols Plot Design
You can also add a lead network in the Graphical Tuning window. To add
a lead network, select Add Pole/Zero > Lead from the right-click menu.
Your cursor turns into a red ‘x’. Left-click along the Nichols curve to add
the lead network. To move the lead network along the curve, left-click the
pole or zero and drag.
You can track the pole’s movement in the status bar at the bottom of the
Graphical Tuning window. The status bar tells you the current location of
the pole.
Using the Compensator Editor page, move the lead network pole to -28
and the zero to -4.3 for this design. The zero should be almost on top of the
right-most pole of the plant (the DC motor model). Adjust the compensator
gain to 84. This gives the final design.
4-111
4 Designing Compensators
The gain and phase margins are 21.9 dB and 65.7 degrees, respectively.
Inspect the closed-loop step response to see if the rise time and overshoot
requirements are met.
4-112
Nichols Plot Design
As this figure shows, the rise time is 0.448 second, and the overshoot is a little
over 3%. This satisfies the rest of the design requirements.
4-113
4 Designing Compensators
• Optimization-based tuning
• PID tuning
• Internal Model Control (IMC) tuning
• LQG synthesis
• Loop shaping
load ltiexamples
4-114
Automated Tuning Design
2 To open the SISO Design Tool and import the DC motor, type
sisotool(sys_dc)
at the MATLAB prompt. This opens both the SISO Design Task node
on the Control and Estimation Tools Manager and the Graphical Tuning
window with sys_dc loaded.
3 Click the Analysis Plots tab to set the analysis plots. Select the plot type
as Step for Plot 1. Then, check the box for plot 1 to the left of Closed-Loop
r to y, as shown in the following figure, to open a linked LTI Viewer with
the closed-loop step response from reference signal r to output signal y.
4 In the LTI Viewer that appears, use the right-click menu to add rise time
and steady state values to your plot.
4-115
4 Designing Compensators
Note that by default, the compensator is 1 and unit negative feedback is used
(see Architecture in the Control System Toolbox User’s Guide). When a unit
step is applied to the setpoint change, the steady state value of the system
output is 0.0361, which is far from the setpoint, and its rise time is 0.589.
4-116
Automated Tuning Design
• P
• PI
• PID
1
• PID with derivative filter
(1 + s / N )
1 For the controller type, click the P option button for proportional-only
control (C = Kp).
4-117
4 Designing Compensators
Note that the rise time is arrived at in just 0.0774 seconds, compared with
0.589 when C=1. However, the steady state value of 0.885 can still be
improved by setting the automated tuning controller type to PI, as described
in “Designing a Proportional-Integral Controller” on page 4-119.
4-118
Automated Tuning Design
1 For the controller type, click the PI option button for proportional-integral
KI
control ( C = K p + ).
s
2 Select the Ziegler-Nichols open loop tuning algorithm from the
Tuning algorithm list.
(1 + 0.36 s)
is now 487.64 × .
s
Although the rise time has increased slightly (0.0876), the steady state value
is 1. Applying automated tuning using PID tuning set to PI will guarantee
zero offset.
4-119
4 Designing Compensators
4-120
Multi-Loop Compensator Design
The design goal for this example is the minimize the closed-loop step response
settling time while maintaining an inner loop phase margin of at least 65º
with maximum bandwidth.
R=2.0 % Ohms
L = 0.5 % Henrys
Km=0.1; Kb = 0.1 % Torque and back emf constants
4-121
4 Designing Compensators
First, construct a state-space model of the DC motor with one input, the
applied voltage (Va). The output is the angular rate w.
h1 = tf(Km,[L,R]); % Armature
h2 = tf(1,[J, Kf]) % Equation of motion
dcm = ss(h2) *h1; % w = h2 cascaded with h1
dcm = feedback(dcm, Kb, 1, 1);% Closes back emf loop
4-122
Multi-Loop Compensator Design
sisotool
at the MATLAB prompt. Once the Controls & Estimation Tools Manager
opens, click Control Architecture on the Architecture page. Select the
multi-loop configuration with two compensators, C1 in the forward path and
C2 in the inner feedback loop — located in the lower-right corner.
4-123
4 Designing Compensators
the workspace. Assume a perfect sensor and set H to 1. C1 and C2 are the
gains you will use to design a compensator. Set C1 to 1 and C2 to C2 from the
workspace. Your System Data dialog box should look like this.
1 Open-Loop 1 to "Root-Locus"
4-124
Multi-Loop Compensator Design
Click Show Design Plot to see the SISO Design Graphical editor.
4-125
4 Designing Compensators
4-126
Multi-Loop Compensator Design
Notice how the C1 piece of the compensator and the outer loop are grayed out.
This means that they will have no effect on the inner loop at this time.
Next, turn to the SISO Design Graphical editor. Use the Bode plot for open
loop 2 (the inner loop) and increase the gain to maximize bandwidth subject to
a 65º phase margin. This turns out to be a gain of about 16.1 for C2.
4-127
4 Designing Compensators
1 Go to the Analysis Plot tab in the Controls & Estimation Tools Manager.
Select the Closed-Loop r to y check box.
2 Select Step from the Plot 1 pull-down menu. This opens the LTI Viewer
for SISO Design.
4-128
Multi-Loop Compensator Design
Return to the SISO Design Graphical editor and increase the gain of C1 in the
root locus plot. At a gain of about 90.2, you will see the complex pair of poles
move toward a slower time constant as the third pole moves toward a faster
one. You can view the trade-off in the LTI Viewer for SISO Design. As the
gain is changed, the closed-loop step response changes.
The 90.2 gain seems to yield a good compromise between rise and settling
time.
4-129
4 Designing Compensators
Validating the Design with the LTI Viewer for SISO Design
Turning back to the LTI Viewer for SISO Design, it is evident that the settling
time is now much lower than the original 78.9 s.
4-130
Multi-Loop Compensator Design
With a settling time of about 0.8 s, and a phase margin of 65º in the inner
loop, the design is complete.
4-131
4 Designing Compensators
The controller you design for such a system must satisfy design requirements
for dynamics of all models.
Control design analysis of multiple models in the SISO Design Tool requires
you to specify either the plant G or sensor H or both as row or column arrays
of LTI models. If both G and H are arrays, their sizes must match.
4-132
Control Design Analysis of Multiple Models
4 Analyze if the controller meets the design requirements for all models in
the array.
If the controller design does not meet design requirements on all the models,
specify a different nominal model and redesign the controller. For more
information, see “How to Analyze the Controller Design for Multiple Models”
on page 4-137.
You use the design and analysis plots to visualize and analyze the effect of the
controller on the remaining plants in the array.
4-133
4 Designing Compensators
if
the software uses the second element in both the arrays to compute the
nominal model:
4-134
Control Design Analysis of Multiple Models
Nominal Model
r y
2
CGnom
T= ,
1 + CGnom H nom
The software also computes and plots the responses showing the effect of C on
the remaining pairs of plant and sensor combinations—G1H1 and G3H3.
If only G is an array of LTI models, and the specified nominal model is 2, then
the control architecture for nominal response is:
Nominal Model
r y
2
The software also computes and plots the responses showing the effect of C for
the remaining pairs of plant indices and sensor—G1H and G3H.
4-135
4 Designing Compensators
Tip You can plot and analyze the open-loop dynamics of the system on a Bode
plot to determine which model to choose as nominal.
If the controller design for the nominal model does not meet the design
requirements on the remaining plants in the array, you can specify a
different nominal model and redesign the controller. See “How to Analyze the
Controller Design for Multiple Models” on page 4-137 for more information.
• The automatic grid does not capture the system dynamics sufficiently.
4-136
Control Design Analysis of Multiple Models
Tip Specifying a less dense grid reduces the number of computations and is
less expensive computationally.
For more information, see “How to Analyze the Controller Design for Multiple
Models” on page 4-137.
• Create multiple LTI models using the tf, ss, zpk, or frd commands. For
example:
4-137
4 Designing Compensators
end
% m = 3, b = 0.5, k = 8:1:10.
% Create an array of LTI models to model plant (G) variations.
G1 = tf(1, [1 1 8]);
G2 = tf(1, [1 1 9]);
G3 = tf(1, [1 1 10]);
% Create an array of LTI models
G = stack(1, G1, G2, G3);
4-138
Control Design Analysis of Multiple Models
sisotool(G,1,H)
By default, the combination of the first plant and sensor in the arrays is
the nominal model on which you perform the control design. For more
information, see “How Is a Nominal Model Computed?” on page 4-133.
The Graphical Tuning window, which opens with the SISO Design Tool,
shows the individual responses of all models in the arrays.
4-139
4 Designing Compensators
Tip You can view the envelope of the Bode response instead by
right-clicking the plot and selecting Multimodel Display > Bounds. See
“Using the Graphical Tuning Window” on page 4-42 for more information.
4-140
Control Design Analysis of Multiple Models
2 Configure the analysis plots in the Analysis Plots tab in Control and
Estimation Tools Manager.
4-141
4 Designing Compensators
See “Analysis Plots for Loop Responses” on page 4-36 for more information.
4-142
Control Design Analysis of Multiple Models
Tip You can keep the Multimodel Configuration Dialog window open as
you are following the next steps.
5 Design the controller for the nominal plant using graphical or automated
tuning.
4-143
4 Designing Compensators
As you design the controller, use the design and analysis plots analyze to
analyze the controller’s effects on the remaining models in the array.
6 (Optional) If the controller design for the nominal model does not meet the
design requirements for the remaining models in the array:
a Specify a different nominal model in the Nominal Model Index field of
the Multimodel Configuration Dialog window.
The design and analysis plots update to show the updated nominal
model. For example, for a nominal model value of 2, the plots appear as
shown in the next figures.
4-144
Control Design Analysis of Multiple Models
4-145
4 Designing Compensators
4-146
Functions for Compensator Design
In addition to the SISO Design Tool, you can use functions for a broader range
of control applications, including
Function Description
pzmap Pole-zero map
rlocus Evans root locus plot
sgrid
Continuous n , grid for root locus plots
4-147
4 Designing Compensators
Function Description
sisotool Root Locus Design GUI
zgrid
Discrete n , grid for root locus plots
Pole Placement
The closed-loop pole locations have a direct impact on time response
characteristics such as rise time, settling time, and transient oscillations.
Root locus uses compensator gains to move closed-loop poles to achieve design
specifications for SISO systems. You can, however, use state-space techniques
to assign closed-loop poles. This design technique is known as pole placement,
which differs from root locus in the following ways:
x = Ax + Bu
y = Cx + Du
where u is the vector of control inputs, x is the state vector, and y is the vector
of measurements.
x = ( A − BK ) x
and the closed-loop poles are the eigenvalues of A-BK. Using the place
function, you can compute a gain matrix K that assigns these poles to any
desired locations in the complex plane (provided that (A,B) is controllable).
4-148
Functions for Compensator Design
For example, for state matrices A and B, and vector p that contains the desired
locations of the closed loop poles,
K = place(A,B,p);
= A + Bu + L( y − C − Du)
The estimator poles are the eigenvalues of A-LC, which can be arbitrarily
assigned by proper selection of the estimator gain matrix L, provided that (C,
A) is observable. Generally, the estimator dynamics should be faster than the
controller dynamics (eigenvalues of A-BK).
L = place(A',C',q).'
where A and C are the state and output matrices, and q is the vector containing
the desired closed-loop poles for the observer.
= [ A − LC − ( B − LD) K ] + Ly
u = − K
4-149
4 Designing Compensators
⎡ x ⎤ ⎡ A − BK BK ⎤ ⎡ x ⎤
⎢ e ⎥ = ⎢ 0 , e = x −
⎣ ⎦ ⎣ A − LC ⎥⎦ ⎢⎣ e ⎥⎦
sys_pp = ss(A,B,C,D)
with seven outputs and four inputs, suppose you have designed
You can then connect the controller and estimator and form the dynamic
compensator using this code:
controls = [1,2,4];
sensors = [4,7,1];
known = [3];
regulator = reg(sys_pp,K,L,sensors,known,controls)
• Compute gain matrices K and L that achieve the desired closed-loop pole
locations.
• Form the state estimator and dynamic compensator using these gains.
4-150
Functions for Compensator Design
Functions Description
acker SISO pole placement
estim Form state estimator given estimator gain
place MIMO pole placement
reg Form output-feedback compensator given state-feedback
and estimator gains
The function acker is limited to SISO systems, and you should use it only for
systems with a small number of states. The function place is a more general
and numerically robust alternative to acker.
Caution
Pole placement can be badly conditioned if you choose unrealistic pole
locations. In particular, you should avoid:
To design LQG regulators and set point trackers, you perform the following
steps:
4-151
4 Designing Compensators
3 Form the LQG design by connecting the LQ-optimal gain and the Kalman
filter.
For more information about using LQG design to create LQG regulators , see
“Linear-Quadratic-Gaussian (LQG) Design for Regulation” on page 4-152.
For more information about using LQG design to create LQG servo controllers,
see “Linear-Quadratic-Gaussian (LQG) Design of Servo Controller with
Integral Action” on page 4-157.
u w v
Kalman -K Plant y
y Filter
u
LQG Regulator
x = Ax + Bu + Gw
y = Cx + Du + Hw + v
4-152
Functions for Compensator Design
Note LQG design requires a state-space model of the plant. You can use ss
to convert other model formats to state space.
To design LQG regulators, you can use the design techniques shown in the
following table.
4-153
4 Designing Compensators
K= lqr(A,B,Q,R,N)
This command computes the optimal gain matrix K, for which the state
feedback law u = − Kx minimizes the following quadratic cost function for
continuous time:
∞
∫0 { x
T
J (u) = Qx + 2 xT Nu + uT Ru}dt
You construct the state estimate x̂ such that u = − Kxˆ remains optimal for
the output-feedback problem. You construct the Kalman state estimator gain
from the following elements:
4-154
Functions for Compensator Design
Note You construct the Kalman state estimator in the same way for both
regulation and servo control.
[kest,L,P] = kalman(sys,Qn,Rn,Nn);
This command computes a Kalman state estimator, kest with the following
plant equations:
x = Ax + Bu + Gw
y = Cx + Du + Hw + v
where w and v are modeled as white noise. L is the Kalman gain and P the
covariance matrix.
The software generates this state estimate using the Kalman filter
d
xˆ = Axˆ + Bu + L( y − Cxˆ − Du)
dt
with inputs u (controls) and y (measurements). The noise covariance data
4-155
4 Designing Compensators
The Kalman filter is an optimal estimator when dealing with Gaussian white
noise. Specifically, it minimizes the asymptotic covariance
(
lim E ( x − xˆ ) ( x − xˆ )
t→∞
T
)
of the estimation error x − xˆ .
u Kalman x
y Estimator
For more information, see the kalman reference page. For a complete example
of a Kalman filter implementation, see Kalman Filtering.
Forming the LQG Regulator. To form the LQG regulator, connect the
Kalman filter kest and LQ-optimal gain K by typing the following command:
This command forms the LQG regulator shown in the following figure.
y kest -K
u
LQG Regulator
d
xˆ = [ A − LC − ( B − LD) K ]xˆ + Ly
dt
u = − Kxˆ
For more information on forming LQG regulators, see the lqgreg reference
page and LQG Regulation: Rolling Mill Example.
4-156
Functions for Compensator Design
v
u y w
kest y
x u Plant
-K
r-y
r
-
Integrator x
i
y
LQG Servo Controller
The servo controller you design ensures that the output y tracks the reference
command r while rejecting process disturbances w and measurement noise v.
x = Ax + Bu + Gw
y = Cx + Du + Hw + v
Note LQG design requires a state-space model of the plant. You can use ss
to convert other model formats to state space.
To design LQG servo controllers, you can use the design techniques shown
in the following table.
4-157
4 Designing Compensators
4-158
Functions for Compensator Design
K= lqi(sys,Q,R,N)
This command computes the optimal gain matrix K, for which the state
feedback law u = − Kz = − K[ x; xi ] minimizes the following quadratic cost
function for continuous time:
∫0 {z }
∞ T
J (u) = Qz + uT Ru + 2 zT Nu dt
You construct the state estimate x̂ such that u = − Kxˆ remains optimal for
the output-feedback problem. You construct the Kalman state estimator gain
from the following elements:
4-159
4 Designing Compensators
Note You construct the Kalman state estimator in the same way for both
regulation and servo control.
[kest,L,P] = kalman(sys,Qn,Rn,Nn);
This command computes a Kalman state estimator, kest with the following
plant equations:
x = Ax + Bu + Gw
y = Cx + Du + Hw + v
where w and v are modeled as white noise. L is the Kalman gain and P the
covariance matrix.
The software generates this state estimate using the Kalman filter
d
xˆ = Axˆ + Bu + L( y − Cxˆ − Du)
dt
with inputs u (controls) and y (measurements). The noise covariance data
4-160
Functions for Compensator Design
The Kalman filter is an optimal estimator when dealing with Gaussian white
noise. Specifically, it minimizes the asymptotic covariance
(
lim E ( x − xˆ ) ( x − xˆ )
t→∞
T
)
of the estimation error x − xˆ .
u Kalman x
y Estimator
For more information, see the kalman reference page. For a complete example
of a Kalman filter implementation, see Kalman Filtering.
This command forms the LQG servo controller shown in the following figure.
u y
kest
x u
-K
r-y
r
-
Integrator x
i
y
LQG Servo Controller
4-161
4 Designing Compensators
10
s+10 n
d
y
y F(s) Plant
u u+d
LQG Regulator
The goal is to regulate the plant output y around zero. The input disturbance
d is low frequency with power spectral density (PSD) concentrated below
10 rad/s. For LQG design purposes, it is modeled as white noise driving a
lowpass filter with a cutoff at 10 rad/s, shown in the following figure.
10
w (white noise) s+10 d (colored noise)
For simplicity, this noise is modeled as Gaussian white noise with variance
of 1.
The following figure shows the Bode magnitude of the shaping filter.
4-162
Functions for Compensator Design
E(n2 ) = 0.01
∞
∫0 (10 y
2
J (u) = + u2 ) dt
x = Ax + Bu + Bd (state equations)
y = Cx + n (measurements)
4-163
4 Designing Compensators
The following commands design the optimal LQG regulator F(s) for this
problem:
To validate the design, close the loop with feedback, create and add the
lowpass filter in series with the closed-loop system, and compare the open-
and closed-loop impulse responses by using the impulse function.
% Close loop
clsys = feedback(sys,F,+1)
% Note positive feedback.
These commands produce the following figure, which compares the open- and
closed-loop impulse responses for this example.
4-164
Functions for Compensator Design
v
w
r y
trksys u Plant
y
LQG Servo Controller
4-165
4 Designing Compensators
The plant has two states (x), two control inputs (u), two random inputs (w),
one output (y), measurement noise for the output (v), and the following state
and measurement equations:
x = Ax + Bu + Gw
y = Cx + Du + Hw + v
where
⎡0 1 0 ⎤ ⎡ 0 .3 1 ⎤ ⎡ −0.7 1.12⎤
A = ⎢⎢0 0 1 ⎥⎥ ⎢
B=⎢ 0 1 ⎥⎥ G = ⎢⎢ −1.17 1 ⎥⎥
⎢⎣1 0 0 ⎥⎦ ⎢⎣ −0.3 0.9 ⎥⎦ ⎢⎣ 0.14 1.5 ⎥⎦
⎡4 2⎤
Qn = E(wwT ) = ⎢ ⎥
⎣2 1⎦
Rn = E(vvT ) = 0.7
Use the following cost function to define the tradeoff between tracker
performance and control effort:
∞⎛ ⎡1 0 ⎤ ⎞
∫0 ⎜⎝ 0.1x
T
J (u) = x + xi2 + uT ⎢ ⎥ u ⎟dt
⎣0 2 ⎦ ⎠
1 Create the state space system by typing the following in the MATLAB
Command Window:
4-166
Functions for Compensator Design
H = [-1.2 -0.89];
sys = ss(A,[B G],C,[D H]);
2 Construct the optimal state-feedback gain using the given cost function
by typing the following commands:
nx = 3; %Number of states
ny = 1; %Number of outputs
Q = blkdiag(0.1*eye(nx),eye(ny));
R = [1 0;0 2];
K = lqi(ss(A,B,C,D),Q,R);
3 Construct the Kalman state estimator using the given noise covariance
data by typing the following commands:
Qn = [4 2;2 1];
Rn = 0.7;
kest = kalman(sys,Qn,Rn);
4 Connect the Kalman state estimator and the optimal state-feedback gain to
form the LQG servo controller by typing the following command:
trksys = lqgtrack(kest,K)
a =
x1_e x2_e x3_e xi1
x1_e -2.373 -1.062 -1.649 0.772
x2_e -3.443 -2.876 -1.335 0.6351
x3_e -1.963 -2.483 -2.043 0.4049
xi1 0 0 0 0
b =
r1 y1
x1_e 0 0.2849
x2_e 0 0.7727
x3_e 0 0.7058
xi1 1 -1
4-167
4 Designing Compensators
c =
x1_e x2_e x3_e xi1
u1 -0.5388 -0.4173 -0.2481 0.5578
u2 -1.492 -1.388 -1.131 0.5869
d =
r1 y1
u1 0 0
u2 0 0
Input groups:
Name Channels
Setpoint 1
Measurement 2
Output groups:
Name Channels
Controls 1,2
Continuous-time model.
4-168
Functions for Compensator Design
• The error signal between and the ref is passed through an integrator.
This aids in driving the error to zero.
x = Ax + Bu
where
x = [u, v, w, p, q, r, , ]T
4-169
4 Designing Compensators
The variables u, v, and w are the three velocities with respect to the body
frame, shown as follows.
The variables and are roll and pitch, and p, q, and r are the roll, pitch,
and yaw rates, respectively.
The airframe dynamics are nonlinear. The following equation shows the
nonlinear components added to the state space equation.
⎡ − g sin θ ⎤
⎢ g cos θ sin φ ⎥
⎢ ⎥
⎢ g cos θ cos φ ⎥
⎢ ⎥
⎢ 0 ⎥
x = Ax + Bu +
⎢ 0 ⎥
⎢ ⎥
⎢ 0 ⎥
⎢ q cos φ − r sin φ ⎥
⎢ ⎥
⎢⎣(q sin φ + r cos φ) ⋅ tan θ ⎥⎦
load lqrpilot
A, B
4-170
Functions for Compensator Design
Trimming
For LQG design purposes, the nonlinear dynamics are trimmed at = 15 and
p, q, r, and θ set to zero. Since u, v, and w do not enter into the nonlinear term
Problem Definition
The goal to perform a steady coordinated turn, as shown in this figure.
To achieve this goal, you must design a controller that commands a steady
turn by going through a 60° roll. In addition, assume that θ, the pitch angle,
is required to stay as close to zero as possible.
Results
To calculate the LQG gain matrix, K, type
lqrdes
at the MATLAB prompt. Then, start the lqrpilot model with the nonlinear
model, sf_aerodyn, selected.
4-171
4 Designing Compensators
As you can see, the system tracks the commanded 60° roll in about 60 seconds.
Another goal was to keep θ, the pitch angle, relatively small. This figure
shows how well the LQG controller did.
4-172
Functions for Compensator Design
Try adjusting the Q and R matrices in lqrdes.m and inspecting the control
inputs and the system states, making sure to rerun lqrdes to update the LQG
gain matrix K. Through trial and error, you may improve the response time of
this design. Also, compare the linear and nonlinear designs to see the effects
of the nonlinearities on the system performance.
4-173
4 Designing Compensators
4-174
Index
A
Index regulators 4-156
automated tuning design 4-114 root locus 4-147
state estimator 4-149
state estimator, Kalman 4-154
B
building models
E
MIMO 2-13
SISO 2-6 estimator
gain 4-149
Kalman 4-154
C exporting compensators and models 4-49
cell array 2-16
changing
F
units on a plot 4-47
comparing final time. See also time response 3-40
models in plots 3-44 frequency response 3-41
compensator design customizing plots 3-47
multi-loop 4-120 plotting 3-44
compensators functions
editing in SISO Design Tool 4-96 time and frequency response 3-37
exporting 4-49
feedback (state estimator design) 4-149 G
concatenation
gain
model 2-16
estimator, Kalman 4-155 4-160
control design analysis of multiple models 4-132
selection 4-82
Control System Toolbox product
state-feedback 4-154
related products 1-4
Graphical Tuning window 4-26
covariance
changing units on a plot 4-47
noise 4-155 4-160
display 4-43
right-click menus 4-48
D using 4-42
data markers 3-42
denominator I
specification 2-16
input vector 2-2
design
Kalman estimator 4-154
LQG Tracker, example of 4-168 K
LQG, description 4-151 Kalman estimator
pole placement 4-148 continuous 4-154
Index-1
Index
Index-2
Index
Index-3
Index
W Z
white noise 3-38 zero-pole-gain (ZPK) models 2-3
See also noise
Index-4