You are on page 1of 19

Control System

(Practical File)

BACHELORS OF TECHNOLOGY
(Electronics and Communication)

NSUT EAST CAMPUS


Formerly(AIACTR)

Submitted To-:Dr. Richa Bhatia


Submitted by-: Yash
ENROLL NO-:08310102819
SEMESTER-: FIFTH
CLASS-:ECE-2
EXPERIMENT NO 1

AIM: Introduction to MATLAB and to study the basic signals Ramp, Step,
Impulse, Sine, Cosine, Exponential
SOFTWARE USED: MATLAB 5.1.0
THEORY:
1. Unit impulse signal: A signal which has infinite magnitude at time equal to
zero only.
Impulse function is denoted by δ(t). and it is defined as
δ(t) = {1 t=0,
0 t≠0
2. Unit step signal: A signal with magnitude one for time greater than zero .
Unit step function is denoted by u(t). It is defined as
u(t) = { 1 t⩾0,
0 t<0
3. Unit Ramp signal: A signal whose magnitude increases same as time . It can
be obtained by integrating unit step.
Ramp signal is denoted by r(t), and it is defined as
r(t) = {t t⩾0,
0 t<0
4. Unit Parabolic signal: A signal whose magnitude increases with the square of
time . It can be
obtained by integrating unit ramp.
Parabolic signal can be defined as
x(t) = {t^2/2 t⩾0,
0 t<0
5. Exponential Signal: Exponential signal is in the form of
x(t) = e^αt
The shape of exponential can be defined by α.
PROGRAM:
clc;
close all;
clear all;
% unit impulse signal
t=-1:0.001:1;
impulse=[zeros(1,1000),ones(1,1),zeros(1,1000)];
subplot(2,3,1);
plot(t,impulse);
xlabel('time->');
ylabel('Amplitude->');
title('Unit impulse signal');
axis([-1 1 0 1.5]);
%Unit step signal
t=-5:0.01:5;
step=[zeros(1,500),ones(1,501)];
subplot(2,3,2);
plot(t,step);
xlabel('time->');
ylabel('Amplitude->');
title('Unit step signal');
axis([-5 5 0 1.5]);
%Unit ramp signal
t=0:0.01:6;
ramp=t;
subplot(2,3,3);
plot(t,ramp);
xlabel('time->');
ylabel('Amplitude->');
title('Unit ramp signal');
%Sine wave signal
t = [0:0.1:2*pi];
a = sin(t);
subplot(2,3,4);
plot(t,a);
xlabel('time->');
ylabel('Amplitude->');
title('Sine wave signal');
%Cosine wave signal
t = [0:0.1:2*pi];
a = cos(t);
subplot(2,3,5);
plot(t,a);
xlabel('time->');
ylabel('Amplitude->');
title('Cosine wave signal');
% exponential signal
t=-5:0.01:5;
exp=exp(-t);
subplot(2,3,6);
plot(t,exp);
xlabel('time->');
ylabel('Amplitude->');
title('Exponential signal');
OUTPUT:

RESULT: All the signals are plotted.


EXPERIMENT NO 2

AIM : To plot poles and zeros of a Transfer Function. G(S) = 2S^2 +S+5 /
(3S+1)(6s^2+2S+4
SOFTWARE USED: MATLAB 5.1.0
PROGRAM:
% To obtain poles and zeros plot of a Transfer Function
num = [2 1 5];
den = conv([3 1],[6 2 4]);
g = tf(num, den);
[p,z]=pzmap(g);
pzmap(g);
sgrid;
OUTPUT

G(s) = 2s^2 +s+5


---------------
(3S+1)(6s^2+2S+4)

RESULT : Continuous-time transfer function.


p = -0.167 + 0.799i
-0.167 - 0.799i
z = -0.25 + 1.56i
-0.25 - 1.56i
EXPERIMENT NO 3

AIM : To Determine step response and impulse response of a second order


unity feedback system
e.g. Plot Response of given system  G(S) = 1/ (3S^2 +9S +15)
SOFTWARE USED: MATLAB 5.1.0
PROGRAM of STEP RESPONSE:
%% Step response
clc;
clear all;
close all;
num = [1];
den = [3 9 15];
g = tf (num,den);
t= feedback (g,1);
step (t)
OUTPUT:
PROGRAM of IMPULSE RESPONSE
%%Impulse response
clc;
clear all;
close all;
num = [1];
den = [3 9 15];
g = tf (num,den);
t= feedback (g,1);
impulse (t)
OUTPUT :

RESULT : Step Response and Impulse Response are Verified


EXPERIMENT NO 4

AIM : To determine the stability of a system using Routh Hurwitz Criteria


%RH stability of given system 2s^4 +s^3+ 3s^2+5s+10
SOFTWARE USED: MATLAB 5.1.0
PROGRAM:
%%%Routh Hurwitz Automatically
clear
clc
close all
syms K
coeff = [2,1,3,5,10]

%%%%Create the First Row of the Routh Table


routh_table = [];
first_row = [];
for idx = 1:2:length(coeff)
first_row = [first_row,coeff(idx)];
end
while length(first_row) <= 2
first_row = [first_row,0];
end
disp('First Row')
routh_table = [routh_table;first_row]
%%%%Create the second row of the Routh Table
second_row = [];
for idx = 2:2:length(coeff)
second_row = [second_row,coeff(idx)];
end
while length(second_row) < length(first_row)
second_row = [second_row,0];
end
%disp('Second Row')
%routh_table = [routh_table;second_row]
routh_table_width = length(first_row);
%%%Now create the next rows
required_rows_to_compute = length(coeff)-2;

%%%Check and see if this is first order or smaller


if required_rows_to_compute < 0
disp('Trivial Solution')
return
end

for loop_row = 1:required_rows_to_compute


row = [];
disp(['Computing Row ',num2str(loop_row+2)])
disp('Divide All Determinants by this var = ')
divisor = routh_table(loop_row+1,1)
%%THe left part of the determinant for a given row is
constant
disp('Left Half Determinat')
left_half_det = routh_table(loop_row:loop_row+1,1);
for col = 1:routh_table_width
%disp(['Computing Column ',num2str(col)])
if col == routh_table_width
right_half_det = [0;0];
else
right_half_det =
routh_table(loop_row:loop_row+1,col+1);
end
disp('Determinant to be computed')
both_det = [left_half_det,right_half_det]
value = -det(both_det)/divisor;
row = [row,value];
end
disp('Next Row of Routh Table')
routh_table = [routh_table;row]
end

%%%Check for stability


routh_table
first_column = routh_table(:,1)
s = sign(first_column(1));
unstable = 0;
for idx = 2:length(first_column)
value = first_column(idx);
if s ~= sign(value)
disp('Unstable ')
unstable = 1;
break
end
end
if ~unstable
disp('System is Stable')
end

OUTPUT:

Result : The given System 2s^4 +s^3+ 3s^2+5s+10 is Unstable.


EXPERIMENT NO 5

AIM:- Determine the polar plot of a second order feedback system.


SOFTWARE USED:- MATLAB
THEORY:- Polar plot is a plot to be drawn between magnitude and phase. But the
magnitudes are presented with normal values only.
The Polar plot is a plot, which can be drawn between the magnitude and the phase
angle of G(jω)H(jω) by differentiating from zero to ∞. The polar graph sheet is
described in below mentioned image.

This graph sheet includes various concentric circles and radial lines. The concentric
circles and the radial lines are considered as the magnitudes and phase angles.
These angles are highlighted with positive values in anti-clock wise direction. So
that, we can mark angles with negative values in clockwise direction. Let’s see this
example where the angle 270 0 in anti-clock wise direction is equal to the angle
−90 0 in clockwise direction.
Rules for Drawing Polar Plots
Below mentioned rules are used for plotting the polar plots.
 Substitute, s= jω in the open loop transfer function.
 Write the expressions for magnitude and the phase of G(jω)H(jω).
 Find the starting magnitude and the phase of G(jω)H(jω) by substituting ω=0.
So, the polar plot starts with this magnitude and the phase angle.
 Find the ending magnitude and the phase of G(jω)H(jω)by substituting ω=∞.
So, the polar plot ends with this magnitude and the phase angle.
 Check whether the polar plot intersects the real axis, by making the
imaginary term of G(jω)H(jω) equal to zero and find the value(s) of ω.
 Check whether the polar plot intersects the imaginary axis, by making real
term of G(jω)H(jω) equal to zero and find the value(s) of ω.
 For drawing polar plot more clearly, find the magnitude and phase of
G(jω)H(jω) by considering the other value(s) of ω.

EXAMPLE:- Consider the transfer function 20/s^2 + 6s + 25 and draw the polar
plot.
CODE:-
w=[[0:.1:5], [6:1000]];
%G(s) = 20/s^2 + 6s + 25
num = [20];
den= [1 6 25];
G = freqs(num, den, w);
M = abs(G);
Ph = angle(G);
polar(Ph, M);

OUTPUT:-
num = 20
den = 1 6 25
PLOT:-
RESULT/OUTPUT:- Show the polar plot of the given system transfer function.
EXPERIMENT NO 6

AIM:- Determine and analyze  the bode plot for the given system using suitable
software tools (e.g. MATLAB)  and comment on system stability
SOFTWARE USED:- 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 systems 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 closed loop. 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.

Example: Obtain Bode Plot of the system having forward path transfer function of
(2s + 5)/(3s^2 + 7s + 4)

CODE:
clc
num=[2 5];
den=conv([1 1], [3,4]);
w=logspace(-1,3,100);
figure(1);
bode(num,den,w);
title('Bode Plot for the given transfer function G(s)=(2s +
5)/(3s^2 + 7s + 4)')
grid;
[Gm Pm Wcg Wcp] =margin(num,den);
Gain_Margin_dB=20*log10(Gm)
Phase_Margin=Pm
Gaincrossover_Frequency=Wcp
Phasecrossover_Frequency=Wcg
[M P w]=bode(num,den);
[Mp i]=max(M);
Resonant_PeakdB=20*log10(Mp)
Wp=w(i);
Resonant_Frequency=Wp
for i=1:1:length(M);
if M(i)<=1/(sqrt(2));
Bandwidth=w(i)
break;
end;
end;

OUTPUT:

RESULT: Discuss the bode plot of the given transfer function.


EXPERIMENT NO 7

AIM: Determine and analyze the root locus plot for the given system transfer
function using suitable software tools (e.g. MATLAB)  and comment on system
stability.

SOFTWARE USED: MATLAB


ALGORITHM:
 Input characteristic equation in a variable.
 Display the open loop of characteristic equation.
 Find and display the asymptote angle.
 Display the characteristic equation.
 Find and display breakaway point.
 Call the function rlocus() to plot the graph.
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 The closed-loop poles are the roots of d(s) + k*n(s)=0.
EXAMPLE: Obtain Root Locus Plot of a system having forward path transfer
function of 10(s+1)/s^2(s+2)
CODE:
%Root Locus Plot
clear all;
clc;
disp('Transfer Function of given system is:
G(s)=10(s+1)/s^2(s+2)');
num=[10 10];
den=conv([1 0 0],[1,2]);
G = tf(num,den);
rlocus(G)
OUTPUT:

RESULT: Discuss the root locus plot of the given system transfer function.

You might also like