LORD JEGANNATH COLLEGE OF
ENGINEERING AND TECHNOLOGY
PSN Nagar, Ramanathichanputhur, Kanyakumari District
RECORD NOTE
CONTROL AND INSTRUMENTATION
LABORATORY
Reg No:
DEPARTMENT OF ELECTRICAL AND ELECTRONICS
ENGINEERING
LORD JEGANNATH COLLEGE OF ENGINEERING
AND TECHNOLOGY
PSN Nagar, Ramanathichanputhur, Kanyakumari District
DEPARTMENT OF ELECTRICAL AND ELECTRONICS
ENGINEERING
Certified that this is the bonafied record of work done by
Mr/Ms …………………………………………… of the 5th semester in
CONTROL AND INTRUMENTATION LABORATORY (EE3512)
during the academic year 2024-2025 in partial fulfillment of the
requirements of the B.E degree course of the ANNA UNIVERSITY
Chennai
Staff in charge Head of the Department
Reg. No: ………………………………..
University Examination held on: ………………………………
Internal Examiner External Examiner
INDEX
EX DATE NAME OF THE EXPERIMENT PAGE SIGN
No: NO
OUTPUT
2
Ex. No:
Date:
STUDY OF P, PI, PD and PID CONTROLLERS
AIM
To obtain the response of the P, PI, PD, PID controller using MATLAB software.
APPARATUS REQUIRED
1. MATLAB Software
PROGRAM
clc
clear all
close all
% Step Response for OLTF 1/(s^2+10s+20)
num=[1];
den=[1 10 20];
figure(1);
step(num,den)
title('Step Response for OLTF 1/(s^2+10s+20) ');
grid;
% Proportional Controller
Kp=300;
num1=[Kp];
den1=[1 10 20+Kp];
t=0:0.01:2;
figure(2);
step(num1,den1,t)
title('Step Response for Proportional Controller');
grid;
% Proportional Derivative Controller
Kp=300;
Kd=10;
num2=[Kd Kp];
den2=[1 10+Kd 20+Kp];
t=0:0.01:2;
figure(3);
step(num2,den2,t)
title('Step Response for Proportional Derivative Controller');
grid;
% Proportional Integral Controller
Kp1=30
Ki=70;
num3=[Kp1 Ki]
den3=[1 10 20+Kp1 Ki]
t=0:0.01:2;
figure(4);
step(num3,den3,t)
title('Step Response for Proportional Integral Controller');
grid;
3
4
%Proportional Integral Derivative Controller
Kp2=350;
Kd2=50;
Ki2=300;
num4=[Kd2 Kp2 Ki2]
den4=[1 10+Kd2 20+Kp2 Ki2]
t=0:0.01:2;
figure(5);
step(num4,den4,t)
title('Step Response for Proportional Integral Derivative Controller');
grid;
PROCEDURE
i) Open the MATLAB software
ii) Check the title menu and select a new M file
iii) Enter the program and save the program
iv) Execute the program using debug to get the output
RESULT
5
OUTPUT
num = 20
den = 1 5 4 0
G= 20
s^3 + 5 s^2 + 4 s
Gm = 1.0000
Pm = 7.3342e-06
Wcp = 2.0000
Wcp = 2.0000
PM = -135
Wg = 0.7016
beta = 5.7480
tau = 11.4025
D = 11.4 s + 1
65.54 s + 1
Gc = 228 s + 20
65.54 s^4 + 328.7 s^3 + 267.2 s^2 + 4 s
Gm1 = 5.2261
Pm1 = 38.9569
Wcg1 = 1.9073
Wcp1 = 0.7053
6
Ex. No:
Date:
DESIGN OF LAG COMPENSATOR AND EVALUATION OF CLOSED LOOP
PERFORMANCE
AIM
To Design the Lag compensator for the given system using MATLAB Software.
APPARATUS REQUIRED
1. MATLAB Software
DESIGN PROBLEM
Design a Phase Lag compensator for the unity feedback transfer function G(s)=K /s(s+1)(s+4) has
specifications : a. Phase Margin>_ 400 b. The steady state error for ramp input is less than or equal
to 0.2 and check the results using MATLAB Software.
PROGRAM
num=[20]
den=[1 5 4 0]
G=tf(num,den)
figure(1);
bode(G);
title('bode plot for uncompensated system G(s)=20/S(S+1)(S+4)')
grid;
[Gm,Pm,Wcp,Wcp]=margin(G)
Gmdb=20*log10(Gm);
W=logspace(-1,1,100)';
[mag,ph]=bode(G,W); ph=reshape(ph,100,1);
mag=reshape(mag,100,1);
PM=-180+40+5
Wg=interp1(ph,W,PM)
beta=interp1(ph,mag,PM)
tau=8/Wg
D=tf([tau 1],[beta*tau 1])
Gc=D*G
figure(2);
bode(Gc);
title('Bode Plot for the Lag compensated System')
grid;
[Gm1,Pm1,Wcg1,Wcp1]=margin(Gc)
7
8
PROCEDURE
i) Open the MATLAB software
ii) Check the title menu and select a new M file
iii) Enter the program and save the program
iv) Execute the program using debug to get the output
RESULT
9
OUTPUT
num = 5
den =1 2 0
G = 5
s^2 + 2 s
Gm = Inf
Pm = 47.3878
Wcg = Inf
Wcp = 1.8399
GmdB = Inf
PM = 10.6122
alpha = 0.6890
Gm = -1.6181
Wm = 2.0853
tau = 0.5777
D =0.5777 s + 1
0.398 s + 1
Gc = 2.889 s + 5
0.398 s^3 + 1.796 s^2 + 2 s
Gm1 = Inf
Pm1 = 54.4212
Wcg1 = Inf
Wcp1 = 2.0849
10
Ex. No:
Date:
DESIGN OF LEAD COMPENSATOR AND EVALUATION OF CLOSED LOOP
PERFORMANCE
AIM
To Design the Lead compensator for the given system using MATLAB Software.
APPARATUS REQUIRED
1. MATLAB Software
DESIGN PROBLEM
Design a Phase Lead compensator for the unity feedback transfer function G(s)=K /s(s+2) has
specifications : a. Phase Margin>_ 550 b. The steady state error for ramp input is less than or equal
to 0.33 and check the results using MATLAB Software. (Assume K=5)
PROGRAM
num=[5]
den=[1 2 0]
G=tf(num,den)
figure(1);
bode(G);
title('Bode Plot for uncompensated system G(s)=5/s(s+2)')
grid on
[Gm,Pm,Wcg,Wcp]=margin(num,den)
GmdB=20*log10(Gm)
PM=55-Pm+3
alpha=(1-sin(PM*pi/180))/(1+sin(PM*pi/180))
Gm=-20*log10(1/sqrt(alpha))
w=logspace(-1,1,100)';
[mag1,phase1]=bode(G,w);
mag=20*log10(mag1);
magdB=reshape(mag,100,1);
Wm=interp1(magdB,w,-20*log10(1/sqrt(alpha)))
tau=1/(Wm*sqrt(alpha))
D=tf([tau 1],[alpha*tau 1])
Gc=D*G
figure(2);
bode(Gc);
title('Bode Plot for the Lead Compensated System')
grid on
[Gm1,Pm1,Wcg1,Wcp1]=margin(Gc)
11
12
PROCEDURE
i) Open the MATLAB software
ii) Check the title menu and select a new M file
iii) Enter the program and save the program
iv) Execute the program using debug to get the output
RESULT
13
OUTPUT
14
Ex. No:
Date:
ROOT LOCUS
AIM
To draw the root locus of the given system or transfer function using MATLAB Software.
APPARATUS REQUIRED
1. MATLAB Software
DESIGN PROBLEM
The open loop transfer function of a unity feedback system G(s)=K/s(s2+8s+17) Draw the root locus
manually and Check the same results using MATLAB Software. (Assume K=1)
PROGRAM
clc
clear all
close all
% Rootlocus of the transfer function G(s)=1/(S^3+8S^2+17S)
num=[1];
den=[1 8 17 0];
figure(1);
rlocus(num,den);
title('Root Locus for the transfer function G(s)=1/(S^3+8S^2+17S)')
grid
15
16
PROCEDURE
i) Open the MATLAB software
ii) Check the title menu and select a new M file
iii) Enter the program and save the program
iv) Execute the program using debug to get the output
RESULT
17
OUTPUT
18
Ex. No:
Date:
BODE PLOT
AIM
To draw the Bode Plot of the given system or transfer function using MATLAB Software.
APPARATUS REQUIRED
1. MATLAB Software
DESIGN PROBLEM
Draw the Bode Plot for the given transfer functionG(S)=1/S(S2+2S+3) %Find (i)Gain Margin (ii)
Phase Margin (iii) Gain Cross over Frequency %(iv) Phase Cross over Frequency (v)Resonant
Peak (vi)Resonant %Frequency (vii)Bandwidth
PROGRAM
num=[1 ];
den=[1 2 3 0];
G=tf(num,den)
w=logspace(-1,3,100);
figure(1);
bode(G,w);
title('Bode Plot for the given transfer function G(s)=1/s(s^2+2s+3)')
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(G);
[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;
19
20
PROCEDURE
i) Open the MATLAB software
ii) Check the title menu and select a new M file
iii) Enter the program and save the program
iv) Execute the program using debug to get the output
RESULT
21
OUTPUT
Problem 1:
Enter the coefficients of characteristic equation: [1 4 16 10 6]
The Routh Matrix:
1.0000 16.0000 6.0000
4.0000 10.0000 0
13.5000 6.0000 0
8.2222 0 0
6.0000 0 0
System is Stable
Problem 2:
Enter the coefficients of characteristic equation: [1 1 3 3 2 5]
The Routh Matrix:
1 3 2
1 3 5
0 -3 0
-Inf NaN 0
NaN NaN 0
NaN NaN 0
System is Unstable
22
Ex. No:
Date:
STABILITY ANALYSIS USING ROUTH HURWITZ CRITERION
AIM
To check the stability of the given system or transfer function by Routh Hurwitz criterion using
MATLAB Software.
APPARATUS REQUIRED
1. MATLAB Software
PROGRAM
%%routh hurwitz criteria
clear
clc
%firstly it is required to get first two row of routh matrix
e=input('Enter the coefficients of characteristic equation: ');
disp('
--')
l=length(e);
m=mod(l,2);
if m==0
a=rand(1,(l/2));
b=rand(1,(l/2));
for i=1:(l/2)
a(i)=e((2*i)-1);
b(i)=e(2*i);
end
else
e1=[e 0];
a=rand(1,((l+1)/2));
b=[rand(1,((l-1)/2)),0];
for i=1:((l+1)/2)
a(i)=e1((2*i)-1);
b(i)=e1(2*i);
end
end
%%now we genrate the remaining rows of routh matrix
l1=length(a);
c=zeros(l,l1);
c(1,:)=a;
c(2,:)=b;
for m=3:l
for n=1:l1-1
c(m,n)=-(1/c(m-1,1))*det([c((m-2),1) c((m-2),(n+1));c((m-1),1) c((m-
1),(n+1))]);
end
end
disp('The Routh Matrix:')
disp(c)
23
24
%%now we check the stablity of system
if c(:,1)>0
disp('System is Stable')
else
disp('System is Unstable');
end
PROCEDURE
i) Open the MATLAB software
ii) Check the title menu and select a new M file
iii) Enter the program and save the program
iv) Execute the program using debug to get the output
RESULT
25
OUTPUT
Problem 1: Problem 2:
A = -1 1 A=0 1
0 -3 -2 -3
B=0 B=0
1 1
C =0 1 C = 1 -1
Controllable Matrix is Qc = 0 1 Controllable Matrix is Qc = 0 1
1 -3 1 -3
Given System is Controllable Given System is Controllable
Observable Matrix is Qb = 0 1 Observable Matrix is Qb = 1 -1
0 -3 2 4
Given System is Not Observable Given System is Observable
26
Ex. No:
Date:
TEST OF CONTROLLABILITY AND OBSERVABILITY IN SIMULATION PLATFORM
AIM
To test the controllability and observability of the given system in simulation platform.
APPARATUS REQUIRED
1. MATLAB Software
PROGRAM
A = [-1 1;0 -3]
B = [0;1]
C = [0 1]
% Controllable Matrix
Qc = ctrb(A,B);
rankQc = rank(Qc);
disp('Controllable Matrix is Qc = ');
disp(Qc);
if(rankQc == rank(A))
disp('Given System is Controllable');
else
disp('Given System is Not Controllable');
end
% Observable Matrix
Qb = obsv(A, C);
rankQb = rank(Qb);
disp('Observable Matrix is Qb = ');
disp(Qb);
if(rankQb == rank(A))
disp('Given System is Observable');
else
disp('Given System is Not Observable');
end
27
Problem 3: Problem 4:
A= 0 0 1 A= 0 6 -5
-2 -3 0 1 0 2
0 2 -3 3 2 4
B= 0 B= 0
-6 1
4 2
C= 1 0 0 C= 1 2 3
Controllable Matrix is Qc = 0 4 -24 Controllable Matrix is Qc = 0 -4 -26
-6 18 -62 1 4 16
4 -24 108 2 10 36
Given System is Controllable Given System is Controllable
Observable Matrix is Qb = 1 0 0 Observable Matrix is Qb = 1 2 3
0 0 1 11 12 11
0 2 -3 45 88 13
Given System is Observable Given System is Observable
28
PROCEDURE
i) Open the MATLAB software
ii) Check the title menu and select a new M file
iii) Enter the program and save the program
iv) Execute the program using debug to get the output
RESULT
29
OUTPUT
Gr = 9
s^2 + 4.2 s + 9
cp = -2.1000 + 2.1424i
-2.1000 - 2.1424i
K = -0.4200 -0.4652
A= x1 x2
x1 -0.3077 1123
x2 -0.006947 -3.892
B= u1
x1 0
x2 0.008014
C = x1 x2
y1 1 0
D = u1
y1 0
op = -20.0000 -22.0000
L = -340.4215
-225.3519
A= x1 x2 x3 x4
x1 -0.3077 1123 0 0
x2 -0.006947 -3.892 -341.5 -378.2
x3 0 0 340.1 1123
x4 0 0 -116.1 -382.1
30
Ex. No:
Date:
STATE FEEDBACK AND STATE OBSERVER DESIGN AND EVALUATION OF CLOSED
LOOP PERFORMANCE
AIM
To design state feedback and state observer and evaluate the closed loop performance in
simulation platform.
APPARATUS REQUIRED
1. MATLAB Software
PROGRAM
% Parameters
Rs = 0.47;
Lq = 1.23e-3;
B = 0.0002;
Kb = 0.42;
Kt = 0.73;
J = 6.5e-4;
% State-space Matrices of the Uncompensated Plant
A = [-B/J Kt/J;
-Kb/Lq -Rs/Lq];
B = [0;
1/Lq];
C = [1 0];
D = 0;
% Reference trajectory design
wr = 3; % reference omega, ?
zr = 0.7; % reference zeta, ?
nr = wr^2;
dr = [1 2*zr*wr wr^2]; % x" + 2·?·?·x' + ?²·x
Gr = tf(nr, dr) % reference model
% Controller design
cp = pole(Gr) % controller poles
K = place(A, B, cp) % controller gains
% Closed-loop control system without observer
sys = ss(A-B*K, B, C, D);
Nbar = 1/dcgain(sys); % Normalizer (to rescale the reference input)
cls = ss(A-B*K, B*Nbar, C, D)
% Observer design
or = 10*real(cp(1)); % make the observer response 10 times faster
op = [or+1 or-1] % observer poles (make op ? cp but no repeated
poles)
L = place(A', C', op)' % observer gains
% Combine state-feedback controller and observer
Aco = [A-B*K B*K;
zeros(size(A)) A-L*C];
Bco = [B*Nbar;
zeros(size(B))];
31
B=
u1
x1 0
x2 0.008014
x3 0
x4 0
C=
x1 x2 x3 x4
y1 1 0 0 0
D=
u1
y1 0
32
Cco = [C zeros(size(C))];
Dco = 0;
% Closed-loop observer-based control system
clco = ss(Aco, Bco, Cco, Dco)
step(clco, 6), grid on
PROCEDURE
i) Open the MATLAB software
ii) Check the title menu and select a new M file
iii) Enter the program and save the program
iv) Execute the program using debug to get the output
RESULT
33
OUTPUT
34
Ex. No:
DATE:
DISCRETIZATION OF CONTINUOUS SYSTEM
AIM
To discretize and draw the step response of the given system or transfer function of a continuous
system using MATLAB Software.
APPARATUS REQUIRED
1. MATLAB Software
PROGRAM
clc
clear all
close all
G = tf([1 -2],[1 3 20],'inputdelay',1);
Ts = 0.1; % sampling interval
Gd = c2d(G,Ts)
step(G,'b',Gd,'r')
legend('Continuous','Discretized')
35
36
PROCEDURE
i) Open the MATLAB software
ii) Check the title menu and select a new M file
iii) Enter the program and save the program
iv) Execute the program using debug to get the output
RESULT
37
OUTPUT
38
Ex. No:
DATE:
ANALOG (OP AMP BASED) SIMULATION OF LINEAR DIFFERENTIAL EQUATIONS
AIM
To simulate the given differential equation using Op-Amp in MATLAB Software.
APPARATUS REQUIRED
1. MATLAB Software
SIMULINK DIAGRAM
39
40
PROCEDURE
i) Open the MATLAB software
ii) Open new Simulink file
iii) Construct the block diagram model for the given differential equation using Simulink library
browser
iv) Run the model and get the output
RESULT
41
OUTPUT
Problem 1: Problem 2: Problem 3:
Problem 4: Problem 5: Problem 6:
42
Ex. No:
Date:
NUMERICAL SIMULATION OF GIVEN NONLINEAR DIFFERENTIAL EQUATIONS
AIM
To simulate the given non-linear differential equation in MATLAB platform.
APPARATUS REQUIRED
1. MATLAB Software
PROGRAM
%Problem 1-Nonlinear Differential Equation with Initial Condition
syms y(t)
ode = (diff(y,t)+y)^2 == 1;
cond = y(0) == 0;
disp('Output 1')
ySol(t) = dsolve(ode,cond)
%Problem 2-Second-Order ODE with Initial Conditions
syms y(x)
Dy = diff(y);
ode = diff(y,x,2) == cos(2*x)-y;
cond1 = y(0) == 1;
cond2 = Dy(0) == 0;
conds = [cond1 cond2];
ySol(x) = dsolve(ode,conds);
disp('Output 2')
ySol = simplify(ySol)
%Problem 3-Third-Order ODE with Initial Conditions
syms u(x)
Du = diff(u,x);
D2u = diff(u,x,2);
ode = diff(u,x,3) == u;
cond1 = u(0) == 1;
cond2 = Du(0) == -1;
cond3 = D2u(0) == pi;
conds = [cond1 cond2 cond3];
disp('Output 3')
uSol(x) = dsolve(ode,conds)
%Problem 4
syms y(t)
ode = diff(y)+4*y == exp(-t);
cond = y(0) == 1;
disp('Output 4')
ySol(t) = dsolve(ode,cond)
%Problem 5
syms y(x)
ode = 2*x^2*diff(y,x,2)+3*x*diff(y,x)-y == 0;
disp('Output 5')
ySol(x) = dsolve(ode)
43
44
%Problem 6
syms y(x)
ode = diff(y,x,2) == x*y;
disp('Output 6')
ySol(x) = dsolve(ode)
PROCEDURE
i) Open the MATLAB software
ii) Check the title menu and select a new M file
iii) Enter the program and save the program
iv) Execute the program using debug to get the output
RESULT
45
OUTPUT
Mechanical System
46
Ex. No:
DATE:
MATHEMATICAL MODELING AND SIMULATION OF PHYSICAL SYSTEMS
AIM
To simulate the given Mechanical and Electrical system in MATLAB Software.
APPARATUS REQUIRED
1. MATLAB Software
SIMULINK DIAGRAM
Mechanical System
47
Electrical System
48
Electrical System
PROCEDURE
i) Open the MATLAB software
ii) Open new Simulink file
iii) Construct the block diagram model for the given differential equation using Simulink library
browser
iv) Run the model and get the output
RESULT
49
OUTPUT
50
Ex. No:
DATE:
SYSTEM IDENTIFICATION THROUGH PROCESS REACTION CURVE
AIM
To approximate high-order (linear or nonlinear) systems with a first-order-plus-time delay model
using step response data using Process reaction curve in MATLAB Software.
APPARATUS REQUIRED
1. MATLAB Software
PROGRAM
FUNCTION:
function [model,controller]=ReactionCurve(t,y,u)
%Inputs:
% t: time vector of step repose
% y: output vector of step repose
% u: step input vector or scalar (input change)
%Outputs:
% model: first-order-plus-timedelay model structue, which includes
% gain (steady-state gain), time_constant (first-order time
% constant) and tiem_deltay.
% controllers: structure of transfer functions of P-only, PI and PID
% controllers.
if nargin<3
du=1;
t0=0;
u=1;
elseif isscalar(u)
du=u;
t0=0;
else
du=u(end)-u(1);
t0=find(diff(u));
end
gain=(y(end)-y(1))/du;
dy=diff(y);
dt=diff(t);
[mdy,I]=max(abs(dy)./dt);
time_constant=abs(y(end)-y(1))/mdy;
time_delay=t(I)-abs(y(I)-y(1))/mdy-t0;
subplot(211)
plot(t,y,[t0+time_delay t0+time_delay+time_constant],[y(1) y(end)],...
[t(1) t(end)],[y(1) y(1)],'--',[t(1) t(end)],[y(end) y(end)],'--');
title('output')
subplot(212)
if isscalar(u)
plot([t0 t(end)],[u u])
else
plot(t,u)
51
52
end
title('input')
model.gain=gain;
model.time_constant=time_constant;
model.time_delay=time_delay;
time_delay=max(time_delay,time_constant/10);
controller.P=time_constant/time_delay/gain;
controller.PI=0.9*time_constant/time_delay/gain*tf([3.3*time_delay
1],[3.3*time_delay 0]);
controller.PID=1.2*time_constant/time_delay/gain*tf([time_delay^2
2*time_delay 1],[2*time_delay 0]);
MAIN PROGRAM:
clc
clear all
close all
G = tf(1,[1 1]);
subplot(221)
step(G)
G2 = tf(1, [1 4 6 4 1]);
subplot(222)
step(G2)
subplot(223)
step(G)
hold
% plot([0 1],[0 1],'Linewidth',2)
% plot([1 1],[0 1],':')
% set(gca,'Xtick',1)
[y,t]=step(G2);
% The maximum response speed and the corresponding time point
[dydt,idx]=max(diff(y)./diff(t));
% The crossing point with the initial line
t0=t(idx)-y(idx)/dydt;
% The crossing point with the steady state line
t1=t(idx)+(1-y(idx))/dydt;
% plot the step response with the maximum slope
subplot(224)
plot(t,y,'-',[t0 t1],[0 1],'r--','Linewidth',2)
figure(2)
[model,controller]=ReactionCurve(t,y);
fprintf('Process gain: %g, Time constant: %g, Time delay: %g\n',model.gain,
model.time_constant, model.time_delay)
% comparing how good the approximation is.
figure()
Ga = tf(model.gain,[model.time_constant 1]);
set(Ga,'InputDelay',model.time_delay')
step(Ga)
hold
plot(t,y,'--','Linewidth',2)
legend('approximation','Process Reaction Curve')
% This shows that the approximation matches the maximum response
% speed well but overall response speed is slower than original system.
53
54
PROCEDURE
i) Open the MATLAB software
ii) Check the title menu and select a new M file
iii) Enter the program and save the program
iv) Execute the program using debug to get the output
RESULT
55