Control System Lab Manual V 1
Control System Lab Manual V 1
Control System Lab Manual V 1
Lab Manual
(Based on OBE System)
Prepared by:
Engr. M.Farhan
(Lecturer, UET Campus Kohat)
1
List of Experiment
Lab - 1: Modeling – Transfer Function...................................................................................................... 06
Exercises
Assessment Sheet
Lab - 2: Transfer Function block in Simulink.......................................................................................... 21
Exercises
Assessment Sheet
Lab - 3: The Representation of a State Space Expression in MATLAB............................................. 43
Exercises
Assessment Sheet
Lab - 4: Transient Response Analysis with MATLAB............................................................................. 57
Exercises
Assessment Sheet
Lab - 5: System Stability Analysis using MATLAB.................................................................................. 77
Exercises
Assessment Sheet
Lab - 6: Steady State Analysis with MATLAB ........................................................................................... 85
Exercises
Assessment Sheet
Lab - 7: Time Response Characteristics and LTI Viewer...................................................................... 98
Exercises
Assessment Sheet
Lab - 8: Plotting Root Loci with MATLAB................................................................................................ 108
Exercises
Assessment Sheet
Lab - 9: Root Locus Design and SISO Design Tools.............................................................................. 117
Exercises
Assessment Sheet
Lab - 10: Stability Analysis on Bode / Nyquist Plots.......................................................................... 147
Exercises
Assessment Sheet
Lab - 11: To study DC Servo trainer and its uses...................................................................................160
Exercises
Assessment Sheet
Lab - 12: Testing the Motor direction in easy motion studio............................................................164
Exercises
Assessment Sheet
Lab - 13: Testing the voltage applied and current control in EMS.................................................167
Exercises
Assessment Sheet
Lab - 14: Open Ended Lab.............................................................................................................................170
Exercises
Assessment Sheet
2
Instructions for Students
1. Attendance is mandatory for students in all the labs. If a student is absent
from a lab due to any reason, he/she will have to get written permission of
the Chairman to perform that lab. The Chairman may allow students to
perform lab if he finds that the student has a genuine excuse.
2. Students should bring their text books to the lab, so that they can refer to
theory and diagrams whenever required.
3. Labs will be graded in double entry fashion; one entry in the assessment
sheet given at the end of every lab and another entry in the instructor’s
record. This system of keeping records will keep students aware of their
performance throughout the lab.
4. The tentative marks distribution for final grade is as follows:
Lab Performance – 30 %
Mid (Practical + Simulation) – 20%
Lab Project– 20%
Lab Final (Practical + Simulation) – 30 %
3
Control System
Course learning Outcomes:
Upon successful completion of the course Lab, the student will be able to:
4
Lab No. _____________
The Rubric assessment sheet at the end of every lab looks like this: Name:_______________
5
Lab – 1: Modeling – Transfer Function
1.1 Introduction
MATLAB provide “Control System Toolbox” for the analysis and design of different
control system. We will be using some of thes commands, because of limited
nature of course profile. Description of these commands will be distributed in
different modules. In this section, we will present commands related to Transfer
Functions. To see all the commands in the control system toolbox and their
functionalities, type help control in the MATLAB window.
>> help control
General.
ctrlpref - Set Control System Toolbox preferences.
InputOutputModel - Overview of input/output model objects.
DynamicSystem - Overview of dynamic system objects.
lti - Overview of linear time-invariant system
objects.
Linear models.
tf - Create transfer function (TF) models.
zpk - Create zero/pole/gain (ZPK) models.
ss - Create state-space (SS) models.
dss - Create descriptor state-space models.
delayss - Create state-space models with delayed terms.
frd - Create frequency response data (FRD) models.
pid - Create PID controller in parallel form.
pidstd - Create PID controller in standard form.
tf/exp - Create pure continuous-time delays(TF and ZPK )
filt - Specify digital filters.
InputOutputModel/set - Set/modify properties of model object.
setDelayModel - Specify internal delay model (state space only).
6
Data extraction.
tfdata - Extract numerators and denominators.
zpkdata - Extract zero/pole/gain data.
ssdata - Extract state-space matrices.
dssdata - Descriptor version of SSDATA.
frdata - Extract frequency response data.
piddata - Extract PID parameters in parallel form.
pidstddata - Extract PID parameters in standard form.
InputOutputModel/get - Access properties of model object.
ss/getDelayModel - Access internal delay model (state space only).
Model conversion.
tf - Conversion to transfer function.
zpk - Conversion to zero/pole/gain.
ss - Conversion to state space.
frd - Conversion to frequency data.
pid - Conversion to PID controller in parallel form.
pidstd - Conversion to PID controller in standard form.
c2d - Continuous to discrete conversion.
d2c - Discrete to continuous conversion.
d2d - Resample discrete-time model.
upsample - Upsample discrete-time systems.
chgTimeUnit - Change time units.
imp2exp - Implicit to explicit conversion.
System interconnection.
append - Aggregate models by appending inputs and outputs.
parallel - Connect models in parallel (see overloaded +).
series - Connect models in series (see also overloaded *).
feedback - connect models with a feedback loop.
lft - Generalized feedback interconnection.
connect - Arbitrary block-diagram interconnection.
sumblk - Specify summing junction (for use with connect).
strseq - Builds sequence of indexed strings (for I/O
naming).
System dynamics.
dcgain - Steady-state (D.C.) gain.
pole - System poles.
zero - Zeros and gain of SISO system.
tzero - Invariant zeros of MIMO system.
order - System order (number of states).
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.
freqsep - Slow/fast decomposition.
modsep - Region-based modal decomposition.
Time-domain analysis.
7
step - Step response.
stepinfo - Step response characteristics (rise time, ...)
impulse - Impulse response.
initial - Free response with initial conditions.
lsim - Response to user-defined input signal.
lsiminfo - Linear response characteristics.
gensig - Generate input signal for LSIM.
covar - Covariance of response to white noise.
Frequency-domain analysis.
bode - Bode diagrams of the frequency response.
bodemag - Bode magnitude diagram only.
sigma - Singular value frequency plot.
nyquist - Nyquist plot.
nichols - Nichols plot.
freqresp - Frequency response over a frequency grid.
evalfr - Evaluate frequency response at given frequency.
margin - Gain and phase margins.
allmargin - All crossover frequencies and related gain/phase
margins.
bandwidth - System bandwidth.
getPeakGain - Peak gain of frequency response.
getGainCrossover - Gain crossover frequencies.
DynamicSystem/norm - H2 and Hinfinity norms of LTI models.
Model simplification.
minreal - Minimal realization and pole/zero cancellation.
sminreal - Structurally minimal realization (state space).
hsvd - Hankel singular values (state contributions)
balred - Reduced-order approximations of linear models.
modred - Model order reduction.
Compensator design.
pidtune - Tune PID controller based on linear plant model.
rlocus - Evans root locus.
place - Pole placement.
estim - Form estimator given estimator gain.
reg - Form regulator given state-feedback and estimator
gains.
ss/lqg - Single-step LQG design.
lqr, dlqr - Linear-Quadratic (LQ) state-feedback regulator.
lqry - LQ regulator with output weighting.
lqrd - Discrete LQ regulator for continuous plant.
lqi - Linear-Quadratic-Integral (LQI) controller.
kalman - Kalman state estimator.
kalmd - Discrete Kalman estimator for continuous plant.
lqgreg - Build LQG regulator from LQ gain and Kalman
estimator.
lqgtrack - Build LQG servo-controller.
augstate - Augment output by appending states.
Time delays.
8
hasdelay - True for models with time delays.
totaldelay - Total delay between each input/output pair.
absorbDelay - Replace delays by poles at z=0 or phase shift.
pade - Pade approximation of continuous-time delays.
thiran - Thiran approximation of fractional discrete-time
delays.
9
replaceBlock - Replace block by value or by another block.
Demonstrations.
Type "demo toolbox control" for a list of available demos.
10
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
1.3 Polynomials
3 2
Consider a polynomial . MATLAB can interpret a vector of
length as the coefficients of an 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 can be represented by the vector in
MATLAB. For example:
>> p=[1 3 0 4]
p =
1 3 0 4
r =
-3.3553
0.1777 + 1.0773i
0.1777 - 1.0773i
11
Given roots of a polynomial in a vector, a vector of polynomial coefficients can be
obtained by the command poly.
>> polyval(p,sqrt(2))
>> p3=conv(p1,p2)
p3 =
1 5 6 4 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
12
Consider the rational fractions of the form:
Where the coefficients and are real constants, and and are integers.
A fraction of the form can be expanded into partial fractions. To do this, first
of all we factorize the denominator polynomial into first-order factors.
The roots of can be real or complex; distinct or repeated.
If , K is empty (zero).
Example 1:
13
A =
1.6667
-15.0000
13.3333
p =
-3
-1
0
K =
[ ]
Example 2:
>> 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 =
[ ]
Transfer function:
150 s^2 + 300 s + 1050
----------------------------
s^3 + 5 s^2 + 4s
Transfer function:
20 s^2 +120 s + 160
------------------------------------
s^3 + 24 s^2 + 191s + 504
The command poly([-1 -2 -4]) creates a polynomial with roots at -1,-2 and -4 and
hence (s+1)(s+2)(s+4)=s^3+7s^2+14s+8
Example 5:
G= tf (2,poly([-1 -2 -4]))
G =
15
2
----------------------
s^3 + 7 s^2 + 14 s + 8
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
>> [num,den]=tfdata(G,'v')
num =
0 1 1
den =
1 3 1
>> [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:
16
(s+1)
---------------------------
(s+2.618)(s+0.382)
Transfer function:
s+1
---------------------
s^2 + 3s +1
The function pzmap(G3) 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(G3)
p =
-2.6180
-0.3820
z =
-1
Solving ODE:
This note will consider only ODEs with constant coefficients and also only
demonstrates 1st and 2nd order. This is best illustrated by a number of examples.
Example 6:
xt=dsolve('4*Dy+3*y=1','y(0)=3')
Example 7:
17
, ̇
xt2=dsolve('2*D2y+6*Dy+4*y=sin(t)','y(0)=1','Dy(0)=0')
Lab Task 1:
Lab Task 2:
Consider the rational fraction: Identify the poles and zero of system.
Lab Task 3:
, ̇
18
Assessment Sheet
Name:___________________________
Regd. No._________________________
Date of Lab:_________________________
Example
Lab Section
Lab Task
Working
Lab Performance
Viva
Instructor’s Verification
19
Lab No. _____________
Name:_______________
20
Lab – 02: Transfer Function block in Simulink
1 Introduction:
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
behavior. Once satisfactory model performance has been achieved, various
control schemes can be designed and implemented.
21
aspects neglected in the approximate model. Simulink is an excellent tool for this
evaluation.
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-touse building blocks to build the mathematical models and
system structures in terms of 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.
22
Figure 1 MATLAB Desktop main menu and SIMULINK icon
23
Figure 2 SIMULINK Library Browser
Expand the node labeled Simulink. Sub nodes of this node (Commonly Used
Blocks, Continuous, Discontinuities, Discrete, Logic and Bit Operations, etc) are
displayed. Now for example, expanding the Sources sub node displays a long list
of Sources library blocks. Simply click on any block to learn about its functionality
in the description box (see Fig .3a).
You may now collapse the Sources sub node, and expand the Sinks sub node. A
list of Sinks library block appears (Fig.6.3b). Learn the purpose of various blocks in
Sinks sub node by clicking on the blocks.
We have described some of the subsystem libraries available that contain the
basic building blocks of simulation diagrams. The reader is encouraged to explore
24
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 press Ctrl+N to open an ‘untitled' workspace (Fig. 4) to build up an
interconnection of SIMULINK blocks from the subsystem libraries.
25
Example 1 Let us take a simple example. The block diagram of a dc motor
(armature-controlled) system is shown in Fig. 5
where
We will implement the model shown in Fig. 5 in the untitled work space (Fig. 4).
Let us first identify the SIMULINK blocks required to implement the block diagram
of Fig. 5. This is given in Fig. 6.
26
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.
Expand the Sources sub node, 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. 6.7).
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...
27
Figure 8 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. 8.
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.
28
Figure 9 Transfer function block parameters window
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.
29
Another simple methodology doesn't require dragging the line. Block1 output
port is required to be connected to Block2 input port.
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.
30
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.
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'.
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
displays a tree structured view of parameter submenu. In the Solver submenu,
enter the start and stop time of the simulation (Fig. 11).
31
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 auto scale icon in the display window to scale the axes as per
the variable ranges. Auto scaled scope display is shown in Fig. 12a. With zoom
facility, try to zoom 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.
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. 12b.
Click the icon shown on the icon bar to open scope parameter editor (Fig. 13).
General parameters include Number of axes, Time range, Tick labels, and
Sampling.
32
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.
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
33
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.
2. Structure: This is the same as Structure with time; the only difference is that
the time steps will not be saved.
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.
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.
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).
The transfer function Gc(s)G(s) is computed using the series function as shown In
Figure 14 .The resulting transfer function is
35
where sys is the transfer function name
Figure 14: Application of the series function via (a) Simulink (b) series command
Let the process, G(s), and the controller, Gc(s), be as shown in Figure 15. To apply
the feedback function, we first use the series function to compute Gc(s)G(s),
followed by the feedback function to close the loop. The command sequence is
shown in Figure 15(b). The closed-loop transfer function is
36
Figure 15: Application of the feedback function via (a) Simulink (b) feedback
command
As an example, we will use Simulink to solve the first order differential equation
(ODE)
37
We can solve Equation (1) by integrating to formally obtain
∫( )
38
Lab Task 01. Simulate the control system shown in Figure 16 (a) and (b) using
SIMULINK
(a)
(b)
Lab Task 02: A multiloop feedback system is shown in Figure 17. Simulate the
control system using SIMULINK
39
Figure 17: Multiloop feedback system
(i)
(ii)
(iii)
40
Assessment Sheet
Name:___________________________
Regd. No._________________________
Date of Lab:________________________
Example
Lab Section
Lab Task
Working
Lab Performance
Viva
Instructor’s Verification
41
Lab No. _____________
Name:_______________
42
Lab – 3: The Representation of a State Space Expression in MATLAB
1 Introduction
The representation of a state space expression in MATLAB is simple and
straightforward. One can simply enter the coefficient matrices A, B, C, and D into
the MATLAB environment, and the state space object can be entered as
G=ss(A,B,C,D).
can be entered into the MATLAB workspace using the following MATLAB
statements:
MATLAB is quite useful to transform the system model from transfer function to
state space, and vice versa.
43
Once we have this transfer-function expression, the MATLAB command
[A,B,C,D] = tf2ss(num,den) will give a state-space representation. It is
important to note that the state-space representation for any system is not
unique. There are many (infinitely many) state-space representations for the
same system. The MATLAB command gives one possible such state-space
representation.
There are many (infinitely many) possible state-space representations for this
system. One possible state-space representation is
44
MATLAB transforms the transfer function into the state-space representation. For
the example system considered here, MATLAB Program will produce matrices A,
B, C, and D as:
num = [1 0];
den = [1 14 56 160];
[A,B,C,D] = tf2ss(num,den)
A =
-14 -56 -160
1 0 0
0 1 0
B =
100
C =
0 1 0
D =
0
Example 3. Obtain the transfer function of the system defined by the following
state-space equations:
45
MATLAB Program will produce the transfer function for the given system.
A = [0 1 0; 0 0 1; -5 -25 -5];
B = [0; 25; -120];
C = [1 0 0];
D = [0];
[num,den] = ss2tf(A,B,C,D)
num =
0 0.0000 25.0000 5.0000
den
1.0000 5.0000 25.0000 5.0000
% ***** The same result can be obtained by entering the
following command: *****
[num,den] = ss2tf(A,B,C,D,1)
num =
0 0.0000 25.0000 5.0000
den =
1.0000 5.0000 25.0000 5.0000
46
This system involves two inputs and two outputs. Four transfer functions are
involved: Y2(s)/U1(s), Y1(s)/U2(s), Y2(s)/U2(s), Y1(s)/U1(s), and (When considering
input u1, we assume that input u2 is zero and vice versa.)
Solution. MATLAB Program produces four transfer functions. This is the MATLAB
representation of the following four transfer functions:
A = [0 1;-25 -4];
B = [1 1;0 1];
C = [1 0;0 1];
D = [0 0;0 0];
[NUM,den] = ss2tf(A,B,C,D,1)
NUM =
0 1 4
0 0 –25
den =
1 4 25
[NUM,den] = ss2tf(A,B,C,D,2)
NUM =
0 1.0000 5.0000
0 1.0000 -25.0000
den =
1 4 25
47
Example 4: Consider the mechanical system shown in Figure 1. We assume that
the system is linear. The external force u(t) is the input to the system, and the
displacement y(t) of the mass is the output. The displacement y(t) is measured
from the equilibrium position in the absence of the external force. This system is a
single-input, single-output system.
̈ ̇
This system is of second order. This means that the system involves two
integrators. Let us define state variables and as:
̇
Then we obtain
48
The output equation is
We will implement the model shown in Fig. 2 in the untitled work space. Let us
first identify the SIMULINK blocks required to implement the block diagram
of Fig. 2. This is given in Fig. 3.
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.
49
Figure 3: Simulink Model with signals connected.
50
METHOD 2: State Space Representation.
Start a new, blank model. Click on the “State-Space” block and drag this
into your blank model. Your model should now look like Figure 5.
51
Figure 5: Simulink model with source and sink
We would like to look at the response of the system using the scope.
Double click on the scope block to open it up. Auto scale the plot so
that you can see the response. You should see something similar to
Figure 4.
52
Lab Task 1: Use the feedback function to obtain the closed-loop transfer
function and then function to obtain the closed-loop state space model of
the system in Figure 7.
Lab Task 2:
53
Figure 8: Mechanical system.
54
Assessment Sheet
Name:___________________________
Regd. No._________________________
Date of Lab:_________________________
Example
Lab Section
Lab Task
Working
Lab Performance
Viva
Instructor’s Verification
55
Lab No. _____________
Name:_______________
56
Lab – 4: Transient Response Analysis with MATLAB
Introduction
Once a system is described by a certain model—be it in state space, by a transfer
function, or otherwise—it is often important to perform some form of analysis on
it. How does it respond to different system component ? Which inputs
correspond to which outputs? Is this thing stable or can we make it stable? These
are all questions we may ask of a system that comes presented to us as
a “black box.”
The MATLAB Control System Toolbox contains the functions in Table 1 for analysis
of time-domain response.
57
This system can be represented as two arrays, each containing the coefficients of
the polynomials in decreasing powers of s as follows:
num = [2 25]
den = [1 4 25]
An alternative representation is
num = [0 2 25]
den = [1 4 25]
G = tf(num,den)
For a control system defined in a state-space form, where state matrix A, control
matrix B, output matrix C, and direct transmission matrix D of state-space
equations are known, One can simply enter the coefficient matrices A, B, C, and D
into the MATLAB environment, and the state space object can be entered as
G=ss(A,B,C,D).
3 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)
>> impulse(G)
subplot(2,1,1)
step(sys)
subplot(2,1,2)
impulse(sys)
4. Response Characteristics
Right-clicking on response plots gives access to a variety of options and
annotations. In particular, the Characteristics menu lets you display standard
59
metrics such as rise time and settling time for step responses, or peak gain and
stability margins for frequency response plots.
Using the example 1 from the previous section, plot the step response:
>>step(sys)
Now, right-click on the plot to display the Peak Response and Settling Time
Characteristics, and click on the blue dots to read the corresponding overshoot
and settling time values:
If num and den (the numerator and denominator of the closed-loop transfer
function) are known, commands such as
step(num,den), step(num,den,t)
will generate plots of unit-step responses (t in the step command is the user-
specified time.)
60
Example 2:
Obtain the unit step response of the system with the closed-loop transfer
function above. Also, use the damp function to obtain the roots of the
characteristic equation, the corresponding damping factors, and the natural
frequencies.
Solution:
The following code produces the response seen in Figure 1.
>> num = 25*[0.4 1];
>> den = conv([0.16 1], [1 6 25]) % Multiplies two
polynomials.
>> T = tf(num,den) % Create TF object.
>> step(T), grid % Produces step response plot.
>> damp(T) % Produces data below:
Eigenvalue Damping Freq. (rad/s)
-3 + 4i 6.00e-001 5.00
-3 - 4i 6.00e-001 5.00
-6.25 1.00e+000 6.25
The damping factors and natural frequencies are displayed in the right two
columns. The eigenvalues are the roots of the characteristic equation.
61
Example 3:
Solution:
1. The poles are the roots of the denominator polynomial. To find this, we use
roots([1 36 205 750]). This gives us roots at −30 and −3 ± 4. To determine
dominance, we look at the time constants (negative inverse of real part)
associated with these poles. We see the pole at −30 has time constant 1 = 1/30
where as the other two have time constant 2 = 1/3. The order of magnitude
difference tells us that the poles at 3±4 are dominant.
2. To reduce the model, we factor out the negligible pole and divide the
numerator by its magnitude:
For a control system defined in a state-space form, where state matrix A, control
matrix B, output matrix C, and direct transmission matrix D of state-space
equations are known, the command
step(A,B,C,D), step(A,B,C,D,t)
will generate plots of unit-step responses. When t is not explicitly included in the
step commands, the time vector is automatically determined.
63
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
response amplitudes in y and time samples in t. (y has as many columns as
outputs and one row for each element in t.
[y,t] = step(G)
[y,t] = step(num,den,t)
[y,t] = step(A,B,C,D,iu)
[y,t] = step(A,B,C,D,iu,t)
Note in above equation that the scalar iu is an index into the inputs of the system
and specifies which input is to be used for the response, and t is the user specified
time. If the system involves multiple inputs and multiple outputs, the step
command produces a series of step-response plots, one for each input and output
combination
64
such an expression for reference. The transfer matrix G(s) for the given system
becomes
Hence,
Since this system involves two inputs and two outputs, four transfer functions
may be defined, depending on which signals are considered as input and output.
Note that, when considering the signal u1 as the input, we assume that signal u2
is zero, and vice versa.The four transfer functions are
65
Assume that u1 and u2 are unit-step functions. The four individual step-response
curves can then be plotted by use of the command
To plot two step-response curves for the input u1 in one diagram and two step-
response curves for the input u2 in another diagram, we may use the commands
step(A,B,C,D,1)
and
step(A,B,C,D,2)
respectively.
Example 5: MATLAB Program to plot two step-response curves for the input u1
in one diagram and two step-response curves for the input u2 in another diagram
Solution:
% ***** In this program we plot step-response curves of a system
% having two inputs (u1 and u2) and two outputs (y1 and y2)
*****
% ***** We shall first plot step-response curves when the input
is
% u1. Then we shall plot step-response curves when the input is
% u2 *****
% ***** Enter matrices A, B, C, and D *****
A = [-1 -1;6.5 0];
B = [1 1;1 0];
C = [1 0;0 1];
D = [0 0;0 0];
% ***** To plot step-response curves when the input is % u1,
enter the command 'step(A,B,C,D,1)' *****
figure (1) %creates a new figure window
step(A,B,C,D,1)
grid
title ('Step-Response Plots: Input = u1 (u2 = 0)')
gtext('Y1')
gtext('Y2')
66
% ***** Next, we shall plot step-response curves when the input
is u2. Enter the command 'step(A,B,C,D,2)'
figure (2) %creates a new figure window
step(A,B,C,D,2)
grid
title ('Step-Response Plots: Input = u2 (u1 = 0)')
gtext('Y1')
gtext('Y2')
gtext('text')
When gtext is executed, the computer waits until the cursor is positioned (using a
mouse) at the desired position in the screen. When the left mouse button is
pressed, the text enclosed in simple quotes is written on the plot at the cursor’s
position. Any number of gtext commands can be used in a plot.
printsys(num,den) or printsys(num,den,s)
Consider, for example, the case where =5 rad/sec and =0.4. MATLAB
Program generates the standard second-order system, where =5 rad/sec
and =0.4. Note that in MATLAB Program “num 0” is 1.
wn = 5;
damping_ratio = 0.4;
[num0,den] = ord2(wn,damping_ratio);
67
num = 5^2*num0;
printsys(num,den,'s');
MATLAB can conveniently be used to obtain the rise time, peak time, maximum
overshoot, and settling time.
S = stepinfo(sys)computes the step-response characteristics for a dynamic system
model sys. The function returns the characteristics in a structure containing the
fields:
RiseTime — Time it takes for the response to rise from 10% to 90% of the
steady-state response.
SettlingTime — Time it takes for the error |y(t) - yfinal| between the
response y(t) and the steady-state response yfinal to fall to within 2% of yfinal.
SettlingMin — Minimum value of y(t) once the response has risen.
SettlingMax — Maximum value of y(t) once the response has risen.
Overshoot — Percentage overshoot, relative to yfinal).
Undershoot — Percentage undershoot.
Peak — Peak absolute value of y(t)
PeakTime — Time at which the peak value occurs.
MATLAB Program yields the rise time, peak time, maximum overshoot, and
settling time.
num = [25];
den = [1 6 25];
G=tf(num,den)
S = stepinfo(G)
68
You can also simulate the response to an arbitrary signal, for example, a sine
wave, using the lsim command. The input signal appears in gray and the
system's response in blue.
t = 0:0.01:4;
u = sin(10*t);
For state-space models, you can also plot the unforced response from some given
initial state, for example:
69
C = [1.2 0 0.6];
D = -0.6;
G = ss(A,B,C,D);
x0 = [-1;0;2]; % initial state
initial(G,x0)
grid
The poles and zeros of a system contain valuable information about its dynamics, stability, and limits of
performance. For example, consider the feedback loop in Figure 1 where
70
Figure 1: SISO Feedback Loop.
For the gain value k = 0.7, you can plot the closed-loop poles and zeros
using pzmap:
s = tf('s');
G = (2*s+1)/(s^2+3*s+2);
k = 0.7;
T = feedback(G*k,1);
pzmap(T)
grid, axis([-2 0 -1 1])
71
The closed-loop poles (marked by blue x's) lie in the left half-plane so the
feedback loop is stable for this choice of gain k. You can read the damping ratio of
the closed-loop poles from this chart (see labels on the radial lines). Here the
damping ratio is about 0.7, suggesting a well-damped closed-loop response as
confirmed by:
clf
step(T)
To further understand how the loop gain k affects closed-loop stability, you can
plot the locus of the closed-loop poles as a function of k:
11 Comparing Systems
You can plot multiple systems at once using any of the response plot commands.
You can assign a specific color, marker, or line style to each system for easy
comparison. Using the feedback example above, plot the closed-loop step
response for three values of the loop gain k in three different colors:
72
s = tf('s');
G = (s+9)/(s^2+3*s+2);
k=0.7;
T = feedback(G*k,1);
k1 = 0.4;
T1 = feedback(G*k1,1);
k2 = 1;
T2 = feedback(G*k2,1);
step(T,'b',T1,'r',T2,'g')
legend('k = 0.7','k = 0.4','k = 1')
73
Lab Task 1: For the system represented by closed loop differential
equation, determine natural frequency, damping ratio, peak time, %
overshoot and settling time with 2 % tolerance band.
Lab Task. 2: For the system with open loop transfer function,
74
Assessment Sheet
Name:___________________________
Regd. No._________________________
Date of Lab:_________________________
Example
Lab Section
Lab Task
Working
Lab Performance
Viva
Instructor’s Verification
75
Lab No. _____________
Name:_______________
76
Lab – 05: System Stability Analysis using MATLAB
1 Introduction.
This section begins with a discussion of the Routh-Hurwitz stability method. We
will see how the computer can assist us in the stability analysis by providing an
easy and accurate method for computing the poles of the characteristic equation.
For the case of the characteristic equation as a function of a single parameter, it
will be possible to generate a plot displaying the movement of the poles as the
parameter varies.
77
Figure 2: Routh-Hurwitz array
The two sign changes in the first column indicate that there are two roots of the
characteristic polynomial in the right half-plane; hence, the closed-loop system is
unstable. We can verify the Routh-Hurwitz result by directly computing the roots
of the characteristic equation, using the pole function. Recall that the pole
function computes the system poles.
num=[1];
den=[1 1 2 23];
sysg=tf(num,den);
sys=feedback(sysg,[1]);
pole(sys)
ans =
-3.0000
1.0000+ 2.6458i
1.0000-2.6458i
78
Example 3: Consider the closed-loop feedback system shown in Figure 3 with
Transfer function associated with the closed-loop control system.
Using a Routh-Hurwitz approach, we find that we require 0 < K < 8 for stability.
We can verify this result graphically. As shown in Figure 4, we establish a vector of
values for K at which we wish to compute the roots of the characteristic equation.
Then using the roots function, we calculate and plot the roots of the characteristic
equation, as shown in Figure 4. It can be seen that as K increases, the roots of the
characteristic equation move toward the right half-plane as the gain tends toward
K — 8, and eventually into the right half-plane when K > 8.
79
The MATLAB script contains the for function. This function provides a
mechanism for repeatedly executing a series of statements a given number of
times. The for function connected to an end statement sets up a repeating
calculation loop
80
Figure 4: Closed-loop control system
The following MATLAB script plots the step response for k = 846 and k=
1460, as shown in Figure 5.
s = tf('s');
G = 1/(s*(s+7)*(s+11));
K1 = 860;
step(feedback(K1*G,1),5);
hold; % Current plot held
K2 = 1460;
step(feedback(K2*G,1),5)
K = 860 K = 1460
Lab Task 2 Consider the following closed loop of below figure, find the range of
gain K that will cause system to be stable , unstable and marginally stable. Plot
step response for three value of K
Lab Task 3: Consider the following feedback system, find the range of gain K1 and
k2 that will cause system to be stable. Plot step response for value of K1 and k2
Let
82
Assessment Sheet
Name:___________________________
Regd. No._________________________
Date of Lab:_________________________
Example
Lab Section
Lab Task
Working
Lab Performance
Viva
Instructor’s Verification
83
Lab No. _____________
Name:_______________
84
Lab – 6: Steady State Analysis with MATLAB
Objective:
1. Calculating steady-state errors
2. System type and steady-state error
3. Example: Meeting steady-state error requirements
Introduction:
Steady-state error is defined as the difference between the input (command) and
the output of a system in the limit as time goes to infinity (i.e. when the response
has reached steady state). The steady-state error will depend on the type of input
(step, ramp, etc.) as well as the system type (0, I, or II).
Note: Steady-state error analysis is only useful for stable systems. You should
always check the system for stability before performing a steady-state error
analysis. Many of the techniques that we present will give an answer even if the
error does not reach a finite steady-state value.
Before talking about the relationships between steady-state error and system
type, we will show how to calculate error regardless of system type or input.
Then, we will start deriving formulas we can apply when the system has a specific
structure and the input is one of our standard functions. Steady-state error can be
calculated from the open- or closed-loop transfer function for unity feedback
systems. For example, let's say that we have the system given below.
85
This is equivalent to the following system, where T(s) is the closed-loop transfer
function.
We can calculate the steady-state error for this system from either the open- or
closed-loop transfer function using the Final Value Theorem. Recall that this
theorem can only be applied if the subject of the limit (sE(s) in this case) has poles
with negative real part.
Now, let's plug in the Laplace transforms for some standard inputs and determine
equations to calculate steady-state error from the open-loop transfer function in
each case.
86
When we design a controller, we usually also want to compensate for
disturbances to a system. Let's say that we have a system with a disturbance that
enters in the manner shown below.
We can find the steady-state error due to a step disturbance input again
employing the Final Value Theorem (treat R(s) = 0).
87
Manipulating the blocks, we can transform the system into an equivalent unity-
feedback structure as shown below.
If you refer back to the equations for calculating steady-state errors for unity
feedback systems, you will find that we have defined certain constants (known as
the static error constants). These constants are the position constant (Kp), the
velocity constant (Kv), and the acceleration constant (Ka). Knowing the value of
these constants, as well as the system type, we can predict if our system is going
to have a finite steady-state error.
First, let's talk about system type. The system type is defined as the number of
pure integrators in the forward path of a unity-feedback system. That is, the
system type is equal to the value of n when the system is represented as in the
following figure. It does not matter if the integrators are part of the controller or
the plant.
88
Therefore, a system can be type 0, type 1, etc. The following tables summarize
how steady-state error varies with system type.
89
Since this system is type 1, there will be no steady-state error for a step input and
there will be infinite error for a parabolic input. The only input that will yield a
finite steady-state error in this system is a ramp input. We wish to choose K such
that the closed-loop system has a steady-state error of 0.1 in response to a ramp
reference. Let's first examine the ramp input response for a gain of K = 1.
s = tf('s');
G = ((s+3)*(s+5))/(s*(s+7)*(s+8));
T = feedback (G,1);
t = 0:0.1:25;
u = t;
[y,t,x] = lsim(T,u,t);
plot(t,y,'y',t,u,'m')
xlabel('Time (sec)')
ylabel('Amplitude')
title('Input-purple, Output-yellow')
The steady-state error for this system is quite large, since we can see that at time
20 seconds the output is approximately 16 as compared to an input of 20 (steady-
state error is approximately equal to 4). Let's examine this in further detail.
90
We know from our problem statement that the steady-state error must be 0.1.
Therefore, we can solve the problem following these steps:
Let's see the ramp input response for K = 37.33 by entering the following code in
the MATLAB command window.
K = 37.33 ;
s = tf('s');
G = (K*(s+3)*(s+5))/(s*(s+7)*(s+8));
sysCL = feedback(G,1);
t = 0:0.1:50;
u = t;
[y,t,x] = lsim(sysCL,u,t);
plot(t,y,'y',t,u,'m')
xlabel('Time (sec)')
ylabel('Amplitude')
title('Input-purple, Output-yellow')
91
In order to get a better view, we must zoom in on the response. We choose to
zoom in between time equals 39.9 and 40.1 seconds because that will ensure that
the system has reached steady state.
axis([39.9,40.1,39.9,40.1])
Examination of the above shows that the steady-state error is indeed 0.1 as
desired.
92
Now let's modify the problem a little bit and say that our system has the form
shown below.
In essence we are not distinguishing between the controller and the plant in our
feedback system. Now we want to achieve zero steady-state error for a ramp
input.
From our tables, we know that a system of type 2 gives us zero steady-state error
for a ramp input. Therefore, we can get zero steady-state error by simply adding
an integrator (a pole at the origin). Let's view the ramp input response for a step
input if we add an integrator and employ a gain K = 1.
s = tf('s');
P = ((s+3)*(s+5))/(s*(s+7)*(s+8));
C = 1/s;
sysCL = feedback(C*P,1);
t = 0:0.1:250;
u = t;
[y,t,x] = lsim(sysCL,u,t);
plot(t,y,'y',t,u,'m')
xlabel('Time (sec)')
ylabel('Amplitude')
title('Input-purple, Output-yellow')
93
As you can see, there is initially some oscillation (you may need to zoom in).
However, at steady state we do have zero steady-state error as desired. Let's
zoom in around 240 seconds.
axis([239.9,240.1,239.9,240.1])
94
As you can see, the steady-state error is zero. Feel free to zoom in on different
areas of the graph to observe how the response approaches steady state.
Lab Task 1: Determine the steady state errors for unit step, unit ramp, and unit
parabolic inputs of a unity feedback control system having the plant transfer
function.
Lab Task 2: Obtain the response of the system shown in Figure when the input r(t)
is given by
Discuss the effects that varying the values of K and B has on the steady-state error
in unit-ramp response. Sketch typical unit-ramp response curves for a small value,
medium value, and large value of K, assuming that B is constant.
95
Assessment Sheet
Name:___________________________
Regd. No._________________________
Date of Lab:_________________________
Example
Lab Section
Lab Task
Working
Lab Performance
Viva
Instructor’s Verification
96
Lab No. _____________
Name:_______________
OBE System
Level of Proficiency
Criteria PLO Below Basic Marks
Excellent (4) Very Good (3) Basic (2)
(1)
Model 1 Perfectly apply basic Model the behavior Model the Could not
knowledge to Model of physical systems behavior of Model the
the behavior of but have no physical systems behavior of
physical systems with supporting materials in bit and pieces physical systems
supporting materials with no
(mathematically , supporting
block diagram, material
formula)
97
Lab – 07: Time Response Characteristics and LTI Viewer
Objectives:
1. Analysis of the system behavior to changes in input reference signals or
disturbances using steady-state and transient performance indices.
2. Brief introduction to LTI Viewer, and time response analysis using this
GUI tool.
7.1 Introduction:
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.
98
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 Figure 1, can be
accessed by typing ltiview in the MATLAB Command Window or by executing this
command in an M-file.
99
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.
>> s = tf('s');
>> G = 1/(s+1);
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 (s) results in Figure 2.
3.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.
100
4.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
5. 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. 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.
101
Figure. 4 LTI Viewer with step response plot and characteristics
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.
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.
102
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, x and y limits, font sizes
and styles, colors, and response characteristics definitions.
Coordinates and curve: Left-click the mouse at any point on the plot to read
the system identification and the coordinates (Fig. 5, shown by square
block).
Add text and graphics: Under the File menu, choose Print to Figure. An
additional figure with toolbar will open (Fig. 6).The toolbar of this figure has
additional tools for adding text, arrows, lines, legends, and to rotate the
figure.
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.
Viewer preferences: Choose Viewer Preferences… in the Edit menu. LTI
Viewer Preferences window (Fig. 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).
103
Fig. 6 LTI response with text and graphics editor toolbar
104
Lab Task 1: For the system with closed loop transfer function ,
determine natural frequency, damping ratio, peak time, % overshoot and settling
time with 2 % tolerance band.
Lab Task 2: For the system represented by closed loop differential equation,
determine natural frequency, damping ratio, peak time, % overshoot and settling
time with 2 % tolerance band.
Find the range of gain K that will cause system to be stable , unstable and
marginally stable. Plot step response for three value of K
Lab Task 4: Using LTI GUI, obtain the unit-step response, unit-ramp response, and
unit-impulse response of the following system:
105
Assessment Sheet
Name:___________________________
Regd. No._________________________
Date of Lab:_________________________
Example
Lab Section
Lab Task
Working
Lab Performance
Viva
Instructor’s Verification
106
Lab No. _____________
Name:_______________
107
Lab – 08: Plotting Root Loci with MATLAB
8.1 Introduction:
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.
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
108
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.
With
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. 2. We find that the closed-loop system is stable for K <
1360; and unstable for K > 1360.
109
Figure 2: Root Locus plot for example 1.
110
Example 2: Consider the system shown in Figure 4.
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)
111
Figure 5: Root Locus plot for example 2.
selected_point =
-2.2204 + 3.0099i
K =
1.4494
p =
-2.2468 + 3.0734i
-2.2468 - 3.0734i
Example 3
112
a root locus plot shown in Fig. 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.
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.
113
Lab Task 01: Sketch the root loci for the system shown in Figure 7. (The gain K is
assumed to be positive.) Observe that for small or large values of K the system is
overdamped and for medium values of K it is underdamped.
Lab Task 02: Consider the system shown in Figure 8. Plot the root loci with
MATLAB. Locate the closed-loop poles when the gain K is set equal to 2.
Lab Task 03:Plot the root loci for the system shown in Figure 9. Determine the
range of gain K for stability.
Name:___________________________
Regd. No._________________________
Date of Lab:_________________________
Example
Lab Section
Lab Task
Working
Lab Performance
Viva
Instructor’s Verification
115
Lab No. _____________
Name:_______________
116
Lab – 9: Root Locus Design and SISO Design Tools
Objectives:
1. Design using root locus plots.
2. Brief introduction to SISO Design Tool, and root locus design using this GUI
tool.
1 Introduction:
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.
Our goal is to design a cascade Lag Lead 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.
117
s = tf('s');
G1 = (s+8)/((s+3)*(s+6)*(s+10));
zeta = 0.456;
rlocus(G1);
sgrid(zeta,0);
Selecting the point of intersection of the root locus with 20% overshoot line ( ) in
Fig. 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:
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)
The step response is shown in Fig.2; the peak time t p =0.296 sec.
The position error constant is
119
Therefore,
Let us now fix specifications for design. Say, we want to design a Lag-Lead
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.
Evaluate the angle contributed by all the poles and zeros of G(s) at
using the following MATLAB command:
>> Sd = -8.1571+15.9202i
Sd =
120
-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.3, we obtain
This gives
121
The complete root locus for the Lead-compensated system is sketched in Fig.4.
Using rlocfind command, the gain at the design point is 5.2410. Complete analysis
of Lead-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
-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.
122
The Lead-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.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 Lag compensator to reduce the steady-state error to zero for a
step input. Any Lag compensator will work as long as the zero is placed close to
the origin. This ensures that Lag compensator will not change the transient
response obtained with the Lead 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
123
We sketch the root locus for the Lead Lag compensated system.
The following session generates the root locus and simulates the Lead Lag
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)
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.
Searching the 0.456 damping ratio line (Fig. 6), we find the dominant second-
order poles to be with an associated gain of 4.3928.
Simulation in Fig. 7 gives settling time 2.67 sec, peak time 0.184 sec, and zero
steady state error.
124
Figure 6: root locus for the Lead Lag compensated system.
125
Lead 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 Lead Lag controller further improved the steady-
state error without appreciably changing the transient response designed with
the Lead controller.
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. 8,
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.
126
Fig. 8 SISO Design Tool window
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 .
127
num=4500;
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. 9.
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. 10). Root locus
and Bode diagrams will change immediately to reflect the changes in the
feedback structure (Fig. 10).
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. 10. In this example, we have considered
the open-loop system given by
Under the Analysis menu, select the desired response to open the LTI Viewer for
SISO Design Tool window (Fig. 11). Right-click on the LTI Viewer for SISO Design
Tool and choose desired Plot Types, Systems, and Characteristics.
128
Fig. 9 Import System Data Window
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
129
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.
Fig. 10 Root locus and Bode plots of G in SISO Design Tool window
130
Fig. 11 LTI Viewer for SISO Design Tool window
Constraints may also be edited on the plots. Two black squares appear on
131
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.
132
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. 13. 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. M7.23).This
operation will open prefilter or compensator editor window shown in Fig.
M7.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.
133
That alters 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 pre-filter F(s) to reduce the effect of this zero on M(s). For example,
if we select
We cancel the effect of the zero without changing the dc gain. Pre-filters may
be employed with lead/PD compensation.
134
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)):
The first step is to import the model into SISO Design Tool. System transfer
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;
G=tf(num,den)
135
Fig. 15: Root locus of the system.
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. 16.
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. 18,
which shows the unit step response of the closed-loop system with unity gain
controller, i.e. , K= 1.
Fig. 18: which shows the unit step response of the closed-loop system
with unity gain controller
137
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 19 shows the addition of settling time constraint. Peak
overshoot constraint is added on similar lines.
Figure 20 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.
138
Changing K will affect the pole locations. In the Root Locus window, C(s)
represents the controller transfer function. Fig. 20 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. 21 wherein K= 16.8
gives closed-loop poles on the damping lines. However, the settling time
requirement is not met.
Fig: 20 shows the desired closed-loop system pole locations on the root
locus after inclusion of the design constraints
139
Fig 21: The closed-loop poles of the system must lie to the left of the
boundary imposed by the settling time
The closed-loop poles of the system must lie to the left of the boundary
imposed by the settling time (Fig. 21). 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:
To add a zero to the controller, click the C block in the block diagram in top-
right corner of Fig. 21. Fig. 22 shows the Edit Compensator window and
how the PD controller is added:
140
Fig. 22: the Edit Compensator window
Figure 23 shows the plot for s= - 1/0.00095. Note that the closed-loop poles
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. 24.
141
Fig 24: The system closed-loop poles
The step response of the controlled system in Fig. 25 shows that the system
has now complied with all design criteria.
142
Lab Task
Question No. 1: Consider the system shown in Figure 1. Design a compensator
such that the dominant closed-loop poles are located at .
Question No. 02: Consider the control system shown in Figure 9. Design a lag
compensator Gc(s) such that the static velocity error constant Kv is 50 sec–1
without appreciably changing the location of the original closed-loop poles, which
are at
Question No. 03: A unity feedback control system has the following forward
transfer function:
143
b. Is your second-order approximation valid ?
do the following:
a. Design a lead lag compensator to yield the following specifications: settling
time = 2.86 seconds; percent overshoot = 4.32%; the steady-state error is to be
improved by a factor of 2 over the uncompensated system.
b. Compare the transient and steady-state error specifications of the
uncompensated and compensated systems.
c. Compare the gains of the uncompensated and compensated systems.
d. Discuss the validity of your second-order approximation.
do the following:
a. Find the gain, K, for the uncompensated system to operate with 30%
overshoot.
b. Find the peak time and Kv for the uncompensated system.
c. Design a lag-lead compensator to decrease the peak time by a factor of 2,
decrease the percent overshoot by a factor of 2, and improve the steady-state
error by a factor of 30. Specify all poles, zeros, and gains.
144
Assessment Sheet
Name:___________________________
Regd. No._________________________
Date of Lab:_________________________
Example
Lab Section
Lab Task
Working
Lab Performance
Viva
Instructor’s Verification
145
Lab No. _____________
Name:_______________
146
Lab – 10: Stability Analysis on Bode / Nyquist Plots
Objectives:
Introducing MATLAB commands for Bode and Nyquist plots.
Stability analysis using these plots
1.Introduction:
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
2.Bode Plots:
For a given transfer function G(s), Bode plot can be produced in different ways:
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. 1 shows the Bode diagram for the transfer function
147
s = tf('s');
G = (s+1)/(0.1*s+1);
bode(G);
For example, bode(G,{0.1,10}) will produce a Bode plot in the range 0.1 to 10
rad/sec, shown in Fig. 2.
148
Fig. 2: Bode plot over a specified frequency range wmin to wmax.
and type
bode (G,w)
MATLAB will compute the magnitude and phase at the frequency points supplied
in the frequency vector.
149
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)
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
phase(:,:,1) =
5.1377
phase(:,:,2) =
150
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
th th
access the magnitude and phase points for p input and q output, we have to
write mag(p, q, :) orphase(p, q, :). For example,
>> mag(1,1,3)
ans =
1.4072
>> phase(1,1,3)
ans =
39.2894
For SISO systems, mag(:,:,3) and phase(:,:,3) will also give the same answer.
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
151
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.
3. 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
152
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 wby
using [re,im] = nyquist(G,w).
s = tf('s');
G = 1/(s^2+0.8*s+1);
nyquist(G);
axis equal;
Axis used should be ' equal ', otherwise circles appear squashed.
153
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. 5.
G=1/((s)*(s+1));
nyquist(G)
154
Fig. 6: Nyquist plot for transfer function
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.
3. 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. 7.
155
s = tf('s');
G = 1/(s^2+0.8*s+1);
margin(G);
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.
156
Lab Task
Question No 1: Find analytical expressions for the magnitude and phase response
for each G(s) below.
Question No 2: Sketch the Nyquist diagram for each of the systems in Fig. 8.
Question No 3: Using the Nyquist criterion, find out whether each system of Lab
Task 2 is stable.
157
Assessment Sheet
Name:___________________________
Regd. No._________________________
Date of Lab:_________________________
Example
Lab Section
Lab Task
Working
Lab Performance
Viva
Instructor’s Verification
158
Lab No. _____________
Name:_______________
159
160
161
Assessment Sheet
Name:___________________________
Regd. No._________________________
Date of Lab:_________________________
Example
Lab Section
Lab Task
Working
Lab Performance
Viva
Instructor’s Verification
162
Lab No. _____________
Name:_______________
163
164
Assessment Sheet
Name:___________________________
Regd. No._________________________
Date of Lab:_________________________
Example
Lab Section
Lab Task
Working
Lab Performance
Viva
Instructor’s Verification
165
Lab No. _____________
Name:_______________
166
167
Assessment Sheet
Name:___________________________
Regd. No._________________________
Date of Lab:_________________________
Example
Lab Section
Lab Task
Working
Lab Performance
Viva
Instructor’s Verification
168
Lab No. _____________
Name:_______________
169
Lab – 14: Open Ended Lab
Introduction
To make a joint project within lab addressing a real life task/problem using all the
available apparatus in the lab.
This is Open Ended (OE) in the sense that the problem can be solved using more
than one solution and students are free to choose using their own initiative and
creativity.
Students are encouraged to get extensive information from the library, journals
and reports to research methods.
Pre-Lab Reading
All the Labs that has been done.
Exercise
To be announced by Instructor in the last lab of manual.
Methodology
The students are divided into groups of four/five and each group is given 3 hours
duration of in-lab sessions and one week of out-lab session. An in-lab session
means students carry out work during laboratory class, while an out-lab session is
the discussion handled outside class time with the group members once the
project is underway.
OBE System:
The OE project is designed so that students will achieve the course Lab outcomes.
Assesment:
Assessments will be carrying out using the rating given in the rubrics.
170
Rubrics for Assessment of Open Ended Lab
1. Accuracy (Marks = 4)
How much a student identifies and clearly addresses both the main question and subsidiary,
embedded, or implicit aspects of the problem.
2. Completeness (Marks = 4)
How much a student explains, accurately and thoroughly, multiple solutions, positions, or
perspectives that balance opposing points of view?
Unsatisfactory (1) Good (2) Very Good (3) Excellent (4) Marks
The open ended task The open ended The open ended The open ended
was complete but did task was task was task was 100%
not work as required; complete but complete and complete and
needed several major did not work as worked, but worked
modifications. required; needed few according to the
needed some minor task
minor modifications. description.
modifications.
171
3. Teamwork (Marks = 4)
How much a student is able to work collaboratively, if the student is giving his/her best in any
circumstances? If the student is able to cooperate, using his/her individual skills and providing
constructive feedback, despite any personal conflict between individuals.
Unsatisfactory (1) Good (2) Very Good (3) Excellent (4) Marks
Shares ideas but does Offers new Offers alternative Helps the team
not advance the work suggestions solutions or move forward by
of the group. to advance courses of action articulating the
the work of that build on the merits of alternative
the group. ideas of others. ideas or proposals.
It is key to efficient working. How much a student is able to use his/her time effectively or
productively towards achieving the goal?
Unsatisfactory (1) Good (2) Very Good (3) Excellent (4) Marks
Original Timeline Original Original timeline
is not followed; timeline is not is not followed
Project lagging followed exactly due to Original
behind. exactly; unforeseen timeline is
exceptions circumstances. followed and
were not met.
properly
handled.
5. Presentation (Marks = 4)
How much a student clearly states and discusses conclusions. Does he /she considers
implications and consequences of the conclusion in context, relative to assumptions, and
supporting evidence? Does he provide reflective thought with regards to the assertions?
Unsatisfactory (1) Good (2) Very Good (3) Excellent (4) Marks
Contents Contents Contents Contents
unorganized, organized in organized in organized in
inability to answer order, inability order and with detail and in
any questions. to answer some proper details, order, able to
questions able to answer answer all
accurately. most questions questions with
adequately. precision.
172
173