Control System Lab Manual
Control System Lab Manual
LAB MANUAL
1
Experiment – 1
(A) TRANSFER FUNCTION FROM ZEROS AND POLES
AIM:
To obtain a transfer function from given poles and zeroes using MATLAB
APPARATUS:
Software: MATLAB
THEORY:
A transfer function is also known as the network function is a mathematical representation, in
terms of spatial or temporal frequency, of the relation between the input and output of a (linear
time invariant) system. The transfer function is the ratio of the output Laplace Transform to the
input Laplace Transform assuming zero initial conditions. Many important characteristics of
dynamic or control systems can be determined from the transfer function.
The transfer function is commonly used in the analysis of single-input single-output electronic
system, for instance. It is mainly used in signal processing, communication theory, and control
theory. The term is often used exclusively to refer to linear time-invariant systems (LTI). In its
simplest form for continuous time input signal x(t) and output y(t), the transfer function is the
linear mapping of the Laplace transform of the input, X(s), to the output Y(s).
Zeros are the value(s) for z where the numerator of the transfer function equals zero. The
complex frequencies that make the overall gain of the filter transfer function zero. Poles are the
value(s) for z where the denominator of the transfer function equals zero. The complex
frequencies that make the overall gain of the filter transfer function infinite.
The general procedure to find the transfer function of a linear differential equation from input to
output is to take the Laplace Transforms of both sides assuming zero conditions, and to solve for
the ratio of the output Laplace over the input Laplace.
MATLAB PROGRAM:
z=input(‘enter zeroes’)
p=input(‘enter poles’)
k=input(‘enter gain’)
2
[num,den]=zp2tf(z,p,k)
tf(num,den)
PROCEDURE:
Write MATLAB program in the MATLAB editor
document. Then save and run the program.
Give the required input.
The syntax “zp2tf(z,p,k)” and “tf(num,den)” solves the
given input poles and zeros and gives the transfer function.
zp2tf forms transfer function polynomials from the zeros,
poles, and gains of a system in factored form.
Now find the output theoretically for the given transfer
function and compare it with the output obtained practically
EXAMPLE:
Given poles are -3.2+j7.8,-3.2-j7.8,-4.1+j5.9,-4.1-j5.9,-8 and the zeroes are -0.8+j0.43,-0.8-
j0.43,-0.6 with a gain of 0.5
THEORITICAL CALCULATIONS:
Enter zeros
Z=
Enter poles
P=
Enter gain
K=
num =
den =
Transfer function=
RESULT:
3
(B) ZEROS AND POLES FROM TRANSFER FUNCTION
AIM:
To obtain zeros and poles from a given transfer function using MATLAB.
APPARATUS
Software: MATLAB
THEORY:
The transfer function provides a basis for determining important system response characteristics
without solving the complete differential equation. As defined, the transfer function is a rational
function in the complex variable that is
D(s), have real coefficients defined by the system’s differential equation and .
As written in the above equation, the are the roots of the equation and are defined
to be the system zeros, the are the roots of the equation and are defined to be the
system poles.
4
MATLAB PROGRAM:
[z,p,k] = tf2zp(num,den)
EXAMPLE:
Obtain the poles and zeros of the transfer function given below:
PROCEDURE:
o [z,p,k] = tf2zp(b,a) finds the matrix of zeros z, the vector of poles p, and the
associated vector of gains k from the transfer function parameters b and a:
o The numerator polynomials are represented as columns of the
matrix b. The denominator polynomial is represented in the
vector a.
o Note down the output of the program that is zeros, poles and gain obtained in
MATLAB. The zeros, poles and gain are also obtained theoretically.
5
THEORITICAL CALCULATIONS:
num =
den =
z=
p=
RESULT:
6
Experiment – 2
(A) Step Response of Transfer Function
AIM:
To obtain the step response of a transfer function of the given system using MATLAB.
APPARATUS:
Software: MATLAB
THEORY:
A step signal is a signal whose value changes from one level to another level in zero time.
Mathematically, the step signal is represented as given below:
where
So,
7
MATLAB PROGRAM:
EXAMPLE:
PROCEDURE:
When invoked with no output arguments, this function plots the step response on the
screen.
step (sys) plots the response of an arbitrary LTI system.
The step response of multi-input systems is the collection of step responses for each
input channel.
The duration of simulation is determined automatically based on the system poles
and zeroes.
Note down the response of the transfer function obtained in MATLAB.
The response of the transfer function is also obtained theoretically.
8
THEORETICAL CALCULATIONS:
GRAPH:
RESULT:
9
(B) Impulse Response of Transfer Function
AIM:
To obtain the impulse response of a transfer function of the given system using MATLAB.
APPARATUS:
Software: MATLAB
THEORY:
An impulse signal is a signal whose value changes from zero to infinity in zero time.
Mathematically, the unit impulse signal is represented as given below:
where:
So,
10
MATLAB PROGRAM:
EXAMPLE:
PROCEDURE:
Type the program in the MATLAB editor that is in M-
file. Save and run the program.
Give the required inputs in the command window of MATLAB in matrix
format. ‘impulse’ calculates the impulse response of a linear system.
The impulse response is the response to the Dirac input, δ (t) for continuous time systems
and to a unit pulse at for discrete time systems.
When invoked without left hand arguments, this function plots the impulse response on
the screen.
‘impulse(sys)’ plots the impulse response of an arbitrary LTI
model sys. This model can be continuous or discrete, SISO or
MIMO.
The impulse response of multi-input systems is the collection of impulse responses for
each input channel.
The duration of simulation is determined automatically to display the transient behaviour
of the response.
Note down the response of the given transfer function obtained in
MATLAB. The response of the transfer function is also obtained
theoretically.
11
THEORETICAL CALCULATIONS:
GRAPH
RESULT:
12
(C) Ramp Response of Transfer Function
AIM:
To obtain the ramp response of a transfer function of the given system using MATLAB.
APPARATUS:
Software: MATLAB
THEORY:
A ramp signal is a signal which changes with time gradually in a linear fashion. Mathematically,
the unit ramp signal is represented as given below:
So,
13
MATLAB PROGRAM:
EXAMPLE:
PROCEDURE:
lsim simulates the (time) response of continuous or discrete linear systems to arbitrary
inputs.
When invoked without left-hand arguments, lsim plots the response on the screen.
lsim(sys,u,t) produces a plot of the time response of the LTI model sys to the input time
history t, u.
The vector t specifies the time samples for the simulation and consists of regularly spaced
time samples.
t = 0:dt:Tfinal
The matrix u must have as many rows as time samples (length(t)) and as many
columns as system inputs.
Each row u (i,:) specifies the input value(s) at the time sample t(i).
14
THEORETICAL CALCULATIONS:
GRAPH
RESULTS
15
Experiment – 3
Time Response of Second Order System
AIM:
To obtain the time response of a given second order system with its damping frequency.
APPARATUS:
Software: MATLAB
THEORY:
The time response has utmost importance for the design and analysis of control systems because
these are inherently time domain systems where time is independent variable. During the
analysis of response, the variation of output with respect to time can be studied and it is known
as time response. To obtain satisfactory performance of the system with respect to time must be
within the specified limits. From time response analysis and corresponding results, the stability
of system, accuracy of system and complete evaluation can be studied easily.
Due to the application of an excitation to a system, the response of the system is known as time
response and it is a function of time. The two parts of response of any system:
(i) Transient response
Transient response: The part of the time response which goes to zero after large interval of time
is known as transient response.
Steady state response: The part of response that means even after the transients have died out is
said to be steady state response.
The total response of a system is sum of transient response and steady state response:
C(t)=Ctr(t)+Css(t)
16
Transfer function is given by:
TF=
MATLAB PROGRAM:
n=[wn*wn]
p=sqrt(1-z^2)
wd=wn*p
h=[p/z]
k=atan(h)
m=pi-k;
tr=[m/wd]
17
tp=[pi/wd]
q=z*wn
ts=[h/q]
r=z*pi
f=[r/p]
mp=exp(-f)
num=[0 0 n]
den=[1 2*z*wn n]
s=tf(num,den)
hold on
step(s)
impulse(s)
hold off
PROCEDURE:
Time response of the system is being found when we give the values of
natural undamped frequency and damping ratio.
When we give these values first rise time , peak time, peak overshoot, transfer function
are being calculated.
Then “ step(s)” And “impulse(s)” generates time response of the system.
The hold function determines whether new graphics object are added to the graph
or replaces objects in the graph.
18
hold on retains the current plot and certain axes properties so that subsequent graphing
command add to the existing graph.
hold off resets axes properties to their defaults before drawing new plots. hold off is the
default.
THEORETICAL CALCULATIONS:
GRAPH:
RESULTS:
19
Experiment – 4
Root Locus of a Transfer Function
AIM:
To plot the root locus for a given transfer function of the system using MATLAB.
APPARATUS:
Software: MATLAB
THEORY:
rlocus computes the Evans root locus of a SISO open-loop model. The root locus gives the
closed- loop pole trajectories as a function of the feedback gain k (assuming negative feedback).
Root loci are used to study the effects of varying feedback gains on closed-loop pole locations. In
turn, these locations provide indirect information on the time and frequency responses.
rlocus(sys) calculates and plots the rootlocus of the open-loop SISO model sys. This function can
be applied to any of the following feedback loops by setting sys appropriately.
If sys has transfer function h(s) = n(s)/d(s)
The closed-loop poles are the roots of
d(s) + k*n(s)=0
MATLAB PROGRAM:
num=input(‘enter the numerator of the transfer function’)
den=input(‘enter the denominator of the transfer function’)
h=tf(num,den)
rlocus(h)
PROCEDURE:
20
rlocus(sys,k)
rlocus(sys1,sys2,….)
[r,k] = rlocus(sys)
r = rlocus(sys,k)
rlocus(sys) calculates and plots the root locus of the open loop SISO model
sys. Now we have to solve it theoretically.
Now we have to compare the practical and theoretical ouputs to verify each other
correctly.
EXAMPLE:
Transfer function =
THEORETICAL CALCULATIONS:
GRAPH:
RESULT:
21
Experiment – 5
Bode Plot of a Transfer Function
AIM:
To obtain bode plot for a givan transfer function of the system using MATLAB.
APPARATUS:
Software: MATLAB
THEORY:
Bode computes the magnitude and phase of the frequency response of LTI models. When
invoked without left-side arguments, bode produces a Bode plot on the screen. The magnitude is
plotted in decibels (dB), and the phase in degrees. The decibel calculation for mag is computed
as 20log10(|H(jw)|), where H(jw) is the system's frequency response. Bode plots are used to
analyze system properties such as the gain margin, phase margin, DC gain, bandwidth,
disturbance rejection, and stability.
If we convert both sides to decibels, the logarithms from the decibel calculations convert
multiplication of the arguments into additions, and the divisions into subtractions:
bode(sys) plots the Bode response of an arbitrary LTI model sys. This model can be continuous
or discrete, and SISO or MIMO. In the MIMO case, bode produces an array of Bode plots, each
plot showing the Bode response of one particular I/O channel. The frequency range is
determined automatically based on the system poles and zeros.
bode(sys,w) explicitly specifies the frequency range or frequency points to be used for the plot.
To focus on a particular frequency interval [wmin,wmax], set w = {wmin,wmax}. To use
particular
22
frequency points, set w to the vector of desired frequencies. Use logspace to generate
logarithmically spaced frequency vectors. All frequencies should be specified in radians/sec.
bode(sys1,'r--',sys2,'gx')
uses red dashed lines for the first system sys1 and green 'x' markers for the second system sys2.
When invoked with left-side arguments
[mag,phase,w] = bode(sys)
[mag,phase] = bode(sys,w)
return the magnitude and phase (in degrees) of the frequency response at the frequencies w (in
rad/sec). The outputs mag and phase are 3-D arrays with the frequency as the last dimension (see
"Arguments" below for details). You can convert the magnitude to decibels by
magdb = 20*log10(mag)
MATLAB PROGRAM:
num=input('enter the numerator of the transfer function')
den=input('enter the denominator of the transfer function')
h=tf(num,den)
[gm pm wcp wcg]=margin(h)
bode(h)
PROCEDURE:
Write the MATLAB program in the MATLAB
editor. Then save and run the program.
Give the required inputs.
The syntax "bode(h)" solves the given input transfer function and gives the bode
plot, where num,den are the numerator and denominator of the transfer function.
Now plot the bode plot theoretically for the given transfer function and compare it with
the plot obtained practically.
EXAMPLE:
23
Transfer function=
THEORETICAL CALCULATIONS:
enter the numerator of the transfer function
num =
enter the denominator of the transfer function
den =
Transfer function:
gm =
pm =
wcp =
wcg =
GRAPH
RESULT:
24
Experiment - 6
(A) Transfer Function from State Space Model
AIM:
To obtain the transfer function from the state model.
APPARATUS:
Software: MATLAB
THEORY:
The transfer function is defined as the ratio of Laplace transform of output to Laplace
transform of input. The transfer function of a given state model is given by:
MATLAB PROGRAM:
25
EXAMPLE:
Obtain the transfer function from the State Model given below:
A=
B=
C=
D=
PROCEDURE:
Type the program in the MATLAB editor that is in M-
file. Save and run the program.
Give the required inputs in the command window of MATLAB in matrix format.
The command ss2tf(A,B,C,D)) converts the given transfer function into a state
model. Note down the output obtained in MATLAB.
The Transfer Function is also obtained
theoretically.
Both the state models are compared.
THEORETICAL CALCULATIONS:
A=
B=
C=
D=
RESULT:
26
(A) State Space Model from Transfer Function
AIM:
To obtain the state model from the given transfer function.
APPARATUS:
Software: MATLAB
THEORY:
There are three methods for obtaining state model from transfer function:
1. Phase variable method
Out of three methods given above canonical form is probably the most straightforward method
for converting from the transfer function of a system to a state space model is to generate a
model in "controllable canonical form." This term comes from Control Theory but its exact
meaning is not important to us. To see how this method of generating a state space model
works, consider the third order differential transfer function:
We start by multiplying by Z(s)/Z(s) and then solving for Y(s) and U(s) in terms of Z(s).
We also convert back to a differential equation.
We can now choose z and its first two derivatives as our state variables
27
Now we just need to form the output
From these results we can easily form the state space model:
In this case, the order of the numerator of the transfer function was less than that of
the denominator. If they are equal, the process is somewhat more complex. A result
th
that works in all cases is given below; the details are here. For a general n order
transfer function:
MATLAB PROGRAM:
num=input(‘enter the numerator of the transfer function’)
den=input(‘enter the denominator of the transfer function’)
ss(tf(num,den))
28
EXAMPLE:
Obtain the state model from the transfer function given below:
PROCEDURE:
Type the program in the MATLAB editor that is in M-
file. Save and run the program.
Give the required inputs in the command window of MATLAB in matrix format.
The command ss(tf(num,den)) converts the given transfer function into a state model.
Note down the output obtained in MATLAB.
The state model is also obtained theoretically.
Both the state models are compared.
THEORETICAL CALCULATIONS
Enter the transfer function
A=
B=
C=
D=
RESULT:
29
Experiment – 7
Nyquist Plot from a Transfer Function
AIM:
To obtain the Nyquist plot for a given transfer function of the system.
APPARATUS:
Software: MATLAB
THEORY:
A nyquist plot is used in automatic control and signal processing for assessing the stability of a
system with feedback. It is represented by a graph in polar coordinates in which the gain and
phase of a frequency response are plotted. The plot of these phasor quantities shows the phase as
the angle and the magnitude as the distance from the origin. This plot combines the two types of
Bode plot — magnitude and phase — on a single graph with frequency as a parameter along the
curve.
Nyquist calculates the Nyquist frequency response of LTI models. When invoked without left-
hand arguments, nyquist produces a Nyquist plot on the screen. Nyquist plots are used to analyze
system properties including gain margin, phase margin, and stability.
The nyquist stability criterion , provides a simple test for stability of a closed-loop control system
by examining the open-loop system's Nyquist plot. Stability of the closed-loop control system
may be determined directly by computing the poles of the closed-loop transfer function. The
Nyquist Criteria can tell us things about the frequency characteristics of the system. For
instance, some systems with constant gain might be stable for low-frequency inputs, but become
unstable for high- frequency inputs. Also, the Nyquist Criteria can tell us things about the phase
of the input signals, the time-shift of the system, and other important information.
The Nyquist Contour
The nyquist contour, the contour that makes the entire nyquist criterion work, must encircle the
entire right half of the complex s plane. Remember that if a pole to the closed-loop transfer
function (or equivalently a zero of the characteristic equation) lies in the right-half of the s plane,
the system is an unstable system.To satisfy this requirement, the nyquist contour takes the shape
of an infinite semi-circle that encircles the entire right-half of the s plane.
Nyquist Criteria
Let us first introduce the most important equation when dealing with the Nyquist criterion:
Where:
N is the number of encirclements of the (-1, 0) point. Z is the number of zeros of the
characteristic equation. P is the number of poles of the characteristic equation.
With this equation stated, we can now state the Nyquist Stability Criterion:
30
Nyquist Stability Criterion
A feedback control system is stable, if and only if the contour in the F(s) plane does
not encircle the (-1, 0) point when P is 0. A feedback control system is stable, if and only if the
contour in the F(s) plane encircles the (-1, 0) point a number of times equal to the
number of poles of F(s) enclosed by Γ. In other words, if P is zero then N must equal zero.
Otherwise, N must equal P. Essentially, we are saying that Z must always equal zero,
because Z is the number of zeros of the characteristic equation (and therefore the number of
poles of the closed-loop transfer function) that are in the right-half of the s plane.
MATLAB PROGRAM:
PROCEDURE:
Write MATLAB program in the MATLAB editor
document. Then save and run the program.
Give the required input.
The syntax “tf(num,den)” solves the given transfer function and gives poles and zeros of
the function.
“nyquist(sys)”, nyquist calculates the Nyquist frequency response of LTI models. When
invoked without left-hand arguments, nyquist produces a Nyquist plot on the screen.
Nyquist plots are used to analyze system properties including gain margin, phase margin,
and stability.
“nyquist(sys)” plots the Nyquist response of an arbitrary LTI model sys. This model can
be continuous or discrete, and SISO or MIMO. In the MIMO case, nyquist produces an
array of Nyquist plots, each plot showing the response of one particular I/O channel. The
frequency points are chosen automatically based on the system poles and zeros.
“[Gm,Pm,Wcg,Wcp] = margin(sys)”, margin calculates the minimum gain margin, phase
margin, and associated crossover frequencies of SISO open-loop models. The gain and
phase margins indicate the relative stability of the control system when the loop is closed.
31
RESULT:
32
33
Experiment – 8
PID Controller Design
AIM:
APPARATUS:
Software: MATLAB
THEORY:
PID controllers are commercially successful and widely used as controllers in industries. For
example, in a typical paper mill there may be about 1500 controllers and out of these 90 percent
would be PID controllers. The PID controller consists of a proportional mode, an Integral mode
and a Derivative mode. The first letters of these modes make up the name PID controller.
Depending upon the application one or more combinations of these modes are used. For
example, in a liquid control system where we want zero steady state error, a PI controller can be
used and in a temperature control system where zero stead state error is not specified, a simple P
controller can be used.
The equation of a PID controller in time-domain is given by
Where is the proportional gain, is the integral reset time and is the derivative time of the
PID controller, m(t) is the output of the controller and e(t) is the error signal given by e(t)=r(t)-
c(t).
The controller used here is a PID controller represented by a block PID and the system or plant is
represented by G(s). R(s) and D(s) are reference signal and disturbance signal respectively. Y(s),
E(s) and M(s) are the output, error and controller output of the system respectively. For the
purpose of good control, we require the system output Y(s) to track any reference signal F(s) and
at the same time reject or suppress deviation due to the disturbance signal D(s). Hence the PID
controller can realize this objective.
Proportional controller: A proportional controller has a proportional term alone. The output of a
proportional controller is proportional to the error e(t) .
MATLAB PROGRAM:
num=input('enter the numerator of the transfer function')
den=input('enter the denominator of the transfer function')
34
h=tf(num,den)
[gm pm wcp wcg]=margin(h)
km=10*(gm/20)
wm=wcp
kp=0.6*km
ki=(kp*wm)/pi
kd=(kp*ki)/(4*wm)
h1=tf([1,0],[1])
g=(kp+(kd*h1)+(ki/h1))*h
bode(g)
PROCEDURE:
Note down the given transfer function.
Sketch the bode plot for the given transfer function by Factor the transfer function into
pole-zero form.
Find the frequency response from the Transfer function.
Use logarithms to separate the frequency response into a sum of decibel
terms Use w=0 to find the starting magnitude.
The locations of every pole and every zero are called break points. At a zero
breakpoint, the Slope of the line increases by 20dB/Decade. At a pole, the
slope of the line decreases by 20dB/Decade.
At a zero breakpoint, the value of the actual graph differs from the value
of the straight-line graph by 3dB. A zero is +3dB over the straight line,
and a pole is -3dB below the straight line.
Sketch the actual bode plot as a smooth-curve that follows the straight lines
of the previous point, and travels through the breakpoints
If A is positive, start your graph (with zero slopes) at 0 degrees. If A is negative, start
your graph with zero slope at 180 degrees (or -180 degrees, they are the same thing).
For every zero, slope the line up at 45 degrees per decade when w= (1 decade before
the Break frequency). Multiple zeros means the slope is steeper.
For every pole, slope the line down at 45 degrees per decade when w = (1 decade
before the break frequency). Multiple poles means the slope is steeper. Find out the
gain margin, phase margin, wcp and wcg
From those calculate km,wm,kp,ki,kd
Already transfer function h1 is given. Now find out the transfer function g and
sketch bode plot for g by repeating steps from 2 -13.
EXAMPLE:
35
Given Transfer function =
THEORITICAL CALCULATIONS
A=
W A
0.01
0.1
1
5
7
10
100
Phase plot:
W Ø
0.01
0.1
1
5
7
10
100
Km = 10 x
36
Wm = wcp =
Kp = 0.6 x km =
Ki = (kp x km)/pi =
Kd = (kp x ki)/(4 x wm) =
Transfer function h1 = s
g = [kp + (kd x h1) + (ki/h1)] x h =
Bode plot for transfer function g:
Magnitude Plot:
A=
W A
0.01
0.1
1
5
7
10
50
100
200
500
1000
Phase Plot:
W Ø
0.01
0.1
1
5
7
10
50
100
200
500
1000
37
THEORETICAL CALULATIONS:
enter the numerator of the transfer function[ ]
num =
38
enter the denominator of the transfer function
den =
Transfer function:
gm =
pm =
wcp =
wcg =
km =
wm =
kp =
ki =
kd =
Transfer function:
GRAPH:
RESULT:
39