CSE-Lab Manual 2015
description
Transcript of CSE-Lab Manual 2015
2015
Subject Code-2141004
Control System EngineeringLaboratory File
B.E. (Electronics and Communication)
Submitted to Department of Electronics and Communication Engineering
Sanjaybhai Rajguru College of Engineering-Rajkot.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Sanjaybhai Rajguru College of Engineering, RAJKOT
This is to certify that Mr./Ms. Of semester , Enrollment no.: has satisfactorily completed his term work in For the term ending in 2015.
Date:
Signature of Teacher Head of the Department
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Sanjaybhai Rajguru College of Engineering‐Rajkot Department of Electronics & Communication Engineering
Semester‐IV Subject: Control System Engineering (2141004)
Index
Sr. No Title Date Sign 1 Introduction to MATLAB family of programs.
2 Using 'MATLAB base program + Control System
toolbox', for control systems analysis and design.
Brief introduction to Symbolic Math toolbox.
3 Building simple Simulink simulations. Running
Simulink simulation to predict a system's
behaviour.
4 Presenting MATLAB functions to carryout block
diagram manipulations, followed by time-response
analysis. Using Simulink simulation for time-
response analysis.
5 Analysis of the system behaviour to changes in
input reference signals or disturbances using steady-
state and transient performance indices. Brief
introduction to LTI Viewer, and time response
analysis using this GUI tool.
6 Stability analysis in state space. Stability analysis
using root locus plots.
7 Design using root locus plots. Brief introduction to
SISO Design Tool, and root locus design using this
GUI tool.
8 Introducing MATLAB commands for Bode and
Nyquist plots. Stability analysis using these plots.
9 Frequency response measures from Bode plots and
Nichols chart, for unity-feedback systems.
Frequency response measures from Bode plots for
non-unity-feedback systems.
10 Design using Bode plots and Nichols chart.
Frequency response design using SISO Design
Tool.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL - 1
MATLAB Window Environment and the Base Program
Objectives:
Introduction to MATLAB family of programs
Brief introduction to MATLAB base program in an interactive "hands on" tutorial style
MATLAB, an abbreviation of MATrix LABoratory, is a high-level technical computing
environment suitable for solving scientific and engineering problems. The MATLAB family
of programs includes the base program plus a variety of application-specific solutions called
toolboxes. Toolboxes are comprehensive collections of MATLAB functions that extend the
MATLAB environment to solve particular classes of problems. In this module, the
environment provided by the base program is explored.
The MATLAB base program along with the functions from the Control System Toolbox, can
be used to analyze and design control systems problems such as those covered in this course.
Control System Toolbox includes interactive analysis and design tools called LTI Viewer,
and SISO Design Tool. The LTI Viewer uses a Graphical User Interface (GUI) to generate
and view time and frequency response plots of Linear Time-Invariant (LTI) transfer functions
and obtain measurements from these plots. The SISO Design Tool uses a GUI to provide a
convenient and interactive way to design Single-Input-Single-Output (SISO) control systems
by the conventional trial-and-error approach. We start using functions of Control System
Toolbox in module 2, and enhance its usage in later modules. Whenever MATLAB is
referred to in this course, you can interpret that to mean the base program plus the Control
System Toolbox. This, in fact, constitutes the beginning of the study of MATLAB for control
engineering. There is so much more that must be explored for additional functionality and
convenience in designing control systems and analyzing a system's behaviour.
Symbolic Math Toolbox adds symbolic mathematics capability to the MATLAB
environment. Functions and equations can be entered symbolically. Symbolic expressions can
be manipulated algebraically and simplified. Transfer functions can be entered almost as
written. Laplace transforms as well as their inverses can be entered and found in symbolic
form. An introduction to Symbolic Math Toolbox and its capabilities will be provided in
Module 2.
MATLAB's Simulink software is used to simulate systems. It uses a GUI to interact with
blocks that represent subsystems. We can position the blocks, resize the blocks, label the
blocks, specify block parameters, and interconnect blocks to form complete systems from
which simulations can be run. Simulink will be introduced in Module 3. We will enhance
usage of Simulink in later modules to study the effects of nonlinearities, and uncertainties in
model parameters on the performance of closed-loop systems.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL - 2
Control System Toolbox and Symbolic Math Toolbox
Objectives:
Using 'MATLAB base program + Control System toolbox', for control systems analysis
and design.
Brief introduction to Symbolic Math toolbox.
MATLAB is presented as an alternate method of solving control system problems. You are
encouraged to solve problems first by hand and then by MATLAB so that insight is not lost
through mechanized use of computer programs.
In Module 1, we have presented a tutorial on MATLAB window environment and some of its
basic commands. In the present module, our objective is to take a primary look at MATLAB
Control System Toolbox, which expands MATLAB base program to include control-system
specific commands. In addition, presented is a MATLAB enhancement – Symbolic Math
Toolbox, that gives added functionality to MATLAB base program and Control System
Toolbox.
Control System Toolbox
Symbolic Math Toolbox
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL – 2.1
Control System Toolbox and Symbolic Math Toolbox
Control System Toolbox
Control System Toolbox is a collection of commands to be used for control systems' analysis
and design. We will be using only some of these commands, because of the limited nature of
course profile. Description of these commands will be distributed in different modules.
In this module, we will present commands related to transfer functions and system responses.
To see all the commands in the Control System Toolbox and their functionalities, type help
control in the MATLAB command window. MATLAB will respond with >> help control
General.
ctrlpref - Set Control System Toolbox preferences.
ltimodels - Detailed help on the various types of LTI models.
ltiprops - Detailed help on available LTI model properties.
Creating linear models.
tf - Create transfer function models.
zpk - Create zero/pole/gain models.
ss, dss - Create state-space models.
frd - Create a frequency response data models.
filt - Specify a digital filter.
lti/set - Set/modify properties of LTI models.
Data extraction.
tfdata - Extract numerator(s) and denominator(s).
zpkdata - Extract zero/pole/gain data.
ssdata - Extract state-space matrices.
dssdata - Descriptor version of SSDATA.
frdata - Extract frequency response data.
lti/get - Access values of LTI model properties.
Conversions.
tf - Conversion to transfer function.
zpk - Conversion to zero/pole/gain.
ss - Conversion to state space.
frd - Conversion to frequency data.
chgunits - Change units of FRD model frequency points.
c2d - Continuous to discrete conversion.
d2c - Discrete to continuous conversion.
d2d - Resample discrete-time model.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
System interconnections.
append - Group LTI systems by appending inputs and outputs.
parallel - Generalized parallel connection (see also overloaded +).
series - Generalized series connection (see also overloaded *).
feedback - Feedback connection of two systems.
lft - Generalized feedback interconnection (Redheffer star product).
connect - Derive state-space model from block diagram description.
System gain and dynamics.
dcgain - D.C. (low frequency) gain.
bandwidth - System bandwidth.
lti/norm - Norms of LTI systems.
pole, eig - System poles.
zero - System (transmission) zeros.
pzmap - Pole-zero map.
iopzmap - Input/output pole-zero map.
damp - Natural frequency and damping of system poles.
esort - Sort continuous poles by real part.
dsort - Sort discrete poles by magnitude.
stabsep - Stable/unstable decomposition.
modsep - Region-based modal decomposition.
Time-domain analysis.
ltiview - Response analysis GUI (LTI Viewer).
step - Step response.
impulse - Impulse response.
initial - Response of state-space system with given initial state.
lsim - Response to arbitrary inputs.
gensig - Generate input signal for LSIM.
covar - Covariance of response to white noise.
Frequency-domain analysis.
ltiview - Response analysis GUI (LTI Viewer).
bode - Bode diagrams of the frequency response.
bodemag - Bode magnitude diagram only.
sigma - Singular value frequency plot.
nyquist - Nyquist plot.
nichols - Nichols plot.
margin - Gain and phase margins.
allmargin - All crossover frequencies and related gain/phase margins.
freqresp - Frequency response over a frequency grid.
evalfr - Evaluate frequency response at given frequency.
frd/interp - Interpolates frequency response data.
Classical design.
sisotool - SISO design GUI (root locus and loop shaping techniques).
rlocus - Evans root locus.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Pole placement.
place - MIMO pole placement.
acker - SISO pole placement.
estim - Form estimator given estimator gain.
reg - Form regulator given state-feedback and estimator gains.
LQR/LQG design.
lqr, dlqr - Linear-quadratic (LQ) state-feedback regulator.
lqry - LQ regulator with output weighting.
lqrd - Discrete LQ regulator for continuous plant.
kalman - Kalman estimator.
kalmd - Discrete Kalman estimator for continuous plant.
lqgreg - Form LQG regulator given LQ gain and Kalman estimator.
augstate - Augment output by appending states.
State-space models.
rss, drss - Random stable state-space models.
ss2ss - State coordinate transformation.
canon - State-space canonical forms.
ctrb - Controllability matrix.
obsv - Observability matrix.
gram - Controllability and observability gramians.
ssbal - Diagonal balancing of state-space realizations.
balreal - Gramian-based input/output balancing.
modred - Model state reduction.
minreal - Minimal realization and pole/zero cancellation.
sminreal - Structurally minimal realization.
Time delays.
hasdelay - True for models with time delays.
totaldelay - Total delay between each input/output pair.
delay2z - Replace delays by poles at z=0 or FRD phase shift.
pade - Pade approximation of time delays.
Model dimensions and characteristics.
class - Model type ('tf', 'zpk', 'ss', or 'frd').
size - Model sizes and order.
lti/ndims - Number of dimensions.
lti/isempty - True for empty models.
isct - True for continuous-time models.
isdt - True for discrete-time models.
isproper - True for proper models.
issiso - True for single-input/single-output models.
reshape - Reshape array of linear models.
Overloaded arithmetic operations.
+ and - - Add and subtract systems (parallel connection).
* - Multiply systems (series connection).
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
\ - Left divide -- sys1\sys2 means inv(sys1)*sys2.
/ - Right divide -- sys1/sys2 means sys1*inv(sys2).
^ - Powers of a given system.
' - Pertransposition.
.' - Transposition of input/output map.
[..] - Concatenate models along inputs or outputs.
stack - Stack models/arrays along some array dimension.
lti/inv - Inverse of an LTI system.
conj - Complex conjugation of model coefficients.
Matrix equation solvers.
lyap, dlyap - Solve Lyapunov equations.
lyapchol, dlyapchol - Square-root Lyapunov solvers.
care, dare - Solve algebraic Riccati equations.
gcare, gdare - Generalized Riccati solvers.
bdschur - Block diagonalization of a square matrix.
Demonstrations.
Type "demo" or "help ctrldemos" for a list of available demos.
control is both a directory and a function.
--- help for modeldev/control.m ---
MODELDEV/CONTROL
In this module, we will learn how to represent transfer functions in the MATLAB, partial
fraction expansion of rational expressions, representation of transfer functions as LTI objects,
and to obtain time domain responses of LTI systems. Important commands for this module
are:
roots – Find polynomial roots
poly – Convert roots to polynomial
polyval – Evaluate polynomial value
conv – Convolution and polynomial multiplication
deconv – Deconvolution and polynomial division
residue – Partial-fraction expansion (residues)
tf – Creation of transfer functions or conversion to transfer functions
pole – Compute the poles of LTI models
zero – Transmission zeros of LTI systems
tfdada – Quick access to transfer function data
zpkdata – Quick access to zero-pole-gain data
pzmap – Pole-zero map of LTI models
zpk – Create zero-pole-gain models or convert to zero-pole-gain format
step – Step response of LTI models
impulse – Impulse response of LTI models
lsim – Simulate time response of LTI models to arbitrary inputs
gensig – Periodic signal generator for time response simulations with lsim
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Polynomials
Consider a polynomial ‘s 3
+3 s 2 +4', to which we attach the variable name p. MATLAB can
interpret a vector of length n +1 as the coefficients of an n th
-order polynomial. Coefficients
of the polynomial are interpreted in descending powers. Thus, if the polynomial is missing
any coefficient, we must enter zeros in the appropriate places in the vector. For example,
polynomial p can be represented by the vector [1 3 0 4] in MATLAB. For example:
>> p=[1 3 0 4]
p =
1 3 0 4
Roots of the polynomial can be obtained by roots command.
>> r=roots(p)
r =
-3.3553
0.1777 + 1.0773i
0.1777 - 1.0773i
Given roots of a polynomial in a vector, a vector of polynomial coefficients can be obtained
by the command poly.
>> p=poly(r)
p =
1.0000 3.0000 0.0000 4.0000
Use the command polyval(p, s) to evaluate the polynomial represented by vector p at arbitrary value
of s. For example, to evaluate the polynomial ‘s 3 +3 s 2 +4' at , type
>> polyval(p,sqrt(2))
ans =
12.8284
The product of two polynomials is found by taking the convolution of their coefficients. The
function conv will do this for us. Consider an example of multiplying polynomial ‘s 3 +3 s 2
+4' with ‘s +2':
>> p1=[1 3 4];
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
>> p2=[1 2];
>> p3=conv(p1,p2)
p3 =
1 5 10 8
The function deconv divides two polynomials and returns quotient as well as the remainder
polynomial.
>> [q,r]=deconv(p1,p2)
q =
1 1
r =
0 0 2
where q is the quotient and r is the remainder polynomial.
Exercise 2.1
Verify the deconvolution result given in vectors q and r.
Hint: Check whether p1 = conv(q,p2) + r or not?
Exercise 2.2
Let
and . Obtain .
Consider the rational fractions of the form:
where the coefficients and are real constants, and and are integers.A fraction of
the form G(s) can be expanded into partial fractions. To do this, first of all we factorize the
denominator polynomial D(s) into first-order factors. The roots of D(s) can be real or
complex; distinct or repeated.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Let, vectors N and D specify the coefficients of numerator and denominator polynomials
and respectively. The command [A,p,K]=residue(N,D) returns residues in
column vector A, the roots of the denominator in column vector p, and the direct term in
scalar K. If there are no multiple roots, the fraction can be represented as:
If there are roots of multiplicity mr , i.e. , , then the expansion
includes terms of the form:
If , K is empty (zero).
Supplying 3 arguments A, p, and K to residue converts the partial fraction expansion back to
the polynomial with coefficients in N and D.
Consider the rational fraction:
MATLAB solution to partial fraction problem can be given by:
>> N=[10 40];
>> D=[1 4 3 0];
>> [A,p,K]=residue(N,D)
A =
1.6667
-15.0000
13.3333
p =
-3
-1
0
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
K =
[ ]
Example 2.1
Consider the function
The following MATLAB session evaluates the residues.
>> N = 13;
>> D = [1 6 22 30 13 0];
>> [A,p,K]=residue(N,D)
A =
0.0200 - 0.0567i
0.0200 + 0.0567i
-1.0400
-1.3000
1.0000
p =
-2.0000 + 3.0000i
-2.0000 - 3.0000i
-1.0000
-1.0000
0
K =
[ ]
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Exercise 2.3
Represent the matrices A, p, and K obtained in Example 2.1 in partial fraction form and convert
back to the polynomial form. Counter check your answer with MATLAB.
Exercise 2.4
Consider the rational fraction:
Obtain partial fraction form in terms of K. Solve using MATLAB for and countercheck your
answer.
Exercise 2.5
Consider the rational fraction: .
Identify the points where:
1. and
2.
Note: The roots of the numerator polynomial, i.e. , , are known as the zeros of and
the roots of the denominator polynomial, i.e. , , are known as the poles of
Transfer Functions
Transfer functions can be represented in MATLAB as LTI (Linear Time Invariant) objects
using numerator and denominator polynomials. Consider the transfer function given by
It can be represented in MATLAB as:
>> num = [1 1];
>> den = [1 3 1];
>> G = tf(num,den)
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Transfer function:
..s + 1
-----------------
s^2 + 3 s + 1
Example 2.2
The function conv has been used to multiply polynomials in the following MATLAB session
for the transfer function
>> n1 = [5 1];
>> n2 = [15 1];
>> d1 = [1 0];
>> d2 = [3 1];
>> d3 = [10 1];
>> num = 100*conv(n1,n2);
>> den = conv(d1,conv(d2,d3));
>> GH = tf(num,den)
Transfer function:
7500 s^2 + 2000 s + 100
-----------------------------------
....30 s^3 + 13 s^2 + s
To learn more about LTI objects given by tf, type ltimodels tf in MATLAB command
window. Type ltiprops tf on MATLAB prompt to learn the properties associated with an LTI
object represented by tf.
Transfer functions can also be entered directly in polynomial form as we enter them in the
notebook using LTI objects. For example, observe the following MATLAB session.
>> s=tf('s') %Define 's' as an LTI object in polynomial form
Transfer function:
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
s
>> G1=150*(s^2+2*s+7)/[s*(s^2+5*s+4)] % Form G1(s) as an LTI transfer function
% in polynomial form.
Transfer function:
150 s^2 + 300 s + 1050
---------------------------------
......s^3 + 5 s^2 + 4s
>> G2=20*(s+2)*(s+4)/[(s+7)*(s+8)*(s+9)] % Form G2(s) as an LTI transfer
% function in polynomial form.
Transfer function:
.....20 s^2 +120 s + 160
------------------------------------
s^3 + 24 s^2 + 191s + 504
The commands pole and zero calculate the poles and zeros of LTI models.
>> pole(G1)
ans =
0
-4
-1
>> zero(G1)
ans =
-1.0000 + 2.4495i
-1.0000 - 2.4495i
To extract numerator and denominator polynomials, use the function tfdata .
>> [num,den]=tfdata(G,'v')
num =
0 1 1
den =
1 3 1
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
To extract zeros and poles of transfer function simultaneously, use the function zpkdata .
>> [z,p]=zpkdata(G,'v')
z =
-1
p =
-2.6180
-0.3820
If we know zeros and poles of the system with gain constant, the transfer function of LTI
system can be constructed by zpk command. For example, to create a unity gain transfer
function G3(s) with zero at -1 and two poles at -2.618 and -0.382, follow the MATLAB
session given below.
>> G3=zpk(-1,[-2.618 -0.382],1)
Zero/pole/gain:
(s+1)
---------------------------
(s+2.618)(s+0.382)
The polynomial transfer function created with tf can be converted to zero-pole-gain model by
the command zpk and vice versa . The following MATLAB session gives the zero-pole-gain
format of LTI system represented by G(s).
>> zpk(G)
Zero/pole/gain:
(s+1)
---------------------------
(s+2.618)(s+0.382)
To observe the polynomial form of the transfer function G3(s), enter
>> tf(G3)
Transfer function:
s+1
----------------------
s^2 + 3s +1
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
To learn more about LTI objects given by zpk, type ltimodels zpk in MATLAB command
window. Type ltiprops zpk on MATLAB prompt to learn the properties associated with an
LTI object represented by zpk.
The function pzmap(G) plots the poles and zeros of the transfer function G(s) on complex
plane. When used with two left hand side arguments, [p,z] = pzmap(G), the function returns
the poles and zeros of the system in two column vectors p and z. For example:
>> [p,z]=pzmap(G)
p =
-2.6180
-0.3820
z =
-1
System Response
Step and impulse responses of LTI objects can be obtained by the commands step and
impulse . For example, to obtain the step response of the system represented in LTI object G,
enter
>> step(G)
The MATLAB response to this command is shown in Fig. 2.1.
Fig. 2.1
To obtain the impulse response, enter
>> impulse(G)
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
The MATLAB response to this command is shown in Fig. 2.2.
Fig. 2.2
Step and impulse response data can be collected into MATLAB variables by using two left
hand arguments. For example, the following commands will collect step and impulse
response amplitudes in yt and time samples in t.
[yt, t] = step(G)
[yt, t] = impulse(G)
Response of LTI systems to arbitrary inputs can be obtained by the command lsim. The
command lsim(G,u,t) plots the time response of the LTI model G to the input signal
described by u and t. The time vector t consists of regularly spaced time samples and u is a
matrix with as many columns as inputs and whose ith
-row specifies the input value at time
t(i). Observe the following MATLAB session to obtain the time response of LTI system G to
sinusoidal input of unity magnitude.
>> t=0:0.01:7;
>> u=sin(t);
>> lsim(G,u,t)
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
The response is shown in Fig. 2.3.
Fig. 2.3
Exercise 2.6
i. Obtain the response of to ramp and parabolic inputs using
lsim command.
ii. Obtain the response of to ramp and parabolic inputs using
step command.
The function gensig generates periodic signals for time response simulation with lsim
function. It can generate sine, square, and periodic pulses. All generated signals have unit
amplitude. Observe the following MATLAB session to simulate G ( s ) for 20 seconds with a
sine wave of period 5 seconds.
>> [u,t]=gensig( 'sin' ,5,20); %Sine wave with period 5 sec and duration 20 sec
>> lsim(G,u,t) %Simulate G(s) with u and t.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
The response is shown in Fig. 2.4.
Fig. 2.4
Exercise 2.7
Generate square and pulse signals with the period of 4 seconds and obtain time
response of for a duration of 30 seconds.
Example 2.3
The following MATLAB script calculates the step response of second-order system
with and various values of
t=[0:0.1:12]; num=[1];
zeta1=0.1; den1=[1 2*zeta1 1];
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
zeta2=0.2; den2=[1 2*zeta2 1];
zeta3=0.4; den3=[1 2*zeta3 1];
zeta4=0.7; den4=[1 2*zeta4 1];
zeta5=1.0; den5=[1 2*zeta5 1];
zeta6=2.0; den6=[1 2*zeta6 1];
[y1,x]=step(num,den1,t); [y2,x]=step(num,den2,t);
[y3,x]=step(num,den3,t); [y4,x]=step(num,den4,t);
[y5,x]=step(num,den5,t); [y6,x]=step(num,den6,t);
plot(t,y1,t,y2,t,y3,t,y4,t,y5,t,y6)
xlabel( 't' ), ylabel( 'y(t)' )
grid
Response through the above MATLAB script is shown in Fig 2.5.
Fig. 2.5
The following MATLAB script calculates the impulse response of second-order system
with and various values of
t=[0:0.1:10]; num=[1];
zeta1=0.1; den1=[1 2*zeta1 1];
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
zeta2=0.25; den2=[1 2*zeta2 1];
zeta3=0.5; den3=[1 2*zeta3 1];
zeta4=1.0; den4=[1 2*zeta4 1];
[y1,x,t]=impulse(num,den1,t);
[y2,x,t]=impulse(num,den2,t);
[y3,x,t]=impulse(num,den3,t);
[y4,x,t]=impulse(num,den4,t);
plot(t,y1,t,y2,t,y3,t,y4)
xlabel( 't' ), ylabel( 'y(t)' )
grid
Response through the above MATLAB script is shown in Fig 2.6.
Fig. 2.6
Right-clicking away from the curves obtained by step, impulse, and lsim commands brings
up a menu. From this menu, various time-response characteristics can be obtained and plotted
on the graph.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL – 2.2
Control System Toolbox and Symbolic Math Toolbox
Symbolic Math Toolbox
MATLAB's Symbolic Math (Symbolic Mathematics) toolbox allows users to perform
symbolic mathematical computations using MATLAB. The only basic requirement is
to declare symbolic variables before they are used. For control systems analysis and
design, symbolic math toolbox is particularly important because of the following:
1. Transfer functions and other expressions can be entered in symbolic form as
we write them in the notebook.
2. Symbolic expressions can be manipulated algebraically and simplified.
3. It is straightforward to convert symbolic polynomials to the vectors of
corresponding power-term coefficients.
4. Expressions can be ‘pretty printed' for clarity in the MATLAB command
window.
Type help symbolic on the MATLAB command prompt to see all the functionalities
available with Symbolic Math toolbox. In this section, we will learn commands of
Symbolic Math toolbox particularly useful for control engineering.
First we demonstrate the power of Symbolic Math toolbox by calculating inverse
Laplace transform. The following MATLAB session gives the steps performed during
the calculation of inverse Laplace transform of using Symbolic
Math.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Exercise 2.8
Initialize s and T as symbols. Using Symbolic Math tools, find the response of the
first- order system ,with the step excitation of strength A .
Hint: Find the inverse Laplace transform of .
Exercise 2.9
Find manually the Laplace transform of . Using Symbolic
Math tools, declare t as symbolic variable and countercheck your result. Use the
function laplace(g) to calculate the Laplace transform.
The function simple(G) finds simplest form of G(s) with the least number of terms.
simplify(G) can be used to combine partial fractions. Symbolic Math toolbox also
contains other commands that can change the look of the displayed result for
readability and form. Some of these commands are: collect(G) - collects common-
coefficient terms of G(s); expand(G) - expands product of factors of G(s); factor(G)-
factors G(s); vpa(G, places) - stands for variable precision arithmetic (this command
converts fractional symbolic terms into decimal terms with a specified number of
decimal places).
Consider the function . MATLAB response to the
simplification of using the function simplify is shown below.
>> syms s
>> G = (1/s)+(1/3)*(1/(s+4))-(4/3)*(1/(s+1))
G =
1/s+1/3/(s+4)-4/3/(s+1)
>> pretty(G)
...................1 ....................1
1/s + 1/3 ------- ...- 4/3...-------
................s + 4...............s + 1
>> pretty(simplify(G))
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
.............4
--------------------
s (s + 4) (s + 1)
In the above example, the symbolic fractions 1/3 and 4/3 will be converted to 0.333
and 1.33 if the argument places in vap(G, places) is set to 3.
>> pretty(vpa(G,3))
............0.333 ....1.33
1/s + ---------- - ----------
........... s + 4. ....s + 1.
Exercise 2.10
Consider the function . Show using Symbolic Math
tools that the simplified form of its Laplace transform is .
Basic mathematical operators +, , , and are applicable to symbolic objects also.
For example, simplification of the closed-loop system with forward gain forward-
path transfer function , and feedback-path transfer function
, is given by . This can be done using
Symbolic Math toolbox as follows
>> syms s K;
>> G = 2.5/(s*(s+5));
>> H = 1/(0.1*s+1);
>> M = K*G/(1+G*H)
M =
5/2*K/s/(s+5)/(1+5/2/s/(s+5)/(1/10*s+1))
>> pretty(M)
K
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
5/2 ------------------------------------------
/ 1 \
s (s + 5)| 1 + 5/2 ---------------------- |
\ s (s + 5) (1/10 s + 1) /
>> pretty(simplify(M))
(s + 10) K
5/2 -------------------------
3 2
s + 15 s + 50 s + 25
With Symbolic Math toolbox, symbolic transfer functions can easily be converted to
the LTI (Linear Time-Invariant) transfer function objects. This conversion is done in
two steps. The first step uses the command numden to extract the symbolic numerator
and denominator of G (s). The second step converts, separately, the numerator and
denominator to vectors using the command sym2poly . The last step consists of
forming the LTI transfer function object by using the vector representation of the
transfer function's numerator and denominator. The command sym2poly doesn't work
on symbolic expressions with more than one variable.
As an example, we form the LTI object from obtained in the above example
with .
The command poly2sym converts polynomial coefficient vectors to symbolic
polynomial.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL - 3
Simulink
Objectives:
Building simple Simulink simulations.
Running Simulink simulation to predict a system's behaviour.
The MATLAB Control System Toolbox offers functions for finding the transfer functions
from a given block diagram. However, as we shall shortly see, the simulation environment
provided by MATLAB‟s Simulink Toolkit obviates the need for block diagram reduction.
The Simulink model mimics the block diagram of a feedback control system and is used to
evaluate the response of controlled variable to any test input. It also provides the response of
any internal variable of the control system (output variable of a subsystem block) without the
need for block diagram reduction.
Let us reiterate the fact we have emphasized earlier: a good plant/process model is the
backbone of any realistic control design. A Simulink model based on the structure and
parameters of the system model is constructed. The responses of the actual system and its
Simulink model are obtained using a set of test inputs. If the actual responses to the test
inputs were significantly different from the Simulink responses, certain model parameters
would have to be revised, and/or the model structure would have to be refined to better reflect
the actual system behaviour. Once satisfactory model performance has been achieved,
various control schemes can be designed and implemented.
In practice, it is best to test a control scheme off-line by evaluating the system performance in
the “safety” of the Simulink environment. The key components of a control system include
actuators, sensors, and the plant/process itself. A decision to include all aspects such as
amplifier saturation, friction in the motor, backlash in gears, dynamics of all the devices, etc.,
may improve the model, but the complexity of the model may result in a more complicated
controller design, which will ultimately increase the cost and sophistication of the system.
The design is usually carried out using an approximated model; the evaluation of the design
is done on the “true” model, which includes nonlinearities, and other aspects neglected in the
approximate model. Simulink is an excellent tool for this evaluation.
SIMULINK (SIMUlation LINK) is an extension of MATLAB for modeling, simulating, and
analyzing dynamic, linear/nonlinear, complex control systems. Graphical User Interface
(GUI) and visual representation of simulation process by simulation block diagrams are two
key features which make SIMULINK one of the most successful software packages,
particularly suitable for control system design and analysis.
Simulation block diagrams are nothing but the same block diagrams we are using to describe
control system structures and signal flow graphs. SIMULINK offers a large variety of ready-
to-use building blocks to build the mathematical models and system structures in terms of
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
block diagrams. Block parameters should be supplied by the user. Once the system structure
is defined, some additional simulation parameters must also be set to govern how the
numerical computation will be carried out and how the output data will be displayed.
Because SIMULINK is graphical and interactive, we encourage you to jump right in and try
it. To help you start using SIMULINK quickly, we describe here the simulation process
through a demonstration example with MATLAB version 7.0, SIMULINK version 6.0.
To start SIMULINK, enter simulink command at the MATLAB prompt. Alternatively one
can also click on SIMULINK icon shown in Fig. 3.1.
Fig. 3.1 MATLAB Desktop main menu and SIMULINK icon
A SIMULINK Library Browser (Fig. 3.2) appears which displays tree-structured view of the
SIMULINK block libraries. It contains several nodes; each of these nodes represents a library
of subsystem blocks that is used to construct simulation block diagrams. You can
expand/collapse the tree by clicking on the boxes beside each node and block in the
block set pan.
Fig. 3.2 SIMULINK Library Browser
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Expand the node labeled Simulink. Subnodes of this node ( Commonly Used Blocks,
Continuous, Discontinuities, Discrete, Logic and Bit Operations, etc…) are displayed.
Now for example, expanding the Sources subnode displays a long list of Sources library
blocks. Simply click on any block to learn about its functionality in the description box (see
Fig. 3.3).
Fig. 3.3 Blocks in Sources subnode
You may now collapse the Sources subnode, and expand the Sinks subnode. A list of Sinks
library block appears (Fig.3.4). Learn the purpose of various blocks in Sinks subnode by
clicking on the blocks.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 3.4 Blocks in Sinks subnode
Exercise 3.1
Expand the Continuous, Discontinuities, Discrete, and Math Operations subnodes. Study the
purpose of various blocks in these subnodes in description box.
We have described some of the subsystem libraries available that contain the basic building
blocks of simulation diagrams. The reader is encouraged to explore the other libraries as well.
You can also customize and create your own blocks. For information on creating your own
blocks, see the MATLAB documentation on “Writing S- Functions”.
We are now ready to proceed to the next step, which is the construction of a simulation
diagram. In the SIMULINK library browser, follow File New Model or hit Ctrl+N to
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
open an „untitled' workspace (Fig.3.5) to build up an interconnection of SIMULINK blocks
from the subsystem libraries.
Fig. 3.5 Untitled workspace
Let us take a simple example. The block diagram of a dc motor (armature-controlled) system
is shown in Fig. 3.6
Fig. 3.6 Block diagram of a dc motor (armature-controlled) system
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
where
is the resistance of the motor armature (ohms) = 1.75
is the inductance of the motor armature (H) = 2.83
is the torque constant (Nm/A) = 0.0924
is the back emf constant (V sec/rad) = 0.0924
is the inertia seen by the motor (includes inertia of the load) (kg-m2 ) =
is the mechanical damping coefficient associated with rotation (Nm/(rad/sec))= 5.0
is the applied voltage (volts) = 5 volts
We will implement the model shown in Fig. 3.6 in the untitled work space (Fig. 3.5).
Let us first identify the SIMULINK blocks required to implement the block diagram of Fig.
3.6. This is given in Fig. 3.7.
Fig. 3.7 SIMULINK blocks required for implementation
Identifying the block(s) required for simulation purpose is in fact the first step of the
construction of simulation diagram in SIMULINK. The next step is to “drag and drop ” the
required blocks from SIMULINK block libraries to untitled workspace. Let us put the very
first block for applied voltage (Ea) to workspace.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Expand the Sources subnode, move the pointer and click the block labeled Constant, and
while keeping the mouse button pressed down, drag the block and drop it inside the
Simulation Window; then release the mouse button (Fig. 3.8).
Right clicking on the block will provide various options to users from which one can cut,
copy, delete, format (submenu provides facilities for rotation of the block, flipping, changing
the font of block name,...), etc...
Exercise 3.2
Drag and drop all the blocks we have identified (Fig. 3.7) from the Library Browser to the
untitled Workspace and place them as shown in Fig. 3.9.
Fig. 3.8 Drag and drop blocks to Workspace from Library Browser
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 3.9 Unconnected blocks in Workspace
It is visible that all the block parameters are in their default settings. For example, the default
transfer function of Transfer Fcn block is and default signs of Sum block are + +. We
need to configure these block parameters to meet our modeling requirements. It is
straightforward. Double click the block to set up its parameters. For example, double clicking
the Transfer Fcn block opens the window titled Block Parameters: Transfer Fcn, shown in
Fig. 3.10.
Fig. 3.10 Transfer function block parameters window
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
For armature circuit transfer function, no need to change the numerator parameter. For
denominator parameters, enter for , which will be interpreted by
SIMULINK as .
To enhance the interpretability of simulation diagram, we can also change the block
identification name. Simply click on the text Transfer Fcn to activate the small window
around the text to change the block name. For our simulation block diagram, the suitable text
for Transfer Fcn block may be Armature circuit.
Before we move to the last step of interconnecting the blocks as per the desired structure, just
finish Exercise 3.3. Note that the Decimation parameter value by default is 1. Increasing this
value reduces the number of data samples taken over the simulation time. We have used the
default value of 1.
Exercise 3.3
Modify all the block parameters as per system parameters given for Fig. 3.7, and give
appropriate names to the blocks.
Lines are drawn to interconnect these blocks as per the desired structure. A line can connect
output port of one block to the input port of another block. A line can also connect the output
port of one block with input ports of many blocks by using branch lines. We suggest readers
to perform the following line/block operations on blocks dragged in workspace to get hands
on practice.
To connect the output port of one block to the input port of another block:
1. Position the pointer on the first block's output port; note that the cursor shape
changes to cross hair.
2. Press and hold down the left mouse button.
3. Drag the pointer to second block's input port.
4. Position the pointer on or near the port; the pointer changes to a double cross
hair.
5. Release the mouse button. SIMULINK replaces the port symbol by a connecting
line with an arrow showing the direction of signal flow.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Another simple methodology doesn't require dragging the line. Block1 output port is required
to be connected to Block2 input port.
1. select Block1 by clicking anywhere inside the block.
2. Hold down the Ctrl key.
3. Click on block2; both the blocks will be connected.
To connect the output port of one block with the input ports of several blocks, we can use
branch lines. Both the existing line and the branch line carry the same signal. To add a
branch line, do the following:
1. Position the pointer on the line where you want the branch line to start.
2. While holding down the Ctrl key, left click on the line segment; note that
the cursor shape changes to cross hair.
3. Release the control key, while pressing down the left mouse button; drag the
pointer to the input port of the target block.
4. Release the mouse button; target block will be connected to the line
segment.
Some of the important line-segment and block operations are as follows:
1. To move a line segment, position the pointer on the segment you want to
move. Press and hold down the left mouse button. Drag the pointer to the
desired location and release. Note that this operation is valid with line
segments only, not with the dedicated connecting lines between two blocks.
2. To disconnect a block from its connecting lines, hold down the shift key, then
drag the block to a new location. Incoming and outgoing lines will be
converted to red colored dotted lines. One can insert a different block between
these lines.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Exercise M3.4
Connect all the blocks appropriately as per the block diagram given in Fig. 3.7. Make
use of the block interconnection points discussed above.
Now let us give a name to the untitled workspace. Hit Ctrl + S to save the developed
simulation diagram to the disk with an appropriate name. The file will be saved with the
extension .mdl , an abbreviation for the „model'.
We save the file using the name armature_dcmotor.mdl; the complete simulation diagram
is shown in Fig. 3.11.
Finally, we need to set the parameters for the simulation run. Press Ctrl + E to open the
simulation parameter configuration window. Left panel of the window (Fig. 3.12) displays a
tree structured view of parameter submenu. In the Solver submenu, enter the start and stop
time of the simulation (Fig. 3.13).
Fig. 3.11 Final simulation diagram
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 3.12 Parameter configuration submenu
Fig. 3.13 Enter simulation time
Now we are ready to simulate our block diagram of armature-controlled dc motor. Press
icon to start the simulation. Note that the icon changes to ; pressing this icon, one can stop
the simulation before stop time. After simulation is done, double click the Scope block to
display the angular velocity variation with time. Click the autoscale icon in the display
window to scale the axes as per the variable ranges. Autoscaled scope display is shown in
Fig. 3.14. With zoom facility, try zooming the portion of graph between 0.5 to 1 sec, and 20
to 25 unit angular velocity to identify the numerical value of angular velocity at 0.8 seconds.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 3.14 Scope display of angular velocity
Set y-axis limits by right-clicking the axis and choosing Axes Properties. In Y-min, enter the
minimum value for the y-axis. In Y-max, enter the maximum value for the y-axis. In Title,
enter the title of the plot. See Fig. 3.15.
Fig. 3.15 Scope axis properties editor
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Click the icon shown on the icon bar of Fig. 3.14 to open scope parameter editor (Fig.
3.16). General parameters include Number of axes, Time range, Tick labels, and
Sampling.
Click on the Data history button. If you want input-output data from this scope to be
available to MATLAB workspace for further analysis, check the button Save data to
workspace. In the box Variable name, enter the variable name for saving the data. By
default it will save the data with variable name ScopeData. With the pop-down menu
Format, select the format in which you want to save the data.
Three specific formats for saving the data are as follows:
1. Structure with time: Data will be saved in structured format with time steps. Type
the following commands in your MATLAB prompt and observe the outputs.
Fig. 3.16 Scope parameter setting window
>> ScopeData
ScopeData =
time: [4663x1 double]
signals: [1x1 struct]
blockName: 'armature_dcmotor/Angular Velocity'
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Structures are used in MATLAB to store mixed mode data types, and individual fields of the
structure can be accessed by „dot ' operator. To see the information stored in the field
signals, type:
>> ScopeData.signals
ans =
values: [4663x1 double]
dimensions: 1
label: ''
title: ''
plotStyle: 0
It indicates that the field signals contains subfield values, which is of 4663 x 1 size vector
containing the values of angular velocity. Try accessing the field time of ScopeData.
Exercise 3.5
Plot the angular velocity against time using the plot command. Give suitable title to the
plot and labels to x and y axes.
Hint: You need to plot ScopeData.signals.values against ScopeData.time.
2. Structure : This is the same as Structure with time; the only difference is that the time
steps will not be saved.
Exercise 3.6
Run the simulation with scope data to be saved as Structure format. Verify that the time
field of ScopeData structure is actually an empty matrix.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
3. Array : Array format is simply a two column matrix with number of data points being
equal to number of rows. The maximum number of data points limits to the number entered
in the box Limit data points to last. In Fig. 3.16, the limit is 5000 data points.
Exercise 3.7
Run the simulation with scope data to be saved as Array format. Repeat Exercise 3.5 with
saved data matrix.
We have used an example to show how to build the simulink diagram, how to enter data and
carry out a simulation in the SIMULINK environment. The reader will agree that this is a
very simple process.
Solving the following exercises will make the readers more confident in solving the control
system design and analysis problems through SIMULINK.
Exercise 3.8
This problem requires some modification in the above considered armature-controlled d.c.
motor SIMULINK example.
1. The angular position is obtained by integrating the angular velocity. Implement
this in the model and display angular position in a different scope.
2. Remove the constant applied voltage block. Obtain the Step, Ramp, and Sinusoidal
responses of the system.
3. Simulate a closed-loop position control system assuming a proportional
controller of gain KP .
Hint: Add a reference input signal for angular position and add a summing block which
calculates the error between the angular position reference and the measured angular
position. Multiply this error by the gain KP and let this signal be the applied voltage Ea .
Exercise 3.9
Consider a dynamic system consisting of a single output , and two inputs r and w :
where
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Model the system in SIMULINK.
For and both step signals, obtain the system output . Display the output on scope.
Also, using a SIMULINK block, etch the output to the workspace.
Hint: To implement deadtime, use the block Transport delay from Continuous, and
identify suitable block from Sinks library to fetch the variable directly to the workspace.
Exercise 3.10
Assign 0.5, , and to , respectively.
Simulate for 10 seconds.
Display plots for on scope, and also save to the
MATLAB file Yt.mat.
Hint: Use Math Function, Add, Divide, and Trigonometric Function from Math
Operations block libraries.
Exercise 3.11
This problem is to study the effects of Proportional (P), Proportional + Integral (PI), and
Proportional + Derivative (PD) control schemes on the temperature control system. A
temperature control system has the block diagram given in Fig.3.17. The input signal is a
voltage and represents the desired temperature Simulate the control system using
SIMULINK and find the steady-state error of the system when is a unit-step function
and (i) (ii) and (iii) .
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 3.17
Hint: Use PID Controller block from Simulink Extras Additional Linear to
implement the PID controller.
Exercise 3.12
The block diagram in Fig. 3.18 shows the effect of a simple on-off controller on second-
order process with deadtime.
Fig. 3.18
Implement and test the model in SIMULINK for step inputs of 5.0 and 10.0. Display the
control signal u( t ) and output the on separate scopes and also fetch both the signals
with time information to MATLAB workspace. Using MATLAB plot function, plot the
control signal and the output; both against time on single graph.
Hint: To implement on-off controller, use Relay from Discontinuous block library.
Exercise 3.13
Simulate the Van der Pol oscillator, described by the following nonlinear differential
equation: ,
where is the disturbance (forcing function) given by . Assign
Hint: Rewrite the second-order Van der Pol differential equation as a system of coupled
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
first-order differential equations. Let,
The SIMULINK block diagram is to be built using Signal Generator, Gain, Integrator,
Add, and Scope. The output of Add block is . Integrating it once will lead you to
and second integration will lead you to Double click the Integrator block to add the
initial conditions .
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL - 4
Feedback System Simulation
Objectives:
Presenting MATLAB functions to carryout block diagram manipulations,
followed by time-response analysis.
Using Simulink simulation for time-response analysis.
Transfer Function Manipulation
System Response
Simulink Simulation
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL – 4.1
Feedback System Simulation
Transfer Function Manipulation
Suppose we have developed mathematical models in the form of transfer functions for the
plant, represented by G(s), and the controller, represented by D(s), and possibly many other
system components such as sensors and actuators. Our objective is to interconnect these
components to form block diagram representation of a feedback control system. MATLAB
offers several functions to carry out block diagram manipulations.
Two methods are available:
1. Solution via series, parallel, and feedback commands:
series(G,D) for a cascade connection of G(s) and D(s); parallel(G1,G2) for a parallel
connection of G1(s) and G2(s); feedback(G,H, sign) for a closed-loop connection with G(s)
in the forward path and H(s) in the feedback path; and sign is -1 for negative feedback or +1
for positive feedback (the sign is optional for negative feedback); and cloop(G,sign) for a
unity feedback system with G(s) in the forward path, and sign is -1 for negative feedback or
+1 for positive feedback (the sign is optional for negative feedback).
2. Solution via algebraic operations:
G*D for a cascade connection of G(s) and D(s); G1+G2 for a parallel connection of G1(s)
and G2(s); G/(1+G*H) for a closed-loop negative feedback connection with G(s) in the
forward path and H(s) in the feedback path; and G/(1-G*H) for positive feedback systems.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL – 4.2
Feedback System Simulation
System Response
The transfer function manipulations give us a transfer function model M(s) between
command input R(s) and output Y(s); model Mw(s) between disturbance input W(s) and output
Y(s); a model between command input R(s) and control U(s), etc. It is now easy to use some
of the control analysis commands available from the Control System Toolbox. impulse(M)
and step(M) commands represent common control analysis operations that we meet in this
book. Also frequently used in the book are frequency-response plots.
Example 4.1
Consider the block diagram in Fig. 4.1.
Fig. 4.1
For value of gain KA = 80, the following two MATLAB sessions evaluate the step responses
with respect to reference input R(s) and disturbance signal W(s) for
>> %Step response with respect to R(s)
>> s = tf('s');
>> KA = 80;
>> G1 = 5000/(s+1000);
>> G2 = 1/(s*(s+20));
>> M = feedback(series(KA*G1,G2),1)
>> step(M)
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
The MATLAB responds with
Transfer function:
.......................400000
--------------------------------------------------
s^3 + 1020 s^2 + 20000 s + 400000
and step response plot shown in Fig. 4.2. The grid has been introduced in the plot by right
clicking on the plot and selecting Grid option.
Fig. 4.2
>> %Step response with respect to W(s)
>> s = tf('s');
>> KA = 80;
>> G1 = 5000/(s+1000);
>> G2 = 1/(s*(s+20));
>> Mw = (-1) * feedback(G2, KA*G1)
>> step(Mw)
MATLAB responds with
Transfer function:
.......................s-1000
----------------------------------------------------
s^3 + 1020 s^2 + 20000 s + 400000
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
and step response plot shown in Fig. 4.3.
Fig. 4.3
Example 4.2
Let us examine the sensitivity of the feedback system represented by the transfer function
The system sensitivity to parameter K is
Figure 4.4 shows the magnitudes of and versus frequency for K =
0.25; generated using the following MATLAB script. Text arrows have been introduced in
the plot by following Insert from the main menu and selecting the option Text Arrow.
Note that the sensitivity is small for lower frequencies, while the transfer function primarily
passes low frequencies.
w = 0.1:0.1:10;
M = abs(0.25./((j*w).^2+j*w+0.25));
SMK = abs((j*w .* (j*w + 1))./((j*w).^2 + j*w +0.25));
plot(w,M,'r',w,SMK,'b');
xlabel('Frequency (rad/sec)');
ylabel('Magnitude');
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 4.4
Of course, the sensitivity S only represents robustness for small changes in gain K. If K
changes from 1/4 within the range K = 1/16 to K = 1, the resulting range of step responses,
generated by the following MATLAB script, is shown in Fig. 4.5. This system, with an
expected wide range of K, may not be considered adequately robust. A robust system would
be expected to yield essentially the same (within an agreed-upon variation) response to
selected inputs.
s = tf('s');
S = (s*(s+1))/(s^2+s+0.25);
M1 = 0.0625/(s^2+s+0.0625);
M2 = 0.25/(s^2+s+0.25);
M3 = 1/(s^2+s+1);
step(M1);
hold on;
step(M2);
step(M3);
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 4.5
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL – 4.3
Feedback System Simulation
Simulink Simulation
Simulink simulation is an alternative to block diagram manipulation followed by time-
response analysis. From the Simulink model of a control system, output y in response to
command r, output y in response to disturbance w, control u in response to command r, and
all other desired internal variables can be directly obtained.
Example 4.3
Control system design methods discussed in this course are based on the assumption of
availability of linear time invariant (LTI) models for all the devices in the control loop.
Consider a speed control system. The actuator for the motor is a power amplifier. An
amplifier gives a saturating behaviour if the error signal input to the amplifier exceeds linear
range value.
MATLAB simulink is a powerful tool to simulate the effects of nonlinearities in a feedback
loop. After carrying out a design using LTI models, we must test the design using simulation
of the actual control system, which includes the nonlinearities of the devices in the feedback
loop.
Figure 4.6 is the simulation diagram of a feedback control system: the amplifier gain is 100
and the transfer function of the motor is 0.2083/(s +1.71). We assume the amplifier of gain
100 saturates at +5 or -5volts. The result of the simulation is shown in Fig. 4.7.
The readers are encouraged to construct the simulink model using the procedure described in
Module 3. All the parameter settings can be set/seen by double clicking on related blocks.
Fig. 4.6
Time and Output response data have been transferred to workspace using To Workspace
block from Sinks main block menu. Clock block is available in Sources main menu. These
variables are stored in the structure Output and Time in the workspace, along with the
information regarding simulink model name. For example,
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
>> Output
Output =
time: [ ]
signals: [1x1 struct]
blockName: 'M4_3/To workspace Output'
>> Time
Time =
time: [ ]
signals: [1x1 struct]
blockName: 'M4_3/To workspace Time'
To access output and time values, one needs to access Output.signals.values and
Time.signals.values . The step response plot has been generated by the following MATLAB
script.
>> plot(Time.signals.values,Output.signals.values)
>> xlabel('Time (sec)');
>> ylabel('Output');
>> title('Step Response');
Fig. 4.7
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Example 4.4
In this example, we simulate a temperature control system with measurement noise added to
the feedback signal. The process transfer function is
The deadtime minutes. The measurement noise parameters we have used are: mean
of 0, variance of 0.5, initial seed of 61233, and sample time of 0. The simulink inputs a step
of 30 to the system (Fig. 4.8). Deadtime block in this figure is Transport Delay block from
Continuous library, and Random Number block is from Sources library.
Fig. 4.8
The data has been transferred to the workspace using To Workspace block. The step
response, generated using the following MATLAB script is shown in Fig. 4.9.
>> plot(Time.signals.values,Y.signals.values);
>> ylabel('Output (Y)');
>> xlabel('Time(min)');
>> title('Step Response');
Fig. 4.9
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
The performance of the system with measurement noise removed, is shown in Fig. 4.10. To
remove the effect of noise, simply disconnect the Random number block from the Sum
block in the feedback path.
Fig. 4.10
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL - 5
Time Response Characteristics and LTI Viewer
Objectives:
Analysis of the system behaviour to changes in input reference signals or
disturbances using steady-state and transient performance indices.
Brief introduction to LTI Viewer, and time response analysis using this GUI tool.
Time response characteristics of interest to us in analysis and design of control systems are:
rise time (tr), settling time (ts), peak time (tp) , and peak overshoot (Mp) of step response of a
system. These parameters can directly be obtained from the plot generated by the command
step. Right-clicking away from the curve generated by step brings up a menu. From this
menu, various time-response characteristics can be selected.
MATLAB has a powerful GUI tool, called LTI Viewer, for obtaining both the time and
frequency response characteristics of a given Linear Time Invariant system. In this module,
we give the basic features of this GUI tool and use it for time response analysis. Later in
Module 9, this tool will be exploited for frequency response analysis.
LTI Viewer
Time response characteristics in Matlab window
Time response characteristics in Simulink window
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL – 5.1
Time Response Characteristics and LTI Viewer
LTI Viewer
The LTI ( Linear Time Invariant) Viewer is an interactive graphical user interface
(GUI) for analyzing the time and frequency responses of linear systems and comparing
such systems. In particular, some of the graphs the LTI Viewer can create are step and
impulse responses, Bode, Nyquist, Nichols, pole-zero plots, and responses with
arbitrary inputs. In addition, the values of critical measurements on these plots can be
displayed with a click of the mouse. Table 5.1 shows the critical measurements that are
available for each plot.
Table 5.1
-
Peak time
or Peak
frequency
Settling
time
Rise
time
Steady
state
value
Gain/phase
margins;
zero
dB/1800
frequencies
Pole-
zero
value
Step
- -
Impulse
- - - -
Bode
- - -
-
Nyquist
- - -
-
Nichols
- - -
-
Pole-
zero - - - - -
Here we provide steps you may follow to use the LTI Viewer to plot time and
frequency responses.
1. Access the LTI Viewer: The LTI Viewer window, shown in Fig. 5.1, can be
accessed by typing ltiview in the MATLAB Command Window or by
executing this command in an M-file.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 5.1 LTI Viewer Window
2. Create LTI transfer functions: Create LTI transfer functions for which you
want to obtain responses. The transfer functions can be created in an M-file or
in the MATLAB Command Window. Run the M-file or MATLAB Command
Window statements to place the transfer function in the MATLAB workspace.
All LTI objects in the MATLAB workspace can be exported to the LTI
Viewer.
The following MATLAB commands create the transfer function .
>> s = tf('s');
>> G = 1/(s+1);
3. Select LTI transfer functions for the LTI Viewer: Choose Import… under
the File menu in the LTI Viewer window and select all LTI objects whose
responses you wish to display in the LTI Viewer sometime during your current
session. Selecting G results in Fig. 5.3.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 5.2 Import System Data Window
4. Select the LTI objects for the next response plot: Right-click anywhere in
the LTI Viewer plot area to produce a pop-up menu. Under Systems, select or
deselect the objects whose plots you want or do not want to show in the LTI
Viewer. More than one LTI transfer function may be selected.
5. Select the plot type: Right-click anywhere in the LTI Viewer plot area to
produce a pop-up menu. Under Plot Types, select the type of plot you want to
show in the LTI Viewer (Fig. 5.3).
Fig. 5.3
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Example 5.1
Take a typical underdamped second-order transfer function and import it to the LTI
viewer window.
6. Select the characteristics: Right-click anywhere in the LTI Viewer plot area
to produce a pop-up menu. Under Characteristics, select the characteristics of
the plot you want displayed. More than one characteristic may be selected. For
each characteristic selected, a point will be placed on the plot at the appropriate
location.
The characteristics menu and the submenu are displayed in Fig. 5.4 obtained by
importing a typical second-order transfer function.
Note the difference in the definition of rise time employed in the LTI Viewer with
respect to the one used in the text.
Fig. 5.4 LTI Viewer with step response plot and characteristics
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
7. Interact with the plot:
o Zoom In (Zoom Out): Select the Zoom In (Zoom Out) button (with
the + ( ) sign) on the tool bar. Hold the mouse button down and drag a
rectangle on the plot over the area you want to enlarge (deluge), and
release the mouse button.
o Original View: Select Reset to Original View in the menu popped up
by right-click to return to original view of your plot after zooming.
o Grid: Select Grid in the right-click menu to on or off the grid. The
right click menu will not work if any zoom button on the tool bar is
selected.
o Normalize: Select Normalize in the right-click menu to normalize all
curves in view.
o Characteristics: Read the values of the characteristics by placing the
mouse on the characteristics point on the plot. Left-click the mouse to
keep the values displayed (Fig. 5.5).
o Properties: Select Properties in the right-click menu or double-click
anywhere (except the curve) on the graph sheet to change the
appearance of the graph. You can change the title, axes labels, and
limits, font sizes and styles, colours, and response characteristics
definitions.
o Coordinates and curve: Left-click the mouse at any point on the plot
to read the system identification and the coordinates (Fig. 5.5, shown
by square block).
o Add text and graphics: Under the File menu, choose Print to Figure.
An additional figure with toolbar will open (Fig. 5.6).The toolbar of
this figure has additional tools for adding text, arrows, lines, legends,
and to rotate the figure.
o Additional plot-edit capabilities: The Edit menu of the LTI Viewer
and the figures created by selecting Print to Figure, offer a wide
variety of controls over the plot presentation.
8. Viewer preferences: Choose Viewer Preferences… in the Edit menu. LTI
Viewer Preferences window (Fig. 5.7) will open. This allows users to set
parameters such as units (Units), style of labels (Style), response
characteristics definitions (Characteristics), and also provide a control over
the time and frequency vector generation (Parameters).
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 5.5 Coordinate values in step response curve
Fig. 5.6 LTI response with text and graphics editor toolbar
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 5.7 LTI Viewer Preferences window
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL - 5.2
Time Response Characteristics and LTI Viewer
Time Response Characteristics in MATLAB window
Example 5.1
Consider the position control system shown in Fig. 5.8.
.
Fig. 5.8
(transfer function of motor, gears, and load)
(transfer function of power amplifier)
KA = preamplifier gain
sensitivity of input and output potentiometers
Time response characteristics of the system are generated by the following MATLAB script.
s = tf('s');
G1 = 100/(s+100);
G2 = 0.2083/(s*(s+1.71));
K = 1000;
G = series(K*G1,G2);
H = 1/pi;
M = series(feedback(G,H),H);
ltiview(M);
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
MATLAB response is shown in Fig. 5.9.
Fig. 5.9
In the following we compare the time response characteristics of this system with the one
obtained by replacing the power amplifier with a transfer function of unity (Fig. 5.10).
s = tf('s');
G1 = 1;
G2 = 0.2083/(s*(s+1.71));
K = 1000;
G = series(K*G1,G2);
H = 1/pi;
M1 = series(feedback(G,H),H);
ltiview(M1);
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 5.10
The second-order approximation seems to be quite reasonable.
The two responses in Figs 5.9 and 5.10 can be obtained in a single plot using the command
ltiview(M,M1). Alternatively, choose Import... under the File menu in the LTI Viewer
window and select M.
Example 5.2
Consider a unity feedback system shown in Fig. 5.11.
Fig. 5.11
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
We will consider the following three controllers:
D1(s) = 3; D2(s)=3+(15/ s ); and D3(s)=(3+(15/ s )+0.3 s )
The following MATLAB code generates the step responses shown in Fig. 5.12.
s = tf('s');
G = 59.292/(s^2+6.9779*s+15.12);
D1 = 3;
D2 = 3 + 15/s;
D3 = 3 + 15/s +0.3*s;
M1 = feedback(D1*G,1);
M2 = feedback(D2*G,1);
M3 = feedback(D3*G,1);
step(M1);
hold;
step(M2);
step(M3);
We need not access LTI viewer to find out the time response characteristics of the closed-
loop system. The step command in MATLAB has this feature inbuilt in it as is seen in Fig.
5.12.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 5.12
Note that adding the integral term increases the oscillatory behaviour but eliminates the
steady-state error, and that adding the derivative term reduces the oscillations, while
maintaining zero steady-state error.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL - 5.3
Time Response Characteristics and LTI Viewer
Time Response Characteristics in SIMULINK window
Example 5.3
Consider a unity feedback, PID controlled system with following parameters:
Plant transfer function:
PID controller transfer function:
Reference input:
A Simulink block diagram is shown in Fig. 5.13.
Fig. 5.13
The Simulink model inputs a step of 30 to the system.
Time response characteristics of the model developed in Simulink can be obtained by
invoking the LTI Viewer directly from the Simulink. LTI Viewer for Simulink can be
invoked by following Tools -- Control Design -- Linear Analysis as shown in Fig. 5.14.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 5.14
This opens Control and Estimation Tools Manager shown in Fig. 5.15.
Fig. 5.15
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Select linearization input-output points by right clicking on the desired line and selecting
Linearization Points in your Simulink model. Fig. 5.16 explains the selection of input point.
Similarly output point has been selected. Once input-output linearization points appear in the
Control and Estimation Tools Manager window, click on the Linearize Model at the
bottom of the window (Fig. 5.15). The type of response can be selected from the drop down
menu just near the Linearize Model button. Other linear analysis plots available are: Bode,
Impulse, Nyquist, Nichols, Bode magnitude plot, and pole-zero map.
Fig. 5.16
The step response with the characteristics is shown in Fig. 5.17.
Fig. 5.17
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Example 5.4
Consider a unity feedback, PI controlled system with following parameters:
Plant transfer function:
Plant deat-time: = 0.15 minutes
PI controller transfer function:
Actuator saturation characteristic: Unit slope; maximum control signal =1.7.
Reference input:
A Simulink block diagram is shown in Fig. 5.18. PID controller block is available in
Additional Linear block set in Simulink Extras block library. The parameters of PID
controller block have been set as : P = 0.09, I = 0.95, and D = 0.
Fig. 5.18
We can invoke LTI Viewer to determine the time response characteristics of the system of
Fig. 5.18. However, LTI Viewer will linearize the system and then plot the characteristics.
An alternative is to transfer the output response data to workspace using To Workspace
block and then generate the time response using the plot command. A MATLAB code can
then be written to determine the required characteristics. The following code gives settling
time, peak overshoot, and peak time for the output response data of Fig. 5.18.
time = t.signals.values;
y = Y.signals.values;
plot(time,y);
title('Step response');
xlabel('Time (min)');
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
ylabel('Output');
ymax = max(y);
step_size = 10;
peak_overshoot = ((ymax-step_size)/step_size)*100
index_peak = find(y == ymax);
peak_time = time(index_peak)
s = length(time);
while((y(s)>=0.95*step_size) & (y(s)<=1.05*step_size))
s = s-1;
end
settling_time = time(s)
The MATLAB responds with Fig. 5.19 and the following characteristics.
peak_overshoot =
39.0058
peak_time =
1.9339
settling_time =
5.9739
Fig. 5.19
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL - 6
Stability Analysis on Root Locus Plots
Objectives:
Stability analysis in state space.
Stability analysis using root locus plots.
Stability Analysis in State Space
Root Locus Analysis
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL – 6.1
Stability Analysis on Root Locus Plots
Stability Analysis in State Space
There are several useful MATLAB commands related to analysis and design in state space.
Commands useful for stability analysis in state space are:
ss; step; initial; eig; tf; minreal
The MATLAB program below forms the matrices A,b,c and d for the system
>> A = [0 1 0; 0 0 1; 0 -2 -3];
>> b = [0; 0; 1];
>> c = [1 0 0 ];
>> d = 0;
The output generated in the MATLAB Command Window by executing these commands is
A =
0 1 0
0 0 1
0 -2 -3
b =
0
0
1
c =
1 0 0
d =
0
The command ss (A,b,c,d) creates the state space model; let us call it stmod . The MATLAB
dialogue is given below.
>> stmod = ss(A,b,c,d)
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
a =
......x1 .x2 x3
x1 ..0 ..1 ...0
x2 ..0 ..0 ...1
x3 ..0 .-2 ..-3
b =
.......u1
x1 ...0
x2 ...0
x3 ...1
c =
......x1 x2 x3
y1 ..1 ..0 ...0
d =
.......u 1
y1 ....0
Continuous-time model.
The system stmod can then be used as an argument for many of the MATLAB commands we
have already discussed. For instance, the command step(stmod) generates the plot of unit-
step response y(t) (with zero initial conditions).
The command initial(stmod, x0) creates the free response (with input u(t) = 0) to initial
condition vector x0.
Typing eig(stmod) in the command window produces the dialogue
>> eig(stmod)
ans =
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
0
-1
-2
Thus the eigenvalues of the plant matrix A are
MATLAB has the means to perform model conversions. Given the state model stmod, the
syntax for conversion to transfer function model is
tfmod = tf(stmod)
Common pole-zero factors of the transfer function model must be cancelled before we can
claim that we have the transfer function representation of the system. To assist us in pole-zero
cancellation, MATLAB has mineral (tfmod) function.
Asymptotic stability is given by the command eig(A). If conversion of the state model to
transfer function gives a model with no pole-zero cancellations, the system is both
controllable and observable; asymptotic stability implies BIBO stability and vice versa.
Stability analysis can be carried out using transfer functions under the assumption of
controllability and observability of the corresponding dynamic system.
The command pole(tfmod) finds the poles of a transfer function. The command
pzmap(tfmod) plots the poles and zeros of the transfer function. A MATLAB code for the
Routh stability criterion can easily be written for stability analysis. However, our focus in this
course is on root locus for stability analysis. The focus in this MATLAB module will
therefore be on root locus analysis.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL - 6.2
Stability Analysis on Root Locus Plots
Root Locus Analysis
In the following, we provide brief description of powerful MATLAB commands for root
locus analysis. The reader may wonder why the instructors emphasize learning of hand
calculations when powerful MATLAB commands are available. For a given set of open-loop
poles and zeros, MATLAB immediately plots the root loci. Any changes made in the poles
and zeros, immediately result in new root loci and so on.
Depending on our background and aptitude, we may, after a while, begin to make some sense
of the patterns. May be we finally begin to formulate a set of rules that enables us to quickly
make a mental sketch of the root locus the moment the poles and zeros appear. In other
words, by trial-and-error, we find the rules of the root locus.
Through the systematic formulation of set of rules of the root locus, we look for the clearest,
and simplest explanation of the dynamic phenomena of the system. The rules of the root
locus give us a clear and precise understanding of the endless patterns that can be created by
an infinite set of characteristic equations. We could eventually learn to design without these
rules, but our level of skill would never be as high or our understanding as great. This is true
of other analysis techniques also such as Bode plots, Nyquist plots, Nichols charts, and so on,
covered later in the course.
MATLAB allows root locus for the characteristic equation
1 + G (s)H(s) = 0
to be plotted with the rlocus(GH) command. Points on the root loci can be selected
interactively (placing the cross-hair at the appropriate place) using the [K,p] = rlocfind(GH)
command. MATLAB then yields the gain K at that point as well as all the poles p that have
that gain. The root locus can be drawn over a grid generated using the sgrid (zeta, wn)
command, that allows constant damping ratio zeta and constant natural frequency wn curves.
The command rlocus (GH, K) allows us to specify the range of gain K for plotting the root
locus. Also study the commands [p,K]=rlocus(GH) and [p]=rlocus(GH,K) using MATLAB
online help.
Example 6.1
Consider the system shown in the block diagram of Fig. 6.1.
Fig. 6.1
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
The characteristic equation of the system is
1 + G(s) = 0
with
The following MATLAB script plots the root loci for
s = tf('s');
G = 1/(s*(s+7)*(s+11));
rlocus(G);
axis equal;
Clicking at the point of intersection of the root locus with the imaginary axis gives the data
shown in Fig. 6.2. We find that the closed-loop system is stable for K < 1360; and unstable
for K > 1360.
Fig. 6.2
Fig. 6.3 shows step responses for two values of K .
>> K = 860;
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
>> step(feedback(K*G,1),5)
>> hold;
% Current plot held
>> K = 1460;
>> step(feedback(K*G,1),5)
Fig. 6.3
Example 6.2
Consider the system shown in Fig. 6.4.
Fig 6.4
The plant transfer function G(s) is given as as
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
The following MATLAB script plots the root locus for the closed-loop system.
clear all;
close all;
s = tf('s');
G = (s+1)/(s*(0.1*s-1));
rlocus(G);
axis equal;
sgrid;
title('Root locus for (s+1)/s(0.1s-1)');
[K,p]=rlocfind(G)
Fig 6.5
selected_point =
-2.2204 + 3.0099i
K =
1.4494
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
p =
-2.2468 + 3.0734i
-2.2468 - 3.0734i
Example 6.3
For a unity feedback system with open-loop transfer function
a root locus plot shown in Fig. M6.6 has been generated using the following MATLAB code.
s = tf('s');
G = (s^2-4*s+20)/((s+2)*(s+4));
rlocus(G);
zeta = 0.45;
wn = 0;
sgrid(zeta,wn);
Properly redefine the axes of the root locus using Right click --> Properties --> Limits.
Fig. 6.6
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Clicking on the intersection of the root locus with zeta=0.45 line gives the system gain K =
0.415 that corresponds to closed-loop poles with Clicking on the intersection of the
root locus with the real axis gives the breakaway point and the gain at that point.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL - 7
Root Locus Design and SISO Design Tools
Objectives:
Design using root locus plots.
Brief introduction to SISO Deisgn Tool, and root locus design using this GUI
tool.
We will carry out Control system design using MATLAB dialogues. MATLAB is an
interpreted language. That is, it runs along executing each instruction as it comes to it. This
interactive feature of MATLAB will be exploited in our design exercise. The designer will be
in the loop.
The MATLAB SISO Design Tool, developed on the MATLAB dialogue pattern, is a
powerful GUI tool wherein the designer is always in the design loop. We will outline this
tool, with an example, at the end of this module.
Design using Matlab Dialogues
MATLAB's SISO Design tool
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL - 7.1
Root Locus Design and SISO Design Tools
Design using MATLAB dialogues
Example 7.1
A unity feedback system has forward path transfer function
Our goal is to design a cascade PID compensator that improves the transient as well as
steady-state performance of the closed-loop system (refer Nise(2004)).
We want to achieve a transient response that has no more than 20% overshoot. This, as we
know, can be achieved by simple gain adjustment. We therefore first evaluate the
uncompensated system operating at 20% overshoot. The following MATLAB dialogue is
helpful for this evaluation.
s = tf('s');
G1 = (s+8)/((s+3)*(s+6)*(s+10));
zeta = 0.456;
rlocus(G1);
sgrid(zeta,0);
Fig. 7.1
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Selecting the point of intersection of the root locus with 20% overshoot line in
Fig. 7.1 using rlocfind(G) command, MATLAB yields the gain at that point, as well as all
the poles that have that gain . The MATLAB session follows:
>> [K, p] = rlocfind(G1)
Select a point in the graphics window
selected_point =
-5.4171 +10.4814i
K =
119.6589
p =
-5.4142 +10.4814i
-5.4142 -10.4814i
-8.1716
The unit step response of the uncompensated system with K =119.6589, is given by the
following dialogue:
>> M = feedback(K*G1,1)
Transfer function:
.............119.7 s + 957.3
-------------------------------------------
s^3 + 19 s^2 + 227.7 s + 1137
>> step(M)
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 7.2
The step response is shown in Fig. 7.2; the peak time t p =0.296 sec.
The position error constant is
Therefore
Let us now fix specifications for design. Say, we want to design a PID controller so that the
closed-loop system operates with a peak time that is two-thirds that of the uncompensated
system at 20% overshoot, with zero steady-state error for a step input.
To compensate the system to reduce the peak time to two-thirds of the uncompensated
system, we must first find the compensated system's desired dominant pole location. The
imaginary part of the compensated dominant pole is
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
and the real part is
Next we design a PD compensator. We search for compensator's zero location so that the root
locus of the compensator system passes through the desired dominant pole location. If we are
using SISO Design Tool (described later in this module), the trial-and-error search for the
compensator zero is straightforward. Otherwise, we may proceed as follows.
Evaluate the angle contributed by all the poles and zeros of G(s) at s d = -8.1571+ j 15.9202
using the following MATLAB command:
>> Sd = -8.1571+15.9202i
Sd =
-8.1571 +15.9202i
angle_at_dominant_pole=(180/pi)*(angle(polyval([1,8],Sd))-(angle(polyval([1,3],Sd))...
+angle(polyval([1,6],Sd))+angle(polyval([1,10],Sd))))
angle_at_dominant_pole =
-198.4967
We find the sum of angles from uncompensated system's poles and zero to the desired
compensated dominant pole to be –198.4967o. Thus the contribution required from the
compensator zero is 198.4967 180 = 18.4967o. Assuming that compensator zero is located
at as shown in Fig. 7.3, we obtain
This gives
zc = 55.7467.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 7.3
Thus the PD controller is
The complete root locus for the PD-compensated system is sketched in Fig. 7.4. Using
rlocfind command, the gain at the design point is 5.2410. Complete analysis of PD-
compensated system is as follows:
>> D1 = s+55.7467;
>> rlocus(D1*G1);
>> sgrid(zeta,0);
>> [K,p]=rlocfind(D1*G1)
Select a point in the graphics window
selected_point =
-8.1043 +15.6832i
K =
5.2410
p =
-8.0799 +15.6914i
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
-8.0799 -15.6914i
-8.0812
The zeros are at -8,-55.7467. The effect of third closed-loop pole is nearly cancelled by a
zero.
Fig. 7.4
The PD-compensated system has settling time 0.454 sec., peak time 0.178 sec., and steady-
state error 0.072, as seen in simulation shown in Fig. 7.5.
>> M=feedback(K*D1*G1,1);
>> step(M)
We see the reduction in peak time and improvement in steady-state error over the
uncompensated system.
We now design a PI compensator to reduce the steady-state error to zero for a step input. Any
PI compensator will work as long as the zero is placed close to the origin. This ensures that
PI compensator will not change the transient response obtained with the PD compensator
(The placement of the zero of the PI compensator is not entirely arbitrary. The location of the
zero influences the magnitude of the relevant error constants. In the case of example under
consideration, the placement of the zero influences the magnitude of Kv ).
Choosing
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
we sketch the root locus for the PID-compensated system.
Fig. 7.5
The following session generates the root locus and simulates the PID-compensated system.
>> D2 = (s+0.5)/s
Transfer function:
s + 0.5
----------
.....s
>> D = D1*D2;
>> rlocus(D*G1)
>> sgrid(zeta,0)
>> [K,p]=rlocfind(D*G1)
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Select a point in the graphics window
selected_point =
-7.2512 +14.3478i
K =
4.3928
p =
-7.4116 +14.3004i
-7.4116 -14.3004i
-8.1037
-0.4660
>> step(feedback(K*D*G1,1))
The zeros are at -0.5,-8,-55.7467. The effects of third and fourth closed-loop poles are nearly
cancelled by zeros.
Fig. 7.6
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 7.7
Searching the 0.456 damping ratio line (Fig. 7.6), we find the dominant second-order poles
to be , with an associated gain of 4.3928. Simulation in Fig. 7.7 gives
settling time 2.67 sec, peak time 0.184 sec, and zero steady state error.
PD compensator improved the transient response by decreasing the time required to reach the
first peak as well as yielding some improvement in the steady-state error. The complete PID
controller further improved the steady-state error without appreciably changing the transient
response designed with the PD controller.
Example 7.2
Given a unity feedback position control system with forward path transfer function:
The goal is to design a cascade compensator to meet the following requirements (refer
Nise(2004)).
................(i) 25% overshoot, (ii) settling time: 2 sec, and (iii) Kv = 20.
The 25% overshoot corresponds to a damping ratio of 0.404. Consider the following
MATLAB session.
s = tf('s');
G1 = 6.63/((s)*(s+1.71)*(s+100));
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
zeta = 0.404;
rlocus(G1);
sgrid(zeta,0);
Properly redefine the axes of the root locus using Right click --> Properties --> Limits.
[K,p] = rlocfind(G1);
Select a point in the graphics window
selected_point =
-0.8057 + 1.8944i
>> K
K =
64.6665
>> p
p =
1.0e+002 *
-1.0004
-0.0083 + 0.0190i
-0.0083 - 0.0190i
Fig. .7.8
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
The intersection of 25% overshoot line with the root locus (Fig. 7.8) locates the system's
dominant second-order poles at and the gain at the dominant poles is
64.6665. The location of the third closed-loop pole is at 100.04; second-order
approximation is thus valid.
The simulation of the closed-loop system's step response is given by the following
commands:
M = feedback(K*G1,1);
step(M);
Fig. 7.9
Figure 7.9 shows that the design requirement of 25% overshoot is met.
The settling time is 4.07 sec. and
Comparing these values with the design requirements, we want to improve the settling time
by a factor of two and we want approximately eight-fold improvement in Kv .
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
We first attempt lead compensator design to improve transient response. To obtain a settling
time ts of 2 secs and 25% overshoot, the real part of dominant closed-loop poles should be at
and the imaginary part at
We now assume a lead compensator zero and find the compensator pole location so that lead-
compensated root locus passes through Let us assume compensator zero
at Angular contribution at the design point by open-loop poles and
compensator zero is obtained as follows:
Sd = -2+4.5285i;
angle_at_dominant_pole=(180/pi)*(angle(polyval([1,2],Sd))-(angle(polyval([1,0],Sd))...
+angle(polyval([1,1.71],Sd))+angle(polyval([1,100],Sd))))
angle_at_dominant_pole =
-120.1384
Compensator pole must contribute 120.1384 -180 = -59.8616o for the design point to be on
the compensated system's root locus. From the geometry shown in Fig. 7.10,
This gives pc = 4.6291.
Fig. 7.10
Thus the lead compensator is
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Root locus plot and its analysis for the lead-compensated system is given by the following
MATLAB session.
>> D1 = (s+2)/(s+4.6291);
>> rlocus(D1*G1);
>> sgrid(zeta,0)
Properly redefine the axes of the root locus using Right click --> Properties --> Limits .
>> [K,p] = rlocfind(D1*G1)
Select a point in the graphics window
selected_point =
-1.9621 + 4.4410i
K =
372.8743
p =
1.0e+002 *
-1.0026
-0.0200 + 0.0444i
-0.0200 - 0.0444i
-0.0208
>> step(feedback(K*D1*G1,1));
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 7.11
Fig. 7.12
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
The transient response specifications are satisfied, with gain = 372.8743 (Figs. 7.11-7.12).
The lead-compensated system Kv becomes
Since we want Kv=20, the amount of improvement required over the lead-compensated
system is 20/6.2462=3.2. Choose pc =0.01 and calculate zc =0.0032, which is 3.2 times larger
than pc, that is we choose the lag compensator as
Root locus plot and its analysis for the complete lag-lead compensated system is given by the
following session:
D2 = (s+0.032)/(s+0.01);
rlocus(D1*D2*G1);
sgrid(zeta,0);
Properly redefine the axes of the root locus using Right click --> Properties --> Limits.
>> [K,p] = rlocfind(D1*D2*G1)
Select a point in the graphics window
selected_point =
-1.9621 + 4.4410i
K =
373.5528
p =
1.0e+002 *
-1.0026
-0.0199 + 0.0444i
-0.0199 - 0.0444i
-0.0208
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
-0.0003
>> step(feedback(K*D1*D2*G1,1))
Fig. 7.13
Fig. 7.14
The design point has not moved with the addition of the lag compensator, and the gain at this
point is 373.5528 (Fig. 7.13). We also see from Fig. 7.14 that peak overshoot is higher than
specified. The system may be redesigned to reduce the peak overshoot.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Example 7.3
Consider a unity feedback system with the plant
The plant varies significantly:
It is desired to achieve robust behaviour (refer Dorf and Bishop (1998)). A design carried on
the nominal plant with K =1, gives the following cascade compensator.
For qualitative robustness analysis, we have obtained step response for the four conditions:
and . The results obtained using the
following MATLAB code, are summarized in Fig. 7.15, and Table 7.1.
s = tf('s');
G1 = 1/((s+1)^2);
G2 = 1/((0.5*s+1)^2);
G3 = 2/((s+1)^2);
G4 = 2/((0.5*s+1)^2);
D = (1+0.16*s)*(72.54+12/s);
M1 = feedback(G1*D,1);
M2 = feedback(G2*D,1);
M3 = feedback(G3*D,1);
M4 = feedback(G4*D,1);
step(M1);
hold;
step(M2);
step(M3);
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
step(M4);
The scale has been modified using Right click --> Properties -->Limits.
Fig. 7.15
Table 7.1
Plant
conditions
M1 (nominal
system)
M2 M3 M4
Percent
overshoot
11.9 2.4 8.69 1.63
Settling time
(sec)
0.551 0.155 0.40 0.0351
As is seen from this robustness analysis, the deviations from the nominal design performance
do not take the system outside the acceptable range; the design is therefore robust.
Example 7.4
A control system has the structure shown in Fig 7.16. The parameter variations are
and with the nominal conditions Km = 2 and p =4. Furthermore,
a third pole at s= 50 has been omitted from the model (refer Dorf and Bishop(1998)).
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 7.16
A design carried out on the nominal system gives the following result.
We examine the performance of the system with nominal parameters Km =2, p =4; and worst-
case parameters Km =1.5, p =3. We also examine the nominal system with the third-pole
added, so that the control plant is
The robustness analysis results, obtained using the following MATLAB code, are
summarized in Fig. 7.17 and Table 7.2.
s = tf('s');
G1 = 2/(s*(s+4));
G2 = 1.5/(s*(s+3));
G3 = 2*50/(s*(s+4)*(s+50));
D = (1+0.06*s)*(294.69+4453/s);
M1 = feedback(G1*D,1);
M2 = feedback(G2*D,1);
M3 = feedback(G3*D,1);
step(M1);
hold;
step(M2);
step(M3);
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
The scale has been modified using Right click --> Properties -->Limits.
Fig 7.17
Table 7.2
Plant
conditions
M1 (nominal
system)
M2 M3
Percent
overshoot
31.9 39.2 81.6
Settling time
(sec)
0.266 0.394 0.847
The system does not offer robust performance to parameter variations. The response of the
system with added pole shows that again the system fails the requirement of robust
performance. Since the results are not robust, it is possible to iterate on the design until an
acceptable performance is achieved. The interactive capability of MATLAB allows us to
check the robustness by simulation.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL - 7.2
Root Locus Design and SISO Design Tools
MATLAB's SISO Design Tool
The SISO ( Single- Input/ Single- Output) Design Tool is a graphical user interface
which allows one to design single-input/single-output compensators by interacting
with the root locus plots and Bode plots of the closed-loop/open-loop systems. The
tool also has the option of using a Nichols chart, which can be selected under the
View menu. After the tool produces these plots, one can adjust the closed-loop poles
along the root locus and read gain, damping ratio, natural frequency, and pole
locations. These changes immediately get reflected to Bode plots and immediate
changes in the system's closed-loop response can be viewed in the LTI Viewer for
SISO Design Tool window.
One can add poles, zeros, and compensators, which can be interactively changed to
see the immediate effects on the root locus, Bode plots, and time response.
With Bode plots, one can affect the gain change by shifting the Bode magnitude
curve up and down; and gain, gain margin, gain crossover frequency, phase margin,
phase crossover frequency, and whether the loop is stable or unstable can be checked.
These changes immediately get reflected to root locus plots and immediate changes
in the system's closed-loop response can be viewed in the LTI Viewer for SISO
Design Tool window.
The following steps are required to use the SISO Design Tool.
1. Access the SISO Design Tool: The SISO Design Tool window, shown in Fig.
7.18, can be accessed by typing sisotool in the MATLAB Command Window or by
executing this command in an M-file. In the block diagram given in the top-right
corner of SISO Design Tool window, C represents the compensator.
...............An interactive tutorial on SISO Design Tool can be invoked by selecting
SISO Design Tool Help under the SISO Design Tool window Help menu.
2. Create LTI transfer functions: Create open-loop LTI transfer functions for which
you want to analyze closed-loop characteristics or design compensators. The transfer
functions can be created in an M-file or in the MATLAB Command Window. Run
the M-file or MATLAB Command Window statements to place the transfer function
in the MATLAB workspace. All LTI objects in the MATLAB workspace can be
exported to the SISO Design Tool .
The following MATLAB commands create the transfer function .
num=4500;
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
den=[1 361.2 0];
G=tf(num,den)
3. Create the closed-loop model for the SISO Design Tool: Choose Import… under
the File menu in the SISO Design Tool window to display the window shown in Fig.
7.19.
LTI objects can be selected from the SISO Models list and can be exported
to one of the blocks of the system by pressing the right-facing arrow next to the
selected block ( G, H, F, or C ) located in the section of the window labeled System
Data. Press the Other… button to rotate through a selection of feedback structures
and select the desired configuration. Alternatively, this can also be done by pressing
the FS button on the bottom right corner of closed-loop block diagram in the SISO
Design Tool window (Fig. 7.18). Root locus and Bode diagrams will change
immediately to reflect the changes in the feedback structure (Fig. 7.20).
LTI transfer function generating command, tf(num,den), can also be supplied
directly into the spaces for transfer functions in Fig. 7.19.
Fig. 7.18 SISO Design Tool window
4. Interact with the SISO Design Tool: After the Import System Data window
closes, the SISO Design Tool window now contains the root locus and Bode plots
for the system as shown in Fig. 7.20. In this example, we have considered the open-
loop system given by
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
.
Under the Analysis menu, select the desired response to open the LTI Viewer for
SISO Design Tool window (Fig. 7.21). Right-click on the LTI Viewer for SISO
Design Tool and choose desired Plot Types, Systems, and Characteristics.
Fig. 7.19 Import System Data Window
Loop gain can be changed in three different ways:
i. In Root Locus Editor: Keep the mouse pointer on a closed-loop pole
(squares) on the root locus. The arrow cursor changes to a hand. Hold
down the left mouse button and drag the closed-loop pole along the
root locus. Bode plot and the closed-loop response in the LTI Viewer
will immediately change to reflect the gain change. The value of the
gain will be displayed in the Current Compensator section of the
SISO Design Tool window.
ii. In Open-Loop Bode Editor: Keep the mouse pointer anywhere on
the Bode magnitude curve. The arrow cursor changes to a hand. Hold
down the left mouse button and shift the curve up or down. Root locus
and closed-loop response in the LTI Viewer will immediately change
to reflect the gain change.
iii. In the Current Compensator Window: Type the desired gain value
in the C(s)= box in the SISO Design Tool window.
With gain changes, you can read the gain and phase margins and gain
crossover and phase crossover frequencies at the bottom of the Bode
magnitude and phase plots. Also, at the bottom of the Bode magnitude plot,
you are told whether or not the closed-loop system is stable.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 7.20 Root locus and Bode plots of G in SISO Design Tool window
Fig. 7.21 LTI Viewer for SISO Design Tool window
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
5. Design constraints: Design constraints may be added to your plots. These
constraints may be selected by right-clicking a respective plot and selecting
Design Constraints. To put new constraints, choose New… and to edit
existing constraints, choose Edit… . For example, Fig.7.22 shows the
selection of design constraint: damping ratio=0.5. On pressing OK, indicators
appear identifying portions of the root locus where the damping ratio is less
than 0.5(shaded gray), equal to 0.5(damping line), and greater than 0.5(
Fig.7.23 ). Note the change made in axes limits in this figure with respect to
Fig.7.20 using the Property Editor
Constraints may also be edited on the plots. Two black squares appear
on the constraint. You can drag these with your mouse anywhere in the plot
region. Point the mouse at the boundary of the constraint. When it changes to
four-pointed arrow, you can drag the boundary to a new position. The values
of the constraints are displayed in the Status Bar at the bottom of the plots.
Fig. 7.22 Adding design constraints
Fig.7.23 Adding design constraints
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
6. Properties: Right-clicking in a plot's window and selecting Properties…
displays the Property Editor window. From this window, some of the
properties of the plot such as axes labels and limits can be controlled. Try
exploring various options available with root locus and Bode plot properties
editor.
7. Add poles, zeros, and compensators: Poles and zeros may be added from
the SISO Design Tool window toolbar shown in Fig. 7.23. Let your mouse
pointer rest on the button for a few seconds to see the functionality of the
button in the form of screen tips. Add real pole; Add real zero; Add
complex pole; Add complex zero; Delete pole/zero; ..... functions are
available.
Use the SISO Design Tool toolbar and select the desired real/complex
pole/zero compensator. Move the mouse on the plots; your cursor shows that
a compensator was selected.. Place the cursor arrow to the point on the root
locus or Bode plot where you want to add the compensator, and click. The
compensator will be updated in the Current Compensator section of the
SISO Design Tool window. Compensator addition will be reflected
immediately in the root locus, Bode plots, and LTI Viewer for SISO Design
Tool window.
Go to SISO Tool Preferences… --> Options under the Edit menu to change
the way the compensator is represented.
8. Editing compensators and prefilters: The pole and zero values of the
compensators and prefilters can be edited in several ways. The most
convenient is to click on C or F blocks in the block diagram representation in
top-right corner of the SISO Design Tool window (Fig. 7.23).This operation
will open prefilter or compensator editor window shown in Fig. 7.24. Desired
real/complex zero/pole locations can be edited here. The same windows can
also be opened by following Compensators Edit C or F from the
SISO Design Tool window.
In control systems design, we use compensators of the form
that alter the roots of the characteristic equation of the closed-loop system.
However, the closed-loop transfer function, M(s), will contain the zero of D(s)
as a zero of M(s).This zero may significantly affect the response of the system
M(s). We may use a prefilter F(s) to reduce the effect of this zero on M(s). For
example, if we select
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
we cancel the effect of the zero without changing the dc gain. Prefilters
may be employed with lead/PD compensation.
Fig. 7.24 Editing compensators and prefilters
Example 7.4
Consider a plant with the following transfer function:
We will design a cascade controller using SISO Design Tool in interactive
mode, so that the unity feedback closed-loop system meets the following
criteria (refer Kuo and Golnaraghi(2003)):
Steady-state error due to unit-ramp input 0.000443
Maximum overshoot 5 percent
Rise time 0.002 sec
Settling time sec
The first step is to import the model into SISO Design Tool. System transfer
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
functions can be imported in SISO Design Tool by clicking on File and then
going to Import… Before executing this sequence, create transfer function G
in MATLAB Command Window:
num=4500;
den=[1 361.2 0];
G=tf(num,den)
In order to examine the system performance, we start by using a proportional
controller. The system root locus can be obtained by clicking on View in the
main menu and then selecting Root Locus only. Fig. 7.25 shows the root
locus of the system. The plot is for K =1(by default).
Fig. 7.25
In order to see the poles and zeros of G and H , go to the View menu and
select System Data, or alternatively, double click the block G or H in the top-
right corner of the block diagram in the SISO Design Tool window. The
System Data window is shown in Fig.7.26.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 7.26
You may obtain the closed-loop system poles by selecting Closed-Loop
Poles from the View menu. Closed-loop poles are given in Fig.7.27.
Fig. M7.27
In order to see the closed-loop system time response to a unit-step input,
select the Response to Step Command in the Analysis main menu. With
specific selections made in Systems and Characteristics submenus, we
generate Fig. 7.28, which shows the unit step response of the closed-loop
system with unity gain controller, i.e. , K= 1.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 7.28
As a first step to design a controller, we use the built-in design criteria option
within the SISO Design Tool to establish the desired closed-loop poles
regions on the root locus. To add the design constraints, use the Edit menu
and choose the Root Locus option. Select New to enter the design constraints.
The Design Constraints option allows the user to investigate the effect of the
following:
o Settling time
o Percent overshoot
o Damping ratio
o Natural frequency
We will use the settling time and the percent overshoot as primary constraints.
After designing a controller based on these constraints, we will determine
whether the system complies with the rise time constraint or not. Figure 7.29
shows the addition of settling time constraint. Peak overshoot constraint is
added on similar lines.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 7.29
Figure 7.30 shows the desired closed-loop system pole locations on the root
locus after inclusion of the design constraints (Note that the scale has been
modified by following Right click --> Properties --> Limits. Left-clicking
anywhere inside plot will remove the black squares on the zeta lines).
Obviously, closed-loop poles of the system for K = 1 are not in the desired
area. Note the definition of the desired area: the vertical gray bar signifies the
boundary for that portion of the root locus where the settling time requirement
is not met; and the gray bars on damping lines signify the boundary for that
portion of the root locus where the peak overshoot requirement is not met.
Changing K will affect the pole locations. In the Root Locus window, C(s)
represents the controller transfer function. Fig.7.30 corresponds to C(s) = K =
1 . Hence, if C(s) is increased, the effective value of K increases, forcing the
closed-loop poles to move together on the real axis, and then ultimately to
move apart to become complex. See Fig. 7.31 wherein K= 16.8 gives closed-
loop poles on the damping lines. However, the settling time requirement is not
met.
Fig. 7.30
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 7.31
The closed-loop poles of the system must lie to the left of the boundary
imposed by the settling time(Fig. 7.31). Obviously, it is impossible to use the
proportional controller (for any value of K ) to move the poles of the closed-
loop system farther to the left-hand plane. However, a PD controller C(s)= K
(1+ sTD ) may be used to accomplish this task. The zero s = - 1/ TD of the
compensator has to be placed far into the left half plane to move the root-
locus plot to the left. We have tried various values:
s = - 1/0.0005; - 1/0.001; - 1/0.0015; - 1/0.002,...
The value s = -1/0.00095 gives satisfactory results.
To add a zero to the controller, click the C block in the block diagram in top-
right corner of Fig. 7.31. Fig. 7.32 shows the Edit Compensator window and
how the PD controller is added:
Fig. 7.32
Figure 7.33 shows the plot for s= - 1/0.00095. Note that the closed-loop poles
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
have been dragged to the desired locations. The value of K that achieves the
desired dominent closed-loop poles is 282. This value of K forces the closed-
loop poles to the desired region. The system closed-loop poles are shown in
Fig. 7.34.
Fig. 7.33
Fig. 7.34
The step response of the controlled system in Fig. 7.35 shows that the system
has now complied with all design criteria.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 7.35
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL - 8
Stability Analysis on Bode / Nyquist Plots
Objectives:
Introducing MATLAB commands for Bode and Nyquist plots.
Stability analysis using these plots .
As with the root locus plots, it will be tempting to rely exclusively on MATLAB to obtain
Bode, Nyquist, and other frequency-response plots. We strongly recommend that MATLAB
should be treated as one tool in the tool kit that can be used to design and analyze control
systems. There is no substitute for a clear understanding of the underlying theory.
MATLAB font does not permit the frequency symbol , which will appear as w in our
MATLAB codes. Also note that the default unit for frequency is rad/sec. This can be altered,
if required, to hertz by editing the plot axes; but we will continue to use rad/sec
Bode Plots
Nyquist Plots
Stability Margins
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL – 8.1
Stability Analysis on Bode / Nyquist Plots
Bode Plots
For a given transfer function G(s), Bode plot can be produced in different ways:
1. By simply using the command
bode (G)
We will get the Bode plot of G(s) in the current window for a default frequency range set by
the MATLAB package. MATLAB will automatically choose the frequency values by placing
more points in regions where the frequency response is changing rapidly. Fig. 8.1 shows the
Bode diagram for the transfer function
generated by the following code.
s = tf('s');
G = (s+1)/(0.1*s+1);
bode(G);
Fig. 8.1
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
2. To produce a Bode plot over a specified frequency range wmin to wmax, we use the
command
bode (G, {wmin, wmax})
For example, bode(G,{0.1,10}) will produce a Bode plot in the range 0.1 to 10 rad/sec,
shown in Fig. 8.2.
Fig. 8.2
If we supply the vector
w = [0.1; 0.3; 0.5; 0.7; 0.9; 1.0; 3.0; 5.0; 7.0; 9.0; 10];
and type
bode (G,w)
MATLAB will compute the magnitude and phase at the frequency points supplied in the
frequency vector.
If you choose to specify the frequencies explicitly, it is desirable to generate the vector w
using the logspace function. logspace (d1,d2) generates a vector of 50 points logarithmically
equally spaced between decades 10d1
and 10d2
. (50 points include both endpoints. There are
48 points between the endpoints). To generate 50 points between 0.1 rad/sec and 100 rad/sec,
enter the command
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
w = logspace (-1,2)
logspace(d1,d2,n) generates n points logarithmically equally spaced between decades 10d1
and 10d2
( n points include both endpoints). For example, to generate 100 points between 1
rad/sec and 1000 rad/sec, enter the command
w = logspace (0,3,100)
3. When invoked with left-hand arguments, such as
[mag,phase,w] = bode (G)
bode returns the frequency response of the system in variables mag, phase and w. No plot is
drawn on the screen. The magnitude and phase characteristics are placed in the workspace
through the matrices mag and phase. The vector w contains the values of the frequency in
rad/sec at which the magnitude and phase will be calculated.
If we supply the vector w and type
[mag, phase, w] = bode (G,w)
MATLAB will use the frequency vector supplied and compute the magnitude and phase at
those frequency points. This is clear from the following MATLAB session.
>> w = logspace(-1, 1, 5)
w = 0.1000 0.3162 1.0000 3.1623 10.0000
>> [mag,phase,w]=bode(G,w)
mag(:,:,1) =
1.0049
mag(:,:,2) =
1.0483
mag(:,:,3) =
1.4072
mag(:,:,4) =
3.1623
mag(:,:,5) =
7.1063
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
phase(:,:,1) =
5.1377
phase(:,:,2) =
15.7372
phase(:,:,3) =
39.2894
phase(:,:,4) =
54.9032
phase(:,:,5) =
39.2894
w =
0.1000
0.3162
1.0000
3.1623
10.0000
MATLAB does not assume that the system is a SISO system, but allows greater flexibility for
dealing with more complex systems. MATLAB stores mag and phase variables as matrices
of dimension p x q x n, where p is the number of inputs, q is the number of outputs, and n is
the number of frequency points. For SISO systems, the dimension of mag and phase will be
To access the magnitude and phase points for pth
input and qth
output, we have to
write mag(p, q, :) or phase(p, q, :). For example,
>> mag(1,1,3)
ans =
1.4072
>> phase(1,1,3)
ans =
39.2894
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
For SISO systems, mag(:,:,3) and phase(:,:,3) will also give the same answer.
We use mag(:,:)', phase(:,:)' to convert arrays to column vectors, where the apostrophe
signifies matrix transpose. For example, the following command stores points of the Bode
plot in matrix form with magnitude in dB, phase in degrees, and frequency in rad/sec.
bode_points = [w, 20*log10( mag(:,:)' ), phase(:,:)' ]
Information about the plots obtained with bode can be found by left-clicking the mouse on
the curve. You can find the curve's label, as well as the coordinates of the point on which you
clicked. Right-clicking away from a curve brings up a menu. Form this menu, you can select
(i) system responses to be displayed (magnitude plot, phase plot, or both), and (ii)
characteristics, such as peak response and stability margins. When selected, a dot appears on
the curve at the appropriate point. Let your mouse rest on the point to read the value of the
characteristic. You may also (iii) select the frequency units in Hz., magnitude in absolute,
phase in radians, (iv) set axis limits, and (v) grid etc.
A Bode plot with grid selected is shown in Fig. 8.3.
Fig. 8.3
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL - 8.2
Stability Analysis on Bode / Nyquist Plots
Nyquist Plots
We can use MATLAB to make Nyquist plots using the command nyquist(G). Information
about the plots obtained with this command can be found by left-clicking the mouse on the
curve. You can find the curve's label, as well as the coordinates of the point on which you
have clicked and the frequency. Right-clicking away from a curve brings up a menu. From
this menu, you can select (i) system responses to be displayed (with and without negative
frequencies), and (ii) characteristics, such as peak response and stability margins. When
selected, a dot appears on the curve at the appropriate point. Let your mouse rest on the point
to read the value of the characteristic. You may also (iii) select the frequency units in Hz.,
(iv) set axis limits, and (v) grid etc.
We can obtain points on the plot by using [re im w] = nyquist(G), where the real part,
imaginary part, and frequency are stored in re, im, and w, respectively. re and im are 3-
dimensional arrays. We use re(:,:)' and im(:,:)' to convert the arrays to column vectors. We
can specify the range of w by using [re,im] = nyquist(G,w).
A sample Nyquist plot generation is illustrated below.
s = tf('s');
G = 1/(s^2+0.8*s+1);
nyquist(G);
axis equal;
Fig. 8.4
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Axis used should be ' equal ', otherwise circles appear squashed.
Note that when a MATLAB operation involves ' Divide by zero ', the resulting Nyquist plot
may be erroneous. For example, Nyquist plot of
is shown in Fig. 8.5.
G=1/((s)*(s+1));
nyquist(G)
Fig. 8.5
If such an erroneous Nyquist plot appears, then it can be corrected by manipulating the axes.
For example, manipulating the x-axis to [-2,2] and y-axis to [-5,5] in Fig. 8.5, results in the
Nyquist plot shown in Fig. 8.6.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 8.6
Sometimes in the course of using the nyquist function, we may find that a Nyquist plot looks
nontraditional or that some information appears to be missing. It may be necessary in these
cases to adjust the axes and override the automatic scaling, and/or to use the nyquist function
with left-hand arguments with specified frequency range in conjunction with the plot
function. In this way we can focus on the critical region for our stability analysis.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL – 8.3
Stability Analysis on Bode / Nyquist Plots
Stability Margins
We use [GM, PM] = margin(G) to find gain margin (GM) and phase margin (PM).
We use [GM, PM, wg, wphi] = margin(G) to find gain margin (GM), phase margin (PM),
gain crossover frequency (wg), and phase crossover frequency (wphi).
The margin function is invoked in conjunction with the bode function to compute gain and
phase margins. If the margin(G) is invoked without left-hand arguments, the Bode plot is
automatically generated with gain margin, phase margin, gain crossover frequency, and phase
crossover frequency labeled on the plot. This is illustrated in Fig. 8.7.
s = tf('s');
G = 1/(s^2+0.8*s+1);
margin(G);
Fig. 8.7
Stability margins, and gain and phase crossover frequencies are also given by the right-
clicking feature on the plots generated using the MATLAB functions nyquist and bode .
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL - 9
Frequency Response Characteristics
Objectives:
Frequency response measures from Bode plots and Nichols chart, for unity-
feedback systems.
Frequency response measures from Bode plots for nonunity-feedback systems.
MATLAB has a powerful GUI tool, called LTI Viewer, for obtaining both the time and
frequency response characteristics of a given Linear Time Invariant system. The basic
features of this GUI tool and its use for time response analysis have already been given in
MATLAB Module 5. The use of LTI Viewer for frequency response analysis is similar.
The frequency response parameters can also be obtained from the plots generated by the
commands nyquist, bode, and nichols. Right-clicking away from the curves generated by
these commands brings up a menu. From the menu, various frequency-response
characteristics can be selected.
Important measures of performance of control systems are the resonance peak Mr , the
resonance frequency , the bandwidth of the closed-loop frequency response, phase
margin , gain margin GM , gain crossover frequency , and phase crossover frequency
.
We observed in module 8 that the measures of performance of a closed-loop system can be
obtained from the Bode plots of its open-loop transfer function. In this module, we will use
Nichols chart that gives closed-loop performance measures from the open-loop frequency
response. However, this technique is applicable only for unity feedback systems. For non-
unity feedback systems, we construct the closed-loop frequency response and therefrom
obtain the measures of performance.
Non-unity Feedback Systems
Unity Feedback Systems on Nichols Chart
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL - 10
Frequency Response Design and SISO Design Tool
Objectives:
Design using Bode plots and Nichols chart.
Frequency response design using SISO Design Tool.
We will carry out Control system design using MATLAB dialogues. MATLAB is an
interpreted language. That is, it runs along executing each instruction as it comes to it. This
interactive feature of MATLAB will be exploited in our design exercise. The designer will
always be in the loop.
The MATLAB SISO Design Tool, developed on the MATLAB dialogue pattern, is a
powerful GUI tool, wherein the designer is always in the design loop. We have outlined this
tool earlier in MATLAB Module 7. An example of frequency response design using this tool
will be given at the end of this module.
Design Using MATLAB Dialogues
Robustness Analysis
Design Using SISO Design Tool
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL - 10.1
Frequency Response Design and SISO Design Tool
Design Using MATLAB Dialogues
Example 10.1
A unity feedback system has forward path transfer function
Our goal is to design a cascade PD compensator so that the closed-loop system meets the
following specifications (refer Kuo and Golnaraghi (2003)).
Steady-state error due to unit-ramp input 0.000443
Phase angle
Resonance peak
Bandwidth
We want to achieve a steady-state response that has no more than 0.000443 error due to unit-
ramp input. This, as we know, can be achieved by simple gain adjustment. We therefore first
evaluate the ‘uncompensated system' that meets the steady-state accuracy requirement. K
should be set at 181.17.
We now examine the performance of the uncompensated system. The following MATLAB
dialogue is helpful:
s = tf('s');
G = (4500*181.17)/(s*(s+361.2));
figure(1);
margin(G);
grid;
figure(2);
nichols(G);
ngrid;
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 10.1
Fig. 10.2
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Since the plot in Nichols coordinate system does not touch any of the M-contours
available by default in the ngrid command, we may generate Bode plot of uncompensated
feedback system to obtain resonance peak Mr.
Fig. 10.3
The uncompensated system with K = 181.17 has (Figs 10.1-10.3) a phase margin
gain crossover frequency resonance peak Mr = 2.5527 (
Mr=108.14/20
), and bandwidth
A PD compensator with transfer function
has asymptotic Bode plot of the form shown in Fig. 10.4.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 10.4
The logical way to approach the design problem is to first examine how much additional
phase is needed to realize a of 80o. Since the uncompensated system with the gain set to
meet the steady-state requirement has of only 22.6o, the PD compensator must provide
an additional phase of 80 22.6=57.4o. The additional phase must be placed at the desired
gain crossover frequency of the compensated system in order to realize a of 80o.
Referring to the asymptotic Bode plot of PD compensator shown in Fig. 10.4, we see that the
additional phase at frequencies > 1/ TD is always accompanied by a gain in the magnitude
curve. As a result, the gain crossover of the compensated system will be pushed to a higher
frequency. At new gain crossover, the phase of the uncompensated system would correspond
to smaller . Thus we may run into the problem of diminishing returns.
Simple trial-and-error placement of corner frequency of the compensator around the gain
crossover frequency can meet the design requirements. The performance measures in the
frequency domain for the compensated system with the compensator parameters: TD =
0.0005, 0.001, 0.0015, 0.002, and 0.0017, are tabulated in Table 10.1. With TD = 0.0017, the
performance requirements in frequency domain are all satisfied.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Table 10.1
T D
M r =10 dB/20
0.0005 46.1 913 1330 1.3630
0.001 65.5 1060 1590 1.1311
0.0015 78.5 1320 1600 1.0464
0.002 85.5 1660 2050 1.0125
0.0017 81.9 1450 1650 1.0292
The following MATLAB dialogue gives one result of Table 10.1:
Td = 0.0017;
D = 1+Td*s;
figure(1);
margin(D*G);
grid;
figure(2);
nichols(D*G);
ngrid;
figure(3);
bode(feedback(D*G,1));
Example 10.2
Let us reconsider the system of Example 10.1 (refer Kuo and Golnaraghi (2003)). Initially
we take gain K = 181.17 simply because the value was used in Example 10.1. We will tune
the total loop gain later to meet the steady-state performance requirement.
The uncompensated system with K =181.17 has =22.6o and gain crossover frequency
(refer Fig. 10.1). Let us specify to be atleast 64o , and ess (parabolic
input)
We know that PI compensator is an approximation for the lag compensator:
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
The asymptotic Bode plot of a PI compensator is shown in Fig. 10.5.
Fig. 10.5
From the Bode plot of uncompensated system (Fig. 10.6), we find that the new gain
crossover frequency at which the phase margin is 64o, is 173 rad/sec. The magnitude of
at this frequency is 21.4 dB. Thus the PI compensator should provide an attenuation of
21.4 dB at = 173 rad/sec.
s = tf('s');
G = (4500*181.17)/(s*(s+361.2));
margin(G);
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 10.6
A simple trial-and-error for values of that are sufficiently small (low-
frequency range) can meet the design requirements. The performance measures in the
frequency domain for the compensated system with the compensator parameters: KP =
and KI= 0.00851, 0.0851, 0.851, and 1.702, are tabulated in Table 10.2. Note
that for the values of KP / KI = that are sufficiently small, all vary
little. We choose KI = 0.0851. With this value of KI, the performance requirements in
frequency domain are all satisfied.
Table 10.2
KI
Mr=10
dB/20
0.00851 64.3 173 279 1.0022
0.0851 64.1 173 285 1.0070
0.851 61.1 173 324 1.0572
1.702 57.7 174 323 1.1171
The following MATLAB dialogue gives one of the results of Table 10.2.
KI = 0.0851;
D = 0.0851+(KI/s);
figure(1);
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
margin(D*G);
grid;
figure(2);
nichols(D*G);
ngrid;
figure(3);
bode(feedback(D*G,1));
Let us now evaluate the steady-state performance.
Steady-state requirement is thus satisfied.
It should be noted that of the system can be improved further by increasing the value of
above 1/0.0851. However, the bandwidth of the system will be reduced. For example, for
is increased to 75.7o but is reduced to 127 rad/sec.
Example 10.3
Consider the unity-feedback system whose open-loop transfer function is
The system is to be compensated to meet the following specifications:
1. Velocity error constant K v = 30.
2. Phase margin .
3. Bandwidth .
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
It easily follows that K =30 satisfies the specification on KV. The Bode plot of with
K =30 is shown in Fig. 10.7 from which it is found that the uncompensated system has a gain
crossover frequency and phase margin = 17.2o .
s = tf('s');
G = 1/(s*(0.1*s+1)*(0.2*s+1));
K = 30;
margin(K*G);
Fig. 10.7
If lag compensation is employed for this system, the bandwidth will decrease sufficiently so
as to fall short of the specified value of 12 rad/sec, resulting in a sluggish system. This fact
can be verified by designing a lag compensator. If on the other hand, lead compensation is
attempted, the bandwidth of the resulting system will be much higher than the specified
value; the closed-loop system will be sensitive to noise, which is undesirable. This fact can
also be verified by designing a lead compensation scheme.
Let us design a lag-lead compensator to overcome the difficulties mentioned above. Since a
full lag compensator would reduce the system bandwidth excessively, the lag section of the
lag-lead compensator must be designed to provide partial compensation only. The lag section
design therefore proceeds by making a choice of the new gain crossover frequency, which
must be higher than the crossover frequency if the system were fully lag compensated. Full
lag compensation demands that the gain crossover frequency should be shifted to a point
where the phase angle of the uncompensated system is:
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
+specified phase margin +
From Fig. 10.7, we find that this requirement is met at 2.1 rad/sec. For the design of lag
section of lag-lead compensator, the selected gain crossover frequency should be higher than
2.1. The choice is made as to start with.
From Fig. 10.7, we find that the gain of the uncompensated system at is 20.3 dB.
Therefore to bring the magnitude curve down to 0 dB at , the lag section must provide an
attenuation of 20.3 dB. This gives the parameter of the lag section as
Let us now place the upper corner frequency of the lag section at 1/0.8 rad/sec. This gives the
lag-section transfer function
Bode plot of lag-section compensated system is shown in Fig. 10.8; the phase margin is
23.8o.
D1 = (0.8*s+1)/(8*s+1);
margin(D1*K*G);
Fig. 10.8
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
We now proceed to design the lead section. We choose The maximum phase
lead provided by the lead section is therefore
The lag-compensated system has a gain of at 5.6 rad/sec. Setting
(the frequency at which the lead section has maximum phase ) = 5.6 rad/sec, we get
.
Take the lead section as
From the Bode plot and Nichols chart of the lag-lead compensated system (Figs 10.9 and
10.10), we find that the phase margin is 55.7 o
and the bandwidth is 12.5 rad/sec. The design
therefore does meet the specifications laid down.
D1 = (0.8*s+1)/(8*s+1);
D2 = (0.565*s+1)/(0.0565*s+1);
figure(1);
margin(D1*D2*K*G);
figure(2);
nichols(D1*D2*K*G);
grid;
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig.10.9
Fig.10.10
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PREACTICAL - 10.4
Frequency Response Design and SISO Design Tool
Robustness Analysis
Example 10.4
A unity feedback system has the plant
It is desired to achieve robust performance. A design carried out on nominal plant with K =1
and p0 = 1, gives the following cascade compensator (refer Dorf and Bishop (1998)).
We examine here the robustness properties of this controller for a range of plant parameter
variations of with K =5. We also examine the robustness for variations in K
with p0 fixed at 1. The results generated using the following MATLAB code are displayed in
Figs 10.11 and 10.12.
s = tf('s');
G11 = 5/((s+0.1)^2);
G21 = 5/((s+1)^2);
G31 = 5/((s+10)^2);
D = (1+0.137*s)*(4222+26300/s);
M11 = feedback(G11*D,1);
M21 = feedback(G21*D,1);
M31 = feedback(G31*D,1);
figure(1);
step(M11);
hold;
step(M21);
step(M31);
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
G12 = 1/((s+1)^2);
G22 = 2/((s+1)^2);
G32 = 5/((s+1)^2);
M12 = feedback(G12*D,1);
M22 = feedback(G22*D,1);
M32 = feedback(G32*D,1);
figure(2);
step(M12);
hold;
step(M22);
step(M32);
The scale has been modified using Right click --> Properties -->Limits.
Fig. 10.11 Variations in p0
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 10.12 Variations in K
The simulation results indicate that the PID design is robust with respect to changes in p0 and
K. The differences in the step response for are barely discernible on the plot.
Example 10.5
A unity feedback system has the nominal plant
A cascade design on the nominal system:
We examine here the robustness of the system with respect to deadtime in the loop (refer
Dorf and Bishop (1998)). Simulations were carried out with
with and 0.4 secs. The results are summarized in Fig. 10.13 and Table 10.3. The
MATLAB script is given below.
s = tf('s');
G = 3/(3.1*s+1);
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
D = (1+0.06*s)*(3.22+2.8/s);
M1 = feedback(G*D,1);
[numd1,dend1]=pade(0.1,2);
[numd2,dend2]=pade(0.4,2);
del_1 = tf(numd1,dend1);
del_2 = tf(numd2,dend2);
Gd1 = G*del_1;
Gd2 = G*del_2;
M2 = feedback(Gd1*D,1);
M3 = feedback(Gd2*D,1);
step(M1);
hold;
step(M2);
step(M3);
The scale has been modified using Right click --> Properties -->Limits.
Fig. 10.13
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Table 10.3
Plant
conditions
M1
(zero
deadtime)
M2
(deadtime=0.1)
M3
(deadtime =
0.4)
Percent
overshoot
6.78 8.57 89.4
Settling
time (sec)
3.3 2.89 7.03
Robustness analysis shows that the design is acceptably robust if deadtime is less than 0.1
sec. However, for large deadtimes of the order of 0.4 sec., the design is not robust. It is
possible to iterate on the design until an acceptable performance is achieved.
The interactive capability of MATLAB allows us to check the robustness by simulation.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
PRACTICAL - 10.3
Frequency Response Design and SISO Design Tool
Robustness Analysis
Example 10.4
A unity feedback system has the plant
It is desired to achieve robust performance. A design carried out on nominal plant with K =1
and p0 = 1, gives the following cascade compensator (refer Dorf and Bishop (1998)).
We examine here the robustness properties of this controller for a range of plant parameter
variations of with K =5. We also examine the robustness for variations in K
with p0 fixed at 1. The results generated using the following MATLAB code are displayed in
Figs 10.11 and 10.12.
s = tf('s');
G11 = 5/((s+0.1)^2);
G21 = 5/((s+1)^2);
G31 = 5/((s+10)^2);
D = (1+0.137*s)*(4222+26300/s);
M11 = feedback(G11*D,1);
M21 = feedback(G21*D,1);
M31 = feedback(G31*D,1);
figure(1);
step(M11);
hold;
step(M21);
step(M31);
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
G12 = 1/((s+1)^2);
G22 = 2/((s+1)^2);
G32 = 5/((s+1)^2);
M12 = feedback(G12*D,1);
M22 = feedback(G22*D,1);
M32 = feedback(G32*D,1);
figure(2);
step(M12);
hold;
step(M22);
step(M32);
The scale has been modified using Right click --> Properties -->Limits.
Fig. 10.11 Variations in p0
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Fig. 10.12 Variations in K
The simulation results indicate that the PID design is robust with respect to changes in p0 and
K. The differences in the step response for are barely discernible on the plot.
Example 10.5
A unity feedback system has the nominal plant
A cascade design on the nominal system:
We examine here the robustness of the system with respect to deadtime in the loop (refer
Dorf and Bishop (1998)). Simulations were carried out with
with and 0.4 secs. The results are summarized in Fig. 10.13 and Table 10.3. The
MATLAB script is given below.
s = tf('s');
G = 3/(3.1*s+1);
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
D = (1+0.06*s)*(3.22+2.8/s);
M1 = feedback(G*D,1);
[numd1,dend1]=pade(0.1,2);
[numd2,dend2]=pade(0.4,2);
del_1 = tf(numd1,dend1);
del_2 = tf(numd2,dend2);
Gd1 = G*del_1;
Gd2 = G*del_2;
M2 = feedback(Gd1*D,1);
M3 = feedback(Gd2*D,1);
step(M1);
hold;
step(M2);
step(M3);
The scale has been modified using Right click --> Properties -->Limits.
Fig. 10.13
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot
Table 10.3
Plant
conditions
M1
(zero
deadtime)
M2
(deadtime=0.1)
M3
(deadtime =
0.4)
Percent
overshoot
6.78 8.57 89.4
Settling
time (sec)
3.3 2.89 7.03
Robustness analysis shows that the design is acceptably robust if deadtime is less than 0.1
sec. However, for large deadtimes of the order of 0.4 sec., the design is not robust. It is
possible to iterate on the design until an acceptable performance is achieved.
The interactive capability of MATLAB allows us to check the robustness by simulation.
CSE Lab Manual E.C. Department Sanjaybhai Rajguru College of Engineering, Rajkot