SlideShare a Scribd company logo
1 and Design Using MATLABB
Robert H. Bishop
The University of Texas at Austin
ADDISON-WESLEY PUBLISHING COMPANY
Reading, Massachusetts Menlo Park, C a l i i i a New York
Don Mills, Ontario Wokingharn, England Amsterdam Bonn
Sydney Singapore Tokyo Madrid San Juan Milan Paris
Preface
R.H.B.
Austin. Texas
Contents
Preface v
1 MATLAB Basics 1
. . . . . . . . . . . . . . . . . . . . . . .
1.1 Introduction 1
. . . . . . . . . . . . . . . .
1.2 Statements and Variables 2
. . . . . . . . . . . . . . . . . . . . . . . . .
1.3 Matrices 10
. . . . . . . . . . . . . . . . . . . . . . . . .
1.4 Graphics 16
. . . . . . . . . . . . . . . . . . . . . . . . . .
1.5 Scripts 21
2 Mathematical Modeling of Systems 25
. . . . . . . . . . . . . . . . . . . . . . .
2.1 Introduction 25
. . . . . . . . . . . . . .
2.2 Spring-Mass-DamperSystem 26
. . . . . . . . . . . . . . . . . . .
2.3 Transfer Functions 30
. . . . . . . . . . . . . . . . .
2.4 Block Diagram Models 35
. . . . . . . . . . . . . . . . . . . . .
2.5 Design Example 45
3 Control System Characteristics 49
. . . . . . . . . . . . . . . . . . . . . . .
3.1 Introduction 49
. . . . . . . . . . . . . . .
3.2 Speed Tachometer System 50
. . . . . . . . . . .
3.3 English Channel Boring Machines 54
4 Control System Performance 61
. . . . . . . . . . . . . . . . . . . . . . .
4.1 Introduction 61
. . . . . . . . . . . . . .
4.2 Time-Domain Specifications 61
. . . . . . . . . . . .
4.3 Simplification of Linear Systems 68
5 Control System Stability 71
. . . . . . . . . . . . . . . . . . . . . . .
5.1 Introduction 71
vii
...
VIII Contents
5.2 Routh-Hurwitz Stability . . . . . . . . . . . . . . . . 72
5.3 Example: Tracked Vehicle Turning Control . . . . . . 76
6 Root Locus Method 81
6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . 81
6.2 Obtaining a Root Locus Plot . . . . . . . . . . . . . 82
6.3 Sensitivity and the Root Locus . . . . . . . . . . . . 88
7 Frequency Response Methods 91
7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . 91
7.2 Bode Diagram . . . . . . . . . . . . . . . . . . . . . . 92
7.3 Specifications in the Frequency Domain . . . . . . . . 95
7.4 Example: Engraving Machine System . . . . . . . . . 98
8 Stability in the Frequency Domain 103
8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . 103
8.2 Nyquist Plots . . . . . . . . . . . . . . . . . . . . . . 104
8.3 Nichols Charts . . . . . . . . . . . . . . . . . . . . . 110
8.4 Examples . . . . . . . . . . . . . . . . . . . . . . . . 111
9 State-Space Methods 121
9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . 121
9.2 Model Relationships . . . . . . . . . . . . . . . . . . 122
9.3 Stability of Systems in the Time Domain . . . . . . . 125
9.4 Time Response . . . . . . . . . . . . . . . . . . . . . 129
10 Control System Design 133
10.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . 133
10.2 Lead Compensation . . . . . . . . . . . . . . . . . . . 134
10.3 Lag Compensators . . . . . . . . . . . . . . . . . . . 136
10.4 Example: Rotor Winder Control System . . . . . . . 138
11 Robust Control Systems 151
11.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . 151
11.2 Robust PID Controlled Systems . . . . . . . . . . . . 152
Chapter 1
MATLAB Basics
1.1 Introduction
MATLAB is an interactive program for scientific and engineering
calculations. The MATLAB family of programs includes the base
program plus a variety of toolboxes. The toolboxes are a collection
of special files, called M-files, which extend the functionality of the
base program. Together the base program plus the Control System
Toolbox provide the capability to use MATLAB for control system
design and analysis. In the remainder of this book, whenever we refer
to MATLAB, you can interpret that as meaning the base program
plus the Control System Toolbox.
Most of the statements, functions, and commands are computer
platform independent. Regardless of what particular computer sys-
tem you use, your interaction with MATLAB is basically the same.
This book concentrates on this computer platform independent in-
teraction. A typical session will utilize a variety of objects that
dlow you to interact with the program. These objects are
s
1. statements and variables,
2. matrices,
3. graphics, and
4. scripts.
2 Chapter 1. MATLAB Basics
MATLAB interprets and acts on input in the form of one or more
of these objects. Our goal in this chapter is to introduce each of the
four objects in preparation for our ultimate goal of using MATLAB
for control system design and analysis.
The manner in which MATLAB interacts with your computer
system is computer platform dependent. Examples of computer de-
pendent functions include installation, the file structure, generating
hardcopies of the graphics, invoking and exiting a session, and mem-
ory allocation. Questions related to platform dependent issues are
not addressed here. This is not to imply that they are not impor-
tant, but rather that there are better sources of information such as
your Users Guide and your local resident expert. This book is not
intended as a substitute for your Users Guide.
Before proceeding, make sure that you can invoke a session and
exit MATLAB .You need to be able to get to the command window
and see the command prompt " >> ". To begin a session on a
Macintosh you will probably double-click on the MATLAB program
icon. On an IBM PC compatible you will probably type matlab at
the DOS prompt.
The remainder of this chapter is organized as follows. There are
four sections corresponding to the four objects listed above. In the
first section we present the basics of statements and variables. Fol-
lowing that is the subject of matrices. The third section presents an
introduction to graphics, and the chapter concludes with a discussion
on the important topic of scripts and M-fles.
1.2 Statements and Variables
Statements have the form shown in Figure 1.1. MATLAB uses the
assignment so that equals ("=") implies the assignment of the ex-
pression to the variable. The command prompt is two right arrows,
" >> ". A typical statement is shown in Figure 1.2, wherein we
are entering a 2 x 2 matrix to which we attach the variable name
A. The statement is executed after the carriage return (or enter
key) is pressed. The carriage return is not explicitly denoted in the
remaining examples in this and subsequent chapters.
command prompt
/
I
)/variable=expression
Figure 1.1 MATLAB Statement Form.
The matrix A is automatically displayed after the statement is
executed following the carriage return. If the statement is followed
by a semicolon (;), the output matrix A is suppressed, as seen in
I'igure 1.3. The assignment of the variable A has been carried out
wen though the output is suppressed by the semicolon. It is often
the case that your MATLAB sessions will include intermediate cal-
culations for which the output is of little interest. You should use
the semicolon whenever you have a need to reduce the amount of
output. Output management has the added benefit of increasing the
execution speed of the calculations, since displaying screen output
takes time.
The usual mathematical operators can be used in expressions.
The common operators are shown in Table 1.1. The order of the
arithmetic operations can be altered by using parentheses.
The example in Figure 1.4 illustrates that MATLAB can be used
in a "calculator" mode. When the variable name and "=" are omit-
ted from an expression, the result is assigned to the generic variable
ans. MATLAB has available most of the trigonometric and elemen-
tary math functions of a common scientific calculator. The Users
2; 4 61 <ret>
A =
1 2 carriage return
4 6
Figure 1.2 Example Statement: Matrix Input.
Chapter 1. MATLAB Basics
Figure 1.3 Using Semicolons to Suppress the Output.
Guide has a complete list of available trigonometric and elementary
math functions; the more common ones are summarized in Table 1.2.
Variable names begin with a letter and are followed by any num-
ber of letters and numbers (including underscores). Keep the name
length to 19 characters since MATLAB remembers only the first 19
characters. It is a good practice to use variable names that describe
the quantity they represent. For example, we might use the variable
name vel to represent the quantity aircraft velocity. Generally, we
do not use extremely long variable names even though they may be
legal MATLAB names.
Since MATLAB is case sensitive, the variables M and m are not
the same variables. By case we mean upper and lower case. This is
illuetrated in Figure 1.5. The variables M and m are recognized as
different quantities.
Table 1.1 Mathematical Operators.
ans =
1.7971
+
-
*
/
A
1.2. Statements and Variables
Figure 1.4 Calculator Mode.
MATLAB has several predefined variables, including
t ax$an6;)rhree examples are shown in Figure 1.6.
for Not-a-Number and results from undefined operations. Inf rep-
resents +co and pi represents a. The variable i = -is used to
represent complex numbers. The variable j = f l can be used for
Table 1.2 Common Mathematical Functions.
Addition
Subtraction
Multiplication
Division
Power
sin(X)
cos(X)
asin(X)
acos(X)
tan(X)
atan(X)
atan2(X,Y)
;ax)
G ~ x )
imag(X)
real(X)
(@PX)
log(X)
loglO(X)
(expp)
Sine of the elements of X
Cosine of the elements of X
Arcsine of the elements of X
Arccosine of the elements of X
Tangent of the elements of X
Ardangent of the elements of X
Four quadrant arctangent of the real
elements of X and Y
Absolute value of the elements of X
SquarerootofX
Imaginary part of X
Real part of X
Complex conjugate of X
Natural logarithm of the elements of X
Logarithm base 10 of the elements of X
Exponential of the elements of X
Chapter 1. MATLAB Basics
Figure 1.5 Variables Are Case Sensitive.
cornplex arithmetic by those who prefer it over i. These predefined
variables can be inadvertently overwritten. Of course, they can also
be purposely overwritten in order to free up the variable name for
other uses. For instance, one might want to use i as an integer and
rcscrve j for complex arithmetic. Be safe and leave these predefined
variables alone, as there are plenty of alternative names that can be
used. Predefined variables can be reset to their default values by
using clear name (e.g., clear pi).
rr
The matrix A and the variable ans, in Figures 1.3 and 1.4, are
stored in the workspace. Variables in the workspace are automati-
>>z=3+4*i
z =
3.0000 + 4.0000i
>>lnf
ans =
00
>>O/O
Warning: Divide by zero
ans =
NaN
~ i g u r e
1.6 Three Predefined Variables i, Inf, and Nan.
>)who
Your variables are:
A M ans m z
leaving 675516 bytes of memory free.
Figure 1.7 Using the who Function to Display Variables.
cally saved for later use in your session. The who function gives a
list of the variables in the workspace, as shown in Figure 1.7.
MATLAB has a host of built-in functions. You can refer to the
Users Guide for a complete list. We will describe each function we
e as the need arises.
The whos function lists the variables in the workspace and gives
ditional information regarding variable dimension, type, and mem-
ry allocation. Figure 1.8 gives an example of the whos function.
The memory allocation information given by the whos function
can be interpreted as follows. Each element of the 2 x 2 matrix A
-
Figure 1.8 Using the whos Function to Display Variables.
>>whos
Name Size Total Complex
A 2 b y 2 4 No
M 1 b y 2 2 No
ans 1 by 1 1 No
m 1 b y 3 3 No
z 1 by 1 2 Yes
Grand total is (12 * 8) = 96 bytes,
leaving 664912 bytes of memory free.
Chapter I. MATLAB Basics 1.2. Statements and Variables
>>who
Your variables are:
IM ans m z I
leaving 663780 bytes of memory free.
A
Figure 1.9 Removing the Matrix A from the Workspace.
I . ..................................................
:pBd{*d#&kd
p
a
i
M
.................................................... ...................................
!.:.::.:.::.:.:.. .......................
...............
:.:.:.:.:.)):.:.::
...................................................................................................... .:
r a t o n ; pi )
7
1 ......... (
I .format short e; pi
I
ans =
3.1416e+004
requires 8 bytes of memory for a total of 32 bytes, the 1x 1variable
ans requires 8 bytes, and so forth. All the variables in the workspace
are using a total of 96 bytes. The amount of remaining free memory
depends upon the total memory available in the system. Computers
with virtual memory will not display the remaining free memory.
You can remove variables from the workspace with the clear
function. Using the function clear, by itself, removes all items (vari-
ables and functions) from the workspace; clear variables removes
all variables from the workspace; clear name1 name 2 ... removes
the variables namel, name2, and so forth. The procedure for re-
moving the matrix A from the workspace is shown in Figure 1.9.
A simple calculation shows that clearing the matrix A from
memory freed up more than 32 bytes. In some cases, clearing a
variable may not change the value of the displayed free memory at
811. The who function displays the amount of contiguous remaining
free memory. So, depending upon the "location" of the variable in
the workspace, clearing the variable may or may not increase the
splayed amount of remaining free memory. The point is that your
ailable free memory may be more than displayed with the who or
All computations in MATLAB are performed in doubbecision.
en output can be displayed in several formats.(~he
rmat contains four digitmast the decimal point
his can be chknged by using the format function
.lo. Once a particular format has been speci-
ed, it remains in effect until altered by a different format input.
??? Undefined function or variable
Symbol in question ==> WHO
??? Undefined function or variable
Symbol in question ==> Who
Ti';aiire 1 1 1 F~~nrtinn
Names r]ilsp sSensit,ive.
10 Chapter 1. MATLAB Basics
Remember that the output format does not affect the MATLAB
computations - all computations are in double precision.
On the other hand, the number of digits displayed does not nec-
essarily reflect the number of significant digits of the number. This
is problem dependent, and only you can know the true accuracy of
the numbers that you input and that MATLAB displays.
Since MATLAB is case sensitive, the functions who and WHO
are not the same functions. The function who is a built-in func-
tion, so typing who lists the variables in the workspace. On the
other hand, typing the uppercase WHO results in the error mes-
sage shown in Figure 1.11. Case sensitivity applies to all functions.
1.3 Matrices
k
MATLAB is short for matrix laboratory. The Users Guide describes
the program as a high-performance interactive software package de-
signed to provide easy access to the LINPACK and EISPACK ma-
trix software. Although we will not dwell on the matrix routines
underlying our calculations, we will learn how to use the interactive
capability to assist us in our control system design and analysis. We
begin by introducing the basic concepts associated with manipulat-
ing matrices and vectors.
The basic computational unit is the matrix. Vectors and scalars
can be viewed as special cases of matrices. A typical matrix expres-
sion is enclosed in square brackets, [-I. The column elements are
separated by blanks or commas and the rows are separated-hysemi-
colons or carriage returns. Suppose we want to input the matrix A,
One way to input A is shown in Figure 1.12. The input style in
Figure 1.12 is not unique.
Matrices can be input across multiple lines by using a carriage
return following the semicolon or in place of the semicolon. This is
useful for entering large matrices. Different combinations of spaces
I .:J. Matrices , 11
Figure 1.12 Complex and Real Matrix Input with Automatic Di-
I mension and Type Adjustment.
and commas can be used to separate the columns, and different com-
binations of semicolons and carriage returns can be used to separate
the rows, as illustrated in Figure 1.12.
No dimension statements or type statements are necessary when
using matrices; memory is allocated automatically. Notice in the
example in Figure 1.12 that the size of the matrix A is automatically
adjusted when the input matrix is redefined. Also notice that the
matrix elements can contain trigonometric and elementary math
functions, as well as complex numbers.
The important basic matrix operations are addition and sub-
traction, multiplication, transpose, powers, and the so-called array
operations, which are element-to-element operations. The mathe-
matical operators given in Table 1.1 apply to matrices. We will not
disc~ss~matrix
division, but be aware that MATLAB has a left- and
right-matrix division capability.
Matrix operations require that the matrix dimensions be com-
patible. For matrix addition and subtraction this means that the
matrices must have the same dimensions. If A is an n x m matrix
I2 Chapter 1. MATLAB Basics
atid B is a p x r matrix, then A & B is permitted only if n = p and
m = r. Matrix multiplication, given by A * B, is permitted only
if m = p. Matrix-vector multiplication is a special case of matrix
multiplication. Suppose 6 is a vector of length p. Multiplication
of the vector b by the matrix A, where A is an n x m matrix, is
allowed if m = p. Thus, y = A * b is the n x 1 vector solution of
A * b. Examples of three basic matrix-vector operations are given
in Figure 1.13.
The matrix transpose is formed with the apostrophe (9. We can
L"
-
-
.
-
-
-
-
-
A
,
- --
use the matrix transpose and multiplication operation to create a
vector inner product in the following manner. Suppose w and v
are m x 1 vectors. Then the inner product (also known as the dot
ans =
5 -4
15 9
ans =
16
50
...
1>>A! T f I
." matrix trans~ose
ans =
1 5
3 9
Figure 1.13 Three Basic Matrix Operations: Addition, Multiplica-
tion, and Transpose.
I)~o(l~rct.)
is given by w' * v . The inner product of two vectors is a
1(3nlil,r. The outer product of two vectors can similarly be computed ,
w * v'. The outer product of two m x 1 vectors is an m x mv'
m b i x of rank 1. Examples of inner and outer products are given
'I'he basic matrix operations can be modified for element-by-
s1rl11c:ntoperations by preceding the operator with a period. The
oilified matrix operations are known as array operations. The com-
ay operators are given in Table 1.3. M&rix addition
m
d subtraction are already element-by-element operations and do
_
?
-
-
I
_
additional pezpreceding G operator. However,
xy multiplication, division, and power do require the preceding
I,, as shown in Table 1.3.
Suppose A and B are 2 x 2 matrices given by
bll bl2
= [ : : : a 1 2 ] ,
a22 B = [ b21 b22 1.
hen, using the array multiplication operator, we have
& B = [allbll a12b12
a21b21 a 2 2 b 2
3 *> t > d 
I.
Figure 1.14 Inner and Outer Products. -
4
:
"r".? '-> h 1
>)x=[~;pi;sin(pi/2)]; y=[exp(-0.5);-1 3;piA21;
..................................
.........................................................
&*y 4 !$,;&*~;@,g@,g,u,a%i
..................
.
.
:
v .
.
..............
:
..:.:.:.:.:.:..
:
j
:
..............
............................ :....................
4
............
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. -
:
:
:
:
:
.
.
:
.
:
.
:
j
:
:
ans =
-27.9384
>>x?ylt *
ans =
3.0327 -65.0000 49.3480
1.go55 -40.8407 31-0063
0.6065 -13.0000 9.8696
Chapter 1. MATLAB Basics
Table 1.3 Mathematical Array Operators.
The elements of A. * B are the products of the corresponding ele-
ments of A and B. A numerical example of two array operations is
given in Figure 1.15.
+
-
.*
.
.A
Before proceeding to the important topic of graphics, we need to
introduce the notion of subscripting using colon notation. The colon
notation, shown in Figure 1.16, allows us to generate a row vector
containing the numbers from a given starting value, xi, to a final
value, xr,with a specified increment, dx.
Addition
Subtraction
Multiplication
Division
Power
ans =
-6
14
30
ans =
Figure 1.15 Array Operations.
startingvalue final value
I .
L
x = [ x ~ : ~ x : x ~ ]
t
increment
t
Figure 1.16 The Colon Notation.
! We can easily generate vectors using the colon notation, and
,M we shall soon see, this is quite useful for developing x-y plots.
uppose our objective is to generate a plot of y = x sin(x) versus
...
I for x = 0,0.1,0.2, ,1.O. Our first step is to generate a table of
by data. We can generate a vector containing the values of x at
rhich the values of y(x) are desired using the colon notation. This
1 illustrated in Figure 1.17. Given the desired x vector, the vector
$
/ '
ans =
0
Figure 1.17 Generating Vectors Usin1
I
g the Colon Notation.
Chapter 1. MATLAB Basics
Table 1.3 Mathematical Array Operators.
The elements of A. * B are the products of the corresponding ele-
ments of A and B. A numerical example of two array operations is
given in Figure 1.15.
Before proceeding to the important topic of graphics, we need to
introduce the notion of subscripting using colon notation. The colon
notation, shown in Figure 1.16, allows us to generate a row vector
containing the numbers from a given starting value, xi, to a final
value, xr, with a specified increment, dx.
Figure 1.15 Array Operations.
ans =
-6
14
30
,>A.42
startingvalue fmal value
t
increment
4
Figure 1.16 The Colon Notation.
~:.
:... :
....
......
..away:.~awsr,,,i,:;~
.: .......::.. .:..;. ........
. .
..:.. .
........ .
:
: . . .: ...........
. : : .:.. ..:. ......... :.
We can easily generate vectors using the colon notation, .
and
.
u we shall soon see, this is quite useful for devel
.
ans -
1
4
9
,pose our ol
,r x = 0.0.1
cu data. We can generate a vector containing th
ich the valuc
llustrated in
loping x-y plots.
generate a plot of y = xsin(x) versus
Our first step .
is.to generate a table of
' e values of x at
: desired using the colon notation. This
Given the desired x vector, the vector
3
s of y(s) are
Figure 1.17.
/b
i
i ans =
0 0
0.1000 0.0100
Figure 1.17 Generating Vectors Using the Colon 1Yotation.
1.4. Graphics
16 Chapter 1. MATLAB Basics
y(x) is computed using the multiplication array operation. Creating
a plot of y = xsin(x) versus zis a simple step once the table of x-y
data is generated.
1
.
4 Graphics
Graphics play an important role in both the design and analysis of
control systems. An important component of an interactive control
system design and analysis tool is an effective graphical capability.
A complete solution to the control system design and analysis will
eventually require a detailed look at a multitude of data types in
many formats. The important plot formats includeroot-locus plots,
Bode plots, Nyquist plots, and time-response plots. The objectiveof
--
this section is to acquaint the reader with the basic x-y plotting ca-
pability of MATLAB. More advanced graphics topics are addressed
aa the need arises.
MATLAB uses a graph display to present plots. Some computer
configurations allow both the command display and graph display
to be viewed simultaneously. On computer configurations that allow
only one to be viewed at a time, the command display will disappear
when the graph display is up. The graph display is brought up
automatically when a plot is generated using any function which
generates a plot (e.g., the plot function). Switching from the graph
display back to the command display is accomplished by pressing
the keyboard. The plot in the graph
at the command prompt.
used to switch to the graph display from the
There are two basic groups of graphics functions. The first group
of functions, shown in Table 1.4, specifies the type of plot. The list
of available plot types includes x-y plot, semilog and log plots. The
second group of functions, shown in Table 1.5,allows us to customize
the plots by adding titles, axis labels, and text to the plots and to
change the scales and display multiple plots in subwindows.
The standard x-y plot is created using the plot function. The
x-y data in Figure 1.17 are plotted using the plot function as shown
I Table 1.4 Available Plot Formats.4
Plots the vector x versus the vector y.
The x-axis is log,,; the y axis is linear.
The x-axis is linear; the y axis is loglo.
Creates a plot with loglo scales on both axes.
Figure 1.18. The axis scales and line types are autoqatically
the plot by using the grid command. We see that a basic x-y
t is generated with the combination of functions plot, xlabel,
abel, title, and grid.
Multiple lines can be laced on the graph by using the plot func-
on with multiple arguments, as shown in Figure 1.19. The default
Table 1.5 Functions for Customized Plots.
Labels the x-axis with 'text'.
Labels the yaxis with 'text'.
- where (010,010)
is the lower left and
Chapter 1. MATLAB Basics
Figure 1.18 A Basic x-y Plot of xsin(x) versus x.
line types can also be altered. The available line types are shown
in Table 1.6. The line types will be automatically chosen unless
specified by the user. The use of the text function and changing
the line types is illustrated in Figure 1.19.
The other graphics functions loglog, semilogx, and semilogy
are used in a similar fashion to plot. To obtain an x-y plot where
the x-axis is a linear scale and the y-axis is a loglo scale, you would
use the semilogy function in place of the plot function. The cus-
Figure 1.19 A Basic x-y Plot with Multiple Lines.
Table 1.6 Line Types for Customized Plots.
- - Dashed line
Dotted line
Dashdot line
Chapter 1. MATLAB Basics 1.5. Scripls
tomizing features listed in Table 1.5 can also be utilized with the Scripts
loglog, semilogx, and semilogy functions.
The graph display can be subdivided into smaller subwindows. up to this point, all of our interaction with MATLAB has been at
The function sub~lot(mnp)subdivides the graph display into an ha command prompt. We enter statements and functions at the
grid of smaller subwindows, where m 5 2 and 5 2. ~h~~ ornrnand prompt, and MATLABinterprets our input and takes the
the graph displaycan be subdivided into twoor four windows. bpl,ropriate action. This is the peferable mode of operation when-
The integerP specifiesthe window, where the windowsare numbered or your sessions are short and nonrepetitive. However, the real
left right, top to bottom. This is illustrated in ~i~~~~1.20,where wer of MATLAB for control system design and analysis derives
the graphics window is subdivided into four subwindows. ,m its ability to execute a long sequence of commands stored in a
a. These files are called M-filessince the filename has the formfile-
cime.m. A script is one type of M-file. The Control System Toolbos
a collection of M-filesdesigned specifically for control applications.
r addition to the pre-existing M-files delivered with MATLAB and
tho toolboxes, we can develop scripts for our applications. -
Scripts are ordinary ASCII text files and are created by using
clr own text editor. Creating and storing scripts are computer
&tformdependent topics, which means that you need to seek out
e appropriate expert at your location for more information.
A script is just a sequence of ordinary statements and functions
at you would use at the command prompt level. A script is invoked
the command prompt level by simply typing in the filename (with-
t the .m file type). Scripts can also invoke other scripts. When
e script is invoked, MATLAB executes the statements and func-
tions in the file without waiting for input at the command prompt.
The script operates on variables in the workspace.
Suppose we want to plot the function ~ ( t )
= sinat, where a

is a variable that we want to vary. Using our favorite text editor,)
+
we write a script, which we will call p1otdata.m. This is shown
in Figure 1.21. We input a value of a at the command prompt,
and in doing so we place a in the workspace. Then we execute the
script by typing in plotdata at the command prompt. The script
p1otdata.m will use the most recent value of a in the workspace.
After executing the script we can enter another value of a at the
command prompt and execute the script again.
Figure l
.
2
0 Using subplot to Create a 2x 2 partition of the ~~~~h
Your scripts should be well documented with comments. A com-
Display. rnent begins with a %. If you put a header in your script comprised
of several descriptive comments regarding the function of the script,
p1otdatr.m
-%This is a script to plot the function y=sin(alpha*t).
%
% The value of alpha must exist in the workspace prior
% to invoking the script.
%
t=[0:0.01:1 I
;
y=sin(alpha*t);
plot(t,y)
xlabel('Time [sec]')
ylabel('y(t) = sin( alpha * t )')
grid
Figure 1.21 A Simple Script to Plot the Function y ( t ) = sin at.
then using the help function will display the header comments and
describe the script to the user. This is illustrated in Figure 1.22.
We use p1otdata.m to develop an interactive capability with a
as a variable, as shown in Figure 1.23. At the command prompt,
we input a value of a = 10 followed by the script filename, which in
this case is plotdata. The graph of y(t) = sinat is automatically
,,help plotdata
This is a script to plot the function y=sin(alpha*t).
I
The value of alpha must exist in the workspace prior
to invoking the script.
Figure 1.22 Using the help Function.
1 command prompt
Chapter 1. MATLAB Basics
Notes -
hapter 2
-
eal models of complex physical systems. The mathematical models,
which follow from the physical laws of the process, are generally
.. .. - - .
on to the ~
physical
p~
- - -- system
~- -~
- is
-~
-
described
~~ by a linear,~constanteffi
ent ordinary differential equation. The Laplace tbi~$f~~Zr~mkthOd~
one way to compute the s6lition of the differential equation. The
~~ ~ ~ ~
aplace transform~cii~&lsdb<hsed
to obtain an input-output de-
- -
in the analysis of a typical spring-mass-dampermathematical model
of a mechanical system. Using a MATLAB script, we will develop
Mathematical Modeling
of Systems
2.1 Introduction
The design and analysis of control systems is based on mathemati-
- - -
highly coupled nonlinear differential equations. Fortunately, many
physical systems behave linearly around an operating point within
,me range of the variables and it is possible to develop linear ap-
-
roximations to the physical systems. A Taylor series expansion is
enerally utilized in the lir~earization
process. Thc linear approxima-
:ription of the linear, time-invariant (LTI) system in the form of
L transfer function. The application of the many LLclassical"
and
"modern" control system design and analysis tools are based on
LTI mathematical models. MATLAB can be used witkLTI systems
a given in the form of transfer function descriptions or state-space
b
descriptions (see Chapter 9, State-Space Methods).
We begin this chapter by showing how to use MATLAB to assist
-
an interactive analysis capability to analyze the effects of natural
26 Chapter 2. Mathematical Modeling of Systems
frequency and damping on the unforced response of the mass dis-
placement. This analysis will utilize the fact that we have an ana-
lytic solution that describes the unforced time response of the mass
displacement.
In the subsequent sections, we will discuss transfer functions and
block diagrams. In particular, we are interested in how MATLAB
can assist us in manipulating polynomials, computing poles and ze-
ros of transfer functions, computing closed-loop transfer functions,
block diagram reduction, and computing the response of a system to
a unit step input. The chapter concludes with the electric traction
motor control design example found in MCS, pp. 79-81.
The functions covered in this chapter are roots, rootsl, se-
ries, parallel, feedback, cloop, poly, conv, polyval, printsys,
minreal, pzmap, and step.
2.2 Spring-Mass-Damper System
A spring-mass-damper mechanical system is shown in Figure 2.1.
The motion of the mass, denoted by y(t), is described by the differ-
ential equation
This system is described in MCS, pp. 36-41. The solution, y(t), of
the differential equation describes the displacement of the mass as
a function of time. The forcing function is represented by r(t).The
derivation of the spring-mass-damper mathematical model is based
on the use of ideal springs and dampers. These ideal models for the
spring and damper are based on lumped, linear, dynamic elements
and only approximate the actual elements. The spring-mass-damper
model, given in Eq. (2.1), is a linear, time-invariant approximation
to the physical process; it is valid only in regions where the spring
force is a linear function of the mass displacement and the damping
due to friction is a linear function of the velocity.
The mathematical model, given in Eq. (2.1), might represent an
off-road vehicle shock absorber. Our objective could be to design
an active control system to make the ride smoother when traversing
22. Spring-Mass-DamperSystem
Forcing
function
Figure 2.1 Spring-Mass-Damper System.
paved roads. The control design and subsequent analysis would
based on the vehicle shock absorber model in Eq. (2.1). Of course,
e true test of the control design is the road test. Only then can
prove that the control design does in fact meet the objective of
moother ride on a bumpy road. We will soon see how to use
ATLAB to enhance our control design and analysis capability.
Many physical processes are described by mathematical models
nalogous to Eq. (2.1). A typical electrical RLC circuit is described
an analogous mathematical model where the velocity, G(t), and
voltage, v(t), are analogous variables. This notion of analogous
stems is important in system modeling. Any experience gained
designing and analyzing control systems for mechanical systems
cribed by Eq. (2.1) can be used in controlling analogous electrical,
rmal, and fluid systems. I
The unforced dynamic response, y(t), of the spring-mass-damper
echanical system is
Y(O) e-(~"' s i n ( w . m t +O),
~ ( t )
= (2.2)
where 6
' = cos-'(. The initial displacement is y(0). The tran-
nient system response is underdamped when ( < 1,overdamped when
28 Chapter 2. Mathematical Modeling of Systems
( > 1, and cdically damped when ( = 1. We can use MATLAB
to visualize the unforced time response of the mass displacement
following an initial displacement of y(0) Consider the overdamped
and underdamped cases:
3 (K-2 f - 3 )
Case 1: y(0)=0.15m, u
,= fie, 5, =
M - , M -
Case 2: y(0)=0.15m, u,, = fig, 6 = & ((-2 L-
M - j M - 1 )
The MATLAB commands to generate the plot of the unforced re-
sponse are shown in Figure 2.2. In the MATLABsetup, the variables
bu=c2*exp(-zeta2*wn*t);bl=-bu;
%
plot(t,yl ,'-',t,y2,'--',t,bu,':',t,bl,':'), grid
xlabel('Tirne [sec]'), ylabel('y(t) Displacement [rn]')
text(0.2,0.85,['overdarnped zeta1=',num2str(zetaI),...
'- solid'],'^^')
Figure 2.2 Script to Analyze the Spring-Mass-Damper.
? % Sprirrg-Mass-Da~nperSystem
~(O),wn,
1, t,and C2 are input to the workspace at the command
bvcl. Then the script unforcedcommands.m is executed to gen-
d plots. This creates an interactive analysis capa-
ts of natural frequency and damping on
ponse of the mass displacement. You can investi-
of the natural frequency and the damping on the
simply entering new values of w,, (1, or (2 at the
rompt and running the script unforcedcommands.m
-response plot is in Figure 2.3. Notice that the
y labels the plot with the values of the damping
cients. This avoids confusion when making many interactive
lations. The natural frequency value could also be automati-
plot. Utilizing scripts is an important aspect of
an effective interactive design and analysis capability in
. Sinceyou can relate the natural frequency and damping
t, K, and friction, f , you can also analyze the
ts of I< and f on the response.
n the spring-mass-damper problem, the unforced solution to
ion, given in Eq. (2.1), was readily available.
ating closed-loop feedback control systems
I
T i [SKI
Figure 2.3 Spring-Mass-Damper Unforced Response.
Chapter 2. Mathematical Modeling of Systems 2 'Ikrw18fer Pbnctior~a
subject to a variety of inputs and initial conditions, it is not feasible
to attempt to obtain the solution analytically. In these cases, we can
use MATLAB to compute the solutions numerically and to display
the solution graphically. The simulation capability of MATLAB will
be discussed in detail in subsequent sections and chapters.
2
.
3 Transfer Functions
The transfer function is an input-output description of an LTI sys-
tem, as described in MCS, pp. 52-63. It relates the Laplace trans-
form of the output variable to the Laplace transform of the input
variable with zero initial conditions. Consider the LTI system de- 1.OOOO 3.0000 0.0000 - 0.OOOOi 4.0000 + 0.OOOOi
scribed by the transfer function G(s),where
Y ( s ) a,sm +a,-IS"-' +...+als +a0 re 2.4 Entering the Polynomial p(s) = s3 +3s2$ 4 and Cal-
G(s)= -=
R(s) sn +b,-lsn-I +...+als +b0 '
where m 5 n, and all common factors have been canceled. The ent of the s term is zero, it is included in the input definition
roots of the numerator polynomial of G(s)are called the zeros of the
system; the roots of the denominator polynomial are called the poles. If p is a row vector containing the coefficientsof ~ ( s )
in descend-
Setting the denominator polynomial to zero yields the characteristic
equation
sn +bn-IS"-' +..-+als +4 = 0.
The transient response of a system is directly related to the %plane ial coefficients in descending order. We can compute the roots
locations of the poles and zeros.
We can use MATLAB to analyze systems described by trans-
fer functions. Since the transfer function is a ratio of polynomials, olynornial but gives a more accurate result when the polynomial
we begin by investigating how MATLAB handles polynomials, re- repeated roots. In Figure 2.4 we also show how to reassemble
membering that working with transfer functions means that both a polynomial with the poly function.
numerator polynomial and a denominator polynomial must be spec- Multiplication of polynomials is accomplished with the conv
ified. nction. Suppose we want to expand the polynomial n(s)$where
In MATLAB polynomials are represented by row vectors contain-
n(s) = (3s' +2s +l ) ( s+4).
ing the polynomial coefficientsin descending order. For example, the
polynomial he associated MATLAB commands using the conv function are
p(s) = s3 +3s2 +4 own in Figure 2.5. Thus, the expanded polynomial, given by n, is
is entered as shown in Figure 2.4. Notice that even though the n(s) = 3s3 +14s' +9s +4.
32 Chaptcr 2. Mathematical Modeling of Systems
,,p=[3 2 1I; q=[l 41; I
,,n=conv(p,q) -
[ Multlplypand q. ]
n = I
,,value=polyval(n,-5)
value =
-66
Figure 2.5 Using conv and polyval to Multiply and Evaluate the
Polynomials (3s' +2s +l)(s +4).
The function polyval is used to evaluate the value of a polynomial
at the given value of the variable. The polynomial n(s) has the value
n(-5) = -66, as shown in Figure 2.5.
In the next example we will obtain a plot of the pole-zero lo-
cations in the complex plane. This will be accomplished using the
pzmap function, shown in Figure 2.6. On the pole-zero map, ze-
ros are denoted by an "on and poles are denoted by an "x". If the
pzmap function is invoked without left-hand arguments, the plot is
automatically generated.
Figure 2.6 The pzmap Function.
I ICXAMPLE 2.1 Transfer Functions
Centlider the transfer functions
and H(s) =
(s +1)(s +2)
s3+3s2+3s +1 (s +2i)(s - 2i)(s +3)'
script, we can compute the poles and zeros of
e characteristic equation of H(s), and divide G(s) by H(s).
can also obtain a plot of the pole-zero map of G(s)/H(s) in the
p of the transfer functionG(s)/H(s) is shown
nd the associated MATLAB commands are shown in
zero map shows clearly the five zero locations,
that there are only two poles. This cannot be the
now that the number of poles must be greater than
number of zeros. Using the roots1 function we can
rtain that there are in fact four poles at s = -1. Hence, multiple
s or multiple zeros at the same ldcation cannot be discerned on
Pole-ZeroMap b
....................
...............
.
:
. ..:.
. . . . ..:..
...Do*:.,: . . . . . . . . . .
.:!::w*::.:?:
'T
3 ............... <;
................
:
,...:...............
......
............... -
-
. . . . . . . . X - . . . . . . . . . . . . . . . . . . . X . . . . . . . . . . . . . . . . . . . . .
.
i
< I
-
-2 -1.5 -1 -0.5 8'
RealAxis
Figure 2.7 Pole-Zero Map for G(s)/H(s).
34 Chapter 2. Mathematical Modeling of Systems
I 3 4. Block iliagram Modela
z =
0+ 0.40821'
0 - 0.4082i
~p=rootsl
(deng)
s A 5 + 6 s A 4 + 1 4 s A 3 + 1 6 s A 2 + 9 s + 2
>>pzmap(num,den) 4
>>title('Pole-ZeroMap')
Figure 2.8 Transfer Function Example for G(s) and H(s).
2.4 Block Diagram Models
Buppose we have developed mathematical models in the form of
r ~ s f e r
functions for the plant, represented by G(s), and the con-
roller, represented by H(s), and possibly many other system com-
nents such as sensors and actuators. Our objective is to inter-
nnect these components to form a control system. We will utilize
TLABfunctions to carry out the block diagram transformations.
ock diagram models are described in MCS, pp. 64-69.
The process to be controlled is shown in Figure 2.9. A simple
an-loop control system can be obtained by interconnecting the
ant and the controller in series as illustrated in Figure 2.10. We
n use MATLAB to compute the transfer function from R(s) to
s), as illustrated in Example 2.2.
EXAMPLE 2.2 Series Connection
t the process, represented by the transfer function G(s), be
1
G(s) = -
500s1'
d let the controller, represented by the transfer function G,(s), be
s +1
Gc(3) = sf2.
can use the series function to cascade two transfer functions
(s) and Gz(s), as shown in Figure 2.11.
The transfer function G,G(s) is computed using the series func-
on as shown in Figure 2.12. The resulting transfer function, G,G(s),
e
Process
U(s) -
T
I
P
b
Y(4
Figure 2.9 Open-Loop System.
36 Chapter 2. Mathematical Modeling of Systems
~~~~~
R(s)
Go(s) Y(s)
Figure 2.10 Open-Loop Control System.
num
G,G(s) = -= s + 1
den 500s3+1000~2
'
Block diagrams quite often have transfer functions in parallel. In
such cases, the function parallel can be quite useful. The parallel
function is described in Figure 2.13.
We can introduce a feedback signal into the control system by
closing the loop with unity feedback, as shown in Figure 2.14. The
signal E,(s) is an error signal; the signal R(s) is a reference input.
In this control system, the controller is in the forward path and the
closed-loop transfer function is
Figure 2.11 The series Function.
. Illock 1)iagram Modaln 37
Figure 2.12 ~p~lication
of the series Function.
re are two functions we can utilize to aid in the block diagram re-
ion process to compute closed-loop transfer functions for single-
multi-loop control systems. These functions are cloop and
Chaplcr 2. Mathematical Modeling of Systenls
Ea (s) Controller u(9 Process
~ ( s )
s
k
* Gc(s) - G(s) --
Y(s)
A
Figure 2.14 A Basic Control System with Unity Feedback
as shown in Figure 2.15 with the associated system configuration
and assumes unity feedback with negative feedback as the default.
The feedback function is shown in Figure 2.16 with the associ-
ated system configuration, which includes H ( s )in the feedback path.
For both the cloop and feedback functions, if the input "sign" is
omitted, then negative feedback is assumed. In Example 2.3 we
show an application of the cloop function, and in Example 2.4 we
show an application of the feedback function.
EXAMPLE 2.3 T h e cloop Function
Let the process, G(s),and the controller, G,(s),be as in Example 2.2
(see Figure 2.12). To apply the cloop function we first use the
series function to compute G,G(s), followed by the cloop function
to close the loop. The command sequence is shown in Figure 2.17.
The closed-loop transfer function, as shown in Figure 2.17, is
T ( s )=
G,G(s) - num
- s + 1
1 +GcG(s) - den - 500s3 +1000s' +s +1'
Figure 2.15 The cloop Function.
Figure 2.16 The feedback Function.
Another basic feedback control configuration is shown in Fig-
2.18. In this case, the controller is located in the feedback path.
error signal, E,(s), is also utilized in this control system con-
ration. The closed-loop transfer function is
~numg=[l];
deng=[500 0 01;
>>numc=[l11; denc=[l 21;
>>[num
1,den1]=series(numg ,deng,numc,denc);
~[num,den]=cloop(numl,den1,-1 );
aprintsys(num,den)
500 sA3 + 1000 sA2 + s + 1
Figure 2.17 Application of the cloop Function.
40 Chapter 2. Mathematical Modeling of Systems
Figure 2.18 A Basic Control System with the Controller in the
Feedback Loop.
Ea(s) ,
RfsJ
EXAMPLE 2.4 The feedback Function
Again, let the process, G(s), and the controller, H(s), be as in Ex-
ample 2.2 (i.e., H(s) = G,(s)). To compute the closed-loop transfer
function with the controller in the feedback loop we use the feed-
back function. The command sequence is shown in Figure 2.19.
The closed-loop transfer function is
Process
G(s)
Controller
H(s)
G(s) num
=-- - s + 2
= 1+G ) den 500s' +1000s2+s + i '
B functions series, cloop, and feedback can be used
+Yfs)
Figure 2.19 Application of the feedback Function.
Block D
i
a
g
r
a
m Model,
as aids in block diagram manipulations for multi-loop block dib
grams. This is illustrated in Example 2.5.
I EXAMPLE 2.5 Multi-Loop Reduction
when
ana
I For this example, a five-step procedure is followed:
Step 1: Input the system transfer functions into MATLAB.
Step 2: Move Hz behind G4.
! A multi-loop feedback system is shown in Figure 2.20. This example
can be found in MCS, pp.67-69. Our objective is to compute the
: closed-loop transfer function
lLr.l
Figure 2.20 Multi-Loop Feedback Control System. 1
42 Chapter 2. Mathematical Modeling of Systems
a Step 3: Eliminate the G3GdHt loop.
a Step 4: Eliminate the loop containing Hz.
a Step 5: Eliminate the remaining loop and calculate T(s).
The five steps are illustrated in Figure 2.21, and the corresponding
block diagram reduction is shown in Figure 2.22. The result of
executing the MATLAB commands is
num
-- - s5 +4s4 +6s3+6s' $59 +2
den 12s' +205s5 +1066s4 +251793 +312892 +2196s +712'
We must be careful in calling this the closed-loop transfer function.
Recall that the transfer function is defined to the input-output rela-
tionship after pole-zero cancellations. If we compute the poles and
zeros of T(s), we find that the numerator and denominator poly-
nomials have (s +1 ) as a common factor. This must be canceled
before we can claim we have the closed-loop transfer function. To
Figure 2.21 Multi-Loop Block Fkduction.
8
igure 2.22 Block Diagram Reduction of Multi-Loop System (See
Example 2.5 in MCS, pp. 67-69).
Chapter 2. Mathematical Modeling of Systems 2 ,
I
. Design Example
Figure 2.23 The minreal Function.
assist us in the pole-zero cancellation we will use the minreal func-
tion. The minreal function, shown in Figure 2.23, removes common
pole-zero factors of a transfer function. The final step in the block
reduction process is to cancel out the common factors, as shown
in Figure 2.24. The closed-loop transfer function is given in Fig-
ure 2.24 as T(s)= num/den. After the application of the minreal
function we find that the order of the denominator polynomial has
been reduced from six to five, implying one pole-zero cancellation.
1 pole-zeros cancelled 
num/den =
Figure 2.24 Application of the minreal Function.
1 2.1 Design Example
motors are utilized on trains and transit vehicles.
he detailed block diagram model with the transfer functions of the
armature controlled motor, and sensor, is shown in
ure 2.25. This is Example 2.9 in MCS, pp. 79-81. Our objective
e closed-loop transfer function and investigate the
a commanded wd. The first step, as shown in Fig-
c 2.26, is to compute the closed-loop transfer function w/wd. The
wed-loop characteristic equation is second-orderwith w, = 52 and
= 0.012. Since the damping is low we might expect the response
be highly oscillatory. We can investigate the response w(t) to
reference input, wd(t), by utilizing the step function. The step
nction, shown in Figure 2.27, calculates the unit step response of
is a very important function since control
specifications are often given in terms of the
e. The state response, given by x(t), is an output
the step function and will be discussed in detail in Chapter 9,
ds. Include x in the left-hand argument list, but
not be concerned with it for the time being.
ive is to plot the output, y(t), we can use the
out left-hand arguments and obtain the plot au-
matically with axis labels. I
f we need y(t) for any reason other
an plotting, we must use the step function with left-hand argu-
ents, followed by the plot function to plot y(t). We define t as a
Figure 2.25 Electric Traction Motor Block Diagram.
46 Chapbcr 2. Mathematical Modeling of Systems
Figure 2.26 Electric Traction Motor Block Reduction.
row vector containing the times at which we wish the value of the
output variable ~ ( t ) .
The step response of the electric traction motor is shown in Fie-
~-
ure 2.28. As expected, the wheel velocity response, given by y(t),is
highly oscillatory.
f(r)
step
input t
Time [secl
% response of the Traction Motor
%Wheel Velocity
%
num=[5400]; den=[2 2.5 54021;
t=[0:0.005:3];
&,x,tl~step(num,den,t); ,
plot(t,y),grid
xlabel('Time [sec]')
ylabel('Whee1 velocity')
Figure 2.28 Traction Motor Wheel Velocity Step Response.
8
Figure 2.27 The step Function.
Chapter 2. Mathematical Modeling of Systems
Notes -
Chapter 3
Control System Characteristics
3.1 Introduction
We introduce feedback to
1. decrease the sensitivity of the system to plant variations,
2. enable adjustment of the system transient response,
3. reject disturbances, and
4. reduce steady-state tracking errors.
The advantages of feedback (listed above) come at the cost of in-
creasing the number of components and system complexity, reduc-
tion in the closed-loop system gain, and the introduction of possi-
ble instabilities. However, the advantages of feedback outweigh the
disadvantages to such an extent that feedback control systems are
found everywhere. In this chapter, the advantages of feedback are
illustrated with two examples. Our objective is to illustrate the use
of MATLAB in the control system analysis.
In the first example, we introduce feedback control to a speed
tachometer system in an effort to reject disturbances. The tachome-
ter speed control system example can be found in MCS, pp. 125-1.28.
The reduction in system sensitivity to plant variations, adjust-
ment of the transient response, and reduction in steady-state error
I are demonstrated in a second example. This is the English Channel
1 boring machine example found in MCS, pp. 134-137.
t
50 Chapter 3. Control System Characteristics
3.2 Speed Tachometer System
The open-loop block diagram description of the armature controlled
dc-motor with a load torque disturbance, Td(s), is shown in Fig-
ure 3.1. The values for the various parameters, taken from Example
2.9 in MCS, pp. 79-81, are given in Table 3.1. We have two in-
puts to our system, V,(s) and Td(s). Relying on the pn'ncipal of
superposition, which applies to our LTI system, we consider each
input separately. To investigate the effects of disturbances on the
system, we let V,(s) = 0 and consider only the disturbance Td(s).
Conversely, to investigate the response of the system to a reference
input, we let Td(s) = 0 and consider only the input V,(s).
The closed-loop speed tachometer control system block diagram
is shown in Figure 3.2. The values for K, and Kt are given in
Table 3.1.
If our system displays good disturbance rejection, then we expect
the disturbance Td(s) to have a small effect on the output w(s).
Consider the open-loop system shown in Figure 3.1 first. We can
use MATLAB to compute the transfer function from Td(s) to W(S)
and evaluate the output response to a unit step disturbance (i.e.,
T~(s)
= 11s). The time response to a unit step disturbance is shown
in Figure 3.3. The script opentach.m, shown in Figure 3.3, is used
to analyze the open-loop speed tachometer system.
The open-loop transfer function is
W(S) num -1
-=-=
Td(3) den 2s +1.5'
Figure 3.1 Open-Loop Speed Tachometer Control System where
Kb is the Back Electromotiv~Force
Constant.
1 Table 3.1 Tachornctcr Control System Parameters.
Ra K, J f Kb Ko Kt
1 10 2 0.5 0.1 54 1
e final value of w(t), which we denote
w,(t) to indicate open-loop. The steady-state error, shown on
pproximate steady-state value of w, is
wo(co)-w,(7) = -0.6632 radlsec.
The plot verifies that we have in fact reached steady-state.
In a similar fashion, we begin the closed-loop system analysis by
computing the closed-loop transfer function from Td(s) to w(s), and
then generating the time-response of w(t) to a unit step disturbance
input. The output response and the script c1osedtach.m are shown
in Figure 3.4. The closed-looptransfer function from the disturbance
Figure 3.2 Closed-Loop Speed Tachometer Control System.
Chapter 3. Control System Characterit
Open-LoopDisturbanceStepResponse
0
I
time [sec]
opentach.m r - --.
num2 and den2 represents
1 the transfer function for
%Speed Tachometer Example the armature and back emf.
% -. - -. . - -- -. . -. -...
Ra=l;Km=l 0; J=2; f=0.5; Kb=O.l ; +
numl=[1 1; denl =[J,f]; numZ=[Km*Kb/Ra]; den2=[1];
[num,den]=feedback(numl ,den1,num2,den2);
% Change sign of transfer function since the
I
num=-num; disturbance has negativesign in the diagram.
~rintsvsfnum.den)
. . * - ,
%
-
CMnputeresponge to
[yo,x,t]=step(num,den); plot(t,yo) step disturbance,
title('0pen-loop Disturbance Step R
xlabel('time [sec]'), ylabel('speedl), grid
% I - - - - - - - - - - -
yo(length(t)) 4
- - -I1
Steady-stateerror -> last value of output yo.
- - - - _ - - - - _ - - - -
Figure 3.3 Open-Loop Analysis of the Tachometer System.
time [secl
closedtach.m
I% Speed Tachometer Example
%
Ra=l ;Km=lO; J=2; f=0.5; Kb=O.l ; Ka=54; Kt=l ;
numl=[l 1; denl=[J,f]; num2=[Ka*Kt]; den2=[1];
num3=[Kb]; den3=[1]; num4=[Km/Ra]; den4=[l I;
[numa,dena]=parallel(num2,den2,num3,den3);
[numb,denb]=series(numa,dena,num4,den4);
[num,den]=feedback(numl ,den1,numb,denb);
J
%
Change sign of transfer function since dist
-has negativesign in the block diagram.
printsys(num,den)
%
[yc,x,t]=step(num,den); plot(t,yc)
title('Closed-loop DisturbanceStep
xlabil('time [sec]'), ylabel('speed [rad/secI1), grid I
7
.... ...-.
%
yc(length(t)) 4
-
Steady-state error -> last value of output yo.
.-
Figure 3.4 Closed-Loop Analysis of the Tachometer System.
Chaptcr 3. Control System Characteristics
input is
W(S) num
-- -1
-
T'(s) - den - 2s +541.5'
As before, the steady-state error is just the final value of w(t), which
we denote by w,(t) to indicate closed-loop. The steady-state error
is shown on the plot in Figure 3.4. We can obtain an approximate
value of the steady-state error by looking at the last value in the
output vector y,, which we generated in the process of making the
plot in Figure 3.4. The approximate steady-state value of w is
We generally expect that w,(co)/w,(co) < 0.02. The ratio of closed-
loop to open-loop steady-state speed output due to a unit step dis-
turbance input, in this example, is
We have achieved a remarkable improvement in disturbance rejec-
tion. It is clear that the addition of the negative feedback loop
reduced the effect of the disturbance on the output. This demon-
strates the disturbance rejection property of closed-loop feedback
systems.
3.3 English Channel Boring Machines
The block diagram description of the English Channel boring ma-
chines is shown in Figure 3.5. The transfer function of the output
due to the two inputs is
The effect of the control gain K on the transient response is shown
in Figure 3.6 along with the script english1.m used to generate the
plots. Comparing the two plots in Figure 3.6, it can be seen that
decreasing K decreases the overshoot. Although it is not as obvious
disturbance
Dfs) boring
I machine
G(s)
angle
2
. ,
1 I CfsJ
*
Figure 3.5 Boring Machine Control System Block Diagram.
s (s+ 12)
from the plots in Figure 3.6, it is also true that decreasing K de-
creases the settling time. This can be verified by taking a closer look
(at the command level) at the data used to generate the plots. This
example demonstrates how the transient response can be altered by
feedback control gain I(. Based on our analysis thus far, we would
prefer to use K = 50. However, there are other considerations that
must be taken into account before we can establish the final design.
Before making the final choice of K , it is important to consider
the system response to a unit step disturbance. This is shown in Fig-
ure 3.7. We see that increasing K reduces the steady-stde response
of c(t) to the step disturbance. The steady-state value of c(t) is 0.02
and 0.01 for K = 50 and 100, respectively. The steady-state errors,
percent overshoot, and settling times are summarized in Table 3.2.
The steady-state values are predicted from the final value theorem
as follows:
angle
If our only design consideration is disturbance rejection, we would
prefer to use I< = 100.
We have just experienced a very common trade-off situation in
control system design. In this particular example, increasing K leads
to better disturbance rejection, while decreasing K leads to better
performance (via less overshoot and quicker settling time). The final
r . Control System Characteristics
Stepresponse forK=lW
overshoot 1
-..----..-
fc?5.
settling time
1
OF0:2 014 0:6 0:s i 1:2 114 1:6 118 1
time [secl
1.5 Stepreswnse forK=SO
minimalovershoot I
0 0 V 0 1 2 o i 0 6 0:s i 1 2 i i 1 6 1:8 1
time [sec]
englishl.m
% Response to a Unit Step Input R(s)=l /s for K=50, 100
%
numg=[l 1; deng=[l 12 01; K1=100; K2=50;
numl=K1*numg; num2=K2*numg;
% dosed-loop trnwfer functions
[numa,dena]=cloop(numl $eng); ,
[numb,denb]=cloop(num2,deng);
Cho6Je tlme inorval.
1
[y1,x,t]=step(numa,dena,t); [y2,x,t]=step(numb,denb,t);
subplot(2 11),plot(t,y 1), title('Step Response for K=lOO1)
xlabel('time [sec]'),ylabel('c(t)')
subplot(212),plot(t,y2), title('Step Response for K=50')
xlabel('time [sec]'),ylabel('c(t)')
Figure 3.6 The Response to a Step Input with 1<=100 and 1<=50.
0.015
DisturbanceResponseforK=lW
0.2 0.4 0:6 0.8 i l i 1:4 lk l:8 !
L
time [sec]
0.025,
Disturbance ResponseforK=lW I
1
2 014 0:6 0:8 i 1:2 1:4 1:6 118 2
time [sec]
english2.m
% Response to a Disturbance D(s)=l /s for K=50, 100
%
numg=[l 1; deng=[l 12 01; K1=100; K2=50;
% clasedtoop transfer functlms
rnuma.denal=feedba
subplot(21 1),plot(t,y 1)
title('Disturbance Response for K=100')
xlabel('time [sec]'),ylabel('c(t)')
subplot(2 12),plot(t,y2)
title('Disturbance Response for K=50')
xlabel('time [sec]'),ylabel('c(t)')
Figure 3.7 The Response to a Step Disturbance with 1<=100 and
1(=50.
98 Chapter 3. Control System Characteristics ,i.:j, (;rlgistt (>I~~I,IIII~:
11ori11gMtl(:l~ixtf:s
Table 3.2 Response of the Boring Machine Control System for K =
50 and If = 100.
decision on how to choose K rests with the designer. So you see that
while MATLAB can certainly assist you in the control system design,
it cannot replace your decision-making capability intuition.
The final step in the analysis is to look at the system sensitivity
to changes in the plant. The system sensitivity is given by ( E ~ .
3.62, 0/6 System Sensitivity Plot
MCS, p. 197)
1
W=[O.I :0.05:201; s=w*i;
'(') = 1+Z<G(s)
s(s +12)
-
-
s(s +12) +K'
We can compute the values of S(s) for different values of 3 and
generate a plot of the system sensitivity. For low frequencies, we
can approximate the system sensitivity by
128
s(s)M j ~ .
Increasing the gain I
f reduces the system sensitivity. The system
sensitivity plots are shown in Figure 3.8 for K = 50. The sensitivity Figure 3
.
8 system sensitivity to Plant Variations.
approximation is also shown in Figure 3.8.
Control
ltes -
System Charactel
hapter 4
Control System Performance
.1 Introduction
P~imary
concerns in control system design are stability and perfor-
nl;Lnce. Performance is an issue for stable systems and is the topic
I this chapter. In order to design and analyze control systems,
c must first establish adequate performance specifications. Per-
mance specifications can be presented in the time domain or the
quency domain. Time-domain specifications generally take the
rm of settling time, percent overshoot, rise time, and steady-state
rror specifications. Stability and frequency-domain specifications
re addressed in the next chapters.
This chapter is organized as follows. In the next section we
rivestigate time-domain performance specificationsgiven in terms d
ansient response to a given input signal and the resulting steady-
alate tracking errors. The chapter concludes with a discussion of
simplification of linear systems.
The MATLAB functions introduced in this chapter are impulse
and lsim. These functions are used to simulate linear systems.
4.2 Time-Domain Specifications
'I'ime-domain performance specifications aregenerally given in terms
ol the transient response of a system to a given input signal. Since
(,heactual input signals are generally unknown, a standard lest input
61
,l,a. yinle-Domain Spc~cific.nl,iorls
R(s) ~Tp~ylTws ( s + ~ w , ) c(s)
steady-state error 2%
Figure 4.2 Single-Loop Second-Order Feedback System.
closed-loop output is
2
C(s) = Wn
s2+25w,s +w;4 R(s).
wehave already discussed the use of the step function to =om-
putethe step response of a system. Now we address another im-
portant test signal: the impulse. The impulse response is the time
derivative of the step response. We compute the impulse response
with the impulse function shown in Figure 4.3.
wecan obtain a plot similar to Figure 4.5(a) in MCS, Pi 162
4-1 Step Response of a Second-Order System. with the step function, as shown in Figure 4.4. Using the impulse
function, we can obtain a plot similar to Figure 4.6 in MCS, P.
signalis used. The test signals are of the general form
163. The response of a second-order system for an impulse
inputis shown in Figure 4.5. In the script, we set wn = 1, which is
r(t) = tn,
and the corresponding Laplace transform is
n!
input
R(s) = -. t
p+1
When = 19%and 3 we have the step, ramp, and parabolic inputs,
An impulse function is also used as a test signal.
The performance measures are usually defined in terms
the response and the impulse response. The most
performance IrIeasUreS are percent overshoot (p.~.),
rise time peak time (T,), and settling time (T,), as shown in
Figure 4.1.
the second-order system shown in Figure 4.2. ~h~ Figure 4.3 The impulse Function.
64 Chapter 4. Control System Performance
% Compute step response for a second-order system
% Duplicate Figure 4.5(a) in MCS, p. 162
% I
1
[yl ,x,t]=step(num,denl ,t); [y2,x,t]=step(num,den2,t);
[y3,x,t]=step(num,den3,t); [y4,x,t]=step(num,den4,t);
[yS,x,tl=step(num,den5,t); [y6,x,t]=step(num,den6,t);
1%
1 :' 'I'ime-DomainSpc!rilic.~Liolrs
(i
6 i i l r 4 Control System Performance
Figure 4.6 The lsim Function.
equivalent to computing the step response versus w,t. This gives us
a more general plot valid for any w, > 0.
In many cases, you may need to simulate the system response to
an arbitrary but known input. In these cases, you can use the lsim
function. The lsim function is shown in Figure 4.6. An example of
the use of lsim is given in Example 4.1.
EXAMPLE 4.1 Mobile Robot Steering Control
The block diagram for a steering control system for a mobile robot
is shown in Figure 4.7 (see MCS, pp. 174-176).
Controller Vehicle dynamics
Figure 4.7Block Diagram of a Steering Control Systemfor a Mobile
Robot.
.J :?. Time-Domain Speciii~aliorl~
67
time [secl
mobilarobot.m
% Compute the response of the Mobile Robot Control
% System to a triangular wave
%
numg=[l 0 201; deng=[l 10 01, ...................................................
:...:
....... : :.,*.,.,.
.................................................. ............
iQ:-triMrr",$
:';;
[num,den]=cloop(numg,deng); 4
7
1
:.:..::
. . . . . . . . .
......................................................
:..................:
.....................:.:
.:wijg:,"p"t"
: . . .
::":l::::.i:l.,:i'.';.::i
: ................../,
t=[0:0.1 :8.211; .............................
..? !..?.;..'.&......z.<$.$. :.i.
.......... .......................
~1=r0:0.1:2]';~2-[2:-0.1:-2]';~3=[-2:O. : ;
I I
Figure 4.8 Transient Response of the Mobile Robot Steering Con-
trol System to a Ramp Input.
Chapter 4. Control Systern Performance
Suppose the steering controller, G1(s),
is
When the input is a ramp, the steady-state error is
I 3. Simplification of 1,ittrnr. Sydcms
1 A ~vcond-orderapproximation (see MCS, pp. 187-188)is
where
Ii, = IGK.
Figure 4.8 for Kl = I< = 1, K2 =2, and 7 = 1/10.
4.3 Simplification of Linear Systems
- , ~ - - ~
e impractical to implement a high-order controller in a control sys-
tem. However, it may be possible to develop a lower-order aDnrox-
"-
compare the approximate model to the actual model, as illustrated
in the following example.
EXAMPLE 4.2 A Simplified Model
Consider the third-order system
rr/  6
K,
GI(8) = Kl +--. 1.60
s L(s) = ~2 +2.5849 +1.60'
A comparison of their respective steprespOnsesis givenin Figure 4.9.
.
-
The effect of the controller constant, Kz, on the steady-state error
is evident from Eq. (4.1). Whenever K2 is large, the steady-state
error is small, and vice versa.
We can simulate the closed-loopsystem response to a ramp input
using the lsim function. The controller gains K l , I(z and the system
gain K can be represented symbolically in the script so that various
values can be selected and simulated. The results are shown in
-.
In practice, it may be necessary to approximate a higher-order trans-
fer function model with a lower-order model. For exam~le.
it ma.v
b
.~r---- % Compare step response for se
imate controller that closely matches the input-output reponse of
the high-order controller. A procedure for approximating transfer numl=[6]; denl=[l 6 11
functions is given in MCS, pp. 185-187. We can use MATLA R tn
n (3) = pigure4.9 Step Response Comparison for an Approximate Transfer
s3+6.s2$11s+6' tion on Versus the Actual Transfer Function.
Chapter 4.
Notes
Control System Performan
ter 5
Control System Stability '
.1 Introduction
'I(: stability of a closed-loop control system is a fundamental issue
01s. Generally speaking, an unstable closed-loop control sys-
8111is of little practical value. For linear systems, a necessary and
Ilicient condition for a feedback system to be stable is that all the
the system transfer function have negative real parts. In
her words, the poles must lie in the left-half plane for the system
hle. The Routh-Hurwitz stability method provides a struc-
d mechanism for determining the number of unstable poles of
-loop characteristic equation. This allows us to obtain a
"no" answer to stability without explicitly calculating the
This chapter begins with a discussion of the Routh-Hurwitz sta-
lily method. We will see how MATLAB can assist us in the stabil-
analysis by providing an easy and accurate method for comput-
the poles of the characteristic equation. For the case where the
hi~racteristic
equation is a function of a single parameter, it will be
ponsible to generate a plot displaying the movement of the poles as
tl~c:parameter varies. The chapter concludes with an example.
The function introduced in this chapter is the function for, which
1s used to repeat a number of statements a specific number of times.
72 Cl~apter
5. Control System StabilityI ,h :
!
. llotlth-ll~lrwitz
Stnhilil,.y
5.2 Routh-Hurwitz Stability
...........
The Routh-Hurwitz criterion is a necessary and sufficient criterion 24 :.:,:::: .
.
.
:
.
.
:
.
.
f
i
.
.
.
:
.
.
. ..:
:., tt..scl
n:.ewMg
[, ,
. . . . . . . . . . . . . .
. . . . . . . . . . . . .
for stability. Given a characteristic equation with fixed coefficients, .drrn.i&ch;rr(gT
!: sl -22
we can use Routh-Hurwitz to determine the number of roots in the . . . . . . . . . . . . . . . . . . . . .
, . :. . . .
::.: ::.:../ . ./../.....$.........
. SO 24 0 I)
right-half plane. For example, consider the characteristic equation
lgure 5.2 Routh-Hurwitz Array for the Closed-Loop Control Sys-
q(s)= s3 +s2 +2s +24 = 0 wn with T ( s )= C ( s ) / R ( s )= 1/(s3+s2+29 +24).
associated with the closed-loop control system shown in Figure 5.1.
The corresponding Routh-Hurwitz array is shown in Figure 5.2. The
two sign changes in the first column indicate that there are two ult graphically. As shown in Figure 5.5, we establish a vector of
roots of the characteristic polynomial in the right-half plane; hence ues for K at which we wish to compute the roots of the charac-
the closed-loop system is unstable. Using MATLAB we can veri ristic equation. Then using the roots function we calculate and
the Routh-Hurwitz result by directly computing the roots of th ot the roots of the characteristic equation, as shown in Figure 5.5.
characteristic equation, as shown in Figure 5.3, using the roots can be seen that as K increases, the roots of the characteristic
function. Recall that the roots function computes the roots of a; uation move toward the right-half plane as the gain tends toward
polynomial. = 8, and eventually into the right-half plane when K > 8. This is
Whenever the characteristic equation is a function of a single raphical verification of the Routh-Hurwitz result obtained above.
parameter, the Routh-Hurwitz method can be utilized to determine, the next chapter we will discover a compact method of obtaining
the range of values that the parameter may take while maintaining e plot of the root locations as a function of one parameter using
stability. Consider the closed-loop feedback system in Figure 5.4. e root locus method.
The characteristic equation is
q(s) = s3 +s2 +4s +K = 0.
Using a Routh-Hurwitz approach we find that we require 0 <K 5 8
for stability (see MCS, p. 215). We can use MATLAB to verify this
>>nurng=[l];deng=[l 1 2 231;
[nurn,den]=cloop(nurng,deng);
~roots(den)
ans =
-3.0000 ..............::...:
R(s)
::. .:............
....:
:...:.. ......................................
1 .OOOO+ 2.64581 :.wtabtcr.'i6;*:~;i:l':i~
.: . . . . . . . . . . . . . . . . .
. . . .......: : :::: ....
:
. ..; : : :
1.OOOO- 2.64581 .....................................
:..
I
Figure 5.1 Closed-Loop Control System with T ( s )= C ( s ) / R ( s )= Figure 5.3 Using the roots h n d i o n to Compute the Closed-Loop
l / ( s 3+s2 +2s $24). (:ontrol System Poles of the System Shown in Figure 5.1.
G(s)= 1
sa+s2+2s+23 ' c ( s )
Chapter 5. Control System Stabili
Figure 5.4 Closed-Loop Control System with T(s) = C(s)/R(s)
K/(s3 +2
3
' +4s +I<).
.
1% This script computes the roots of the characteristic 1
% equation q(s) = sA3 + 2 sA2 + 4 s + K for O<K<20
1% I
K=[0:0.5:20 1;
for i-1 :length(K)
4.11 2 4 K(i)]; }
p(:,i)=roots(q);
end
plot(real(p),imag(p),'x'), grid
xlabel('rea1 axis'), ylabel('imaginary axis')
Figure 5.5 Plot of Root Locations of q(s) = s3 +2sZ +4s +I< fol
0 5 K 5 20.
5.2. Routh-Hurwilz Sl,rrl)ilil,y 75
The script in Figure 5.5 contains the for function. The for func-
I,ic)nprovides a mechanism for repeatedly executing a series of state-
nl(:nts a given number of times. The for function connected to an
end statement sets up a repeating calculation loop. Figure 5.6 de-
rc'ribes the for function format and provides an illustrative example
vcxtor a is set equal to 20 and the scalar b is recomputed.
The Routh-Hurwitz method allows us to make definitive state-
rrlents regarding absolute stability of a linear system. The method
floes not address the issue of relative stability, which is directly
rt:lated to the location of the roots of the characteristic equation.
Il.outh-Hurwitz tells us how many poles lie in the right-half plane,
but not the specific location of the poles. With MATLAB we can
easily calculate the poles explicitly, thus allowing us to comment
on the system relative stability. We conclude this chapter with an
example taken from MCS, pp. 2.23-225.
...............
M
n
i
:
-
i :ii,':
b................ : : . ......I
-for variable=expression
Statement
statement
! Figure 5.6 The for Function and an Illustrative Example.
76 Chapter 5. Control Syst
5.3 Example: Tracked Vehicle Turnin
The block diagram of the control system for the two-track vehi
is shown in Figure 5.7. The design objective is to find a and
such that the system is stable and the steady-state error for a ramp
input is less than or equal to 24% of the command. We can use the
Routh-Hurwitz method to aid in the search for appropriate values
of a and I<. The closed-loop characteristic equation is
~ ( s )
= s4+8s3 +17s' +( K +10)s +aK = 0.
Using the Routh-Hurwitz array we find that for stability we require
K < 126, aIi > 0.
For positive Ii it follows that we can restrict our search to
126 and a > 0. Our approach will be to use MATLAB
parameterized a versus Ii region in which stability is as
we can find a set of (a,
Ii)belonging to the stable region
the steady-state error specification is met. This procedu
in Figure 5.8, involves selecting a range of values for a
computing the roots of the characteristic for specific
K . For each value of K,we find the first value of a t
least one root of the characteristic equation in the r
The process is repeated until the entire selected range of
exhausted. Then, the plot of the (a,
Ii)pairs defines
between the stable and unstable regions.
Controller
Power train and vehicle
GfSl
Gc(s )
K
s3+7 s2 +10s
.
Figure 5.7 Turning Control for a Two-Track Vehicle.
78 Chapter 5. Control System Stabilit 1,9. Example: Il.acked Vehleh nlrrning Control
The region to the left of the plot of a versus I( in Figure 5.8 i
the stable region, since that corresponds to I i < 126.
If we assume that ~ ( t )
= At,t > 0, then the steady-state error i
e,, = lim s . s(s +1)(s+2)(s+5) .-=-
s+o s ( s + l ) ( s + 2 ) ( ~ + 5 ) + K ( s + a ) s2 a l i '
where we have used the fact that
1
E(s) = R(s) =
~ ( 3
+1)(s+2)(s+5)
1+G,G(s) S ( S +1 ) ( ~
+2)(s+5) +Ic(s +a)
Given the steady-state specification, e., < 0.24A, we find that
specification is satisfied when
10A
-
aK
< 0.24A,
or time [sec]
a K > 41.67.
Any values of a and K that lie in the stable region in Figure % This script computes the ramp response
and satisfy Eq. (5.1) will lead to an acceptable design. For exam % for the two-track vehicle turning control
K = 70 and a = 0.6 will satisfy all the design requirements. % problem with a=0.6 and K=70
closed-loop transfer function (with a = 0.6 and K = 70)is
t=[0:0.01:10]; u=t;+ .
:
70s +42
T ( s )=
s4 +8s3 +17s2+80s +42 '
The associated closed-looppoles are
s = -7.0767,
s = -0.5781, plot(t,y,t,u), grid
s = -0.1726 +3.1995i,and xlabel('time [secl'), ylabel('c(t1')
s = -0.1726 - 3.19952'. -
The corresponding unit ramp input response is shown in Figure 5. ure 5.9 Ramp Response for a = 0.6 and K = 70 for Two-Trz
The steady-state error is less than 0.25, as desired. icle Turning Control.
1
Chapter 5. Control System SI
. Notes
hapter 6
oot Locus Method
,I Introduction
hr relative stability of a control system is related to the location
the roots of the closed-loop characteristic equation. The tran-
nt response (i.e., settling time, overshoot, etc.) of a linear control
atem is also related to the location of the poles and zeros of the
sed-loop transfer function. The closed-loop system relative sta-
ty and performance can sometimes be adjusted by changing a
ameter, such as a control gain. The root locus method provides
raphical representation of the locus of roots of the characteristic
ation as one parameter is varied. The graphical representation
called the root locus plot.
An approximate root locus sketch can be obtained by applying
e orderly procedure outlined in MCS, pp. 241-255. Alternatively,
can use MATLAB to obtain an accurate root locus plot. How-
r, do not be tempted to rely solely on MATLAB for obtaining
ot locus plots while neglecting the manual steps in developing an
proximate root locus. The fundamental concepts behind the root
elis method are buried in the manual steps and it is essential to
lly understand their application.
The chapter begins with a discussion on obtaining a root locus
lot with MATLAB. This is followed by a discussion of the connec-
ns between the partial fraction expansion, dominant poles, and
81
U L Chapter 6. Root Locus Method ti 2. Obtaining a Root IJoc.tm I'lot 83
the closed-loop system response. Root sensitivity is covered in the
final section.
The functions covered in this chapter are rlocus, rlocfind, and
residue. The functions rlocus and rlocfind are used to obtain root
locus plots, and the residue function is utilized for partial fraction
expansions of rational fnnctions.
6.2 Obtaining a Root Locus Plot
Consider the closed-loop control system in Figure 6.1. The closed- Figure 6.2 The rlocus Function.
loop transfer function is
the root locus plot associated with Eq. (6.1) are shown in Figure 6.3
c(s) K(s +l)(s +3) dong with the associated root locus plot. Invoking the rlocus func-
T(s) = -=
R(s) s(s+2)(s +3) +K(s +I)' tion without left-hand arguments results in an automatic generation
oi the root locus plot. When invoked with left-hand arguments, the
The characteristic equation can be written as plocus function returns a matrix of root locations and the associated
s + l
1$ I( = 0. (6.1) The steps to obtain a root locus plot with MATLAB are as fol-
4s +2)(s +3)
5% < < + L
The form of the characteristic equation in Eq. (6.1) is necessary to 1. Obtain the characteristic equation in the form given in Eq. (6.2)
use the rlocus function for generating root locus plots. The general where k is the parameter of interest, and
form of the characteristic equation necessary for application of the 2. use the rlocus function to generate the plots.
rlocus function is
P(S) Referring to Figure 6.3, we can see that as K increases, two
1+k-=o,
~(5.1 (6.2)
ranches of the root locus break away from the real axis. This
means that for some values of K, the closed-loop system character-
where k is the parameter of interest to be varied from 0 < k. _< co.
istic equation will have two complex roots. Suppose we want to find
The rlocus function is shown in Figure 6.2. The steps to obtaining the value of K corresponding to a pair of complex roots. We can use
the rlocfind function to do this, but only after a root locus has been
R(s)
G(s)=
s ( s + ~ )
obtained with the rlocus function. Executing the rlocfind function
Cfs) will result in a cross-hair marker appearing on the root-locus lot.
You move the cross-hair marker to the location on the locus of in-
1
H (s)= -
terest and hit the enter key. The value of the parameter K and the
selected point will then be displayed in the command display. The
s + 3 use of the rlocfind function is illustrated in Figure 6.4.
Continuing our third-order root locus example, we find that when
Figure 6-1 Closed-Loop Control System with Unspecified Gain I(. I( = 20.5775, the closed-loop transfer function has three poles and
Chapter 6'. Ilool, 1,or:rru Method
.................................
,>p=[l I];
q=[l 5 6 01; [r,k]=rlocus(p,q); plot(r,'xl)
Figure 6.3 The Root Locus for the Characteristic Eq. (6:l).
two zeros at
(
-2.0505 +4.3227i
poles :s = -2.0505 - 4.3227i ), z e m : s = (
I
:
)
.
-3989
Considering the closed-loop pole locations only, we would expect
that the real pole at s = -.8989 would be the dominant pole (see
MCS, p. 166). To verify this, we can study the closed-loop system
response to a step input, R(s)= l / s . For a step input we have
C ( s )=
20.5775(s +l ) ( s+3) 1
S ( S +2)(s+3) +20.5775(s +1) ' s' (6.3)
Generally, the first step in computing c(t)is to expand Eq. (6.3) in
a partial fraction expansion (see MCS, pp. 45-52). The residue
(i.2. Obtaining a Root l,oc:~~*
l'11)l 85
Real Axis
ap=[l I]; q=[l 5 6 01; rlocus(p,q)
~rlocfind(p,q)
Select a point in the grap ics win ow
selected-point =
-2.0509 + 4.32281
ans =
Figure 6.4 Using the rlocfind Function.
function can be used to expand Eq. (6.3), as shown in Figure 6.5.
The residue function is described in Figure 6.6.
The partial fraction expansion of Eq. (6.3) is
Comparing the residues we see that the coefficient of the term cor-
responding to the pole at s = -.8989 is considerably smaller than
the coefficient of the terms corresponding to the complex-conjugate
poles at s = -2.0505 & 4.3227i. From this we expect that the in-
fluence of the pole at s = -8989 on the output response c(t) is
>>K=20.5775;nurn=K*[l 4 31; den=[l 5 6+K K];
nstep(nurn,den), grid
?
Figure 6.8 Converting a Partial Fraction Expansion Back to a Ra-
tional Function.
response. The main contributors to the transient response are the
complex-conjugate poles at s = -2.0505 f-4.32282'.
One final point regarding the residue function. You can convert
the partial fraction expansion back to the polynomials num/den,
given the residues (T), the pole locations (p), and the direct terma
(k), with the command shown in Figure 6.8.
6.3 Sensitivity and the Root Locus
The roots of the characteristic equation play an important role in
defining the closed-loop system transient response. The effect of
parameter variations on the roots of the characteristic equation is a
useful measure of sensitivity. The root sensitivity can be defined to
be
dTi
-
aklk' (6.4)
We can utilize Eq. (6.4) to investigate the sensitivity of the roots of
the characteristic equation to variations in the parameter k. If we
change k by a small finite amount Ak, and evaluate the modified
root T ; +AT;,it follows from Eq. (6.4) that
Ar;
s; = -
Aklk' (6.5)
The quantity 5'2 is a complex number. Referring back to the third-
order example in the previous section, if we change K a factor of 5%,
w(, find that the dominant complex-conjugate pole at s = -2.0505+
.I
.:1228i changes by
wllcn K changes from K = 20.5775 to K = 21.6064. From Eq. (6.5),
if, follows that
'I'lle sensitivity S
; can also be written in the form
~
'I'he magnitude and direction of S;' provides a measure of the root
ncmsitivity. The script used to perform the above sensitivity calcu-
lations is shown in Figure 6.9.
The root sensitivity measure may be useful for comparing the
~c~nsitivity
for various system parameters at different root locations.
Ilowever, the root sensitivity measure may not be that useful when
titilized in the design process. It is primarily an analysis measure.
fsensitivity.rn
% Compute the system sensitivity to a parameter
% variation
%
K=20.5775; den=[l 5 6+K K]; rl=roots(den);
% . .
:: ss61drjnpa
inx.;:,;,
dk=1.0289; . . . . . : : . .
%
Km=K+dk; denm=[l 5 6+Km Km]; rZ=roots(denm);
dr=rl -r2;
%
4
-
a
fmfij::.;j,,
S=dr/(dk/K); 4 .
..
. . .. ...... .... . ... .
. . ..
..
. .
Figure 6.9 Sensitivity Calculations for the Root Locus for a 5%
Change in K = 20.5775.
Chapter
Notes -
Root
-
Locus Met
-
apter 7
equency Response Methods
.1 Introduction
he frequency response of a system is the steady-state output re-
ponse due to a sinusoidal input signal. In the previous chapters
e have discussed the system response to various other test signals
ncluding steps, ramps, parabolas, and impulses. In this chapter, we
ill investigate the response of systems to sinusoidal inputs.
The frequency response methods are based on considering the
esponse of linear systems to sinusoidal input test signals as the fre-
uency of the sinusoidal test signal varies. A linear, time-invariant
ystem has the characteristic that, in the steady-state, the output
esponse due to a sinusoidal input differs from the input only in
magnitude and phase. The transfer function describing the sinu-
soidal behavior of the system is obtained by replacing s with jw in
the system transfer function G(s). Then, for a fixed w, G(jw) is a
complex number with a magnitude and phase. The magnitude and
phase of G(jw) can be represented graphically as w varies. This
type of graphical representation is known as a Bode diagram. It is
possible to develop control system performance specifications in the
frequency domain so that an effectivecontrol system design method-
ology using the Bode diagram can be used.
The chapter begins with an introduction to the Bode diagram.
Subsequently, the connection between the frequency response and
performance specifications in the time-domain is discussed. The
91
!)2 (:ll:Vler 7. frequency Response Methods 93
clla~)ter
concludes with an illustrative example to gain experience ,,llillyze
control systems. It is essential to develop the capability to
dcsignjng a control system in the frequency domain, ,ll,l,nually
obtain approximate Bode diagrams. There is no substitute
The functions covered are bode and logspace. The bode func- I,,!. a clear understanding of the underlying theory.
tion is used to generate a Bode diagram, and the logspace function A ~~d~ diagram is obtained with the bode function shown in
generates a logarithmically spaced vector of frequencies utilized by ~ " i ~ ~ ~ ~
7.2. The Bode diagram is automatically generated if the
the bode function. function is invoked without left-hand arguments. Otherwise7
(,I~(!
magnitude and phase characteristics are placed in the workspace
7
.
2 Bode Diagram t,l,rough the variables mag and phase. A Bode diagram is obtained
the plot function using mag, phase, and w. The vector w
Suppose we have the transfer function (see MGS, p. 321 c:ontainsthe values of the frequency in radians/= at which the
5(1 +0.1s)
Ijode diagram will be calculated. If w is not specified, MATLABwiu
G(s) =
(7.1) lLlltomatically
choose the frequency values by placing more points in
s(l +0.5s)(l +3 s +$32) '
I.c;gions
where the frequency response is changing quickly. Since the
The diagram corresponding to Eq. (7.1) is shown in Figure 7.1.
ljode diagram is a log scale, if you choose to specify the frequencies
The diagram consists of the logarithmic gain in dB versus in one
explicitly,it is desirable to generate the vector w using the logspace
function. The logspace function is shown in Figure 7.3.
plot and the phase 6(w) versus w in a second plot. The manual
~h~ ~~d~ diagram in Figure 7.1 is generated with the commands
steps for sketching an approximate Bode diagram are given in MCS, sl,own in Figure 7.4. The bode function automatically selected the
PP. 308-317, As with the root locus plots, it will be tempting to
on MATLAB to obtain your Bode diagrams. ~~~~t
MATLABasone tool in your tool kit that you can use to design and
Figure 7
.
1 The Bode Plot Associated with Eq. (7.1). Figure 7.2 The bode Function.
Frequency(radlsec)
7.9, SpecUlcstionr in the Fkquency Domain 95
n points between 10"and lob
den-conv(f 1,c,onv(f2,f3));
Figure 7.4 The Script for the Bode Diagram in Figure 7
.
1
.
quency range as w = 0.1 to 1000 rad/sec. This range is user-
eepi,ngin mind our goal of designi
jfications given in the time domain to those given in the frequency
domain depend upon approximation of the system by a second-order
system with the poles being the system dominant roots. This aP-
proximation is discussed in MCS, pp. 241-255.
Consider the second-order system shown in Figure 7.5. The
C(s)
Frequency r~wsecl
Figure 7.3 The logspace Function.
Figure 7.5 Single-Loop Second-Order Feedback System.
clos(.tl-loop transfer function is
I
The Bode diagram magnitude characteristics associated with the
closed-loop transfer function in Eq. (7.2) are shown in Figure 7.6.
The relationship between the resonant frequency,w,, the maximum
of the frequency response, MPY,and the damping ratio, (,and the
natural frequency, w,, is shown in Figure 7.7 (and in Figure 7.10 in
MCS, p.316). The information in Figure 7.7 will be quite helpful in
designing control systems in the frequency domain while satisfying
time-domain specifications.
We have seen that we can relate frequency-domain specifications
to time-domain specifications by using the information contained in
performancespedflcations
time relatedto frequency
dampingratio w M~~
rise time
overshoot w Mp,
Figure 7.6 Second-Order Closed-Loop System Characteristics.
zeta zeta
NOTE: [mp(l),l]-max(mag) stores the Index
of the maximum mag in the variable I.
Figure 7.7 The Relationship Between (MpY,w,)and ((',w,) for a
Second-Order System.
Chapter 7. Frequency Response Methods 7.4. Exarnpk:: Errgrnvir~gMacl~ine
System
the closed-loop Bode diagram. Stability is an important issue that
can be addressed in the frequency domain by considering the open-
loop transfer function. This topic will be addressed in the next
chapter.
7.4 Example: Engraving Machine System
Consider the block diagram model in Figure 7.8. This example can
be found in MCS,pp. 332-335. Our objective is to design I( so
that the closed-loop system has an acceptable time response to a
step command. A functional block diagram describing the frequency
domain design process is shown in Figure 7.9. First we choose K = 2
and subsequently iterate on K if the performance is unacceptable.
A script, shown in Figure 7.10, is used in the design. The value
of K is defined at the command level. Then the script is executed
and the closed-loop Bode diagram is generated. The values of M,,
and wr are determined by inspection from the Bode diagram. Those
values are used in conjunction with Figure 7.7 to determine the
corresponding values of C and w,.
Given the damping ratio, C, and the natural frequency, w,, the
settling time and percent overshoot are estimated using the formulas
4
T83 -, P.O. =100exp
-5.
Cwn m'
If the time-domain specificationsare not satisfied, then we adjust I(
and iterate.
The values for <and w, corresponding to I< = 2 are C = 0.29 and
w, = 0.88. This leads to a prediction of P.O. = 38% and T, = 16
Motor, screw,
Contrdlu and scribe holder
initial gain
K -
.
A
-
-
-
s @+I) (s+2)
Check
time domain specs
*us)
If satisfied, then exit
and
continue analysis.
Figure 7.8 Engraving Machine Block Diagram Model.
1
Close&loo~Bode diagram
Freq. tradlsecl
DetermineM~~ andm.
I
I I
Establish relationshipbaween frequency domain
specs and time danain specs
3.q : I 1
1 2 : I
.....:
... ..
.....
.................
zeta
Determine a n and <.
Figure 7.9 Frequency Design Functional Block Diagram for the
Rnvravine Machine.
Chapter 7. Frequency Response Methods
,
>>K=2;engravescript1
mp =
1.8371
wr =
0.8171
I
" manud step Determine 0, and 4 from Figure 7.10
>> e i
n MCS, p. 316 using Up, anc 0 , .
>>
I
I QMdc spew and iterate, it nccesaary.
Figure 7.10 Frequency Design Script for the Engraving Machine.
I
7.4. Example: fihgravirrg Machine System
nt.conds. The step response, shown in Figure 7.11, is a verification
I,l~at
the performance predictions are quite accurate and the closed-
loop system performs adequately.
In this example, the second-order system approximation is rea-
~onable
and leads to an acceptable design. However, the second-
order approximation may not always lead directly to a good design.
I'hrtunately, with MATLAB we have the possibility to construct an
interactive design facility that can assist us in the design process
by reducing the manual computational loads while providing easy
access to a host of classical and modern control tools.
Time[sec]
1vestep.m
:2; num=[K]; den=[l 3 2 K];
[0:0.01:20];
=I
.02*ones(length(t),l); . . . . . . . . . . . . .
. :.:: ... . . . . : . . . . . .
...... . . . :..:
,
...... .-*,<~ 2 2 :
.-$-.&..L->2 -*::..:
); ~ 9 : ~ n a
. € I ~ . ~
y y ~ y
. .. .. ....
I=1.38*ones(length(t),l); :3nG..kdAf
..... ........
!
i
:
,. ..!$;
.
.....
.
--. -
plot(t,y,t;l,t,lu,t,ll), grid
xlabel('Time [sec]'), ylabel('c(t)')
Figure 7.11 Engraving Machine Step Response for I( = 2.
Addison Wesley - Modern Control Systems Analysis and Design Using Matlab, Bishop (2006).pdf
104 (!l~nl~l.rr
8. SLa.bilityin thc Ekc:clucr~cyDornaitl
8.2 Nyquist Plots
The Nyquist stability criterion is based on Cauchy's theorem, which
is concerned with mapping contours in the complex s-plane. Con-
sider the system in Figure 8.1. The closed-loop transfer function
and the characteristic equation is
All of the zeroesof F(s) must liein the left-hand s-plane for stability.
We choose a contour, l
'
,
, in the s-plane which encloses the entire
right-hand s-plane, and plot rpin the F(s)-plane and determine the
number of encirclements of the origin. Equivalently, we can plot rp
in the P(s)-plane and determine the number of encirclements of the
-1 point, where P(s)= F(s) - 1. The Nyquist stability criterion
can be stated as follows:
A feedback control system is stable if and only if, for
the contours rp,the number of counterclockwise encir-
clements of the (-1,O) point is equal to the number of
poles of P(s)with positive real parts (see MCS, p. 362).
The plot of rp is the Nyquist plot. It is generally more difficult to
Controller
L
-
1
Figure 8.1 Single-Loop Feedback Control System.
N.2. Nyquist Plots 105
generate the Nyquist plot manually than the Bode diagram. How-
vver, we can use MATLAB to generate the Nyquist plot rather easily.
The Nyquist plot is generated with the nyquist function, as
~hown
in Figure 8.2. When nyquist is used without left-hand argu-
ments, the Nyquist plot is automatically generated; otherwise, you
must use the plot function to generate the plot using the vectors re
and im.
One cautionary remark regarding Nyquist plots: Some time in
lhe course of using the nyquist function you may find that your
Nyquist plot looks strange or that some information appears to be
missing. It may be necessary in these cases to use the axis func-
tion to override the automatic scaling and use the nyquist function
with left-hand arguments in conjunction with the plot function. In
this way you can focus in on the -1 point region for your stability
analysis, as illustrated in Figure 8.3.
, ,Real Axis
Figure 8.2 The nyquist Function.
106 Chaptar 8. Stability in the frequency Domain
0.1
n.ns ....................................
:.....
%axis([-1.O,.l ,-0.1 ,0.1I);
%plot(re,im),grid
Figure 8.3 The nyquist Function with Manual Scaling.
,b
Up to this point we have been consideringabsolute stability only.,'/
In other words, our concern has been whether a system is stable
not. However, relative stability measures of gain and phase
can be determined from both the Nyquist plot and the Bode dia- *
gram. The gain margin is a measure of how much the system gain j
would have to be increased for the GH(jw)locus to pass through
the (-1,O) point, thus resulting in an unstable system. The phase
margin is a measure of the additional phase lag required before the
system becomes unstable. Gain and phase margins can be deter-
mined from both the Nyquist plot and the Bode diagram.
Consider the system shown in Figure 8.4. Relative stability can
h i
Figure 8.4 A Closed-Loop Control System Example for Nvnni-t
and Bode with Relative Stability.
8.2. Nyquist Plots 107
Figure 8.5 The margin Function.
be determined from the Bode diagram using the margin function.
The marginfunction is invoked in conjunction with the bodefunc-
tion to compute the gain and phase margins. The margin function
is shown in Figure 8.5. If the margin function is invoked without
left-hand arguments, the Bode diagram is automatically generated
with the gain and phase margins labeled on the diagram. This is
illustrated in Figure 8.6 for the system that is shown in Figure 8.4.
The script to generate the Nyquist plot for the system in Fig-
ure 8.4 is shown in Figure 8.7. In this case, the number of poles of
GH(s)with positive real parts is zero and the number of counter-
clockwise encirclements of -1 is zero; hence the closed-loop system
is stable. We can also determine the gain and phase margins, as
indicated in Figure 8.7.
108 CJ~q>l,c:r.
8. Stability in the frequency Domain
* - ~
Frequency (radlsec)
I
1
0
-
1 1
w 1
0
'
Frequency (radlsec)
Figure 8.6 The Bode Diagram for the System in Figure 8.4 with
Gain and Phase Margins.
8.2. Nyquist Plots
GainMargin =3.017 Phase Margin=49.41
1.51 I
% Plot Nyquist and compute Gain and Phase
% Margins for GH(s) = 0 . 5 / ~ ~ 3 + 2 ~ ~ 2 + s + 0 . 0 5
I
,"
[rnag,phase,w]=bode(num,denf
[Gm,Pm,Wcg,Wcp]=margin(mag,phase,w);
%
nyquist(nurn,den)
Ci~~&":m~~Psc:
.::.:,
' Phase Margin = ',numZstr(Pm)]) . . . . . . . . . . . . . . .
':m~~~ns.~.prcat.::::.ii:i:i:;:
i;
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . .
Figure 8.7 The Nyquist Plot for the System in Figure 8.4 with
Gain and Phase Margins.
110 Ch&pl,ar8. Stability in the frequency Domain 8.4. Examples 111
8
.
3 Nichols Charts
Another frequency-domain plot that can be used in the design an
is automatically generated, otherwise you must use nichols in con-
junction with the plot function. A Nichols chart grid is drawn on
the existing plot with the ngrid function.
nichols but, unless you desire a Bode plot with gain and pha
Phase (deg)
axis([-210,0,-24,361);
nichols(num,den,w);
Figure 8.9 Nichols Chart for Eq. (8.1).
Nichols chart, shown in Figure 8.9, is for the system
1
G(jw) =
j w ( j u +1)(0.2jw+1)' (8.1)
8.4 Examples
EXAMPLE 8.1 Liquid Level Control System
Consider a liquid level control system described by the block diagram
Figure 8.8 The nichols Function. shown in Figure 8.10 (see MCS, pp. 387-388). Notice that this
112 Chapter 8. Stability in the Fkequency Domain 113
Actuator Tank Substituting Eq. (8.3) into Eq. (8.2) we have
31.5(0.0743s2- 0.4460s +0.8920)
( S +1)(30s+I)(: +$ +1)(O1O743s2
+0.4460s +0.8920)
Now we can build a script to investigate the relative stability of the
nystem using the Bode diagram. Our goal is to have a phase margin
ol 30 degrees. The associated script is shown in Figure 8.12. To
make the script interactive, we let the gain K (now set at K = 31.5)
be variable and defined outside the script at the command level.
Figure 8.10 Liquid Level Control System.
'I'hen we set K and run the script to check the phase margin and
iterate if necessary. The final selected gain is I< = 16. Remember
lhat we have utilized a second-order Pad6 approximation of the time
system has a time delay. The loop transfer function is given by delay in our analysis.
EXAMPLE 8
.
2 Remote Controlled Battlefield Vehicle
(S +1)(30s+I)($ + +1)
Sincewe want to use MATLABin our analysis, we need to ch Consider the speed control system for a remotely controlled battle-
Eq. (8.2)in such a way that GH(s)has a transfer function form w field vehicle shown in Figure 8.13 (see MCS, pp. 392-402). The de-
polynomials in the numerator and denominator. To do this sign objective is to achieve good control with low steady-state error
make an approximation to e-aT with the pade function. The pade and low overshoot to a step command. We will build a script to allow
function is shown in Figure 8.11. For example, suppose our ti us to perform many design iterations quickly and efficiently. First,
delay is T = 1 second and we want a second-order approximati let's investigate the steady-state error specification. The steady-
n = 2. Then, using the pade function we find that state error, e,,, to a unit step command is
1
e-' NN
0.0743s2 -0.4460s +0.8920
ess = 1 +K / 2 . (8.4)
0.0743s2+0.44609 +0.8920'
The effect of the gain K on the steady-state error is clear from
Orderof approximation
Eq. (8.4). If K = 20, the error is 9% of the input magnitude. If
I< = 10, the error is 17% of the input magnitude, and so on.
Now we can investigate the overshoot specification in the fre-
quency domain. Suppose we demand that the percent overshoot be
less than 50%. Solving
P.O. % 100exp-c
.
1
- 5 50
( 2 0.215.
Figure 8.11 The pade Function. Referring to Figure 7.7 (or MCS, p.316) we find that M
,
, 5 2.45.
Chapter 8. Stability in the frequency Domain
50
8
0
.
E
J -50
0 -loo
-150
10-3 10-1 100 1
0
1
Frequency (raws=)
Frequency(raws=)
% Liquid Control System Analysis
num=K*[0.0743 -0.4460 0.89201; dl-[I I]; d2=[30 I];
d3=[1/9 1/3 11; d4=[ 0.0743 0.4460 0.89201;
den=conv(dl ,conv(d2,conv(d3,d4)));
%
w=Iogspace(-2,1,400);
[mag,phase,w]=bode(num,d
Figure 8
.
1
2 Bode Diagram for the Liquid Level Control System.
115
Figure 8.13 Battlefield Vehicle Speed Control System.
We must keep in mind that the information in Figure 7.7 is for
ond-order systems only and can be used here only as a guideline.
now computethe closed-loop Bode diagram and check the values
f M . Any gain K for which M,, < 2.45 may be a valid gain for
our design, but we will have to investigate further to include step
responses to check the actual overshoot. The script in Figure 8.14
aids us in this task. In keeping with the spirit of the design steps in
MCS, pp. 392-402, we investigate further the gains K = 20,10, and
.44 (even though M
,
, > 2.45 for K = 20 ). We can plot the step
esponses to quantify the overshoot, as shown in Figure 8.15.
Alternately, we could have used a Nichols chart to aid the design
process. This is shown in Figure 8.16.
The results of the analysis are summarized in Table 8.1 for K =
20,10, and 4.44. Suppose we choose K = 10 as our design gain.
'I'hen we obtain the Nyquist plot and check relative stability. This
is shown in Figure 8.17. The gain margin is GM = 49.56 and the
phase margin is PM = 26.11'.
Table 8.1 Actual Response for Selected Gains.
-
K 4.44 10 20
Percent overshoot 5% 30% 50%
Settling time 3.5 5 6
Peak time 1.4 1.0 0.7
e,, 31% 17% 9%
116 Chapter 8. Stability in the Frequency Domain X.4. EXILNIP~~R 117
1.6
1.4
1.2
1
s 0.8
U
0.6
0A
0.2
O 0 1 2 3 4 5 6 7 8 9 1 0
frequency [rad/sec] time [sec]
batt1estep.m
[nums,dens]=series(numgc,dengc,numg,deng);
[num,den]=cloop(nums,dens);
[mag,phase,w]=bode(num,den,w);
if i==l
,magl=mag; phase1=phase; K=10; end
if i==2, mag2=mag; phaseZ=phase; K=4.44; end
if i-3, mag3=mag; phase3=phase; end
Figure 8.14 Remotely Controlled Battlefield Vehicle Closed-Loop
System Bode Diagram Script. Figure 8.15 Remotely Controlled Battlefield Vehicle Step Re-
sponse.
if i==3, y3=y; end
G
a
i
n Margin =49.56 Phase Margin = 26.11
5!
-5
-2 -1 0 1 2 3 4 5
Real Axis
% Remotely Controlled Battlefield Vehicle
% Nyquist plot for K=10
%
numgc=l 0*[l 21; dengc=[l 11;
numg=[l]; deng=[l 2 41;
[num,den]=series(numgc,dengc,numg,deng);
%
[mag,phase,w]=bode(num,den);
[Gm,Pm,Wcg,Wcp]=margin(mag,phase,w);
%
nyquist(num,den);
title(['Gain Margin = ',numZstr(Gm), ...
' Phase Margin = ',numZstr(Pm)])
Figure 8.17 Nyquist Chart for the Remotely Controlled Battlefield
Vehicle with I< = 10.
120 Chapter 8. Stability in the Frequency Domain
Notes
Chapter 9
State-Space Methods
f
E
9.1 Introduction
In the previous chapters we considered wntrol system design and
analysis in the frequency domain. We utilized the Laplace trans-
i form to transform the linear, constant coefficient differential equa-
tion model into an algebraic expression in terms of the complex
variable s. Then we operated on our system in input-output (or
transfer function) form
In this chapter we begin to look at wntrol system design and
analysis in the time domain. In contrast to the frequency-domain
approach, the time-domain method utilizes a state-space represen-
tation of the system model, given by
The vector z is the state of the system, A is the constant n x n
system matrix, B is the constant n x m input matrix, D is the
constant p x n output matrix and H is a constant p x m matrix.
The number of inputs, m, and the number of outputs, p, are taken
to be one since we are considering only single-input, single-output
problems. Therefore c and u are not bold variables.
122 Chapter 9. State-Space Methods
Figure 9.1 The State-Space Representation bode Function.
The main elements of the state-space representation in Eq. (9.1)
are the state vector r and the constant matrices (A,B,D , H ) .
Since the main computational unit in MATLAB is the matrix, the
state-space representation lends itself well to the MATLAB envi-
ronment. In fact, MATLAB covers so many aspects of statespace
methods that we will not be able to discuss them all here.
The new functions covered in this chapter are toss and ss2tf.
Most of the functions covered in the previous chapters also apply
here. For example, the the bode function can be utilized with
a state-space model, as shown in Figure 9.1. The same idea ap-
plies to series, parallel, feedback, cloop, printsys, minreal,
step, pzmap, impulse, him, rlocus, rlocfind, residue, bode,
nyquist, and nichols.
9.2 Model Relationships
Given a transfer function we can obtain an equivalent state-space
representation, and vice versa. MATLAB has two functions that
convert systems from transfer function to state space and back.
The function t o s s converts a transfer-function representation to a
state-space representation; the function ss2tf converts a state-space
representation to a transfer function. These functions are shown in
Figure 9.2.
r
1 Figure 9.2 Linear System Model Conversion.
For instance, consider the third-order system
I
We can obtain a state-space representation using the tf2ss function
as shown in Figure 9.3. The state-space representation of Eq. (9.2)
is given by Eq. (9.1) where
and
D = [ 2 8 6 1 , H=[O].
Notice that the printsys function lists the system matrices as a, b, c, d.
The conversion to our notation is as follows:
124 Chapter 9. State-Space Methods 1.3. Stahilif,y of ,S,y~It.rr~?i
ill t11(, 'I'irrre Domain 125
convort.m
9.3 Stability of Systems in the Time Domain
% Convert G(s) = (2sA2+8~+6)/(sA3+8sA2+16~+6)
% to a state-space representation
%
num=[2 8 6
1
; den-I1 8 16 61;
[A,B,D,H]=tf2ss(num,den);
printsys(A,B,D,H)
Suppose we have a system in state-space form as in Eq. (9.1). The
.itability of the system can be evaluated with the characteristzc equa-
Iton associated with the system matrix A. The characteristic equa-
t ion is
det(sI -A) = 0. (9.3)
The characteristic equation is a polynomial in s. If all of the roots
of the characteristic equation have negative real parts (i.e., Re(s,) <
O,Vi), then the system is stable.
When the system model is given in the state-space form we must
>>convert calculate the characteristic polynomial associated with the A ma-
trix. In this regard we have several options. We can calculate the
a = characteristic equation directly from Eq. (9.3)by manually comput-
x1 ~2 ~3 ing the determinant of ( s I - A). Then we can compute the roots
x l -8.00000 -16.00000 -6.00000 using the roots function to check for stability, or alternatively, we
~2 1.00000 0 0 can utilize the Routh-Hurwitz method to detect any unstable roots.
~3 0 1.00000 0 Unfortunately, the mmual computations can become lengthy, espe-
cially if the dimension of A is large. We would like to avoid this
b = manual computation if possible. As it turns out, MATLAB can
u1 assist in this endeavor.
x1 1.00000 The poly function described in Chapter 2 can be used to com-
~2 0 pute the characteristic equation associated with A. Recall that poly
~3 0 is used to form a polynomial from a vector of roots. It can also be
used to compute the characteristic equation of A, as illustrated in
C = Figure 9.4, wherein input matrix, A, is
x1 x2 x3
Y l 2.00000 8.00000 6.00000 -8 -16 -6
d =
u1
A = [ Y :I
0
and the associated characteristic polynomial is
Y l
s3 +8s' +16s +6.
Figure 9.3 Conversion of Eq. (9.2) to a State-Space Representa-
tion. If A is an n x n matrix, poly(A) is the characteristic equation
represented by the n +1element row vector whose elements are the
coefficients of the characteristic equation.
Chapter 9. State-Space Method2
*A=[-8 -1 6 -6;l0 0;O 1 01;
>>p=poly(A) Characteristicpolynomial
I
Figure 9.4 Computing the Characteristic Equation of A with the
poly Function.
EXAMPLE 9.1 Automatic Test System
The state-space representation for the automatic test system (see
MCS, pp. 462-465) is
where
1
Our design specifications are (i) step response with a settling time
less than two seconds, and (ii) overshoot less than 4%. We assume
that the state variables are available for feedback so that the control
9.3. Stability of Sy.rlcmx in the Time Domain 127
is given by
We must select the gains K,K1,Kz and K3 to meet the performance
specifications. Using the design approximation
4
T,M -< 2 and P.O. M 100exp-C * I ~
< 4,
Cwn
we find that
C > 0.72 and w, > 2.8.
This defines a region in the complex plane in which our dominant
roots must lie to have any chance of meeting the design specifica-
, tions. Substituting Eq. (9.5) into Eq. (9.4) yields
where A* is the revised A matrix. The characteristic equation asso-
ciated with Eq. (9.6) can be obtained by evaluating det(s1-A*) = 0.
i This results in
If we view KK3 as a parameter and let = 1, then we can write
Eq. (9.7) as follows:
We place the zeros at s = -4 f 2j in order to pull the locus to
the left in the s-plane. Thus our desired numerator polynomial is
sa +8s +20. Comparing corresponding coefficients leads to
K3 +Kz 1
= 8 and -= 20.
K3 1(3
Therefore Kz = 0.35 and K3 = 0.05. We can now plot a root
locus with KK? as the parameter, as shown in Figure 9.5. The
128 Chapter 9. State-Space Method8 9.4. 'I>;III(!
I~C-SI)IIII;+V 129
Figure 9.6 Step Response for the Automatic Test System.
characteristic equation, Eq. (9.7), is
s2+8s +20
+ 1(1c3s(s +l)(s+5)
= 0.
-10 -8 -6 -4 -2 0
Real Axis The selected gain, KK3 = 12, lies in the ~erformanceregion, as
shown in Figure 9.5. The rlocfind function is used to determine
the value of I(K3 at the selected point. The final gains are
a~tolocus.m
Ii' = 240.00
K, = 1.00
% Root ~OCUS
script for the Automatic Test System
% including performance specs regions
K2 = 0.35
num=[l 8 201; den=[l 6 5 01;
K3 = 0.05
cig; rlocus(num,den); hold on The controller design results in a settling time of about 1.8 seconds
% and an overshoot of 3%, as shown in Figure 9.6.
zeta=0.72; wn=2.8;
x=[-1 0:O.l :-zeta*wn]; y=-(sqrt(1 -zetaA2)/zeta)*x;
xc=[-1 0:O.l :-zeta*wn];c=sqrt(wnA2-xc.A2);
plot(~,y,':',x,-y,':',xc,c,':',xc,-c,':')
9.4 Time Response
The time response of the system in Eq. (9.1) is given by the solution
to the vector differential equation
Figure 9.5 Root Locus for the Automatic Test System. t
z(t)= exp(At)z(O) +1exp[A(t - r)]Bu(r)dr. (9.8)
130 Chapter 9. State-Space Methods
The matrix exponential function in Eq. (9.8) is the state transition
matrix, q5(t), where
+(t) = exp(At).
We can use the function expm to compute the transition matrix for
a given delta time, as illustrated in Figure 9.7. The expm(A) fun^
tion computes the matrix exponential whereas the exp(A) function
returns e0*, for each of the elements a,, E A.
b The time response of the system in Eq. (9.1) can be obtained
by using the lsim function. The lsim function can accept as input
nonzero initial conditions as well as an input function. This is il-
lustrated in Figure 9.8 for the RLC network (see MCS, Chapter 9)
described by the state-space representation
0 -2
A = [, -3] , B = [:I , D = [ 1 01 ,and H=O.
The initial conditions are xl(0) = xz(0) = 1and the input u(t) = 0.
If we can compare the results obtained by the lsim function and by
multiplying the initial condition state vector by the state transition
matrix, we find exactly the identical results. At t = 0.2 the state
transition matrix is given in Figure 9.7. The state at t = 0.2 is
predicted by the state transition methods to be
0 9671 -0.2968 0.6703
( )t=o.a = [0:1484 0.5219 ] ( )t=o = (0.6703 )'
The state at t = 0.2 is also predicted with the lsim function to be
xl(O.2) =~ ~ ( 0 . 2 )
= 0.6703.
Figure 9.7 Computing the State Transition Matrix for a Given
n . 1 ~ . m
>>A=[O-2; 1 -31; dt=0.2; Phi=expm(A*dt)
Phi =
0.9671 -0.2968
0.1484 0.5219
9.4. Time Response 131
0:1 0:2 0:3 0:4 0:5 0:6 0
1
7 0:8 0:9
time [sec]
01
I
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
time [secl
t=[0:0.01:1 I;
subplot(21 I), plot(t,x(:,l))
xlabel('time [sec]'), ylabel('x1')
subplot(212), plot(t,x(:,2))
xlabel('tirne rsecl'), vlabel('x2')
Figure 9.8 Computing the Time Response for Nonzero Initial Con-
ditions and Zero Input.
Chapter 9. State-Space Methc
Notes
Chapter 10
I Control System Design
i
10.1 Introduction
It is often possible to achieve stability and meet all the control sys-
tem performance specifications by adjusting one or two parameters.
We introduced many examples in the previous chapters illustrating
design by adjusting a few parameters. However, in many cases it is
necessary to add a dynamic compensator into the system. Altering
a control system to meet relative stability and performance spec-
ifications is called compensation. We say that our compensators
are dynamic in the sense that the compensator is itself a system
described by a transfer function or state-space representation with
internal states. A compensator is shown in the control system in
Figure 10.1. The compensator in Figure 10.1 is a cascade or series
Spacecraft
rotatlonal motion
Compensator model
.
-
desired -
attitude
Figure 10.1 A Compensated Control System for Spacecraft Rota-
tional Motion.
131 Chapter 10. Control System Design
compensator since it is placed in the feedforward path. A com-
pensator placed in the feedback path is known as a feedback com-
pensator. Compensators can be placed in other paths (e.g., inner
feedback loops) in the control system as well.
The main topic of this chapter is compensation of feedback con-
trol systems. There are many approaches to compensation. We
will consider lead and lag compensators and present a design exam-
ple that uses both the root locus method and the Bode frequency-
domain method to design the compensators. One of the most com-
monly used compensators is the proportional plus derivative plus
integral (PID). The PID compensator is covered in Chapter 11.
10.2 Lead Compensation
Consider the series compensator
K(s +z)
Gc(s) = (10.1)
S S P
The selection of the variables K, z, and p is based on satisfying the
design performance specifications. Whenever
IzI < IPI
the compensator in Eq. (10.1) is a lead compensator. The pole-zero
diagram of the lead compensator is shown in Figure 10.2. We can
:
i
;
o
Figure 10.2 Pole-Zero Diagram of the Lead Compensator.
rewrite Eq. (10.1) as
where .
r = l/p, a = p/z and a > 1. The maximum value of the
phase lead occurs at a frequency w,, where
The maximum phase angle at w,,, is +
,
, where
a-1
sin 4
, = -
a + l
Consider, for example, the lead compensator
The associated Bode diagram is shown in Figure 10.3. The maxi-
mum value of the phase lead occurs at
W", = fi= fi.
The maximum phase lead is
where a = 10.
The phase-lead compensator is a differentiator type compen-
sator. This can be seen by considering the case when [pl >> 1
2
1
.
Then it follows that
K
Gc(s) % [;IS.
We can design lead compensators with frequency-domain design
techniques utilizing Bode diagrams as well as with root locus design
methods. The lead compensator increases the phase margin, thus
providing additional stability, and increases the system bandwidth
to provide speedier dynamic response.
Chapter 10. Control System Design 10.3. l J ~
( ~ O I I I ~ ~ V I I N A ~ ~ ~ ~ ~
-4-
Figure 10.4 Pole-Zero Diagram of the Lag Compensator.
Consider, for example, the lag compensator
O.l(s+10)
Gc(s)=
s + l .
The associated Bode diagram is shown in Figure 10.5.
We see that the lag compensator is an integration type compen-
Figure 10.3 Bode Diagram of the Lead Compensator. sator by considering lzl >> IpI. Then
1
0
.
3 Lag Compensators
K z
G,(s) K +-.S
Again consider the series compensator This has the same form as the widely used lag compensator
K(s +z )
Gc("= s + P . KI
Gc(s)= Kp+g.
Whenever This is known as a proportional plus integral (PI) compensator.
I P ~ < IzI The lag compensator is applicable when high steady-state ac-
curacy is required. Although it is ~ossible
to increase steady-state
the compensator Gc(s)is a lag compensator. The pole-zero diagram accuracy by simply increasing the system gain, this often leads to
of the lag compensator is shown in Figure 10.4. The lag compensator unacceptable transient response and sometimes instability. This
can also be written as in Eq. (10.2)where a < 1. The maximum problem is overcome with the addition of a lag compensator and
value of the phase lag occurs at properly chosen values of K,p, and z. The lag compensator de-
creases the system bandwidth thus suppressing high frequency noise
W, = fi= a. and slows down the transient response.
Figure 10.5 Bode Diagram of the Lag Compensator.
10.4 Example: Rotor Winder Control System
The rotor winder control system is shown in Figure 10.6 (see MCS, ;
pp. 542-545). The design objective is to achieve high steady-state
accuracy to a ramp input. The steady-state error to a unit ramp
I
$
Figure 10.6 Rotor Winder Control System.
Chapter 10. Control System Design
&I-/-- V Z P -" 1-10 ..,-
Frequency (radlsec)
10.4. I~xxnrrrl~lr~:
IlolJor.Wirrtlcr Control System
input, R(s)= l/s2,is
1
ess = -,
K"
where
Gc(s)
K, = lim -
--0 50 '
+
t
9-
-
*-
Of course, the performance specification of overshoot and settling
time must be considered as well as steady-state tracking error. In
all likelihood, a simple gain will not be satisfactory. So we will
consider active compensation utilizing lead and lag compensators
using both Bode diagrams and root locus plots. Our approach is to
develop a series of scripts to aid in the compensator designs.
.. - ,  .
Consider first a simple gain controller, b,(s), wnere
G,(s) = I(.
Then,
50
esa= -
K'
Clearly, the larger we make K , the smaller the steady-state error
e . However, we must consider the effects of increasik- '/-- IL-
. -. - ---.
Gds)
11g A 0 1 1 L11C
transient response. This is shown in Figure 10.7. When K = 500,
our steady-stateerror for a ramp is 10%but the overshoot is 70% and
. - --.
iider
-.
the settling time is around 8 seconds for a step input. We cone
this to be unacceptable performance and turn to compensation. 'l'he
two important compensator types that we consider are lead and lag
compensators.
First we try a lead compensator
K(s +z )
Gc(s)= ( s + p ) I
where lzl < lpl. The lead compensator will give us the capability
to improve the transient response. We will use a frequency domain
approach to design the lead compensator.
Suppose we desire a steady-state error of less than 10%to a ramp
input. Then we desire
K" = 10.
4
1
s(s+ 5)(s + 10) .
-C(s)
Chapter 10. Control Systenl l)e~j8
time [sec]
for i=1:4
[nums,densl=series(K(i),1,num
[n~m,denl=cloop(nums,dens);
[y,xI=step(
Ys(:,i)=y;
end
%
I
I
Figure 10.7 Transient Response for Simple Gain Controller.
In addit,ioll t,o bl~c:3bc:ady-state.specifications, suppose also that we
desire to mcet certain performance specifications:
(i) settling time T,5 3 seconds, and
(ii) percent overshoot for a step input 5 10%.
Solving the approximate formulas
r - 4
P.O. -100exp- "1 l-CZ - 10 and T, w -= 3
Cwn
/ for ( and w, yields
( = 0.5912 and w, = 2.2555.
I
1 The phase margin requirement becomes
I
C
,$p, w -= 60 degrees.
0.01
i
! The steps leading to the final design are as follows:
I 1. Obtain the uncompensated system Bode diagram with h
' =
1
I
500 and compute the phase margin.
2. Determine the amount of necessary phase lead.
3. Evaluate cu where sin 4, = 5.
4. Compute 10loga and find the frequency w, on the uncom-
pensated Bode diagram where the magnitude curve is equal to
-10 log cu .
5. In the neighborhood around w, on the uncompensated Bode,
draw a line through the 0-dB point at w, with slope equal to
the current slope plus 20 dB/dec. Locate the intersection of
the line with the uncompensated Bode to determine the lead
compensation zero location. Then calculate the lead compen-
sator pole location as p = cuz.
6. Draw the compensated Bode and check the phase margin. Re-
peat any steps if necessary.
142 Chapter 10. ConLrol Syslern 1)esign
7. Raise the gain to account for attenuation (l/a).
8. Verify the final design with simulation using step functions,
and repeat any steps if necessary.
We utilize three scripts in the design. The design scripts are shown
in Figures 10.8, 10.9, and 10.10. The first script is for the uncom-
pensated Bode, the next is for the compensated Bode, and the final
script is for the step response analysis. The final lead compensator
design is
The settling time and overshoot specifications are satisfied, but
K, = 5, resulting in a 20% steady-state error to a ramp input. It is
possible to continue the design iteration and refine the compensator
somewhat, although it should be clear that the lead compensator
has added phase margin and improved the transient response as
anticipated.
To improve the steady-state errors we can consider the lag com-
pensator. The lag compensator has the form
where lp( < (21. We will use a root locus approach to design the
lag compensator, although it can be done using Bode as well. The
desired root location region of the dominant roots are specified by
( = 0.5912 and w, = 2.2555.
The steps in the design are as follows:
1. Obtain the root locus of the uncompensated system.
2. Locate suitable root locations on the uncompensated system
which lie in the region defined by ( = 0.5912 and w, = 2.2555.
3. Calculate the loop gain at the desired root location and the
system error constant, Icvuncomp.
frequency [rad/secl
I
.- ---. - - -.
[num,den]=series(K,l ,nGmg,deng); camput. phsu
_ I
margin.
w=loaspace(-l,2,200); I I
semilogx(w,20*logl O(mag),w,M), grid
xlabel('frequency [rad/secI1), ylabel('mag [dB]')
I- I
Figure 10.8 Lead Compensator: Uncompensated Bode.
nurngc=K*[ 1 3.51; dengc
w=logspace(-1,2,200);
[rnag,phase,w]=bode(nurn,den,w);
[Grn,Prn,Wcg,Wcp]=rnargin(rnag,phase,w);
X I : Iloi.o~.Wirltl(,r (,'otllrol System 145
Time (sec)
Figure 10.10 Lead Compensator: Step Response.
10.4. Example: Rotor Winder Control System
147
146 Chapter 10. Control System Des
4. Compute a = K"'mp where KVcomp
= 10.
K"""C,,
5. With a known, determine suitable locations of the comp
sator pole and zero so that the compensated root locus sti
passes through desired location.
6. Verify with simulation and repeat any steps if necessary.
The design methodology is shown in Figures 10.11, 10.12, and 10.13
Using the rlocfind function, we can compute the gain K associate
with the roots of our choice on the uncompensated root locus tha
lie in the performance region. We then compute cu to ensure tha
we achieve the desired h
'
"
. We place the lag compensator pole an
zero in order not to impact the uncompensated root locus. In Fi
ure 10.12, the lag compensator pole and zero are very near the origi
at z = -0.1 and p = -0.01.
The settling time and overshoot specificationsare nearly satisfi
and K, = 10 as desired. It is possible to continue the design iterat'
and refine the compensator somewhat, although it should be cl
that the lag compensator has improved the steady-state errors to
ramp input relative to the lead compensator design. The final
compensator design is
100(s +0.1)
Gc(s) =
(s +0.01) .
The resulting performance is summarized in Table 10.1.
Table 10.1 Compensator Design Results.
Controller
Step overshoot
Settling time (sec)
Steady-state error for ramp
Ic,
Gain, I
t
'
70%
8
10%
10
.
Lead
8%
1
20%
5
Lag
13%
4
10%
10
148 Chapter 10. Control System Der
-15 -10 -5 0
Real Axis
numg=[l 1; deng=[l 15 5 0 01;
numgc=[l 0.11; dengc=[l 0.011;
[num,den]=series(numgc,dengc,numg,deng);
axis([-1 5,1,-10,101);
clg; rlocus(num,den); hold on
%
zeta=0.5912; wn=2.2555;
x=[-l0:O. 1:-zeta*wn]; y=-(sqrt(1 -zetaAZ)/zeta)*x;
xc=[-l0:O.l :-zeta*wn];c=sqrt(wnAZ-xc.AZ);
plot(x,y,':',x,-y,':',xc,c,':',xc,-c,':')
Figure 10.12 Lag Compensator: Compensated Root Locus.
Example: Rotor Winder Control System 149
1.2, ! ! I I
Chapter 10. Control System Dc,sixi~
Notes I
Chapter 11
Robust Control Systems
11.1 Introduction
Designing a highly accurate control system in the presence of plant
uncertainty is a classical design problem. In the previous chapters,
we have generally assumed that the plant parameters are well known
and designed our control system accordingly. In practice, the plant
parameters arenever precisely known and may vary slowlyover time.
It is desirable to design a control system that performs adequately
over a range of plant parameters. A control system is robust when
it maintains a satisfactory level of stability and performance over a
range of plant parameters and disturbances.
In this chapter, we begin to investigaterobust control systems. In
particular we consider the commonly used proportional plus deriva-
Figure 1
1
.
1Feedback Control System with Reference and Distur-
bance Inputs and a Prefilter.
Addison Wesley - Modern Control Systems Analysis and Design Using Matlab, Bishop (2006).pdf
(!l~ilpl,(~
11. Robust, (:on/,rol ,Syshr*tt~ti
11.2. Robust PID Controlled Systems
follows:
To meet the overshoot performance requirements for a step input we
will utilize a cascade gain I( that will be chosen by iterative methods
using the step function. This is illustrated in Figure 11.3. The step
response corresponding to I( = 5 has an acceptable overshoot of
2%. With the addition of the gain K = 5, the final PID controller
is
We did not used the prefilter as is done in the design Example 11.5 in
MCS, pp. 594-595. Instead we increased the system gain to obtain
satisfactory transient response. Now we can consider the question
of robustness to changes in the plant parameter co.
Our investigation into the robustness of our design consists of a
step response analysis using the PID controller given in Eq. (11.2)
for a range of plant parameter variations of Q E [0.1,10]. The results
are displayed in Figure 11.4. The script is written to compute the
step response for a given Q. It might be a good idea to place the
input of Q at the command prompt level to make the script more
interactive.
The simulation results indicate that the PID design is robust
with respect to changes in Q. The differences in the step responses
for Q E [0.1,10] are barely discernible on the plot. If the results
showed otherwise, it would be possible to iterate on the design until
an acceptable performance was achieved.
There exist various control design methods that incorporate ro-
bustness directly into the design process, but their presentation
here is outside the scope of this text. The interactive capability of
MATLABallows us to check our robustness by simulation, although
this is clearly not the most desirable approach to design.
156 (:llapter 11. Robust Control Systcrrra 11.2. Robust PID ~oitrolled
Systems 157
0.05 0.1 0.15 0.2 0.25 0.3
Time (sec)
. .
root locus.
n gain to reduce ovanhwt.
- -
1
Time (sec)
Figure 11.4 Robust PID Controller Analysis with Variations in Q.
Figure 11.3 Step Response for the PID Temperature Controller.
Chapter 11. Robust Control System
Notes 1
axis Controls the manual axis
scaling on plots; 105
I bode Computes a Bode frequency
response 92-93, 107, 110,
122
clear Removes variables and
functions from memory; 6, 9
clg Clears plots from the graph
window; 16
cloop Computes the closed-loop
system with unity feedback; 26,
37-40, 122
conv Multiplies two polynomi-
als via convolution; 26, 31-32,
152
end Terminates a for function;
75
expm Computes the matrix ex-
ponential function; 130
feedback Computes the feed-
back interconnection of two sys-
tems; 26, 37-40, 49, 122
for Ftepeats a group of state-
ments a specificnumber of times;
71, 75
format Controls the output for-
mat; 9
grid Draws grid lines on. the
current plot; 17
help Invokes the help facility;
22
impulse Computes the unit im-
pulse response of a system; 61,
63, 122
loglog Generates an x-y plot
using log-log scales; 17-18, 20
logspace Generates a logarith-
mically spaced frequency vec-
tor for frequency response anal-
ysis; 92-95
lsim Computes the time response
of a system to an arbitrary in-
put and initial conditions; 61,
66, 68, 122, 130
margin Computes the gain mar-
gin, phase margin, and associ-
ated crossoverfrequenciesfrom
frequency response data; 103,
107-110
minreal Transfer function pole-
zero cancellation; 26, 44, 122
ngrid Draws grid lines on a
Nichols chart; 103, 110
nichols Computes a Nichols fre-
quency response plot; 103,110,
122
nyquist Computes a Nyquist
frequency response plot; 103,
105-106, 122
pade Computes an n-th order
Pad6 approximation to a time
delay; 103, 112
parallel Computes a parallel
system connection; 26, 36-37,
122
plot Generates a linear x-y plot;
16-19, 45, 93, 105, 110
poly Returns the characteris-
tic equation when the input is
a matrix and returns a polyno-
mial when the input is a vec-
tor containing the roots of the
polynomial; 26, 31, 125-126
polyval Polynomialevaluation;
26, 32
printsys Prints state-spaceand
transfer function representations
of linear systems in a readable
form; 26, 34, 39, 40, 44, 46,
122-124
pzmap Plots the pole-zero map
of a linear system; 26, 32, 122
residue Computes the residues,
poles, and direct terms of a partl& 1
fraction expansion; 82, 84-86,
88, 122
rlocus Computes the root lo-
cus of a linear system; 82-83,
122
rlocfind Finds the gain asso-
ciated with a given set of roots
on a root locus plot; 82-83,122,
129, 146, 153
roots Computes the roots of a
polynomial; 26, 31, 72-73, 125
roots1 Sameas the roots func-
tion, but gives more accurate
answers when there are repeated
roots; 26, 31, 33
shg Shows the graph window;
16
series Computes a series sys-
tem connection; 26, 35-38, 40,
122, 152
semilogx Generates an x-y plot
using semilog scales with the x-
axis loglo and the y-axis linear;
17-18, 20
semilogy Generates an x-y plot
using semilog scales with the
y-axis log,, and the x-axis lin-
ear; 17-18, 20
ss2tf Converts a state-space sys-
tem representation to a trans-
fer function representation; 122-
123
step Computes the unit step
response of a system; 26, 45-
46, 63, 87, 122, 155
subplot Subdivides the graph
display into sub-windows; 17,
20
tfss Converts a transfer func-
tion system representation to a
state-spacerepresentation; 122-
123
title Puts a title on the cur-
rent plot; 17
who Lists the variables in the
workspace; 7, 9-10
whos Lists the variables in the
workspace including their size
and type; 7, 9
xlabel Puts an x-axis label on
the current plot; 17
ylabel Puts a y-axis label on
the current plot; 17

More Related Content

PDF
Malab tutorial
PDF
EE6711 Power System Simulation Lab manual
PPTX
Mat lab workshop
PDF
Solution Manual for Engineers Guide to MATLAB, 3/E 3rd Edition
PDF
An Introduction to MATLAB with Worked Examples
PPT
4413-lecture-09 Introduction Matlab lecture .ppt
PDF
Summer training matlab
PPTX
Lines and planes in space
Malab tutorial
EE6711 Power System Simulation Lab manual
Mat lab workshop
Solution Manual for Engineers Guide to MATLAB, 3/E 3rd Edition
An Introduction to MATLAB with Worked Examples
4413-lecture-09 Introduction Matlab lecture .ppt
Summer training matlab
Lines and planes in space

Similar to Addison Wesley - Modern Control Systems Analysis and Design Using Matlab, Bishop (2006).pdf (20)

PPTX
PPTX
PDF
++Matlab 14 sesiones
PPTX
Summer training matlab
PDF
Matlab for beginners, Introduction, signal processing
PPT
MatlabIntro (1).ppt
PPTX
BEN520 FUNDAMENTALS OF BOENGINEERING II-4 week-lecture 4.pptx
PPTX
Matlab - Introduction and Basics
PPTX
Simulation lab
DOCX
Introduction to matlab
PPSX
matlab-130408153714-phpapp02_lab123.ppsx
PPT
MATLAB_CIS601-03.ppt
PPT
Matlab Overviiew
PDF
Control system Lab record
PPTX
1. Ch_1 SL_1_Intro to Matlab.pptx
PPSX
Matlab basic and image
PDF
Matlab Primer Eighth Edition Timothy A Davis
PPTX
Introduction_to_Matlab_lecture.pptx
PDF
Introduction to MATLAB
PDF
MATLAB Programming
++Matlab 14 sesiones
Summer training matlab
Matlab for beginners, Introduction, signal processing
MatlabIntro (1).ppt
BEN520 FUNDAMENTALS OF BOENGINEERING II-4 week-lecture 4.pptx
Matlab - Introduction and Basics
Simulation lab
Introduction to matlab
matlab-130408153714-phpapp02_lab123.ppsx
MATLAB_CIS601-03.ppt
Matlab Overviiew
Control system Lab record
1. Ch_1 SL_1_Intro to Matlab.pptx
Matlab basic and image
Matlab Primer Eighth Edition Timothy A Davis
Introduction_to_Matlab_lecture.pptx
Introduction to MATLAB
MATLAB Programming
Ad

More from Gollapalli Sreenivasulu (20)

PDF
Fundamentals Of Computer Organization And Architecture.pdf
PDF
(eBook - CRC Press) - Electrical Energy Systems (2000).pdf
PDF
Kluwer.Academic.Publishers.HVDC.and.FACTS.Controllers.Applications.of.Static....
PDF
Crc - Electrical Power Systems.pdf
PDF
Electrical Power Systems Design and Analysis - The Transmission Subsystem - M...
PDF
electrical-power.pdf
PDF
reference book.pdf
PDF
transmission and distribution.pdf
PDF
sectors of electricity use.pdf
PDF
InTech-Integration_of_hybrid_distributed_generation_units_in_power_grid.pdf
PDF
High_Voltage_Engineering_2E.pdf
PDF
power systems.pdf
PDF
Electrical Engineering - Power System Analysis Short-Circuit Load Flow and Ha...
PDF
Electric Power Systems(Schaum).pdf
PDF
Grigsby, L. - Power Systems (CRC Press, 2007).pdf
PDF
Guide_to_Electric_Power_Generation.pdf
PDF
Electric Power Systems - Analysis and Control - F. Saccomanno (Wiley-IEEE, 20...
PDF
PDF
Mohan N.(2003) Power Electronics and Drives(257s) buono.pdf
PDF
Power Electronics Handbook Second Edition Devices Circuits and Applications.pdf
Fundamentals Of Computer Organization And Architecture.pdf
(eBook - CRC Press) - Electrical Energy Systems (2000).pdf
Kluwer.Academic.Publishers.HVDC.and.FACTS.Controllers.Applications.of.Static....
Crc - Electrical Power Systems.pdf
Electrical Power Systems Design and Analysis - The Transmission Subsystem - M...
electrical-power.pdf
reference book.pdf
transmission and distribution.pdf
sectors of electricity use.pdf
InTech-Integration_of_hybrid_distributed_generation_units_in_power_grid.pdf
High_Voltage_Engineering_2E.pdf
power systems.pdf
Electrical Engineering - Power System Analysis Short-Circuit Load Flow and Ha...
Electric Power Systems(Schaum).pdf
Grigsby, L. - Power Systems (CRC Press, 2007).pdf
Guide_to_Electric_Power_Generation.pdf
Electric Power Systems - Analysis and Control - F. Saccomanno (Wiley-IEEE, 20...
Mohan N.(2003) Power Electronics and Drives(257s) buono.pdf
Power Electronics Handbook Second Edition Devices Circuits and Applications.pdf
Ad

Recently uploaded (20)

PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
OOP with Java - Java Introduction (Basics)
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
Lecture Notes Electrical Wiring System Components
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
Construction Project Organization Group 2.pptx
PDF
Digital Logic Computer Design lecture notes
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
additive manufacturing of ss316l using mig welding
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPT
Mechanical Engineering MATERIALS Selection
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
DOCX
573137875-Attendance-Management-System-original
Automation-in-Manufacturing-Chapter-Introduction.pdf
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
OOP with Java - Java Introduction (Basics)
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
CYBER-CRIMES AND SECURITY A guide to understanding
Lecture Notes Electrical Wiring System Components
Operating System & Kernel Study Guide-1 - converted.pdf
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Construction Project Organization Group 2.pptx
Digital Logic Computer Design lecture notes
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
additive manufacturing of ss316l using mig welding
CH1 Production IntroductoryConcepts.pptx
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Mechanical Engineering MATERIALS Selection
UNIT-1 - COAL BASED THERMAL POWER PLANTS
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
573137875-Attendance-Management-System-original

Addison Wesley - Modern Control Systems Analysis and Design Using Matlab, Bishop (2006).pdf

  • 1. 1 and Design Using MATLABB Robert H. Bishop The University of Texas at Austin ADDISON-WESLEY PUBLISHING COMPANY Reading, Massachusetts Menlo Park, C a l i i i a New York Don Mills, Ontario Wokingharn, England Amsterdam Bonn Sydney Singapore Tokyo Madrid San Juan Milan Paris
  • 2. Preface R.H.B. Austin. Texas Contents Preface v 1 MATLAB Basics 1 . . . . . . . . . . . . . . . . . . . . . . . 1.1 Introduction 1 . . . . . . . . . . . . . . . . 1.2 Statements and Variables 2 . . . . . . . . . . . . . . . . . . . . . . . . . 1.3 Matrices 10 . . . . . . . . . . . . . . . . . . . . . . . . . 1.4 Graphics 16 . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5 Scripts 21 2 Mathematical Modeling of Systems 25 . . . . . . . . . . . . . . . . . . . . . . . 2.1 Introduction 25 . . . . . . . . . . . . . . 2.2 Spring-Mass-DamperSystem 26 . . . . . . . . . . . . . . . . . . . 2.3 Transfer Functions 30 . . . . . . . . . . . . . . . . . 2.4 Block Diagram Models 35 . . . . . . . . . . . . . . . . . . . . . 2.5 Design Example 45 3 Control System Characteristics 49 . . . . . . . . . . . . . . . . . . . . . . . 3.1 Introduction 49 . . . . . . . . . . . . . . . 3.2 Speed Tachometer System 50 . . . . . . . . . . . 3.3 English Channel Boring Machines 54 4 Control System Performance 61 . . . . . . . . . . . . . . . . . . . . . . . 4.1 Introduction 61 . . . . . . . . . . . . . . 4.2 Time-Domain Specifications 61 . . . . . . . . . . . . 4.3 Simplification of Linear Systems 68 5 Control System Stability 71 . . . . . . . . . . . . . . . . . . . . . . . 5.1 Introduction 71 vii
  • 3. ... VIII Contents 5.2 Routh-Hurwitz Stability . . . . . . . . . . . . . . . . 72 5.3 Example: Tracked Vehicle Turning Control . . . . . . 76 6 Root Locus Method 81 6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . 81 6.2 Obtaining a Root Locus Plot . . . . . . . . . . . . . 82 6.3 Sensitivity and the Root Locus . . . . . . . . . . . . 88 7 Frequency Response Methods 91 7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . 91 7.2 Bode Diagram . . . . . . . . . . . . . . . . . . . . . . 92 7.3 Specifications in the Frequency Domain . . . . . . . . 95 7.4 Example: Engraving Machine System . . . . . . . . . 98 8 Stability in the Frequency Domain 103 8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . 103 8.2 Nyquist Plots . . . . . . . . . . . . . . . . . . . . . . 104 8.3 Nichols Charts . . . . . . . . . . . . . . . . . . . . . 110 8.4 Examples . . . . . . . . . . . . . . . . . . . . . . . . 111 9 State-Space Methods 121 9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . 121 9.2 Model Relationships . . . . . . . . . . . . . . . . . . 122 9.3 Stability of Systems in the Time Domain . . . . . . . 125 9.4 Time Response . . . . . . . . . . . . . . . . . . . . . 129 10 Control System Design 133 10.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . 133 10.2 Lead Compensation . . . . . . . . . . . . . . . . . . . 134 10.3 Lag Compensators . . . . . . . . . . . . . . . . . . . 136 10.4 Example: Rotor Winder Control System . . . . . . . 138 11 Robust Control Systems 151 11.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . 151 11.2 Robust PID Controlled Systems . . . . . . . . . . . . 152 Chapter 1 MATLAB Basics 1.1 Introduction MATLAB is an interactive program for scientific and engineering calculations. The MATLAB family of programs includes the base program plus a variety of toolboxes. The toolboxes are a collection of special files, called M-files, which extend the functionality of the base program. Together the base program plus the Control System Toolbox provide the capability to use MATLAB for control system design and analysis. In the remainder of this book, whenever we refer to MATLAB, you can interpret that as meaning the base program plus the Control System Toolbox. Most of the statements, functions, and commands are computer platform independent. Regardless of what particular computer sys- tem you use, your interaction with MATLAB is basically the same. This book concentrates on this computer platform independent in- teraction. A typical session will utilize a variety of objects that dlow you to interact with the program. These objects are s 1. statements and variables, 2. matrices, 3. graphics, and 4. scripts.
  • 4. 2 Chapter 1. MATLAB Basics MATLAB interprets and acts on input in the form of one or more of these objects. Our goal in this chapter is to introduce each of the four objects in preparation for our ultimate goal of using MATLAB for control system design and analysis. The manner in which MATLAB interacts with your computer system is computer platform dependent. Examples of computer de- pendent functions include installation, the file structure, generating hardcopies of the graphics, invoking and exiting a session, and mem- ory allocation. Questions related to platform dependent issues are not addressed here. This is not to imply that they are not impor- tant, but rather that there are better sources of information such as your Users Guide and your local resident expert. This book is not intended as a substitute for your Users Guide. Before proceeding, make sure that you can invoke a session and exit MATLAB .You need to be able to get to the command window and see the command prompt " >> ". To begin a session on a Macintosh you will probably double-click on the MATLAB program icon. On an IBM PC compatible you will probably type matlab at the DOS prompt. The remainder of this chapter is organized as follows. There are four sections corresponding to the four objects listed above. In the first section we present the basics of statements and variables. Fol- lowing that is the subject of matrices. The third section presents an introduction to graphics, and the chapter concludes with a discussion on the important topic of scripts and M-fles. 1.2 Statements and Variables Statements have the form shown in Figure 1.1. MATLAB uses the assignment so that equals ("=") implies the assignment of the ex- pression to the variable. The command prompt is two right arrows, " >> ". A typical statement is shown in Figure 1.2, wherein we are entering a 2 x 2 matrix to which we attach the variable name A. The statement is executed after the carriage return (or enter key) is pressed. The carriage return is not explicitly denoted in the remaining examples in this and subsequent chapters. command prompt / I )/variable=expression Figure 1.1 MATLAB Statement Form. The matrix A is automatically displayed after the statement is executed following the carriage return. If the statement is followed by a semicolon (;), the output matrix A is suppressed, as seen in I'igure 1.3. The assignment of the variable A has been carried out wen though the output is suppressed by the semicolon. It is often the case that your MATLAB sessions will include intermediate cal- culations for which the output is of little interest. You should use the semicolon whenever you have a need to reduce the amount of output. Output management has the added benefit of increasing the execution speed of the calculations, since displaying screen output takes time. The usual mathematical operators can be used in expressions. The common operators are shown in Table 1.1. The order of the arithmetic operations can be altered by using parentheses. The example in Figure 1.4 illustrates that MATLAB can be used in a "calculator" mode. When the variable name and "=" are omit- ted from an expression, the result is assigned to the generic variable ans. MATLAB has available most of the trigonometric and elemen- tary math functions of a common scientific calculator. The Users 2; 4 61 <ret> A = 1 2 carriage return 4 6 Figure 1.2 Example Statement: Matrix Input.
  • 5. Chapter 1. MATLAB Basics Figure 1.3 Using Semicolons to Suppress the Output. Guide has a complete list of available trigonometric and elementary math functions; the more common ones are summarized in Table 1.2. Variable names begin with a letter and are followed by any num- ber of letters and numbers (including underscores). Keep the name length to 19 characters since MATLAB remembers only the first 19 characters. It is a good practice to use variable names that describe the quantity they represent. For example, we might use the variable name vel to represent the quantity aircraft velocity. Generally, we do not use extremely long variable names even though they may be legal MATLAB names. Since MATLAB is case sensitive, the variables M and m are not the same variables. By case we mean upper and lower case. This is illuetrated in Figure 1.5. The variables M and m are recognized as different quantities. Table 1.1 Mathematical Operators. ans = 1.7971 + - * / A 1.2. Statements and Variables Figure 1.4 Calculator Mode. MATLAB has several predefined variables, including t ax$an6;)rhree examples are shown in Figure 1.6. for Not-a-Number and results from undefined operations. Inf rep- resents +co and pi represents a. The variable i = -is used to represent complex numbers. The variable j = f l can be used for Table 1.2 Common Mathematical Functions. Addition Subtraction Multiplication Division Power sin(X) cos(X) asin(X) acos(X) tan(X) atan(X) atan2(X,Y) ;ax) G ~ x ) imag(X) real(X) (@PX) log(X) loglO(X) (expp) Sine of the elements of X Cosine of the elements of X Arcsine of the elements of X Arccosine of the elements of X Tangent of the elements of X Ardangent of the elements of X Four quadrant arctangent of the real elements of X and Y Absolute value of the elements of X SquarerootofX Imaginary part of X Real part of X Complex conjugate of X Natural logarithm of the elements of X Logarithm base 10 of the elements of X Exponential of the elements of X
  • 6. Chapter 1. MATLAB Basics Figure 1.5 Variables Are Case Sensitive. cornplex arithmetic by those who prefer it over i. These predefined variables can be inadvertently overwritten. Of course, they can also be purposely overwritten in order to free up the variable name for other uses. For instance, one might want to use i as an integer and rcscrve j for complex arithmetic. Be safe and leave these predefined variables alone, as there are plenty of alternative names that can be used. Predefined variables can be reset to their default values by using clear name (e.g., clear pi). rr The matrix A and the variable ans, in Figures 1.3 and 1.4, are stored in the workspace. Variables in the workspace are automati- >>z=3+4*i z = 3.0000 + 4.0000i >>lnf ans = 00 >>O/O Warning: Divide by zero ans = NaN ~ i g u r e 1.6 Three Predefined Variables i, Inf, and Nan. >)who Your variables are: A M ans m z leaving 675516 bytes of memory free. Figure 1.7 Using the who Function to Display Variables. cally saved for later use in your session. The who function gives a list of the variables in the workspace, as shown in Figure 1.7. MATLAB has a host of built-in functions. You can refer to the Users Guide for a complete list. We will describe each function we e as the need arises. The whos function lists the variables in the workspace and gives ditional information regarding variable dimension, type, and mem- ry allocation. Figure 1.8 gives an example of the whos function. The memory allocation information given by the whos function can be interpreted as follows. Each element of the 2 x 2 matrix A - Figure 1.8 Using the whos Function to Display Variables. >>whos Name Size Total Complex A 2 b y 2 4 No M 1 b y 2 2 No ans 1 by 1 1 No m 1 b y 3 3 No z 1 by 1 2 Yes Grand total is (12 * 8) = 96 bytes, leaving 664912 bytes of memory free.
  • 7. Chapter I. MATLAB Basics 1.2. Statements and Variables >>who Your variables are: IM ans m z I leaving 663780 bytes of memory free. A Figure 1.9 Removing the Matrix A from the Workspace. I . .................................................. :pBd{*d#&kd p a i M .................................................... ................................... !.:.::.:.::.:.:.. ....................... ............... :.:.:.:.:.)):.:.:: ...................................................................................................... .: r a t o n ; pi ) 7 1 ......... ( I .format short e; pi I ans = 3.1416e+004 requires 8 bytes of memory for a total of 32 bytes, the 1x 1variable ans requires 8 bytes, and so forth. All the variables in the workspace are using a total of 96 bytes. The amount of remaining free memory depends upon the total memory available in the system. Computers with virtual memory will not display the remaining free memory. You can remove variables from the workspace with the clear function. Using the function clear, by itself, removes all items (vari- ables and functions) from the workspace; clear variables removes all variables from the workspace; clear name1 name 2 ... removes the variables namel, name2, and so forth. The procedure for re- moving the matrix A from the workspace is shown in Figure 1.9. A simple calculation shows that clearing the matrix A from memory freed up more than 32 bytes. In some cases, clearing a variable may not change the value of the displayed free memory at 811. The who function displays the amount of contiguous remaining free memory. So, depending upon the "location" of the variable in the workspace, clearing the variable may or may not increase the splayed amount of remaining free memory. The point is that your ailable free memory may be more than displayed with the who or All computations in MATLAB are performed in doubbecision. en output can be displayed in several formats.(~he rmat contains four digitmast the decimal point his can be chknged by using the format function .lo. Once a particular format has been speci- ed, it remains in effect until altered by a different format input. ??? Undefined function or variable Symbol in question ==> WHO ??? Undefined function or variable Symbol in question ==> Who Ti';aiire 1 1 1 F~~nrtinn Names r]ilsp sSensit,ive.
  • 8. 10 Chapter 1. MATLAB Basics Remember that the output format does not affect the MATLAB computations - all computations are in double precision. On the other hand, the number of digits displayed does not nec- essarily reflect the number of significant digits of the number. This is problem dependent, and only you can know the true accuracy of the numbers that you input and that MATLAB displays. Since MATLAB is case sensitive, the functions who and WHO are not the same functions. The function who is a built-in func- tion, so typing who lists the variables in the workspace. On the other hand, typing the uppercase WHO results in the error mes- sage shown in Figure 1.11. Case sensitivity applies to all functions. 1.3 Matrices k MATLAB is short for matrix laboratory. The Users Guide describes the program as a high-performance interactive software package de- signed to provide easy access to the LINPACK and EISPACK ma- trix software. Although we will not dwell on the matrix routines underlying our calculations, we will learn how to use the interactive capability to assist us in our control system design and analysis. We begin by introducing the basic concepts associated with manipulat- ing matrices and vectors. The basic computational unit is the matrix. Vectors and scalars can be viewed as special cases of matrices. A typical matrix expres- sion is enclosed in square brackets, [-I. The column elements are separated by blanks or commas and the rows are separated-hysemi- colons or carriage returns. Suppose we want to input the matrix A, One way to input A is shown in Figure 1.12. The input style in Figure 1.12 is not unique. Matrices can be input across multiple lines by using a carriage return following the semicolon or in place of the semicolon. This is useful for entering large matrices. Different combinations of spaces I .:J. Matrices , 11 Figure 1.12 Complex and Real Matrix Input with Automatic Di- I mension and Type Adjustment. and commas can be used to separate the columns, and different com- binations of semicolons and carriage returns can be used to separate the rows, as illustrated in Figure 1.12. No dimension statements or type statements are necessary when using matrices; memory is allocated automatically. Notice in the example in Figure 1.12 that the size of the matrix A is automatically adjusted when the input matrix is redefined. Also notice that the matrix elements can contain trigonometric and elementary math functions, as well as complex numbers. The important basic matrix operations are addition and sub- traction, multiplication, transpose, powers, and the so-called array operations, which are element-to-element operations. The mathe- matical operators given in Table 1.1 apply to matrices. We will not disc~ss~matrix division, but be aware that MATLAB has a left- and right-matrix division capability. Matrix operations require that the matrix dimensions be com- patible. For matrix addition and subtraction this means that the matrices must have the same dimensions. If A is an n x m matrix
  • 9. I2 Chapter 1. MATLAB Basics atid B is a p x r matrix, then A & B is permitted only if n = p and m = r. Matrix multiplication, given by A * B, is permitted only if m = p. Matrix-vector multiplication is a special case of matrix multiplication. Suppose 6 is a vector of length p. Multiplication of the vector b by the matrix A, where A is an n x m matrix, is allowed if m = p. Thus, y = A * b is the n x 1 vector solution of A * b. Examples of three basic matrix-vector operations are given in Figure 1.13. The matrix transpose is formed with the apostrophe (9. We can L" - - . - - - - - A , - -- use the matrix transpose and multiplication operation to create a vector inner product in the following manner. Suppose w and v are m x 1 vectors. Then the inner product (also known as the dot ans = 5 -4 15 9 ans = 16 50 ... 1>>A! T f I ." matrix trans~ose ans = 1 5 3 9 Figure 1.13 Three Basic Matrix Operations: Addition, Multiplica- tion, and Transpose. I)~o(l~rct.) is given by w' * v . The inner product of two vectors is a 1(3nlil,r. The outer product of two vectors can similarly be computed , w * v'. The outer product of two m x 1 vectors is an m x mv' m b i x of rank 1. Examples of inner and outer products are given 'I'he basic matrix operations can be modified for element-by- s1rl11c:ntoperations by preceding the operator with a period. The oilified matrix operations are known as array operations. The com- ay operators are given in Table 1.3. M&rix addition m d subtraction are already element-by-element operations and do _ ? - - I _ additional pezpreceding G operator. However, xy multiplication, division, and power do require the preceding I,, as shown in Table 1.3. Suppose A and B are 2 x 2 matrices given by bll bl2 = [ : : : a 1 2 ] , a22 B = [ b21 b22 1. hen, using the array multiplication operator, we have & B = [allbll a12b12 a21b21 a 2 2 b 2 3 *> t > d I. Figure 1.14 Inner and Outer Products. - 4 : "r".? '-> h 1 >)x=[~;pi;sin(pi/2)]; y=[exp(-0.5);-1 3;piA21; .................................. ......................................................... &*y 4 !$,;&*~;@,g@,g,u,a%i .................. . . : v . . .............. : ..:.:.:.:.:.:.. : j : .............. ............................ :.................... 4 ............ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - : : : : : . . : . : . : j : : ans = -27.9384 >>x?ylt * ans = 3.0327 -65.0000 49.3480 1.go55 -40.8407 31-0063 0.6065 -13.0000 9.8696
  • 10. Chapter 1. MATLAB Basics Table 1.3 Mathematical Array Operators. The elements of A. * B are the products of the corresponding ele- ments of A and B. A numerical example of two array operations is given in Figure 1.15. + - .* . .A Before proceeding to the important topic of graphics, we need to introduce the notion of subscripting using colon notation. The colon notation, shown in Figure 1.16, allows us to generate a row vector containing the numbers from a given starting value, xi, to a final value, xr,with a specified increment, dx. Addition Subtraction Multiplication Division Power ans = -6 14 30 ans = Figure 1.15 Array Operations. startingvalue final value I . L x = [ x ~ : ~ x : x ~ ] t increment t Figure 1.16 The Colon Notation. ! We can easily generate vectors using the colon notation, and ,M we shall soon see, this is quite useful for developing x-y plots. uppose our objective is to generate a plot of y = x sin(x) versus ... I for x = 0,0.1,0.2, ,1.O. Our first step is to generate a table of by data. We can generate a vector containing the values of x at rhich the values of y(x) are desired using the colon notation. This 1 illustrated in Figure 1.17. Given the desired x vector, the vector $ / ' ans = 0 Figure 1.17 Generating Vectors Usin1 I g the Colon Notation.
  • 11. Chapter 1. MATLAB Basics Table 1.3 Mathematical Array Operators. The elements of A. * B are the products of the corresponding ele- ments of A and B. A numerical example of two array operations is given in Figure 1.15. Before proceeding to the important topic of graphics, we need to introduce the notion of subscripting using colon notation. The colon notation, shown in Figure 1.16, allows us to generate a row vector containing the numbers from a given starting value, xi, to a final value, xr, with a specified increment, dx. Figure 1.15 Array Operations. ans = -6 14 30 ,>A.42 startingvalue fmal value t increment 4 Figure 1.16 The Colon Notation. ~:. :... : .... ...... ..away:.~awsr,,,i,:;~ .: .......::.. .:..;. ........ . . ..:.. . ........ . : : . . .: ........... . : : .:.. ..:. ......... :. We can easily generate vectors using the colon notation, . and . u we shall soon see, this is quite useful for devel . ans - 1 4 9 ,pose our ol ,r x = 0.0.1 cu data. We can generate a vector containing th ich the valuc llustrated in loping x-y plots. generate a plot of y = xsin(x) versus Our first step . is.to generate a table of ' e values of x at : desired using the colon notation. This Given the desired x vector, the vector 3 s of y(s) are Figure 1.17. /b i i ans = 0 0 0.1000 0.0100 Figure 1.17 Generating Vectors Using the Colon 1Yotation.
  • 12. 1.4. Graphics 16 Chapter 1. MATLAB Basics y(x) is computed using the multiplication array operation. Creating a plot of y = xsin(x) versus zis a simple step once the table of x-y data is generated. 1 . 4 Graphics Graphics play an important role in both the design and analysis of control systems. An important component of an interactive control system design and analysis tool is an effective graphical capability. A complete solution to the control system design and analysis will eventually require a detailed look at a multitude of data types in many formats. The important plot formats includeroot-locus plots, Bode plots, Nyquist plots, and time-response plots. The objectiveof -- this section is to acquaint the reader with the basic x-y plotting ca- pability of MATLAB. More advanced graphics topics are addressed aa the need arises. MATLAB uses a graph display to present plots. Some computer configurations allow both the command display and graph display to be viewed simultaneously. On computer configurations that allow only one to be viewed at a time, the command display will disappear when the graph display is up. The graph display is brought up automatically when a plot is generated using any function which generates a plot (e.g., the plot function). Switching from the graph display back to the command display is accomplished by pressing the keyboard. The plot in the graph at the command prompt. used to switch to the graph display from the There are two basic groups of graphics functions. The first group of functions, shown in Table 1.4, specifies the type of plot. The list of available plot types includes x-y plot, semilog and log plots. The second group of functions, shown in Table 1.5,allows us to customize the plots by adding titles, axis labels, and text to the plots and to change the scales and display multiple plots in subwindows. The standard x-y plot is created using the plot function. The x-y data in Figure 1.17 are plotted using the plot function as shown I Table 1.4 Available Plot Formats.4 Plots the vector x versus the vector y. The x-axis is log,,; the y axis is linear. The x-axis is linear; the y axis is loglo. Creates a plot with loglo scales on both axes. Figure 1.18. The axis scales and line types are autoqatically the plot by using the grid command. We see that a basic x-y t is generated with the combination of functions plot, xlabel, abel, title, and grid. Multiple lines can be laced on the graph by using the plot func- on with multiple arguments, as shown in Figure 1.19. The default Table 1.5 Functions for Customized Plots. Labels the x-axis with 'text'. Labels the yaxis with 'text'. - where (010,010) is the lower left and
  • 13. Chapter 1. MATLAB Basics Figure 1.18 A Basic x-y Plot of xsin(x) versus x. line types can also be altered. The available line types are shown in Table 1.6. The line types will be automatically chosen unless specified by the user. The use of the text function and changing the line types is illustrated in Figure 1.19. The other graphics functions loglog, semilogx, and semilogy are used in a similar fashion to plot. To obtain an x-y plot where the x-axis is a linear scale and the y-axis is a loglo scale, you would use the semilogy function in place of the plot function. The cus- Figure 1.19 A Basic x-y Plot with Multiple Lines. Table 1.6 Line Types for Customized Plots. - - Dashed line Dotted line Dashdot line
  • 14. Chapter 1. MATLAB Basics 1.5. Scripls tomizing features listed in Table 1.5 can also be utilized with the Scripts loglog, semilogx, and semilogy functions. The graph display can be subdivided into smaller subwindows. up to this point, all of our interaction with MATLAB has been at The function sub~lot(mnp)subdivides the graph display into an ha command prompt. We enter statements and functions at the grid of smaller subwindows, where m 5 2 and 5 2. ~h~~ ornrnand prompt, and MATLABinterprets our input and takes the the graph displaycan be subdivided into twoor four windows. bpl,ropriate action. This is the peferable mode of operation when- The integerP specifiesthe window, where the windowsare numbered or your sessions are short and nonrepetitive. However, the real left right, top to bottom. This is illustrated in ~i~~~~1.20,where wer of MATLAB for control system design and analysis derives the graphics window is subdivided into four subwindows. ,m its ability to execute a long sequence of commands stored in a a. These files are called M-filessince the filename has the formfile- cime.m. A script is one type of M-file. The Control System Toolbos a collection of M-filesdesigned specifically for control applications. r addition to the pre-existing M-files delivered with MATLAB and tho toolboxes, we can develop scripts for our applications. - Scripts are ordinary ASCII text files and are created by using clr own text editor. Creating and storing scripts are computer &tformdependent topics, which means that you need to seek out e appropriate expert at your location for more information. A script is just a sequence of ordinary statements and functions at you would use at the command prompt level. A script is invoked the command prompt level by simply typing in the filename (with- t the .m file type). Scripts can also invoke other scripts. When e script is invoked, MATLAB executes the statements and func- tions in the file without waiting for input at the command prompt. The script operates on variables in the workspace. Suppose we want to plot the function ~ ( t ) = sinat, where a is a variable that we want to vary. Using our favorite text editor,) + we write a script, which we will call p1otdata.m. This is shown in Figure 1.21. We input a value of a at the command prompt, and in doing so we place a in the workspace. Then we execute the script by typing in plotdata at the command prompt. The script p1otdata.m will use the most recent value of a in the workspace. After executing the script we can enter another value of a at the command prompt and execute the script again. Figure l . 2 0 Using subplot to Create a 2x 2 partition of the ~~~~h Your scripts should be well documented with comments. A com- Display. rnent begins with a %. If you put a header in your script comprised of several descriptive comments regarding the function of the script,
  • 15. p1otdatr.m -%This is a script to plot the function y=sin(alpha*t). % % The value of alpha must exist in the workspace prior % to invoking the script. % t=[0:0.01:1 I ; y=sin(alpha*t); plot(t,y) xlabel('Time [sec]') ylabel('y(t) = sin( alpha * t )') grid Figure 1.21 A Simple Script to Plot the Function y ( t ) = sin at. then using the help function will display the header comments and describe the script to the user. This is illustrated in Figure 1.22. We use p1otdata.m to develop an interactive capability with a as a variable, as shown in Figure 1.23. At the command prompt, we input a value of a = 10 followed by the script filename, which in this case is plotdata. The graph of y(t) = sinat is automatically ,,help plotdata This is a script to plot the function y=sin(alpha*t). I The value of alpha must exist in the workspace prior to invoking the script. Figure 1.22 Using the help Function. 1 command prompt
  • 16. Chapter 1. MATLAB Basics Notes - hapter 2 - eal models of complex physical systems. The mathematical models, which follow from the physical laws of the process, are generally .. .. - - . on to the ~ physical p~ - - -- system ~- -~ - is -~ - described ~~ by a linear,~constanteffi ent ordinary differential equation. The Laplace tbi~$f~~Zr~mkthOd~ one way to compute the s6lition of the differential equation. The ~~ ~ ~ ~ aplace transform~cii~&lsdb<hsed to obtain an input-output de- - - in the analysis of a typical spring-mass-dampermathematical model of a mechanical system. Using a MATLAB script, we will develop Mathematical Modeling of Systems 2.1 Introduction The design and analysis of control systems is based on mathemati- - - - highly coupled nonlinear differential equations. Fortunately, many physical systems behave linearly around an operating point within ,me range of the variables and it is possible to develop linear ap- - roximations to the physical systems. A Taylor series expansion is enerally utilized in the lir~earization process. Thc linear approxima- :ription of the linear, time-invariant (LTI) system in the form of L transfer function. The application of the many LLclassical" and "modern" control system design and analysis tools are based on LTI mathematical models. MATLAB can be used witkLTI systems a given in the form of transfer function descriptions or state-space b descriptions (see Chapter 9, State-Space Methods). We begin this chapter by showing how to use MATLAB to assist - an interactive analysis capability to analyze the effects of natural
  • 17. 26 Chapter 2. Mathematical Modeling of Systems frequency and damping on the unforced response of the mass dis- placement. This analysis will utilize the fact that we have an ana- lytic solution that describes the unforced time response of the mass displacement. In the subsequent sections, we will discuss transfer functions and block diagrams. In particular, we are interested in how MATLAB can assist us in manipulating polynomials, computing poles and ze- ros of transfer functions, computing closed-loop transfer functions, block diagram reduction, and computing the response of a system to a unit step input. The chapter concludes with the electric traction motor control design example found in MCS, pp. 79-81. The functions covered in this chapter are roots, rootsl, se- ries, parallel, feedback, cloop, poly, conv, polyval, printsys, minreal, pzmap, and step. 2.2 Spring-Mass-Damper System A spring-mass-damper mechanical system is shown in Figure 2.1. The motion of the mass, denoted by y(t), is described by the differ- ential equation This system is described in MCS, pp. 36-41. The solution, y(t), of the differential equation describes the displacement of the mass as a function of time. The forcing function is represented by r(t).The derivation of the spring-mass-damper mathematical model is based on the use of ideal springs and dampers. These ideal models for the spring and damper are based on lumped, linear, dynamic elements and only approximate the actual elements. The spring-mass-damper model, given in Eq. (2.1), is a linear, time-invariant approximation to the physical process; it is valid only in regions where the spring force is a linear function of the mass displacement and the damping due to friction is a linear function of the velocity. The mathematical model, given in Eq. (2.1), might represent an off-road vehicle shock absorber. Our objective could be to design an active control system to make the ride smoother when traversing 22. Spring-Mass-DamperSystem Forcing function Figure 2.1 Spring-Mass-Damper System. paved roads. The control design and subsequent analysis would based on the vehicle shock absorber model in Eq. (2.1). Of course, e true test of the control design is the road test. Only then can prove that the control design does in fact meet the objective of moother ride on a bumpy road. We will soon see how to use ATLAB to enhance our control design and analysis capability. Many physical processes are described by mathematical models nalogous to Eq. (2.1). A typical electrical RLC circuit is described an analogous mathematical model where the velocity, G(t), and voltage, v(t), are analogous variables. This notion of analogous stems is important in system modeling. Any experience gained designing and analyzing control systems for mechanical systems cribed by Eq. (2.1) can be used in controlling analogous electrical, rmal, and fluid systems. I The unforced dynamic response, y(t), of the spring-mass-damper echanical system is Y(O) e-(~"' s i n ( w . m t +O), ~ ( t ) = (2.2) where 6 ' = cos-'(. The initial displacement is y(0). The tran- nient system response is underdamped when ( < 1,overdamped when
  • 18. 28 Chapter 2. Mathematical Modeling of Systems ( > 1, and cdically damped when ( = 1. We can use MATLAB to visualize the unforced time response of the mass displacement following an initial displacement of y(0) Consider the overdamped and underdamped cases: 3 (K-2 f - 3 ) Case 1: y(0)=0.15m, u ,= fie, 5, = M - , M - Case 2: y(0)=0.15m, u,, = fig, 6 = & ((-2 L- M - j M - 1 ) The MATLAB commands to generate the plot of the unforced re- sponse are shown in Figure 2.2. In the MATLABsetup, the variables bu=c2*exp(-zeta2*wn*t);bl=-bu; % plot(t,yl ,'-',t,y2,'--',t,bu,':',t,bl,':'), grid xlabel('Tirne [sec]'), ylabel('y(t) Displacement [rn]') text(0.2,0.85,['overdarnped zeta1=',num2str(zetaI),... '- solid'],'^^') Figure 2.2 Script to Analyze the Spring-Mass-Damper. ? % Sprirrg-Mass-Da~nperSystem ~(O),wn, 1, t,and C2 are input to the workspace at the command bvcl. Then the script unforcedcommands.m is executed to gen- d plots. This creates an interactive analysis capa- ts of natural frequency and damping on ponse of the mass displacement. You can investi- of the natural frequency and the damping on the simply entering new values of w,, (1, or (2 at the rompt and running the script unforcedcommands.m -response plot is in Figure 2.3. Notice that the y labels the plot with the values of the damping cients. This avoids confusion when making many interactive lations. The natural frequency value could also be automati- plot. Utilizing scripts is an important aspect of an effective interactive design and analysis capability in . Sinceyou can relate the natural frequency and damping t, K, and friction, f , you can also analyze the ts of I< and f on the response. n the spring-mass-damper problem, the unforced solution to ion, given in Eq. (2.1), was readily available. ating closed-loop feedback control systems I T i [SKI Figure 2.3 Spring-Mass-Damper Unforced Response.
  • 19. Chapter 2. Mathematical Modeling of Systems 2 'Ikrw18fer Pbnctior~a subject to a variety of inputs and initial conditions, it is not feasible to attempt to obtain the solution analytically. In these cases, we can use MATLAB to compute the solutions numerically and to display the solution graphically. The simulation capability of MATLAB will be discussed in detail in subsequent sections and chapters. 2 . 3 Transfer Functions The transfer function is an input-output description of an LTI sys- tem, as described in MCS, pp. 52-63. It relates the Laplace trans- form of the output variable to the Laplace transform of the input variable with zero initial conditions. Consider the LTI system de- 1.OOOO 3.0000 0.0000 - 0.OOOOi 4.0000 + 0.OOOOi scribed by the transfer function G(s),where Y ( s ) a,sm +a,-IS"-' +...+als +a0 re 2.4 Entering the Polynomial p(s) = s3 +3s2$ 4 and Cal- G(s)= -= R(s) sn +b,-lsn-I +...+als +b0 ' where m 5 n, and all common factors have been canceled. The ent of the s term is zero, it is included in the input definition roots of the numerator polynomial of G(s)are called the zeros of the system; the roots of the denominator polynomial are called the poles. If p is a row vector containing the coefficientsof ~ ( s ) in descend- Setting the denominator polynomial to zero yields the characteristic equation sn +bn-IS"-' +..-+als +4 = 0. The transient response of a system is directly related to the %plane ial coefficients in descending order. We can compute the roots locations of the poles and zeros. We can use MATLAB to analyze systems described by trans- fer functions. Since the transfer function is a ratio of polynomials, olynornial but gives a more accurate result when the polynomial we begin by investigating how MATLAB handles polynomials, re- repeated roots. In Figure 2.4 we also show how to reassemble membering that working with transfer functions means that both a polynomial with the poly function. numerator polynomial and a denominator polynomial must be spec- Multiplication of polynomials is accomplished with the conv ified. nction. Suppose we want to expand the polynomial n(s)$where In MATLAB polynomials are represented by row vectors contain- n(s) = (3s' +2s +l ) ( s+4). ing the polynomial coefficientsin descending order. For example, the polynomial he associated MATLAB commands using the conv function are p(s) = s3 +3s2 +4 own in Figure 2.5. Thus, the expanded polynomial, given by n, is is entered as shown in Figure 2.4. Notice that even though the n(s) = 3s3 +14s' +9s +4.
  • 20. 32 Chaptcr 2. Mathematical Modeling of Systems ,,p=[3 2 1I; q=[l 41; I ,,n=conv(p,q) - [ Multlplypand q. ] n = I ,,value=polyval(n,-5) value = -66 Figure 2.5 Using conv and polyval to Multiply and Evaluate the Polynomials (3s' +2s +l)(s +4). The function polyval is used to evaluate the value of a polynomial at the given value of the variable. The polynomial n(s) has the value n(-5) = -66, as shown in Figure 2.5. In the next example we will obtain a plot of the pole-zero lo- cations in the complex plane. This will be accomplished using the pzmap function, shown in Figure 2.6. On the pole-zero map, ze- ros are denoted by an "on and poles are denoted by an "x". If the pzmap function is invoked without left-hand arguments, the plot is automatically generated. Figure 2.6 The pzmap Function. I ICXAMPLE 2.1 Transfer Functions Centlider the transfer functions and H(s) = (s +1)(s +2) s3+3s2+3s +1 (s +2i)(s - 2i)(s +3)' script, we can compute the poles and zeros of e characteristic equation of H(s), and divide G(s) by H(s). can also obtain a plot of the pole-zero map of G(s)/H(s) in the p of the transfer functionG(s)/H(s) is shown nd the associated MATLAB commands are shown in zero map shows clearly the five zero locations, that there are only two poles. This cannot be the now that the number of poles must be greater than number of zeros. Using the roots1 function we can rtain that there are in fact four poles at s = -1. Hence, multiple s or multiple zeros at the same ldcation cannot be discerned on Pole-ZeroMap b .................... ............... . : . ..:. . . . . ..:.. ...Do*:.,: . . . . . . . . . . .:!::w*::.:?: 'T 3 ............... <; ................ : ,...:............... ...... ............... - - . . . . . . . . X - . . . . . . . . . . . . . . . . . . . X . . . . . . . . . . . . . . . . . . . . . . i < I - -2 -1.5 -1 -0.5 8' RealAxis Figure 2.7 Pole-Zero Map for G(s)/H(s).
  • 21. 34 Chapter 2. Mathematical Modeling of Systems I 3 4. Block iliagram Modela z = 0+ 0.40821' 0 - 0.4082i ~p=rootsl (deng) s A 5 + 6 s A 4 + 1 4 s A 3 + 1 6 s A 2 + 9 s + 2 >>pzmap(num,den) 4 >>title('Pole-ZeroMap') Figure 2.8 Transfer Function Example for G(s) and H(s). 2.4 Block Diagram Models Buppose we have developed mathematical models in the form of r ~ s f e r functions for the plant, represented by G(s), and the con- roller, represented by H(s), and possibly many other system com- nents such as sensors and actuators. Our objective is to inter- nnect these components to form a control system. We will utilize TLABfunctions to carry out the block diagram transformations. ock diagram models are described in MCS, pp. 64-69. The process to be controlled is shown in Figure 2.9. A simple an-loop control system can be obtained by interconnecting the ant and the controller in series as illustrated in Figure 2.10. We n use MATLAB to compute the transfer function from R(s) to s), as illustrated in Example 2.2. EXAMPLE 2.2 Series Connection t the process, represented by the transfer function G(s), be 1 G(s) = - 500s1' d let the controller, represented by the transfer function G,(s), be s +1 Gc(3) = sf2. can use the series function to cascade two transfer functions (s) and Gz(s), as shown in Figure 2.11. The transfer function G,G(s) is computed using the series func- on as shown in Figure 2.12. The resulting transfer function, G,G(s), e Process U(s) - T I P b Y(4 Figure 2.9 Open-Loop System.
  • 22. 36 Chapter 2. Mathematical Modeling of Systems ~~~~~ R(s) Go(s) Y(s) Figure 2.10 Open-Loop Control System. num G,G(s) = -= s + 1 den 500s3+1000~2 ' Block diagrams quite often have transfer functions in parallel. In such cases, the function parallel can be quite useful. The parallel function is described in Figure 2.13. We can introduce a feedback signal into the control system by closing the loop with unity feedback, as shown in Figure 2.14. The signal E,(s) is an error signal; the signal R(s) is a reference input. In this control system, the controller is in the forward path and the closed-loop transfer function is Figure 2.11 The series Function. . Illock 1)iagram Modaln 37 Figure 2.12 ~p~lication of the series Function. re are two functions we can utilize to aid in the block diagram re- ion process to compute closed-loop transfer functions for single- multi-loop control systems. These functions are cloop and
  • 23. Chaplcr 2. Mathematical Modeling of Systenls Ea (s) Controller u(9 Process ~ ( s ) s k * Gc(s) - G(s) -- Y(s) A Figure 2.14 A Basic Control System with Unity Feedback as shown in Figure 2.15 with the associated system configuration and assumes unity feedback with negative feedback as the default. The feedback function is shown in Figure 2.16 with the associ- ated system configuration, which includes H ( s )in the feedback path. For both the cloop and feedback functions, if the input "sign" is omitted, then negative feedback is assumed. In Example 2.3 we show an application of the cloop function, and in Example 2.4 we show an application of the feedback function. EXAMPLE 2.3 T h e cloop Function Let the process, G(s),and the controller, G,(s),be as in Example 2.2 (see Figure 2.12). To apply the cloop function we first use the series function to compute G,G(s), followed by the cloop function to close the loop. The command sequence is shown in Figure 2.17. The closed-loop transfer function, as shown in Figure 2.17, is T ( s )= G,G(s) - num - s + 1 1 +GcG(s) - den - 500s3 +1000s' +s +1' Figure 2.15 The cloop Function. Figure 2.16 The feedback Function. Another basic feedback control configuration is shown in Fig- 2.18. In this case, the controller is located in the feedback path. error signal, E,(s), is also utilized in this control system con- ration. The closed-loop transfer function is ~numg=[l]; deng=[500 0 01; >>numc=[l11; denc=[l 21; >>[num 1,den1]=series(numg ,deng,numc,denc); ~[num,den]=cloop(numl,den1,-1 ); aprintsys(num,den) 500 sA3 + 1000 sA2 + s + 1 Figure 2.17 Application of the cloop Function.
  • 24. 40 Chapter 2. Mathematical Modeling of Systems Figure 2.18 A Basic Control System with the Controller in the Feedback Loop. Ea(s) , RfsJ EXAMPLE 2.4 The feedback Function Again, let the process, G(s), and the controller, H(s), be as in Ex- ample 2.2 (i.e., H(s) = G,(s)). To compute the closed-loop transfer function with the controller in the feedback loop we use the feed- back function. The command sequence is shown in Figure 2.19. The closed-loop transfer function is Process G(s) Controller H(s) G(s) num =-- - s + 2 = 1+G ) den 500s' +1000s2+s + i ' B functions series, cloop, and feedback can be used +Yfs) Figure 2.19 Application of the feedback Function. Block D i a g r a m Model, as aids in block diagram manipulations for multi-loop block dib grams. This is illustrated in Example 2.5. I EXAMPLE 2.5 Multi-Loop Reduction when ana I For this example, a five-step procedure is followed: Step 1: Input the system transfer functions into MATLAB. Step 2: Move Hz behind G4. ! A multi-loop feedback system is shown in Figure 2.20. This example can be found in MCS, pp.67-69. Our objective is to compute the : closed-loop transfer function lLr.l Figure 2.20 Multi-Loop Feedback Control System. 1
  • 25. 42 Chapter 2. Mathematical Modeling of Systems a Step 3: Eliminate the G3GdHt loop. a Step 4: Eliminate the loop containing Hz. a Step 5: Eliminate the remaining loop and calculate T(s). The five steps are illustrated in Figure 2.21, and the corresponding block diagram reduction is shown in Figure 2.22. The result of executing the MATLAB commands is num -- - s5 +4s4 +6s3+6s' $59 +2 den 12s' +205s5 +1066s4 +251793 +312892 +2196s +712' We must be careful in calling this the closed-loop transfer function. Recall that the transfer function is defined to the input-output rela- tionship after pole-zero cancellations. If we compute the poles and zeros of T(s), we find that the numerator and denominator poly- nomials have (s +1 ) as a common factor. This must be canceled before we can claim we have the closed-loop transfer function. To Figure 2.21 Multi-Loop Block Fkduction. 8 igure 2.22 Block Diagram Reduction of Multi-Loop System (See Example 2.5 in MCS, pp. 67-69).
  • 26. Chapter 2. Mathematical Modeling of Systems 2 , I . Design Example Figure 2.23 The minreal Function. assist us in the pole-zero cancellation we will use the minreal func- tion. The minreal function, shown in Figure 2.23, removes common pole-zero factors of a transfer function. The final step in the block reduction process is to cancel out the common factors, as shown in Figure 2.24. The closed-loop transfer function is given in Fig- ure 2.24 as T(s)= num/den. After the application of the minreal function we find that the order of the denominator polynomial has been reduced from six to five, implying one pole-zero cancellation. 1 pole-zeros cancelled num/den = Figure 2.24 Application of the minreal Function. 1 2.1 Design Example motors are utilized on trains and transit vehicles. he detailed block diagram model with the transfer functions of the armature controlled motor, and sensor, is shown in ure 2.25. This is Example 2.9 in MCS, pp. 79-81. Our objective e closed-loop transfer function and investigate the a commanded wd. The first step, as shown in Fig- c 2.26, is to compute the closed-loop transfer function w/wd. The wed-loop characteristic equation is second-orderwith w, = 52 and = 0.012. Since the damping is low we might expect the response be highly oscillatory. We can investigate the response w(t) to reference input, wd(t), by utilizing the step function. The step nction, shown in Figure 2.27, calculates the unit step response of is a very important function since control specifications are often given in terms of the e. The state response, given by x(t), is an output the step function and will be discussed in detail in Chapter 9, ds. Include x in the left-hand argument list, but not be concerned with it for the time being. ive is to plot the output, y(t), we can use the out left-hand arguments and obtain the plot au- matically with axis labels. I f we need y(t) for any reason other an plotting, we must use the step function with left-hand argu- ents, followed by the plot function to plot y(t). We define t as a Figure 2.25 Electric Traction Motor Block Diagram.
  • 27. 46 Chapbcr 2. Mathematical Modeling of Systems Figure 2.26 Electric Traction Motor Block Reduction. row vector containing the times at which we wish the value of the output variable ~ ( t ) . The step response of the electric traction motor is shown in Fie- ~- ure 2.28. As expected, the wheel velocity response, given by y(t),is highly oscillatory. f(r) step input t Time [secl % response of the Traction Motor %Wheel Velocity % num=[5400]; den=[2 2.5 54021; t=[0:0.005:3]; &,x,tl~step(num,den,t); , plot(t,y),grid xlabel('Time [sec]') ylabel('Whee1 velocity') Figure 2.28 Traction Motor Wheel Velocity Step Response. 8 Figure 2.27 The step Function.
  • 28. Chapter 2. Mathematical Modeling of Systems Notes - Chapter 3 Control System Characteristics 3.1 Introduction We introduce feedback to 1. decrease the sensitivity of the system to plant variations, 2. enable adjustment of the system transient response, 3. reject disturbances, and 4. reduce steady-state tracking errors. The advantages of feedback (listed above) come at the cost of in- creasing the number of components and system complexity, reduc- tion in the closed-loop system gain, and the introduction of possi- ble instabilities. However, the advantages of feedback outweigh the disadvantages to such an extent that feedback control systems are found everywhere. In this chapter, the advantages of feedback are illustrated with two examples. Our objective is to illustrate the use of MATLAB in the control system analysis. In the first example, we introduce feedback control to a speed tachometer system in an effort to reject disturbances. The tachome- ter speed control system example can be found in MCS, pp. 125-1.28. The reduction in system sensitivity to plant variations, adjust- ment of the transient response, and reduction in steady-state error I are demonstrated in a second example. This is the English Channel 1 boring machine example found in MCS, pp. 134-137. t
  • 29. 50 Chapter 3. Control System Characteristics 3.2 Speed Tachometer System The open-loop block diagram description of the armature controlled dc-motor with a load torque disturbance, Td(s), is shown in Fig- ure 3.1. The values for the various parameters, taken from Example 2.9 in MCS, pp. 79-81, are given in Table 3.1. We have two in- puts to our system, V,(s) and Td(s). Relying on the pn'ncipal of superposition, which applies to our LTI system, we consider each input separately. To investigate the effects of disturbances on the system, we let V,(s) = 0 and consider only the disturbance Td(s). Conversely, to investigate the response of the system to a reference input, we let Td(s) = 0 and consider only the input V,(s). The closed-loop speed tachometer control system block diagram is shown in Figure 3.2. The values for K, and Kt are given in Table 3.1. If our system displays good disturbance rejection, then we expect the disturbance Td(s) to have a small effect on the output w(s). Consider the open-loop system shown in Figure 3.1 first. We can use MATLAB to compute the transfer function from Td(s) to W(S) and evaluate the output response to a unit step disturbance (i.e., T~(s) = 11s). The time response to a unit step disturbance is shown in Figure 3.3. The script opentach.m, shown in Figure 3.3, is used to analyze the open-loop speed tachometer system. The open-loop transfer function is W(S) num -1 -=-= Td(3) den 2s +1.5' Figure 3.1 Open-Loop Speed Tachometer Control System where Kb is the Back Electromotiv~Force Constant. 1 Table 3.1 Tachornctcr Control System Parameters. Ra K, J f Kb Ko Kt 1 10 2 0.5 0.1 54 1 e final value of w(t), which we denote w,(t) to indicate open-loop. The steady-state error, shown on pproximate steady-state value of w, is wo(co)-w,(7) = -0.6632 radlsec. The plot verifies that we have in fact reached steady-state. In a similar fashion, we begin the closed-loop system analysis by computing the closed-loop transfer function from Td(s) to w(s), and then generating the time-response of w(t) to a unit step disturbance input. The output response and the script c1osedtach.m are shown in Figure 3.4. The closed-looptransfer function from the disturbance Figure 3.2 Closed-Loop Speed Tachometer Control System.
  • 30. Chapter 3. Control System Characterit Open-LoopDisturbanceStepResponse 0 I time [sec] opentach.m r - --. num2 and den2 represents 1 the transfer function for %Speed Tachometer Example the armature and back emf. % -. - -. . - -- -. . -. -... Ra=l;Km=l 0; J=2; f=0.5; Kb=O.l ; + numl=[1 1; denl =[J,f]; numZ=[Km*Kb/Ra]; den2=[1]; [num,den]=feedback(numl ,den1,num2,den2); % Change sign of transfer function since the I num=-num; disturbance has negativesign in the diagram. ~rintsvsfnum.den) . . * - , % - CMnputeresponge to [yo,x,t]=step(num,den); plot(t,yo) step disturbance, title('0pen-loop Disturbance Step R xlabel('time [sec]'), ylabel('speedl), grid % I - - - - - - - - - - - yo(length(t)) 4 - - -I1 Steady-stateerror -> last value of output yo. - - - - _ - - - - _ - - - - Figure 3.3 Open-Loop Analysis of the Tachometer System. time [secl closedtach.m I% Speed Tachometer Example % Ra=l ;Km=lO; J=2; f=0.5; Kb=O.l ; Ka=54; Kt=l ; numl=[l 1; denl=[J,f]; num2=[Ka*Kt]; den2=[1]; num3=[Kb]; den3=[1]; num4=[Km/Ra]; den4=[l I; [numa,dena]=parallel(num2,den2,num3,den3); [numb,denb]=series(numa,dena,num4,den4); [num,den]=feedback(numl ,den1,numb,denb); J % Change sign of transfer function since dist -has negativesign in the block diagram. printsys(num,den) % [yc,x,t]=step(num,den); plot(t,yc) title('Closed-loop DisturbanceStep xlabil('time [sec]'), ylabel('speed [rad/secI1), grid I 7 .... ...-. % yc(length(t)) 4 - Steady-state error -> last value of output yo. .- Figure 3.4 Closed-Loop Analysis of the Tachometer System.
  • 31. Chaptcr 3. Control System Characteristics input is W(S) num -- -1 - T'(s) - den - 2s +541.5' As before, the steady-state error is just the final value of w(t), which we denote by w,(t) to indicate closed-loop. The steady-state error is shown on the plot in Figure 3.4. We can obtain an approximate value of the steady-state error by looking at the last value in the output vector y,, which we generated in the process of making the plot in Figure 3.4. The approximate steady-state value of w is We generally expect that w,(co)/w,(co) < 0.02. The ratio of closed- loop to open-loop steady-state speed output due to a unit step dis- turbance input, in this example, is We have achieved a remarkable improvement in disturbance rejec- tion. It is clear that the addition of the negative feedback loop reduced the effect of the disturbance on the output. This demon- strates the disturbance rejection property of closed-loop feedback systems. 3.3 English Channel Boring Machines The block diagram description of the English Channel boring ma- chines is shown in Figure 3.5. The transfer function of the output due to the two inputs is The effect of the control gain K on the transient response is shown in Figure 3.6 along with the script english1.m used to generate the plots. Comparing the two plots in Figure 3.6, it can be seen that decreasing K decreases the overshoot. Although it is not as obvious disturbance Dfs) boring I machine G(s) angle 2 . , 1 I CfsJ * Figure 3.5 Boring Machine Control System Block Diagram. s (s+ 12) from the plots in Figure 3.6, it is also true that decreasing K de- creases the settling time. This can be verified by taking a closer look (at the command level) at the data used to generate the plots. This example demonstrates how the transient response can be altered by feedback control gain I(. Based on our analysis thus far, we would prefer to use K = 50. However, there are other considerations that must be taken into account before we can establish the final design. Before making the final choice of K , it is important to consider the system response to a unit step disturbance. This is shown in Fig- ure 3.7. We see that increasing K reduces the steady-stde response of c(t) to the step disturbance. The steady-state value of c(t) is 0.02 and 0.01 for K = 50 and 100, respectively. The steady-state errors, percent overshoot, and settling times are summarized in Table 3.2. The steady-state values are predicted from the final value theorem as follows: angle If our only design consideration is disturbance rejection, we would prefer to use I< = 100. We have just experienced a very common trade-off situation in control system design. In this particular example, increasing K leads to better disturbance rejection, while decreasing K leads to better performance (via less overshoot and quicker settling time). The final
  • 32. r . Control System Characteristics Stepresponse forK=lW overshoot 1 -..----..- fc?5. settling time 1 OF0:2 014 0:6 0:s i 1:2 114 1:6 118 1 time [secl 1.5 Stepreswnse forK=SO minimalovershoot I 0 0 V 0 1 2 o i 0 6 0:s i 1 2 i i 1 6 1:8 1 time [sec] englishl.m % Response to a Unit Step Input R(s)=l /s for K=50, 100 % numg=[l 1; deng=[l 12 01; K1=100; K2=50; numl=K1*numg; num2=K2*numg; % dosed-loop trnwfer functions [numa,dena]=cloop(numl $eng); , [numb,denb]=cloop(num2,deng); Cho6Je tlme inorval. 1 [y1,x,t]=step(numa,dena,t); [y2,x,t]=step(numb,denb,t); subplot(2 11),plot(t,y 1), title('Step Response for K=lOO1) xlabel('time [sec]'),ylabel('c(t)') subplot(212),plot(t,y2), title('Step Response for K=50') xlabel('time [sec]'),ylabel('c(t)') Figure 3.6 The Response to a Step Input with 1<=100 and 1<=50. 0.015 DisturbanceResponseforK=lW 0.2 0.4 0:6 0.8 i l i 1:4 lk l:8 ! L time [sec] 0.025, Disturbance ResponseforK=lW I 1 2 014 0:6 0:8 i 1:2 1:4 1:6 118 2 time [sec] english2.m % Response to a Disturbance D(s)=l /s for K=50, 100 % numg=[l 1; deng=[l 12 01; K1=100; K2=50; % clasedtoop transfer functlms rnuma.denal=feedba subplot(21 1),plot(t,y 1) title('Disturbance Response for K=100') xlabel('time [sec]'),ylabel('c(t)') subplot(2 12),plot(t,y2) title('Disturbance Response for K=50') xlabel('time [sec]'),ylabel('c(t)') Figure 3.7 The Response to a Step Disturbance with 1<=100 and 1(=50.
  • 33. 98 Chapter 3. Control System Characteristics ,i.:j, (;rlgistt (>I~~I,IIII~: 11ori11gMtl(:l~ixtf:s Table 3.2 Response of the Boring Machine Control System for K = 50 and If = 100. decision on how to choose K rests with the designer. So you see that while MATLAB can certainly assist you in the control system design, it cannot replace your decision-making capability intuition. The final step in the analysis is to look at the system sensitivity to changes in the plant. The system sensitivity is given by ( E ~ . 3.62, 0/6 System Sensitivity Plot MCS, p. 197) 1 W=[O.I :0.05:201; s=w*i; '(') = 1+Z<G(s) s(s +12) - - s(s +12) +K' We can compute the values of S(s) for different values of 3 and generate a plot of the system sensitivity. For low frequencies, we can approximate the system sensitivity by 128 s(s)M j ~ . Increasing the gain I f reduces the system sensitivity. The system sensitivity plots are shown in Figure 3.8 for K = 50. The sensitivity Figure 3 . 8 system sensitivity to Plant Variations. approximation is also shown in Figure 3.8.
  • 34. Control ltes - System Charactel hapter 4 Control System Performance .1 Introduction P~imary concerns in control system design are stability and perfor- nl;Lnce. Performance is an issue for stable systems and is the topic I this chapter. In order to design and analyze control systems, c must first establish adequate performance specifications. Per- mance specifications can be presented in the time domain or the quency domain. Time-domain specifications generally take the rm of settling time, percent overshoot, rise time, and steady-state rror specifications. Stability and frequency-domain specifications re addressed in the next chapters. This chapter is organized as follows. In the next section we rivestigate time-domain performance specificationsgiven in terms d ansient response to a given input signal and the resulting steady- alate tracking errors. The chapter concludes with a discussion of simplification of linear systems. The MATLAB functions introduced in this chapter are impulse and lsim. These functions are used to simulate linear systems. 4.2 Time-Domain Specifications 'I'ime-domain performance specifications aregenerally given in terms ol the transient response of a system to a given input signal. Since (,heactual input signals are generally unknown, a standard lest input 61
  • 35. ,l,a. yinle-Domain Spc~cific.nl,iorls R(s) ~Tp~ylTws ( s + ~ w , ) c(s) steady-state error 2% Figure 4.2 Single-Loop Second-Order Feedback System. closed-loop output is 2 C(s) = Wn s2+25w,s +w;4 R(s). wehave already discussed the use of the step function to =om- putethe step response of a system. Now we address another im- portant test signal: the impulse. The impulse response is the time derivative of the step response. We compute the impulse response with the impulse function shown in Figure 4.3. wecan obtain a plot similar to Figure 4.5(a) in MCS, Pi 162 4-1 Step Response of a Second-Order System. with the step function, as shown in Figure 4.4. Using the impulse function, we can obtain a plot similar to Figure 4.6 in MCS, P. signalis used. The test signals are of the general form 163. The response of a second-order system for an impulse inputis shown in Figure 4.5. In the script, we set wn = 1, which is r(t) = tn, and the corresponding Laplace transform is n! input R(s) = -. t p+1 When = 19%and 3 we have the step, ramp, and parabolic inputs, An impulse function is also used as a test signal. The performance measures are usually defined in terms the response and the impulse response. The most performance IrIeasUreS are percent overshoot (p.~.), rise time peak time (T,), and settling time (T,), as shown in Figure 4.1. the second-order system shown in Figure 4.2. ~h~ Figure 4.3 The impulse Function.
  • 36. 64 Chapter 4. Control System Performance % Compute step response for a second-order system % Duplicate Figure 4.5(a) in MCS, p. 162 % I 1 [yl ,x,t]=step(num,denl ,t); [y2,x,t]=step(num,den2,t); [y3,x,t]=step(num,den3,t); [y4,x,t]=step(num,den4,t); [yS,x,tl=step(num,den5,t); [y6,x,t]=step(num,den6,t); 1% 1 :' 'I'ime-DomainSpc!rilic.~Liolrs
  • 37. (i 6 i i l r 4 Control System Performance Figure 4.6 The lsim Function. equivalent to computing the step response versus w,t. This gives us a more general plot valid for any w, > 0. In many cases, you may need to simulate the system response to an arbitrary but known input. In these cases, you can use the lsim function. The lsim function is shown in Figure 4.6. An example of the use of lsim is given in Example 4.1. EXAMPLE 4.1 Mobile Robot Steering Control The block diagram for a steering control system for a mobile robot is shown in Figure 4.7 (see MCS, pp. 174-176). Controller Vehicle dynamics Figure 4.7Block Diagram of a Steering Control Systemfor a Mobile Robot. .J :?. Time-Domain Speciii~aliorl~ 67 time [secl mobilarobot.m % Compute the response of the Mobile Robot Control % System to a triangular wave % numg=[l 0 201; deng=[l 10 01, ................................................... :...: ....... : :.,*.,.,. .................................................. ............ iQ:-triMrr",$ :';; [num,den]=cloop(numg,deng); 4 7 1 :.:..:: . . . . . . . . . ...................................................... :..................: .....................:.: .:wijg:,"p"t" : . . . ::":l::::.i:l.,:i'.';.::i : ................../, t=[0:0.1 :8.211; ............................. ..? !..?.;..'.&......z.<$.$. :.i. .......... ....................... ~1=r0:0.1:2]';~2-[2:-0.1:-2]';~3=[-2:O. : ; I I Figure 4.8 Transient Response of the Mobile Robot Steering Con- trol System to a Ramp Input.
  • 38. Chapter 4. Control Systern Performance Suppose the steering controller, G1(s), is When the input is a ramp, the steady-state error is I 3. Simplification of 1,ittrnr. Sydcms 1 A ~vcond-orderapproximation (see MCS, pp. 187-188)is where Ii, = IGK. Figure 4.8 for Kl = I< = 1, K2 =2, and 7 = 1/10. 4.3 Simplification of Linear Systems - , ~ - - ~ e impractical to implement a high-order controller in a control sys- tem. However, it may be possible to develop a lower-order aDnrox- "- compare the approximate model to the actual model, as illustrated in the following example. EXAMPLE 4.2 A Simplified Model Consider the third-order system rr/ 6 K, GI(8) = Kl +--. 1.60 s L(s) = ~2 +2.5849 +1.60' A comparison of their respective steprespOnsesis givenin Figure 4.9. . - The effect of the controller constant, Kz, on the steady-state error is evident from Eq. (4.1). Whenever K2 is large, the steady-state error is small, and vice versa. We can simulate the closed-loopsystem response to a ramp input using the lsim function. The controller gains K l , I(z and the system gain K can be represented symbolically in the script so that various values can be selected and simulated. The results are shown in -. In practice, it may be necessary to approximate a higher-order trans- fer function model with a lower-order model. For exam~le. it ma.v b .~r---- % Compare step response for se imate controller that closely matches the input-output reponse of the high-order controller. A procedure for approximating transfer numl=[6]; denl=[l 6 11 functions is given in MCS, pp. 185-187. We can use MATLA R tn n (3) = pigure4.9 Step Response Comparison for an Approximate Transfer s3+6.s2$11s+6' tion on Versus the Actual Transfer Function.
  • 39. Chapter 4. Notes Control System Performan ter 5 Control System Stability ' .1 Introduction 'I(: stability of a closed-loop control system is a fundamental issue 01s. Generally speaking, an unstable closed-loop control sys- 8111is of little practical value. For linear systems, a necessary and Ilicient condition for a feedback system to be stable is that all the the system transfer function have negative real parts. In her words, the poles must lie in the left-half plane for the system hle. The Routh-Hurwitz stability method provides a struc- d mechanism for determining the number of unstable poles of -loop characteristic equation. This allows us to obtain a "no" answer to stability without explicitly calculating the This chapter begins with a discussion of the Routh-Hurwitz sta- lily method. We will see how MATLAB can assist us in the stabil- analysis by providing an easy and accurate method for comput- the poles of the characteristic equation. For the case where the hi~racteristic equation is a function of a single parameter, it will be ponsible to generate a plot displaying the movement of the poles as tl~c:parameter varies. The chapter concludes with an example. The function introduced in this chapter is the function for, which 1s used to repeat a number of statements a specific number of times.
  • 40. 72 Cl~apter 5. Control System StabilityI ,h : ! . llotlth-ll~lrwitz Stnhilil,.y 5.2 Routh-Hurwitz Stability ........... The Routh-Hurwitz criterion is a necessary and sufficient criterion 24 :.:,:::: . . . : . . : . . f i . . . : . . . ..: :., tt..scl n:.ewMg [, , . . . . . . . . . . . . . . . . . . . . . . . . . . . for stability. Given a characteristic equation with fixed coefficients, .drrn.i&ch;rr(gT !: sl -22 we can use Routh-Hurwitz to determine the number of roots in the . . . . . . . . . . . . . . . . . . . . . , . :. . . . ::.: ::.:../ . ./../.....$......... . SO 24 0 I) right-half plane. For example, consider the characteristic equation lgure 5.2 Routh-Hurwitz Array for the Closed-Loop Control Sys- q(s)= s3 +s2 +2s +24 = 0 wn with T ( s )= C ( s ) / R ( s )= 1/(s3+s2+29 +24). associated with the closed-loop control system shown in Figure 5.1. The corresponding Routh-Hurwitz array is shown in Figure 5.2. The two sign changes in the first column indicate that there are two ult graphically. As shown in Figure 5.5, we establish a vector of roots of the characteristic polynomial in the right-half plane; hence ues for K at which we wish to compute the roots of the charac- the closed-loop system is unstable. Using MATLAB we can veri ristic equation. Then using the roots function we calculate and the Routh-Hurwitz result by directly computing the roots of th ot the roots of the characteristic equation, as shown in Figure 5.5. characteristic equation, as shown in Figure 5.3, using the roots can be seen that as K increases, the roots of the characteristic function. Recall that the roots function computes the roots of a; uation move toward the right-half plane as the gain tends toward polynomial. = 8, and eventually into the right-half plane when K > 8. This is Whenever the characteristic equation is a function of a single raphical verification of the Routh-Hurwitz result obtained above. parameter, the Routh-Hurwitz method can be utilized to determine, the next chapter we will discover a compact method of obtaining the range of values that the parameter may take while maintaining e plot of the root locations as a function of one parameter using stability. Consider the closed-loop feedback system in Figure 5.4. e root locus method. The characteristic equation is q(s) = s3 +s2 +4s +K = 0. Using a Routh-Hurwitz approach we find that we require 0 <K 5 8 for stability (see MCS, p. 215). We can use MATLAB to verify this >>nurng=[l];deng=[l 1 2 231; [nurn,den]=cloop(nurng,deng); ~roots(den) ans = -3.0000 ..............::...: R(s) ::. .:............ ....: :...:.. ...................................... 1 .OOOO+ 2.64581 :.wtabtcr.'i6;*:~;i:l':i~ .: . . . . . . . . . . . . . . . . . . . . .......: : :::: .... : . ..; : : : 1.OOOO- 2.64581 ..................................... :.. I Figure 5.1 Closed-Loop Control System with T ( s )= C ( s ) / R ( s )= Figure 5.3 Using the roots h n d i o n to Compute the Closed-Loop l / ( s 3+s2 +2s $24). (:ontrol System Poles of the System Shown in Figure 5.1. G(s)= 1 sa+s2+2s+23 ' c ( s )
  • 41. Chapter 5. Control System Stabili Figure 5.4 Closed-Loop Control System with T(s) = C(s)/R(s) K/(s3 +2 3 ' +4s +I<). . 1% This script computes the roots of the characteristic 1 % equation q(s) = sA3 + 2 sA2 + 4 s + K for O<K<20 1% I K=[0:0.5:20 1; for i-1 :length(K) 4.11 2 4 K(i)]; } p(:,i)=roots(q); end plot(real(p),imag(p),'x'), grid xlabel('rea1 axis'), ylabel('imaginary axis') Figure 5.5 Plot of Root Locations of q(s) = s3 +2sZ +4s +I< fol 0 5 K 5 20. 5.2. Routh-Hurwilz Sl,rrl)ilil,y 75 The script in Figure 5.5 contains the for function. The for func- I,ic)nprovides a mechanism for repeatedly executing a series of state- nl(:nts a given number of times. The for function connected to an end statement sets up a repeating calculation loop. Figure 5.6 de- rc'ribes the for function format and provides an illustrative example vcxtor a is set equal to 20 and the scalar b is recomputed. The Routh-Hurwitz method allows us to make definitive state- rrlents regarding absolute stability of a linear system. The method floes not address the issue of relative stability, which is directly rt:lated to the location of the roots of the characteristic equation. Il.outh-Hurwitz tells us how many poles lie in the right-half plane, but not the specific location of the poles. With MATLAB we can easily calculate the poles explicitly, thus allowing us to comment on the system relative stability. We conclude this chapter with an example taken from MCS, pp. 2.23-225. ............... M n i : - i :ii,': b................ : : . ......I -for variable=expression Statement statement ! Figure 5.6 The for Function and an Illustrative Example.
  • 42. 76 Chapter 5. Control Syst 5.3 Example: Tracked Vehicle Turnin The block diagram of the control system for the two-track vehi is shown in Figure 5.7. The design objective is to find a and such that the system is stable and the steady-state error for a ramp input is less than or equal to 24% of the command. We can use the Routh-Hurwitz method to aid in the search for appropriate values of a and I<. The closed-loop characteristic equation is ~ ( s ) = s4+8s3 +17s' +( K +10)s +aK = 0. Using the Routh-Hurwitz array we find that for stability we require K < 126, aIi > 0. For positive Ii it follows that we can restrict our search to 126 and a > 0. Our approach will be to use MATLAB parameterized a versus Ii region in which stability is as we can find a set of (a, Ii)belonging to the stable region the steady-state error specification is met. This procedu in Figure 5.8, involves selecting a range of values for a computing the roots of the characteristic for specific K . For each value of K,we find the first value of a t least one root of the characteristic equation in the r The process is repeated until the entire selected range of exhausted. Then, the plot of the (a, Ii)pairs defines between the stable and unstable regions. Controller Power train and vehicle GfSl Gc(s ) K s3+7 s2 +10s . Figure 5.7 Turning Control for a Two-Track Vehicle.
  • 43. 78 Chapter 5. Control System Stabilit 1,9. Example: Il.acked Vehleh nlrrning Control The region to the left of the plot of a versus I( in Figure 5.8 i the stable region, since that corresponds to I i < 126. If we assume that ~ ( t ) = At,t > 0, then the steady-state error i e,, = lim s . s(s +1)(s+2)(s+5) .-=- s+o s ( s + l ) ( s + 2 ) ( ~ + 5 ) + K ( s + a ) s2 a l i ' where we have used the fact that 1 E(s) = R(s) = ~ ( 3 +1)(s+2)(s+5) 1+G,G(s) S ( S +1 ) ( ~ +2)(s+5) +Ic(s +a) Given the steady-state specification, e., < 0.24A, we find that specification is satisfied when 10A - aK < 0.24A, or time [sec] a K > 41.67. Any values of a and K that lie in the stable region in Figure % This script computes the ramp response and satisfy Eq. (5.1) will lead to an acceptable design. For exam % for the two-track vehicle turning control K = 70 and a = 0.6 will satisfy all the design requirements. % problem with a=0.6 and K=70 closed-loop transfer function (with a = 0.6 and K = 70)is t=[0:0.01:10]; u=t;+ . : 70s +42 T ( s )= s4 +8s3 +17s2+80s +42 ' The associated closed-looppoles are s = -7.0767, s = -0.5781, plot(t,y,t,u), grid s = -0.1726 +3.1995i,and xlabel('time [secl'), ylabel('c(t1') s = -0.1726 - 3.19952'. - The corresponding unit ramp input response is shown in Figure 5. ure 5.9 Ramp Response for a = 0.6 and K = 70 for Two-Trz The steady-state error is less than 0.25, as desired. icle Turning Control. 1
  • 44. Chapter 5. Control System SI . Notes hapter 6 oot Locus Method ,I Introduction hr relative stability of a control system is related to the location the roots of the closed-loop characteristic equation. The tran- nt response (i.e., settling time, overshoot, etc.) of a linear control atem is also related to the location of the poles and zeros of the sed-loop transfer function. The closed-loop system relative sta- ty and performance can sometimes be adjusted by changing a ameter, such as a control gain. The root locus method provides raphical representation of the locus of roots of the characteristic ation as one parameter is varied. The graphical representation called the root locus plot. An approximate root locus sketch can be obtained by applying e orderly procedure outlined in MCS, pp. 241-255. Alternatively, can use MATLAB to obtain an accurate root locus plot. How- r, do not be tempted to rely solely on MATLAB for obtaining ot locus plots while neglecting the manual steps in developing an proximate root locus. The fundamental concepts behind the root elis method are buried in the manual steps and it is essential to lly understand their application. The chapter begins with a discussion on obtaining a root locus lot with MATLAB. This is followed by a discussion of the connec- ns between the partial fraction expansion, dominant poles, and 81
  • 45. U L Chapter 6. Root Locus Method ti 2. Obtaining a Root IJoc.tm I'lot 83 the closed-loop system response. Root sensitivity is covered in the final section. The functions covered in this chapter are rlocus, rlocfind, and residue. The functions rlocus and rlocfind are used to obtain root locus plots, and the residue function is utilized for partial fraction expansions of rational fnnctions. 6.2 Obtaining a Root Locus Plot Consider the closed-loop control system in Figure 6.1. The closed- Figure 6.2 The rlocus Function. loop transfer function is the root locus plot associated with Eq. (6.1) are shown in Figure 6.3 c(s) K(s +l)(s +3) dong with the associated root locus plot. Invoking the rlocus func- T(s) = -= R(s) s(s+2)(s +3) +K(s +I)' tion without left-hand arguments results in an automatic generation oi the root locus plot. When invoked with left-hand arguments, the The characteristic equation can be written as plocus function returns a matrix of root locations and the associated s + l 1$ I( = 0. (6.1) The steps to obtain a root locus plot with MATLAB are as fol- 4s +2)(s +3) 5% < < + L The form of the characteristic equation in Eq. (6.1) is necessary to 1. Obtain the characteristic equation in the form given in Eq. (6.2) use the rlocus function for generating root locus plots. The general where k is the parameter of interest, and form of the characteristic equation necessary for application of the 2. use the rlocus function to generate the plots. rlocus function is P(S) Referring to Figure 6.3, we can see that as K increases, two 1+k-=o, ~(5.1 (6.2) ranches of the root locus break away from the real axis. This means that for some values of K, the closed-loop system character- where k is the parameter of interest to be varied from 0 < k. _< co. istic equation will have two complex roots. Suppose we want to find The rlocus function is shown in Figure 6.2. The steps to obtaining the value of K corresponding to a pair of complex roots. We can use the rlocfind function to do this, but only after a root locus has been R(s) G(s)= s ( s + ~ ) obtained with the rlocus function. Executing the rlocfind function Cfs) will result in a cross-hair marker appearing on the root-locus lot. You move the cross-hair marker to the location on the locus of in- 1 H (s)= - terest and hit the enter key. The value of the parameter K and the selected point will then be displayed in the command display. The s + 3 use of the rlocfind function is illustrated in Figure 6.4. Continuing our third-order root locus example, we find that when Figure 6-1 Closed-Loop Control System with Unspecified Gain I(. I( = 20.5775, the closed-loop transfer function has three poles and
  • 46. Chapter 6'. Ilool, 1,or:rru Method ................................. ,>p=[l I]; q=[l 5 6 01; [r,k]=rlocus(p,q); plot(r,'xl) Figure 6.3 The Root Locus for the Characteristic Eq. (6:l). two zeros at ( -2.0505 +4.3227i poles :s = -2.0505 - 4.3227i ), z e m : s = ( I : ) . -3989 Considering the closed-loop pole locations only, we would expect that the real pole at s = -.8989 would be the dominant pole (see MCS, p. 166). To verify this, we can study the closed-loop system response to a step input, R(s)= l / s . For a step input we have C ( s )= 20.5775(s +l ) ( s+3) 1 S ( S +2)(s+3) +20.5775(s +1) ' s' (6.3) Generally, the first step in computing c(t)is to expand Eq. (6.3) in a partial fraction expansion (see MCS, pp. 45-52). The residue (i.2. Obtaining a Root l,oc:~~* l'11)l 85 Real Axis ap=[l I]; q=[l 5 6 01; rlocus(p,q) ~rlocfind(p,q) Select a point in the grap ics win ow selected-point = -2.0509 + 4.32281 ans = Figure 6.4 Using the rlocfind Function. function can be used to expand Eq. (6.3), as shown in Figure 6.5. The residue function is described in Figure 6.6. The partial fraction expansion of Eq. (6.3) is Comparing the residues we see that the coefficient of the term cor- responding to the pole at s = -.8989 is considerably smaller than the coefficient of the terms corresponding to the complex-conjugate poles at s = -2.0505 & 4.3227i. From this we expect that the in- fluence of the pole at s = -8989 on the output response c(t) is
  • 47. >>K=20.5775;nurn=K*[l 4 31; den=[l 5 6+K K]; nstep(nurn,den), grid ?
  • 48. Figure 6.8 Converting a Partial Fraction Expansion Back to a Ra- tional Function. response. The main contributors to the transient response are the complex-conjugate poles at s = -2.0505 f-4.32282'. One final point regarding the residue function. You can convert the partial fraction expansion back to the polynomials num/den, given the residues (T), the pole locations (p), and the direct terma (k), with the command shown in Figure 6.8. 6.3 Sensitivity and the Root Locus The roots of the characteristic equation play an important role in defining the closed-loop system transient response. The effect of parameter variations on the roots of the characteristic equation is a useful measure of sensitivity. The root sensitivity can be defined to be dTi - aklk' (6.4) We can utilize Eq. (6.4) to investigate the sensitivity of the roots of the characteristic equation to variations in the parameter k. If we change k by a small finite amount Ak, and evaluate the modified root T ; +AT;,it follows from Eq. (6.4) that Ar; s; = - Aklk' (6.5) The quantity 5'2 is a complex number. Referring back to the third- order example in the previous section, if we change K a factor of 5%, w(, find that the dominant complex-conjugate pole at s = -2.0505+ .I .:1228i changes by wllcn K changes from K = 20.5775 to K = 21.6064. From Eq. (6.5), if, follows that 'I'lle sensitivity S ; can also be written in the form ~ 'I'he magnitude and direction of S;' provides a measure of the root ncmsitivity. The script used to perform the above sensitivity calcu- lations is shown in Figure 6.9. The root sensitivity measure may be useful for comparing the ~c~nsitivity for various system parameters at different root locations. Ilowever, the root sensitivity measure may not be that useful when titilized in the design process. It is primarily an analysis measure. fsensitivity.rn % Compute the system sensitivity to a parameter % variation % K=20.5775; den=[l 5 6+K K]; rl=roots(den); % . . :: ss61drjnpa inx.;:,;, dk=1.0289; . . . . . : : . . % Km=K+dk; denm=[l 5 6+Km Km]; rZ=roots(denm); dr=rl -r2; % 4 - a fmfij::.;j,, S=dr/(dk/K); 4 . .. . . .. ...... .... . ... . . . .. .. . . Figure 6.9 Sensitivity Calculations for the Root Locus for a 5% Change in K = 20.5775.
  • 49. Chapter Notes - Root - Locus Met - apter 7 equency Response Methods .1 Introduction he frequency response of a system is the steady-state output re- ponse due to a sinusoidal input signal. In the previous chapters e have discussed the system response to various other test signals ncluding steps, ramps, parabolas, and impulses. In this chapter, we ill investigate the response of systems to sinusoidal inputs. The frequency response methods are based on considering the esponse of linear systems to sinusoidal input test signals as the fre- uency of the sinusoidal test signal varies. A linear, time-invariant ystem has the characteristic that, in the steady-state, the output esponse due to a sinusoidal input differs from the input only in magnitude and phase. The transfer function describing the sinu- soidal behavior of the system is obtained by replacing s with jw in the system transfer function G(s). Then, for a fixed w, G(jw) is a complex number with a magnitude and phase. The magnitude and phase of G(jw) can be represented graphically as w varies. This type of graphical representation is known as a Bode diagram. It is possible to develop control system performance specifications in the frequency domain so that an effectivecontrol system design method- ology using the Bode diagram can be used. The chapter begins with an introduction to the Bode diagram. Subsequently, the connection between the frequency response and performance specifications in the time-domain is discussed. The 91
  • 50. !)2 (:ll:Vler 7. frequency Response Methods 93 clla~)ter concludes with an illustrative example to gain experience ,,llillyze control systems. It is essential to develop the capability to dcsignjng a control system in the frequency domain, ,ll,l,nually obtain approximate Bode diagrams. There is no substitute The functions covered are bode and logspace. The bode func- I,,!. a clear understanding of the underlying theory. tion is used to generate a Bode diagram, and the logspace function A ~~d~ diagram is obtained with the bode function shown in generates a logarithmically spaced vector of frequencies utilized by ~ " i ~ ~ ~ ~ 7.2. The Bode diagram is automatically generated if the the bode function. function is invoked without left-hand arguments. Otherwise7 (,I~(! magnitude and phase characteristics are placed in the workspace 7 . 2 Bode Diagram t,l,rough the variables mag and phase. A Bode diagram is obtained the plot function using mag, phase, and w. The vector w Suppose we have the transfer function (see MGS, p. 321 c:ontainsthe values of the frequency in radians/= at which the 5(1 +0.1s) Ijode diagram will be calculated. If w is not specified, MATLABwiu G(s) = (7.1) lLlltomatically choose the frequency values by placing more points in s(l +0.5s)(l +3 s +$32) ' I.c;gions where the frequency response is changing quickly. Since the The diagram corresponding to Eq. (7.1) is shown in Figure 7.1. ljode diagram is a log scale, if you choose to specify the frequencies The diagram consists of the logarithmic gain in dB versus in one explicitly,it is desirable to generate the vector w using the logspace function. The logspace function is shown in Figure 7.3. plot and the phase 6(w) versus w in a second plot. The manual ~h~ ~~d~ diagram in Figure 7.1 is generated with the commands steps for sketching an approximate Bode diagram are given in MCS, sl,own in Figure 7.4. The bode function automatically selected the PP. 308-317, As with the root locus plots, it will be tempting to on MATLAB to obtain your Bode diagrams. ~~~~t MATLABasone tool in your tool kit that you can use to design and Figure 7 . 1 The Bode Plot Associated with Eq. (7.1). Figure 7.2 The bode Function. Frequency(radlsec)
  • 51. 7.9, SpecUlcstionr in the Fkquency Domain 95 n points between 10"and lob den-conv(f 1,c,onv(f2,f3)); Figure 7.4 The Script for the Bode Diagram in Figure 7 . 1 . quency range as w = 0.1 to 1000 rad/sec. This range is user- eepi,ngin mind our goal of designi jfications given in the time domain to those given in the frequency domain depend upon approximation of the system by a second-order system with the poles being the system dominant roots. This aP- proximation is discussed in MCS, pp. 241-255. Consider the second-order system shown in Figure 7.5. The C(s) Frequency r~wsecl Figure 7.3 The logspace Function. Figure 7.5 Single-Loop Second-Order Feedback System.
  • 52. clos(.tl-loop transfer function is I The Bode diagram magnitude characteristics associated with the closed-loop transfer function in Eq. (7.2) are shown in Figure 7.6. The relationship between the resonant frequency,w,, the maximum of the frequency response, MPY,and the damping ratio, (,and the natural frequency, w,, is shown in Figure 7.7 (and in Figure 7.10 in MCS, p.316). The information in Figure 7.7 will be quite helpful in designing control systems in the frequency domain while satisfying time-domain specifications. We have seen that we can relate frequency-domain specifications to time-domain specifications by using the information contained in performancespedflcations time relatedto frequency dampingratio w M~~ rise time overshoot w Mp, Figure 7.6 Second-Order Closed-Loop System Characteristics. zeta zeta NOTE: [mp(l),l]-max(mag) stores the Index of the maximum mag in the variable I. Figure 7.7 The Relationship Between (MpY,w,)and ((',w,) for a Second-Order System.
  • 53. Chapter 7. Frequency Response Methods 7.4. Exarnpk:: Errgrnvir~gMacl~ine System the closed-loop Bode diagram. Stability is an important issue that can be addressed in the frequency domain by considering the open- loop transfer function. This topic will be addressed in the next chapter. 7.4 Example: Engraving Machine System Consider the block diagram model in Figure 7.8. This example can be found in MCS,pp. 332-335. Our objective is to design I( so that the closed-loop system has an acceptable time response to a step command. A functional block diagram describing the frequency domain design process is shown in Figure 7.9. First we choose K = 2 and subsequently iterate on K if the performance is unacceptable. A script, shown in Figure 7.10, is used in the design. The value of K is defined at the command level. Then the script is executed and the closed-loop Bode diagram is generated. The values of M,, and wr are determined by inspection from the Bode diagram. Those values are used in conjunction with Figure 7.7 to determine the corresponding values of C and w,. Given the damping ratio, C, and the natural frequency, w,, the settling time and percent overshoot are estimated using the formulas 4 T83 -, P.O. =100exp -5. Cwn m' If the time-domain specificationsare not satisfied, then we adjust I( and iterate. The values for <and w, corresponding to I< = 2 are C = 0.29 and w, = 0.88. This leads to a prediction of P.O. = 38% and T, = 16 Motor, screw, Contrdlu and scribe holder initial gain K - . A - - - s @+I) (s+2) Check time domain specs *us) If satisfied, then exit and continue analysis. Figure 7.8 Engraving Machine Block Diagram Model. 1 Close&loo~Bode diagram Freq. tradlsecl DetermineM~~ andm. I I I Establish relationshipbaween frequency domain specs and time danain specs 3.q : I 1 1 2 : I .....: ... .. ..... ................. zeta Determine a n and <. Figure 7.9 Frequency Design Functional Block Diagram for the Rnvravine Machine.
  • 54. Chapter 7. Frequency Response Methods , >>K=2;engravescript1 mp = 1.8371 wr = 0.8171 I " manud step Determine 0, and 4 from Figure 7.10 >> e i n MCS, p. 316 using Up, anc 0 , . >> I I QMdc spew and iterate, it nccesaary. Figure 7.10 Frequency Design Script for the Engraving Machine. I 7.4. Example: fihgravirrg Machine System nt.conds. The step response, shown in Figure 7.11, is a verification I,l~at the performance predictions are quite accurate and the closed- loop system performs adequately. In this example, the second-order system approximation is rea- ~onable and leads to an acceptable design. However, the second- order approximation may not always lead directly to a good design. I'hrtunately, with MATLAB we have the possibility to construct an interactive design facility that can assist us in the design process by reducing the manual computational loads while providing easy access to a host of classical and modern control tools. Time[sec] 1vestep.m :2; num=[K]; den=[l 3 2 K]; [0:0.01:20]; =I .02*ones(length(t),l); . . . . . . . . . . . . . . :.:: ... . . . . : . . . . . . ...... . . . :..: , ...... .-*,<~ 2 2 : .-$-.&..L->2 -*::..: ); ~ 9 : ~ n a . € I ~ . ~ y y ~ y . .. .. .... I=1.38*ones(length(t),l); :3nG..kdAf ..... ........ ! i : ,. ..!$; . ..... . --. - plot(t,y,t;l,t,lu,t,ll), grid xlabel('Time [sec]'), ylabel('c(t)') Figure 7.11 Engraving Machine Step Response for I( = 2.
  • 56. 104 (!l~nl~l.rr 8. SLa.bilityin thc Ekc:clucr~cyDornaitl 8.2 Nyquist Plots The Nyquist stability criterion is based on Cauchy's theorem, which is concerned with mapping contours in the complex s-plane. Con- sider the system in Figure 8.1. The closed-loop transfer function and the characteristic equation is All of the zeroesof F(s) must liein the left-hand s-plane for stability. We choose a contour, l ' , , in the s-plane which encloses the entire right-hand s-plane, and plot rpin the F(s)-plane and determine the number of encirclements of the origin. Equivalently, we can plot rp in the P(s)-plane and determine the number of encirclements of the -1 point, where P(s)= F(s) - 1. The Nyquist stability criterion can be stated as follows: A feedback control system is stable if and only if, for the contours rp,the number of counterclockwise encir- clements of the (-1,O) point is equal to the number of poles of P(s)with positive real parts (see MCS, p. 362). The plot of rp is the Nyquist plot. It is generally more difficult to Controller L - 1 Figure 8.1 Single-Loop Feedback Control System. N.2. Nyquist Plots 105 generate the Nyquist plot manually than the Bode diagram. How- vver, we can use MATLAB to generate the Nyquist plot rather easily. The Nyquist plot is generated with the nyquist function, as ~hown in Figure 8.2. When nyquist is used without left-hand argu- ments, the Nyquist plot is automatically generated; otherwise, you must use the plot function to generate the plot using the vectors re and im. One cautionary remark regarding Nyquist plots: Some time in lhe course of using the nyquist function you may find that your Nyquist plot looks strange or that some information appears to be missing. It may be necessary in these cases to use the axis func- tion to override the automatic scaling and use the nyquist function with left-hand arguments in conjunction with the plot function. In this way you can focus in on the -1 point region for your stability analysis, as illustrated in Figure 8.3. , ,Real Axis Figure 8.2 The nyquist Function.
  • 57. 106 Chaptar 8. Stability in the frequency Domain 0.1 n.ns .................................... :..... %axis([-1.O,.l ,-0.1 ,0.1I); %plot(re,im),grid Figure 8.3 The nyquist Function with Manual Scaling. ,b Up to this point we have been consideringabsolute stability only.,'/ In other words, our concern has been whether a system is stable not. However, relative stability measures of gain and phase can be determined from both the Nyquist plot and the Bode dia- * gram. The gain margin is a measure of how much the system gain j would have to be increased for the GH(jw)locus to pass through the (-1,O) point, thus resulting in an unstable system. The phase margin is a measure of the additional phase lag required before the system becomes unstable. Gain and phase margins can be deter- mined from both the Nyquist plot and the Bode diagram. Consider the system shown in Figure 8.4. Relative stability can h i Figure 8.4 A Closed-Loop Control System Example for Nvnni-t and Bode with Relative Stability. 8.2. Nyquist Plots 107 Figure 8.5 The margin Function. be determined from the Bode diagram using the margin function. The marginfunction is invoked in conjunction with the bodefunc- tion to compute the gain and phase margins. The margin function is shown in Figure 8.5. If the margin function is invoked without left-hand arguments, the Bode diagram is automatically generated with the gain and phase margins labeled on the diagram. This is illustrated in Figure 8.6 for the system that is shown in Figure 8.4. The script to generate the Nyquist plot for the system in Fig- ure 8.4 is shown in Figure 8.7. In this case, the number of poles of GH(s)with positive real parts is zero and the number of counter- clockwise encirclements of -1 is zero; hence the closed-loop system is stable. We can also determine the gain and phase margins, as indicated in Figure 8.7.
  • 58. 108 CJ~q>l,c:r. 8. Stability in the frequency Domain * - ~ Frequency (radlsec) I 1 0 - 1 1 w 1 0 ' Frequency (radlsec) Figure 8.6 The Bode Diagram for the System in Figure 8.4 with Gain and Phase Margins. 8.2. Nyquist Plots GainMargin =3.017 Phase Margin=49.41 1.51 I % Plot Nyquist and compute Gain and Phase % Margins for GH(s) = 0 . 5 / ~ ~ 3 + 2 ~ ~ 2 + s + 0 . 0 5 I ," [rnag,phase,w]=bode(num,denf [Gm,Pm,Wcg,Wcp]=margin(mag,phase,w); % nyquist(nurn,den) Ci~~&":m~~Psc: .::.:, ' Phase Margin = ',numZstr(Pm)]) . . . . . . . . . . . . . . . ':m~~~ns.~.prcat.::::.ii:i:i:;: i; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Figure 8.7 The Nyquist Plot for the System in Figure 8.4 with Gain and Phase Margins.
  • 59. 110 Ch&pl,ar8. Stability in the frequency Domain 8.4. Examples 111 8 . 3 Nichols Charts Another frequency-domain plot that can be used in the design an is automatically generated, otherwise you must use nichols in con- junction with the plot function. A Nichols chart grid is drawn on the existing plot with the ngrid function. nichols but, unless you desire a Bode plot with gain and pha Phase (deg) axis([-210,0,-24,361); nichols(num,den,w); Figure 8.9 Nichols Chart for Eq. (8.1). Nichols chart, shown in Figure 8.9, is for the system 1 G(jw) = j w ( j u +1)(0.2jw+1)' (8.1) 8.4 Examples EXAMPLE 8.1 Liquid Level Control System Consider a liquid level control system described by the block diagram Figure 8.8 The nichols Function. shown in Figure 8.10 (see MCS, pp. 387-388). Notice that this
  • 60. 112 Chapter 8. Stability in the Fkequency Domain 113 Actuator Tank Substituting Eq. (8.3) into Eq. (8.2) we have 31.5(0.0743s2- 0.4460s +0.8920) ( S +1)(30s+I)(: +$ +1)(O1O743s2 +0.4460s +0.8920) Now we can build a script to investigate the relative stability of the nystem using the Bode diagram. Our goal is to have a phase margin ol 30 degrees. The associated script is shown in Figure 8.12. To make the script interactive, we let the gain K (now set at K = 31.5) be variable and defined outside the script at the command level. Figure 8.10 Liquid Level Control System. 'I'hen we set K and run the script to check the phase margin and iterate if necessary. The final selected gain is I< = 16. Remember lhat we have utilized a second-order Pad6 approximation of the time system has a time delay. The loop transfer function is given by delay in our analysis. EXAMPLE 8 . 2 Remote Controlled Battlefield Vehicle (S +1)(30s+I)($ + +1) Sincewe want to use MATLABin our analysis, we need to ch Consider the speed control system for a remotely controlled battle- Eq. (8.2)in such a way that GH(s)has a transfer function form w field vehicle shown in Figure 8.13 (see MCS, pp. 392-402). The de- polynomials in the numerator and denominator. To do this sign objective is to achieve good control with low steady-state error make an approximation to e-aT with the pade function. The pade and low overshoot to a step command. We will build a script to allow function is shown in Figure 8.11. For example, suppose our ti us to perform many design iterations quickly and efficiently. First, delay is T = 1 second and we want a second-order approximati let's investigate the steady-state error specification. The steady- n = 2. Then, using the pade function we find that state error, e,,, to a unit step command is 1 e-' NN 0.0743s2 -0.4460s +0.8920 ess = 1 +K / 2 . (8.4) 0.0743s2+0.44609 +0.8920' The effect of the gain K on the steady-state error is clear from Orderof approximation Eq. (8.4). If K = 20, the error is 9% of the input magnitude. If I< = 10, the error is 17% of the input magnitude, and so on. Now we can investigate the overshoot specification in the fre- quency domain. Suppose we demand that the percent overshoot be less than 50%. Solving P.O. % 100exp-c . 1 - 5 50 ( 2 0.215. Figure 8.11 The pade Function. Referring to Figure 7.7 (or MCS, p.316) we find that M , , 5 2.45.
  • 61. Chapter 8. Stability in the frequency Domain 50 8 0 . E J -50 0 -loo -150 10-3 10-1 100 1 0 1 Frequency (raws=) Frequency(raws=) % Liquid Control System Analysis num=K*[0.0743 -0.4460 0.89201; dl-[I I]; d2=[30 I]; d3=[1/9 1/3 11; d4=[ 0.0743 0.4460 0.89201; den=conv(dl ,conv(d2,conv(d3,d4))); % w=Iogspace(-2,1,400); [mag,phase,w]=bode(num,d Figure 8 . 1 2 Bode Diagram for the Liquid Level Control System. 115 Figure 8.13 Battlefield Vehicle Speed Control System. We must keep in mind that the information in Figure 7.7 is for ond-order systems only and can be used here only as a guideline. now computethe closed-loop Bode diagram and check the values f M . Any gain K for which M,, < 2.45 may be a valid gain for our design, but we will have to investigate further to include step responses to check the actual overshoot. The script in Figure 8.14 aids us in this task. In keeping with the spirit of the design steps in MCS, pp. 392-402, we investigate further the gains K = 20,10, and .44 (even though M , , > 2.45 for K = 20 ). We can plot the step esponses to quantify the overshoot, as shown in Figure 8.15. Alternately, we could have used a Nichols chart to aid the design process. This is shown in Figure 8.16. The results of the analysis are summarized in Table 8.1 for K = 20,10, and 4.44. Suppose we choose K = 10 as our design gain. 'I'hen we obtain the Nyquist plot and check relative stability. This is shown in Figure 8.17. The gain margin is GM = 49.56 and the phase margin is PM = 26.11'. Table 8.1 Actual Response for Selected Gains. - K 4.44 10 20 Percent overshoot 5% 30% 50% Settling time 3.5 5 6 Peak time 1.4 1.0 0.7 e,, 31% 17% 9%
  • 62. 116 Chapter 8. Stability in the Frequency Domain X.4. EXILNIP~~R 117 1.6 1.4 1.2 1 s 0.8 U 0.6 0A 0.2 O 0 1 2 3 4 5 6 7 8 9 1 0 frequency [rad/sec] time [sec] batt1estep.m [nums,dens]=series(numgc,dengc,numg,deng); [num,den]=cloop(nums,dens); [mag,phase,w]=bode(num,den,w); if i==l ,magl=mag; phase1=phase; K=10; end if i==2, mag2=mag; phaseZ=phase; K=4.44; end if i-3, mag3=mag; phase3=phase; end Figure 8.14 Remotely Controlled Battlefield Vehicle Closed-Loop System Bode Diagram Script. Figure 8.15 Remotely Controlled Battlefield Vehicle Step Re- sponse. if i==3, y3=y; end
  • 63. G a i n Margin =49.56 Phase Margin = 26.11 5! -5 -2 -1 0 1 2 3 4 5 Real Axis % Remotely Controlled Battlefield Vehicle % Nyquist plot for K=10 % numgc=l 0*[l 21; dengc=[l 11; numg=[l]; deng=[l 2 41; [num,den]=series(numgc,dengc,numg,deng); % [mag,phase,w]=bode(num,den); [Gm,Pm,Wcg,Wcp]=margin(mag,phase,w); % nyquist(num,den); title(['Gain Margin = ',numZstr(Gm), ... ' Phase Margin = ',numZstr(Pm)]) Figure 8.17 Nyquist Chart for the Remotely Controlled Battlefield Vehicle with I< = 10.
  • 64. 120 Chapter 8. Stability in the Frequency Domain Notes Chapter 9 State-Space Methods f E 9.1 Introduction In the previous chapters we considered wntrol system design and analysis in the frequency domain. We utilized the Laplace trans- i form to transform the linear, constant coefficient differential equa- tion model into an algebraic expression in terms of the complex variable s. Then we operated on our system in input-output (or transfer function) form In this chapter we begin to look at wntrol system design and analysis in the time domain. In contrast to the frequency-domain approach, the time-domain method utilizes a state-space represen- tation of the system model, given by The vector z is the state of the system, A is the constant n x n system matrix, B is the constant n x m input matrix, D is the constant p x n output matrix and H is a constant p x m matrix. The number of inputs, m, and the number of outputs, p, are taken to be one since we are considering only single-input, single-output problems. Therefore c and u are not bold variables.
  • 65. 122 Chapter 9. State-Space Methods Figure 9.1 The State-Space Representation bode Function. The main elements of the state-space representation in Eq. (9.1) are the state vector r and the constant matrices (A,B,D , H ) . Since the main computational unit in MATLAB is the matrix, the state-space representation lends itself well to the MATLAB envi- ronment. In fact, MATLAB covers so many aspects of statespace methods that we will not be able to discuss them all here. The new functions covered in this chapter are toss and ss2tf. Most of the functions covered in the previous chapters also apply here. For example, the the bode function can be utilized with a state-space model, as shown in Figure 9.1. The same idea ap- plies to series, parallel, feedback, cloop, printsys, minreal, step, pzmap, impulse, him, rlocus, rlocfind, residue, bode, nyquist, and nichols. 9.2 Model Relationships Given a transfer function we can obtain an equivalent state-space representation, and vice versa. MATLAB has two functions that convert systems from transfer function to state space and back. The function t o s s converts a transfer-function representation to a state-space representation; the function ss2tf converts a state-space representation to a transfer function. These functions are shown in Figure 9.2. r 1 Figure 9.2 Linear System Model Conversion. For instance, consider the third-order system I We can obtain a state-space representation using the tf2ss function as shown in Figure 9.3. The state-space representation of Eq. (9.2) is given by Eq. (9.1) where and D = [ 2 8 6 1 , H=[O]. Notice that the printsys function lists the system matrices as a, b, c, d. The conversion to our notation is as follows:
  • 66. 124 Chapter 9. State-Space Methods 1.3. Stahilif,y of ,S,y~It.rr~?i ill t11(, 'I'irrre Domain 125 convort.m 9.3 Stability of Systems in the Time Domain % Convert G(s) = (2sA2+8~+6)/(sA3+8sA2+16~+6) % to a state-space representation % num=[2 8 6 1 ; den-I1 8 16 61; [A,B,D,H]=tf2ss(num,den); printsys(A,B,D,H) Suppose we have a system in state-space form as in Eq. (9.1). The .itability of the system can be evaluated with the characteristzc equa- Iton associated with the system matrix A. The characteristic equa- t ion is det(sI -A) = 0. (9.3) The characteristic equation is a polynomial in s. If all of the roots of the characteristic equation have negative real parts (i.e., Re(s,) < O,Vi), then the system is stable. When the system model is given in the state-space form we must >>convert calculate the characteristic polynomial associated with the A ma- trix. In this regard we have several options. We can calculate the a = characteristic equation directly from Eq. (9.3)by manually comput- x1 ~2 ~3 ing the determinant of ( s I - A). Then we can compute the roots x l -8.00000 -16.00000 -6.00000 using the roots function to check for stability, or alternatively, we ~2 1.00000 0 0 can utilize the Routh-Hurwitz method to detect any unstable roots. ~3 0 1.00000 0 Unfortunately, the mmual computations can become lengthy, espe- cially if the dimension of A is large. We would like to avoid this b = manual computation if possible. As it turns out, MATLAB can u1 assist in this endeavor. x1 1.00000 The poly function described in Chapter 2 can be used to com- ~2 0 pute the characteristic equation associated with A. Recall that poly ~3 0 is used to form a polynomial from a vector of roots. It can also be used to compute the characteristic equation of A, as illustrated in C = Figure 9.4, wherein input matrix, A, is x1 x2 x3 Y l 2.00000 8.00000 6.00000 -8 -16 -6 d = u1 A = [ Y :I 0 and the associated characteristic polynomial is Y l s3 +8s' +16s +6. Figure 9.3 Conversion of Eq. (9.2) to a State-Space Representa- tion. If A is an n x n matrix, poly(A) is the characteristic equation represented by the n +1element row vector whose elements are the coefficients of the characteristic equation.
  • 67. Chapter 9. State-Space Method2 *A=[-8 -1 6 -6;l0 0;O 1 01; >>p=poly(A) Characteristicpolynomial I Figure 9.4 Computing the Characteristic Equation of A with the poly Function. EXAMPLE 9.1 Automatic Test System The state-space representation for the automatic test system (see MCS, pp. 462-465) is where 1 Our design specifications are (i) step response with a settling time less than two seconds, and (ii) overshoot less than 4%. We assume that the state variables are available for feedback so that the control 9.3. Stability of Sy.rlcmx in the Time Domain 127 is given by We must select the gains K,K1,Kz and K3 to meet the performance specifications. Using the design approximation 4 T,M -< 2 and P.O. M 100exp-C * I ~ < 4, Cwn we find that C > 0.72 and w, > 2.8. This defines a region in the complex plane in which our dominant roots must lie to have any chance of meeting the design specifica- , tions. Substituting Eq. (9.5) into Eq. (9.4) yields where A* is the revised A matrix. The characteristic equation asso- ciated with Eq. (9.6) can be obtained by evaluating det(s1-A*) = 0. i This results in If we view KK3 as a parameter and let = 1, then we can write Eq. (9.7) as follows: We place the zeros at s = -4 f 2j in order to pull the locus to the left in the s-plane. Thus our desired numerator polynomial is sa +8s +20. Comparing corresponding coefficients leads to K3 +Kz 1 = 8 and -= 20. K3 1(3 Therefore Kz = 0.35 and K3 = 0.05. We can now plot a root locus with KK? as the parameter, as shown in Figure 9.5. The
  • 68. 128 Chapter 9. State-Space Method8 9.4. 'I>;III(! I~C-SI)IIII;+V 129 Figure 9.6 Step Response for the Automatic Test System. characteristic equation, Eq. (9.7), is s2+8s +20 + 1(1c3s(s +l)(s+5) = 0. -10 -8 -6 -4 -2 0 Real Axis The selected gain, KK3 = 12, lies in the ~erformanceregion, as shown in Figure 9.5. The rlocfind function is used to determine the value of I(K3 at the selected point. The final gains are a~tolocus.m Ii' = 240.00 K, = 1.00 % Root ~OCUS script for the Automatic Test System % including performance specs regions K2 = 0.35 num=[l 8 201; den=[l 6 5 01; K3 = 0.05 cig; rlocus(num,den); hold on The controller design results in a settling time of about 1.8 seconds % and an overshoot of 3%, as shown in Figure 9.6. zeta=0.72; wn=2.8; x=[-1 0:O.l :-zeta*wn]; y=-(sqrt(1 -zetaA2)/zeta)*x; xc=[-1 0:O.l :-zeta*wn];c=sqrt(wnA2-xc.A2); plot(~,y,':',x,-y,':',xc,c,':',xc,-c,':') 9.4 Time Response The time response of the system in Eq. (9.1) is given by the solution to the vector differential equation Figure 9.5 Root Locus for the Automatic Test System. t z(t)= exp(At)z(O) +1exp[A(t - r)]Bu(r)dr. (9.8)
  • 69. 130 Chapter 9. State-Space Methods The matrix exponential function in Eq. (9.8) is the state transition matrix, q5(t), where +(t) = exp(At). We can use the function expm to compute the transition matrix for a given delta time, as illustrated in Figure 9.7. The expm(A) fun^ tion computes the matrix exponential whereas the exp(A) function returns e0*, for each of the elements a,, E A. b The time response of the system in Eq. (9.1) can be obtained by using the lsim function. The lsim function can accept as input nonzero initial conditions as well as an input function. This is il- lustrated in Figure 9.8 for the RLC network (see MCS, Chapter 9) described by the state-space representation 0 -2 A = [, -3] , B = [:I , D = [ 1 01 ,and H=O. The initial conditions are xl(0) = xz(0) = 1and the input u(t) = 0. If we can compare the results obtained by the lsim function and by multiplying the initial condition state vector by the state transition matrix, we find exactly the identical results. At t = 0.2 the state transition matrix is given in Figure 9.7. The state at t = 0.2 is predicted by the state transition methods to be 0 9671 -0.2968 0.6703 ( )t=o.a = [0:1484 0.5219 ] ( )t=o = (0.6703 )' The state at t = 0.2 is also predicted with the lsim function to be xl(O.2) =~ ~ ( 0 . 2 ) = 0.6703. Figure 9.7 Computing the State Transition Matrix for a Given n . 1 ~ . m >>A=[O-2; 1 -31; dt=0.2; Phi=expm(A*dt) Phi = 0.9671 -0.2968 0.1484 0.5219 9.4. Time Response 131 0:1 0:2 0:3 0:4 0:5 0:6 0 1 7 0:8 0:9 time [sec] 01 I 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 time [secl t=[0:0.01:1 I; subplot(21 I), plot(t,x(:,l)) xlabel('time [sec]'), ylabel('x1') subplot(212), plot(t,x(:,2)) xlabel('tirne rsecl'), vlabel('x2') Figure 9.8 Computing the Time Response for Nonzero Initial Con- ditions and Zero Input.
  • 70. Chapter 9. State-Space Methc Notes Chapter 10 I Control System Design i 10.1 Introduction It is often possible to achieve stability and meet all the control sys- tem performance specifications by adjusting one or two parameters. We introduced many examples in the previous chapters illustrating design by adjusting a few parameters. However, in many cases it is necessary to add a dynamic compensator into the system. Altering a control system to meet relative stability and performance spec- ifications is called compensation. We say that our compensators are dynamic in the sense that the compensator is itself a system described by a transfer function or state-space representation with internal states. A compensator is shown in the control system in Figure 10.1. The compensator in Figure 10.1 is a cascade or series Spacecraft rotatlonal motion Compensator model . - desired - attitude Figure 10.1 A Compensated Control System for Spacecraft Rota- tional Motion.
  • 71. 131 Chapter 10. Control System Design compensator since it is placed in the feedforward path. A com- pensator placed in the feedback path is known as a feedback com- pensator. Compensators can be placed in other paths (e.g., inner feedback loops) in the control system as well. The main topic of this chapter is compensation of feedback con- trol systems. There are many approaches to compensation. We will consider lead and lag compensators and present a design exam- ple that uses both the root locus method and the Bode frequency- domain method to design the compensators. One of the most com- monly used compensators is the proportional plus derivative plus integral (PID). The PID compensator is covered in Chapter 11. 10.2 Lead Compensation Consider the series compensator K(s +z) Gc(s) = (10.1) S S P The selection of the variables K, z, and p is based on satisfying the design performance specifications. Whenever IzI < IPI the compensator in Eq. (10.1) is a lead compensator. The pole-zero diagram of the lead compensator is shown in Figure 10.2. We can : i ; o Figure 10.2 Pole-Zero Diagram of the Lead Compensator. rewrite Eq. (10.1) as where . r = l/p, a = p/z and a > 1. The maximum value of the phase lead occurs at a frequency w,, where The maximum phase angle at w,,, is + , , where a-1 sin 4 , = - a + l Consider, for example, the lead compensator The associated Bode diagram is shown in Figure 10.3. The maxi- mum value of the phase lead occurs at W", = fi= fi. The maximum phase lead is where a = 10. The phase-lead compensator is a differentiator type compen- sator. This can be seen by considering the case when [pl >> 1 2 1 . Then it follows that K Gc(s) % [;IS. We can design lead compensators with frequency-domain design techniques utilizing Bode diagrams as well as with root locus design methods. The lead compensator increases the phase margin, thus providing additional stability, and increases the system bandwidth to provide speedier dynamic response.
  • 72. Chapter 10. Control System Design 10.3. l J ~ ( ~ O I I I ~ ~ V I I N A ~ ~ ~ ~ ~ -4- Figure 10.4 Pole-Zero Diagram of the Lag Compensator. Consider, for example, the lag compensator O.l(s+10) Gc(s)= s + l . The associated Bode diagram is shown in Figure 10.5. We see that the lag compensator is an integration type compen- Figure 10.3 Bode Diagram of the Lead Compensator. sator by considering lzl >> IpI. Then 1 0 . 3 Lag Compensators K z G,(s) K +-.S Again consider the series compensator This has the same form as the widely used lag compensator K(s +z ) Gc("= s + P . KI Gc(s)= Kp+g. Whenever This is known as a proportional plus integral (PI) compensator. I P ~ < IzI The lag compensator is applicable when high steady-state ac- curacy is required. Although it is ~ossible to increase steady-state the compensator Gc(s)is a lag compensator. The pole-zero diagram accuracy by simply increasing the system gain, this often leads to of the lag compensator is shown in Figure 10.4. The lag compensator unacceptable transient response and sometimes instability. This can also be written as in Eq. (10.2)where a < 1. The maximum problem is overcome with the addition of a lag compensator and value of the phase lag occurs at properly chosen values of K,p, and z. The lag compensator de- creases the system bandwidth thus suppressing high frequency noise W, = fi= a. and slows down the transient response.
  • 73. Figure 10.5 Bode Diagram of the Lag Compensator. 10.4 Example: Rotor Winder Control System The rotor winder control system is shown in Figure 10.6 (see MCS, ; pp. 542-545). The design objective is to achieve high steady-state accuracy to a ramp input. The steady-state error to a unit ramp I $ Figure 10.6 Rotor Winder Control System. Chapter 10. Control System Design &I-/-- V Z P -" 1-10 ..,- Frequency (radlsec) 10.4. I~xxnrrrl~lr~: IlolJor.Wirrtlcr Control System input, R(s)= l/s2,is 1 ess = -, K" where Gc(s) K, = lim - --0 50 ' + t 9- - *- Of course, the performance specification of overshoot and settling time must be considered as well as steady-state tracking error. In all likelihood, a simple gain will not be satisfactory. So we will consider active compensation utilizing lead and lag compensators using both Bode diagrams and root locus plots. Our approach is to develop a series of scripts to aid in the compensator designs. .. - , . Consider first a simple gain controller, b,(s), wnere G,(s) = I(. Then, 50 esa= - K' Clearly, the larger we make K , the smaller the steady-state error e . However, we must consider the effects of increasik- '/-- IL- . -. - ---. Gds) 11g A 0 1 1 L11C transient response. This is shown in Figure 10.7. When K = 500, our steady-stateerror for a ramp is 10%but the overshoot is 70% and . - --. iider -. the settling time is around 8 seconds for a step input. We cone this to be unacceptable performance and turn to compensation. 'l'he two important compensator types that we consider are lead and lag compensators. First we try a lead compensator K(s +z ) Gc(s)= ( s + p ) I where lzl < lpl. The lead compensator will give us the capability to improve the transient response. We will use a frequency domain approach to design the lead compensator. Suppose we desire a steady-state error of less than 10%to a ramp input. Then we desire K" = 10. 4 1 s(s+ 5)(s + 10) . -C(s)
  • 74. Chapter 10. Control Systenl l)e~j8 time [sec] for i=1:4 [nums,densl=series(K(i),1,num [n~m,denl=cloop(nums,dens); [y,xI=step( Ys(:,i)=y; end % I I Figure 10.7 Transient Response for Simple Gain Controller. In addit,ioll t,o bl~c:3bc:ady-state.specifications, suppose also that we desire to mcet certain performance specifications: (i) settling time T,5 3 seconds, and (ii) percent overshoot for a step input 5 10%. Solving the approximate formulas r - 4 P.O. -100exp- "1 l-CZ - 10 and T, w -= 3 Cwn / for ( and w, yields ( = 0.5912 and w, = 2.2555. I 1 The phase margin requirement becomes I C ,$p, w -= 60 degrees. 0.01 i ! The steps leading to the final design are as follows: I 1. Obtain the uncompensated system Bode diagram with h ' = 1 I 500 and compute the phase margin. 2. Determine the amount of necessary phase lead. 3. Evaluate cu where sin 4, = 5. 4. Compute 10loga and find the frequency w, on the uncom- pensated Bode diagram where the magnitude curve is equal to -10 log cu . 5. In the neighborhood around w, on the uncompensated Bode, draw a line through the 0-dB point at w, with slope equal to the current slope plus 20 dB/dec. Locate the intersection of the line with the uncompensated Bode to determine the lead compensation zero location. Then calculate the lead compen- sator pole location as p = cuz. 6. Draw the compensated Bode and check the phase margin. Re- peat any steps if necessary.
  • 75. 142 Chapter 10. ConLrol Syslern 1)esign 7. Raise the gain to account for attenuation (l/a). 8. Verify the final design with simulation using step functions, and repeat any steps if necessary. We utilize three scripts in the design. The design scripts are shown in Figures 10.8, 10.9, and 10.10. The first script is for the uncom- pensated Bode, the next is for the compensated Bode, and the final script is for the step response analysis. The final lead compensator design is The settling time and overshoot specifications are satisfied, but K, = 5, resulting in a 20% steady-state error to a ramp input. It is possible to continue the design iteration and refine the compensator somewhat, although it should be clear that the lead compensator has added phase margin and improved the transient response as anticipated. To improve the steady-state errors we can consider the lag com- pensator. The lag compensator has the form where lp( < (21. We will use a root locus approach to design the lag compensator, although it can be done using Bode as well. The desired root location region of the dominant roots are specified by ( = 0.5912 and w, = 2.2555. The steps in the design are as follows: 1. Obtain the root locus of the uncompensated system. 2. Locate suitable root locations on the uncompensated system which lie in the region defined by ( = 0.5912 and w, = 2.2555. 3. Calculate the loop gain at the desired root location and the system error constant, Icvuncomp. frequency [rad/secl I .- ---. - - -. [num,den]=series(K,l ,nGmg,deng); camput. phsu _ I margin. w=loaspace(-l,2,200); I I semilogx(w,20*logl O(mag),w,M), grid xlabel('frequency [rad/secI1), ylabel('mag [dB]') I- I Figure 10.8 Lead Compensator: Uncompensated Bode.
  • 76. nurngc=K*[ 1 3.51; dengc w=logspace(-1,2,200); [rnag,phase,w]=bode(nurn,den,w); [Grn,Prn,Wcg,Wcp]=rnargin(rnag,phase,w); X I : Iloi.o~.Wirltl(,r (,'otllrol System 145 Time (sec) Figure 10.10 Lead Compensator: Step Response.
  • 77. 10.4. Example: Rotor Winder Control System 147 146 Chapter 10. Control System Des 4. Compute a = K"'mp where KVcomp = 10. K"""C,, 5. With a known, determine suitable locations of the comp sator pole and zero so that the compensated root locus sti passes through desired location. 6. Verify with simulation and repeat any steps if necessary. The design methodology is shown in Figures 10.11, 10.12, and 10.13 Using the rlocfind function, we can compute the gain K associate with the roots of our choice on the uncompensated root locus tha lie in the performance region. We then compute cu to ensure tha we achieve the desired h ' " . We place the lag compensator pole an zero in order not to impact the uncompensated root locus. In Fi ure 10.12, the lag compensator pole and zero are very near the origi at z = -0.1 and p = -0.01. The settling time and overshoot specificationsare nearly satisfi and K, = 10 as desired. It is possible to continue the design iterat' and refine the compensator somewhat, although it should be cl that the lag compensator has improved the steady-state errors to ramp input relative to the lead compensator design. The final compensator design is 100(s +0.1) Gc(s) = (s +0.01) . The resulting performance is summarized in Table 10.1. Table 10.1 Compensator Design Results. Controller Step overshoot Settling time (sec) Steady-state error for ramp Ic, Gain, I t ' 70% 8 10% 10 . Lead 8% 1 20% 5 Lag 13% 4 10% 10
  • 78. 148 Chapter 10. Control System Der -15 -10 -5 0 Real Axis numg=[l 1; deng=[l 15 5 0 01; numgc=[l 0.11; dengc=[l 0.011; [num,den]=series(numgc,dengc,numg,deng); axis([-1 5,1,-10,101); clg; rlocus(num,den); hold on % zeta=0.5912; wn=2.2555; x=[-l0:O. 1:-zeta*wn]; y=-(sqrt(1 -zetaAZ)/zeta)*x; xc=[-l0:O.l :-zeta*wn];c=sqrt(wnAZ-xc.AZ); plot(x,y,':',x,-y,':',xc,c,':',xc,-c,':') Figure 10.12 Lag Compensator: Compensated Root Locus. Example: Rotor Winder Control System 149 1.2, ! ! I I
  • 79. Chapter 10. Control System Dc,sixi~ Notes I Chapter 11 Robust Control Systems 11.1 Introduction Designing a highly accurate control system in the presence of plant uncertainty is a classical design problem. In the previous chapters, we have generally assumed that the plant parameters are well known and designed our control system accordingly. In practice, the plant parameters arenever precisely known and may vary slowlyover time. It is desirable to design a control system that performs adequately over a range of plant parameters. A control system is robust when it maintains a satisfactory level of stability and performance over a range of plant parameters and disturbances. In this chapter, we begin to investigaterobust control systems. In particular we consider the commonly used proportional plus deriva- Figure 1 1 . 1Feedback Control System with Reference and Distur- bance Inputs and a Prefilter.
  • 81. (!l~ilpl,(~ 11. Robust, (:on/,rol ,Syshr*tt~ti 11.2. Robust PID Controlled Systems follows: To meet the overshoot performance requirements for a step input we will utilize a cascade gain I( that will be chosen by iterative methods using the step function. This is illustrated in Figure 11.3. The step response corresponding to I( = 5 has an acceptable overshoot of 2%. With the addition of the gain K = 5, the final PID controller is We did not used the prefilter as is done in the design Example 11.5 in MCS, pp. 594-595. Instead we increased the system gain to obtain satisfactory transient response. Now we can consider the question of robustness to changes in the plant parameter co. Our investigation into the robustness of our design consists of a step response analysis using the PID controller given in Eq. (11.2) for a range of plant parameter variations of Q E [0.1,10]. The results are displayed in Figure 11.4. The script is written to compute the step response for a given Q. It might be a good idea to place the input of Q at the command prompt level to make the script more interactive. The simulation results indicate that the PID design is robust with respect to changes in Q. The differences in the step responses for Q E [0.1,10] are barely discernible on the plot. If the results showed otherwise, it would be possible to iterate on the design until an acceptable performance was achieved. There exist various control design methods that incorporate ro- bustness directly into the design process, but their presentation here is outside the scope of this text. The interactive capability of MATLABallows us to check our robustness by simulation, although this is clearly not the most desirable approach to design.
  • 82. 156 (:llapter 11. Robust Control Systcrrra 11.2. Robust PID ~oitrolled Systems 157 0.05 0.1 0.15 0.2 0.25 0.3 Time (sec) . . root locus. n gain to reduce ovanhwt. - - 1 Time (sec) Figure 11.4 Robust PID Controller Analysis with Variations in Q. Figure 11.3 Step Response for the PID Temperature Controller.
  • 83. Chapter 11. Robust Control System Notes 1 axis Controls the manual axis scaling on plots; 105 I bode Computes a Bode frequency response 92-93, 107, 110, 122 clear Removes variables and functions from memory; 6, 9 clg Clears plots from the graph window; 16 cloop Computes the closed-loop system with unity feedback; 26, 37-40, 122 conv Multiplies two polynomi- als via convolution; 26, 31-32, 152 end Terminates a for function; 75 expm Computes the matrix ex- ponential function; 130 feedback Computes the feed- back interconnection of two sys- tems; 26, 37-40, 49, 122 for Ftepeats a group of state- ments a specificnumber of times; 71, 75 format Controls the output for- mat; 9 grid Draws grid lines on. the current plot; 17 help Invokes the help facility; 22 impulse Computes the unit im- pulse response of a system; 61, 63, 122 loglog Generates an x-y plot using log-log scales; 17-18, 20 logspace Generates a logarith- mically spaced frequency vec- tor for frequency response anal- ysis; 92-95 lsim Computes the time response of a system to an arbitrary in- put and initial conditions; 61, 66, 68, 122, 130 margin Computes the gain mar- gin, phase margin, and associ- ated crossoverfrequenciesfrom frequency response data; 103, 107-110
  • 84. minreal Transfer function pole- zero cancellation; 26, 44, 122 ngrid Draws grid lines on a Nichols chart; 103, 110 nichols Computes a Nichols fre- quency response plot; 103,110, 122 nyquist Computes a Nyquist frequency response plot; 103, 105-106, 122 pade Computes an n-th order Pad6 approximation to a time delay; 103, 112 parallel Computes a parallel system connection; 26, 36-37, 122 plot Generates a linear x-y plot; 16-19, 45, 93, 105, 110 poly Returns the characteris- tic equation when the input is a matrix and returns a polyno- mial when the input is a vec- tor containing the roots of the polynomial; 26, 31, 125-126 polyval Polynomialevaluation; 26, 32 printsys Prints state-spaceand transfer function representations of linear systems in a readable form; 26, 34, 39, 40, 44, 46, 122-124 pzmap Plots the pole-zero map of a linear system; 26, 32, 122 residue Computes the residues, poles, and direct terms of a partl& 1 fraction expansion; 82, 84-86, 88, 122 rlocus Computes the root lo- cus of a linear system; 82-83, 122 rlocfind Finds the gain asso- ciated with a given set of roots on a root locus plot; 82-83,122, 129, 146, 153 roots Computes the roots of a polynomial; 26, 31, 72-73, 125 roots1 Sameas the roots func- tion, but gives more accurate answers when there are repeated roots; 26, 31, 33 shg Shows the graph window; 16 series Computes a series sys- tem connection; 26, 35-38, 40, 122, 152 semilogx Generates an x-y plot using semilog scales with the x- axis loglo and the y-axis linear; 17-18, 20 semilogy Generates an x-y plot using semilog scales with the y-axis log,, and the x-axis lin- ear; 17-18, 20 ss2tf Converts a state-space sys- tem representation to a trans- fer function representation; 122- 123 step Computes the unit step response of a system; 26, 45- 46, 63, 87, 122, 155 subplot Subdivides the graph display into sub-windows; 17, 20 tfss Converts a transfer func- tion system representation to a state-spacerepresentation; 122- 123 title Puts a title on the cur- rent plot; 17 who Lists the variables in the workspace; 7, 9-10 whos Lists the variables in the workspace including their size and type; 7, 9 xlabel Puts an x-axis label on the current plot; 17 ylabel Puts a y-axis label on the current plot; 17