Control System Lab Manual (Kec-652)
Control System Lab Manual (Kec-652)
Communication Engineering
LAB MANUAL
Semester : SIX
List of Experiments
1. Introduction to MATLAB Control System Toolbox.
2. Determine transpose, inverse values of given matrix.
3. Plot the pole-zero configuration in s-plane for the given transfer function.
4. Determine the transfer function for given closed loop system in block diagram representation.
5. Create the state space model of a linear continuous system.
6. Determine the State Space representations of the given transfer function.
7. Determine the time response of the given system subjected to any arbitrary input.
8. Plot unit step responses of given transfer function and find delay time, rise time, peak time, peak
overshoot and settling time.
9. Determine the steady state errors of a given transfer function.
10. Plot root locus of given transfer function, locate closed loop poles for different values of k.
11. Plot bode plot of given transfer function. Also determine gain and phase margins.
12. Plot Nyquist plot for given transfer function. Also determine the relative stability by measuring
gain and phase margin.
EXPERIMENT -1
THEORY-
Introduction to Control System Toolbox
Control System Toolbox is a package for MATLAB consisting of tools specificallydeveloped for control
applications. The package offers data structures to describecommon system representations such as state
space models and transfer functions,as well as tools for analysis and design of control systems. There are
alsotools for simulation of systems.
In this exercise you will get to know the basic commands of Control SystemToolbox. When you have
completed this exercise, you should be able to understandand use Control Systems Toolbox to create and
analyze linear systems.
Extensive use of the MATLAB help command is recommended. It is also recommended that you create
a script file (e.g. myscript.m) in which you write your commands.By running a script file instead of
typing the commands directly at the MATLABprompt, it is easier to correct mistakes, and also, your
work will be saved forlater use.
The system you will use is
SOFTWARE REQUIRED-MATLAB
THEORY-
A matrix which is formed by turning all the rows of a given matrix into columns and vice-versa. The
transpose of matrix A is written AT
MATLAB CODE-
X = [ 10 12 23 ; 14 8 6; 27 8 9]
Y = X'
Inverse Matrix
X = [10 12 23 ; 14 8 6; 27 8 9]
Y = inv(X)
EXPERIMENT -3
OBJECTIVE-
Plot the pole-zero configuration in s-plane for the given transfer function.
SOFTWARE REQUIRED-MATLAB
THEORY-
pzmap(sys) creates a pole-zero plot of the continuous- or discrete-time dynamic system model sys. For
SISO systems, pzmap plots the transfer function poles and zeros. For MIMO systems, it plots the system
poles and transmission zeros. The poles are plotted as x's and the zeros are plotted as o's.
pzmap(sys1,sys2,...,sysN) creates the pole-zero plot of multiple models on a single figure. The models
can have different numbers of inputs and outputs and can be a mix of continuous and discrete systems.
[p,z] = pzmap(sys) returns the system poles and (transmission) zeros in the column vectors p and z. No
plot is drawn on the screen.
You can use the functions sgrid or zgrid to plot lines of constant damping ratio and natural frequency in
the s- or z-plane.
Let Transfer Function
2
𝑠 +4𝑠+3
𝐻(𝑆) = 2 2
(𝑠 +5)(𝑠 +4𝑠+7)
MATLAB CODE-
Clc
Clear all;
num = [1 4 3]
den= conv([1 5], [3 4 7])
g = tf (num,den)
[z,p,k] = tf2zp(num,den)
pzmap(g)
grid on;
EXPERIMENT- 4
OBJECTIVE- Determine the transfer function for given closed loop system in block diagram
representation.
Evaluate the transfer function of the feedback system shown in the figure above using MATLAB where
G1(s) = 4s/(s+1), G2(s) = 1/(s+2) and H(s) = 5s.
THEORY-The numerator and denominator of the transfer function in the forward path of block diagram
are found in the first step. The numerator polynomial is considered as n1 and denominator polynomial as
d1. The MATLAB function printsyn is used to display the transfer function in the forward path.
Similarly the transfer function in the second and third feedback path of the block diagram are displayed.
In the successive step the closed loop transfer function is obtained using the closed function. The – sign
in the parenthesis for the loop indicates the –vefeed back. Next the parallel function is used to obtain the
resultant transfer function in the feedback path. Finally feedback function is used the transfer function.
MATLABCODE-
% Program for finding Transfer Function from block diagram.
Clc
Clear all;
G1 = tf([4 0],[1 1]);
G2 = tf([0 1],[1 2]);
H = tf([5 0],[0 1]);
SYS = feedback(G1*G2,H)
EXPERIMENT -5
SOFTWARE REQUIRED-MATLAB
THEORY-
State-Space Model Representations
State-space models rely on linear differential equations or difference equations to describe system
dynamics. Control System Toolbox™ software supports SISO or MIMO state-space models in
continuous or discrete time. State-space models can include time delays. You can represent state-space
models in either explicit or descriptor (implicit) form.
State-space models can result from:
● Linearizing a set of ordinary differential equations that represent a physical model of the system.
● State-space model identification using System Identification Toolbox™ software.
● State-space realization of transfer functions. (See Conversion Between Model Types for more
information.)
Use ss model objects to represent state-space models.
Explicit State-Space Models
Explicit continuous-time state-space models have the following form:
where x is the state vector. u is the input vector, and y is the output vector. A, B, C, and D are the
state-space matrices that express the system dynamics.
A discrete-time explicit state-space model takes the following form:
where the vectors x[n], u[n], and y[n] are the state, input, and output vectors for the nth sample.
Create State-Space Model From Matrices
Create a model of an electric motor where the state-space equations are:
where the state variables are the angular position θ and angular velocity dθ/dt:
u is the electric current, the output y is the angular velocity, and the state-space matrices are:
MATLABCODE-
% Create state space model from matrices
Clc
Clear all;
A = [0 1;-5 -2]
B = [0;3]
C = [0 1]
D = 0
sys = ss(A,B,C,D)
EXPERIMENT -6
OBJECTIVE- Determine the State Space representations of the given transfer function.
SOFTWARE REQUIRED-MATLAB
THEORY-
Find the state-space representation in phase-variable form for the transfer function shown in Figure (1):
Figure 1
Step 1. Find the associated differential equation:
Cross-multiplying yields:
The corresponding differential equation is found by taking the inverse Laplace Transform, assuming
zero initial conditions:
Step 2. Select the state variables. Choosing the state variables as successive derivatives, we get:
Step 4. Expressing the last equations in vector-matrix form, we get the state-space representation of the
system as:
At this point, we can create an equivalent block diagram of the systemof Figure 1(a) to help visualize the
state variables.We draw three integral blocks as shown in Figure 1(b) and label each output as one of the
state variables, xi(t), as shown.
The transfer function of the previous Example has a constant term in the numerator. If a transfer function
has a polynomial in s in the numerator that is of order less than the polynomial in the denominator, as
shown in Figure 2(a), the numerator and denominator can be handled separately. First separate the
transfer function into two cascaded transfer functions, as shown in Figure 2(b); the first is the
denominator, and the second is just the numerator. The first transfer function with just the denominator
is converted to the phase-variable representation in state space as demonstrated in the last example.
Hence, phase variable x1 is the output, and the rest of the phase variables are the internal variables of the
first block, as shown in Figure 2(b).
Figure 2
The second transfer function with just the numerator yields:
Where, after taking the inverse Laplace transform with zero initial conditions, we obtain:
But the derivative terms are the definitions of the phase variables obtained in the
first block. Thus, writing the terms in reverse order to conform to an output equation, we obtain:
Hence, the second block simply forms a specified linear combination of the state
variables developed in the first block.
From another perspective, the denominator of the transfer function yields the
state equations, while the numerator yields the output equation. The next example
demonstrates the process.
MATLABCODE-
% creat ss model from given transfer function
Clc
Clear all;
b=[24];
a=[1 9 26 24];
H = tf(b,a)
sys = ss(H)
[A,B,C,D] = tf2ss(H)
EXPERIMENT -7
OBJECTIVE-Determine the time response of the given system subjected to any arbitrary input.
SOFTWARE REQUIRED-MATLAB
THEORY-
Equation (3) shows that the response curve is exponential in nature as shown on figure.
b) Step response of 2nd order system
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: Transient response; Steady-state 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)
Time Response Specification Parameters: The transfer function of a 2-nd order system is generally
represented by the following transfer function:
The dynamic behavior of the second-order system can then be described in terms of two parameters:
the damping ratio and the natural frequency. If the dumping ratio is between 0 and 1, the system poles
are complex conjugates and lie in the left half s plane. The system is then called underdamped, and the
transient response is oscillatory. If the damping ratio is equal to 1 the system is called critically damped,
and when the damping ratio is larger than 1 we have overdamped system. The transient response of
critically damped and overdamped systems do not oscillate. If the damping ratio is 0, the transient
response does not die out.
Delay time (td) The delay time is the time required for the response to reach half the final value the very
first time.
Rise time (tr) The rise time is the time required for the response to rise from 10% to 90%, 5% to 95%, or
0% to 100% of its final value. For underdamped second-order systems, the 0% to 100% rise time is
normally used. For overdamped systems, the 10% to 90% rise time is commonly used.
Peak time (tp) The peak time is the time required for the response to reach the first peak of the
overshoot.
Maximum (percent) overshoot (Mp) The maximum overshoot is the maximum peak value of the
response curve measured from unity. If the final steady-state value of the response differs from unity,
then it is common to use the maximum percent overshoot. It is defined by
Settling time (ts) The settling time is the time required for the response curve to reach and stay within a
range about the final value of size specified by absolute percentage of the final value (usually 2% or 5%).
The settling time is related to the largest time constant of the control system.
MATLABCODE-
Clc
Clear all
% step response of a unity feedback system with G(s) = 1/(𝑠+4)
num1 = [1];
den1 = [1 4]
g1 = tf (num1,den1)
t1 = feedback(g1,1)
step(t1,'r')
OBJECTIVE-Plot unit step responses of given transfer function and find delay time, rise time, peak
time and peak overshoot.
SOFTWARE REQUIRED-MATLAB
THEORY-
Second order system is represented by the transfer function.
Peak time
Rise time
Delay time
Settling time
PROCEDURE:
2) Write the program using MATLAB to simulate step response of the givensystem.
3) Evaluate time domain specifications:
i. Run the program. Step response appears on the screen.
ii. Right click anywhere in the plot region, this opens the followingmenu
list in the plot region.
Plot type >
System >
Characteristics >
Zoom >
Grid >
iii. Click on Characteristics, the following submenu will appear in theplot region.
Peak response
Setting time
Rise time
Steady state
iv. Select the submenu item, the LTI viewer displays the respectivemarker on the plot, click on the
marker and hold the mouse buttondown to read the values of the plot.
v. Left click anywhere on a particular point to see the response valuesof that plot at that point
MATLABCODE-
clc
num = 1;
den = [1 10 20];
G = tf(num, den)
kp=dcgain(G)
ess=1/(1+kp)
w = sqrt (den(3))
zeta = den(2) / (2*w)
TD=(1+0.7*zeta)/w
TS = 4/ (zeta*w)
TP = pi/ (w*sqrt(1-zeta^2))
TR=(pi-atan((sqrt(1-zeta^2))/zeta))/(w*sqrt(1-zeta^2))
Percentovershoot= exp(-zeta*pi/ sqrt(1-zeta^2))*100
step(G)
title('Step response of c(t)')
figure
pzmap(G)
title('pole zero map of c(t)')
figure
EXPERIMENT -9
SOFTWARE REQUIRED-MATLAB
THEORY-
Steady State Error
Steady-state error is the difference between the input and the output for a prescribed test input as time tends to
infinity. Test inputs used for steady-state error analysis and design are summarized in Table 7.1.
Definition of the error in steady state depending on the configuration of the system.
The steady-state errors of linear control systems depend on the type of the reference signal and the type of system.
Before undertaking the error in steady state, it must be clarified what is the meaning of the system error.
The error can be seen as a signal that should quickly be reduced to zero, if this is possible. Consider the system of
Figure 1:
Figure 1
Where r (t) is the input signal, u (t) is the acting signal, b (t) is the feedback signal and y (t) is the output signal.
When H(s) is equal to 1, the error is simply:
That is, the error is the actuating signal, u (t).
The error in steady state is defined as:
Figure 1
The transfer function between the error signal e(t) and the input signal r(t) is:
Where:
Is the gain of the forward transfer function. In order to have zero steady-state error,
The steady-state response for unit step input of zero steady-state error is shown in Figure 2a, ouput 1.
The steady-state error for a ramp input is shown in Figure 2b, output 1:
In order to have zero steady-state error for a parabolic input, we must have:
MATLABCODE-
%Steady State Error Calculation
Clc
Clear all;
% Enter the numerator and denominator of G(s)
n1= [10 20];
d1= [1 7 12 0 0];
% Enter the numerator and denominator of H(s)
n2= [1];
d2= [1];
% To determine the loop transfer function G(s)H(s)
[n3,d3]=series(n1,d1,n2,d2);
[z,p,k]=tf2zp(n3,d3);
t=0;
for i=1:length(p)
if(p(i)==0)
t=t+1;
end
end
K=n3(length(n3))/d3(length(d3)-t);
switch k
case 0
position_const=K; velocity_const=0;acceleration_const=0;
step_steady_error=1/(1+ position_const);
ramp_steady_error=1/velocity_const;
parabolic_steady_error=1/acceleration_const;
case 1
position_const=inf; velocity_const=K;acceleration_const=0;
step_steady_error=1/(1+ position_const);
ramp_steady_error=1/velocity_const;
parabolic_steady_error=1/acceleration_const;
case 2
position_const=inf; velocity_const=inf;acceleration_const=K;
step_steady_error=1/(1+ position_const);
ramp_steady_error=1/velocity_const;
parabolic_steady_error=1/acceleration_const;
otherwise
position_const=inf; velocity_const=inf;acceleration_const=inf;
step_steady_error=1/(1+ position_const);
ramp_steady_error=1/velocity_const;
parabolic_steady_error=1/acceleration_const;
end
fprintf(‘The given system is TYPE %d system\n’,k);
fprintf(‘The error constants of the system are\n’);
fprintf(‘Kp=%f \n Kv=%f \n Ka=%f \n\n’, position_const, velocity_const,
acceleration_const);
fprintf(‘The steady state error of the system for \n’);
fprintf(‘Unit Step Input=%f \n Unit Ramp Input =%f \n Unit Parabolic Input =%f
\n\n’, step_steady_error, ramp_steady_error, parabolic_steady_error);
EXPERIMENT -10
OBJECTIVE- Plot root locus of given transfer function, locate closed loop poles for different values of
k.
SOFTWARE REQUIRED-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 G(s) = N(𝑆)/D(𝑆) , The
closed-loop poles are the roots of d(s) + k*n(s)=0
MATLABCODE-
Clc
Clear all;
𝑌(𝑆) 𝑆+7
% 𝐻(𝑆) 𝑈(𝑆)
= 𝑆(𝑆+5)(𝑆+15)(𝑆+20)
s = tf('s');
sys = (s + 7)/(s*(s + 5)*(s + 15)*(s + 20));
rlocus(sys)
% Alternate way
num = [1 7]
g = tf(num,den);
rlocus(g)
EXPERIMENT - 11
OBJECTIVE- Plot bode plot of given transfer function. Also determine gain and phase margins.
SOFTWARE REQUIRED-MATLAB
THEORY-
The frequency response method may be less intuitive than other methods you have studied previously.
However, it has certain advantages, especially in real-life situations such as modeling transfer functions
from physical data. The frequency response of a system can be viewed two different ways: via the Bode
plot or via the Nyquist diagram. Both methods display the same information; the difference lies in the
way the information is presented. We will explore both methods during this lab exercise. The frequency
response is a representation of the system's response to sinusoidal inputs at varying frequencies. The
output of a linear system to a sinusoidal input is a sinusoid of the same frequency but with a different
magnitude and phase. The frequency response is defined as the magnitude and phase differences
between the input and output sinusoids. In this lab, we will see how we can use the open-loop frequency
response of a system to predict its behavior in closedloop. To plot the frequency response, we create a
vector of frequencies (varying between zero or "DC" and infinity i.e., a higher value) and compute the
value of the plant transfer function at those frequencies. If G(s) is the open loop transfer function of a
system and ω is the frequency vector, we then plot G(jω) vs. ω . Since G(jω) is a complex number, we
can plot both its magnitude and phase (the Bode plot) or its position in the complex plane (the Nyquist
plot).
The gain margin is defined as the change in open loop gain required to make the system unstable.
Systems with greater gain margins can withstand greater changes in system parameters before becoming
unstable in closed loop.
The phase margin is defined as the change in open loop phase shift required to make a closed loop
system unstable.
MATLAB CODE:
%
num = [4 8]
g = tf(num,den)
bode(g)
margin(g)
EXPERIMENT - 12
OBJECTIVE- Plot Nyquist plot for given transfer function. Also determine the relative stability by
measuring gain and phase margin.
SOFTWARE REQUIRED-MATLAB
THEORY-
A stability test for time invariant linear systems can also be derived in the frequency domain. It is known
as Nyquist stability criterion. It is based on the complex analysis result known as Cauchy’s principle of
argument. Note that the system transfer function is a complex function. By applying Cauchy’s principle
of argument to the open-loop system transfer function, we will get information about stability of the
closed-loop system transfer function and arrive at the Nyquist stability criterion (Nyquist, 1932). The
importance of Nyquist stability lies in the fact that it can also be used to determine the relative degree of
system stability by producing the so-called phase and gain stability margins. These stability margins are
needed for frequency domain controller design techniques.
We present only the essence of the Nyquist stability criterion and define the phase and gain stability
margins. The Nyquist method is used for studying the stability of linear systems with pure time delay.
For a SISO feedback system the closed-loop transfer function is given by:
Since the system poles are determined as those values at which its transfer function becomes infinity, it
follows that the closed-loop system poles are obtained by solving the following equation.
In the following we consider the complex function
whose zeros are the closed-loop poles of the transfer function. In addition, it is easy to see that the poles
of D(s) are the zeros of T(s) . At the same time the poles of are the open-loop control system poles since
they are contributed by the poles of , which can be considered as the open-loop control system transfer
function—obtained when the feedback loop is open at some point. The Nyquist stability test is obtained
by applying the Cauchy principle of argument to the complex function. First, we state Cauchy’s
principle of argument.
Let F(s) be an analytic function in a closed region of the complex plane except at a finite number of
points. It is also assumed that F(s) is analytic at every point on the contour. Then, as travels around the
contour in the - plane in the clockwise direction, the function F(s) encircles the origin in the plane in the
same direction N times, given by N = Z-P
Where Z and P stand for the number of zeros and poles (including their multiplicities) of the function
inside the F(s) contour.
The above result can be also written as
Arg(F(s)) = 2πn
Nyquist Criterion:
It states that the number of unstable closed-loop poles is equal to the number of unstable open-loop
poles plus the number of encirclements of the origin of the Nyquist plot of the complex function D(s).
This can be easily justified by applying Cauchy’s principle of argument to the function D(s) with the
-plane contour. Note that and represent the numbers of zeros and poles, respectively, of in the unstable
part of the complex plane. Atthe same time, the zeros of D(s) are the closed-loop system poles, and the
poles of D(s) are the open-loop system poles (closed-loop zeros).
The above criterion can be slightly simplified if instead of plotting the function D(s) = 1+(𝑠)𝐻(𝑠), we
plot only the function 𝐺(s)𝐻(𝑠) and count encirclement of the Nyquist plot of around the point (-1+j0) ,
so that the modified Nyquist criterion has the following form. The number of unstable closed-loop poles
(Z) is equal to the number of unstable open-loop poles (P) plus the number of encirclements (N) of the
point (=1+j0),Z=N+P
MATLAB CODE-
Clc
Clear all;
%
num = [1 2]
den = poly([-1 1])
g = tf(num,den);
nyquist(g)
[Gm,Pm] = margin(g)