0% found this document useful (0 votes)
5 views23 pages

Control System Lab

The document outlines a series of experiments related to control systems, including block diagram reduction, signal flow graphs, time response specifications, frequency response analysis, stability analysis using various methods, and the implementation of controllers. Each experiment includes MATLAB programs to compute transfer functions, simulate system responses, and analyze stability through Routh's criterion, root locus, Bode plots, Nyquist plots, and state-space models. The document provides detailed outputs for each experiment, demonstrating the application of control theory concepts in practical scenarios.

Uploaded by

mynameisbeast229
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views23 pages

Control System Lab

The document outlines a series of experiments related to control systems, including block diagram reduction, signal flow graphs, time response specifications, frequency response analysis, stability analysis using various methods, and the implementation of controllers. Each experiment includes MATLAB programs to compute transfer functions, simulate system responses, and analyze stability through Routh's criterion, root locus, Bode plots, Nyquist plots, and state-space models. The document provides detailed outputs for each experiment, demonstrating the application of control theory concepts in practical scenarios.

Uploaded by

mynameisbeast229
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

EXPERIMENT NO 1:-

Implement Block diagram reduction technique to obtain transfer


function a control system.

1.

s+1 s+1
g1 = ------- g2 = --------- C(S)
500 s^2 s+2
R(S)

PROGRAM :
num1=[1 1];
den1=[500 0 0];
num2=[1 1];
den2=[1 2];
[num,den] = series(num1,den1,num2,den2);
Printsys(num,den)

Output:
s^2 + 2 s + 1
num/den = ----------------------------
500 s^3 + 1000 s^2
02.

s+1
R(S) g1 = ------- C(S)
500 s^2

s+1
g2 = ---------
s+2

PROGRAM :
num1=[1 1];
den1=[500 0 0];
num2=[1 1];
den2=[1 2];
[num,den] = feedback(num1,den1,num2,den2);
Printsys(num,den)

Output:

s^2 + 3 s + 2
num/den = ----------------------------------------
500 s^3 + 1001 s^2 + 2 s + 1
03.

s+1
R(S) g1 = ------- C(S)
500 s^2

s+1
g2 = ---------
s+2

PROGRAM :
num1=[1 1];
den1=[500 0 0];
num2=[1 1];
den2=[1 2];
[num,den] = parallel(num1,den1,num2,den2);
printsys(num,den)

Output:

500 s^3 + 501 s^2 + 3 s + 2


num/den = -----------------------------------------
500 s^3 + 1000 s^2
04.
s+1 s+3 s+5
R(S) g1 = ------- g3 = --------- g4 = ------- C(S)
500 s^2 s+5 700 s^2

s+1 s+7
g2 = --------- g5 = ---------
s+2 s+5
PROGRAM :
num1=[1 1];
den1=[500 0 0];
num2=[1 1];
den2=[1 2];
num3=[1 3];
den3=[1 5];
num4=[1 5];
den4=[700 0 0];
num5=[1 7];
den5=[1 5];
g1=tf(num1,den1);
g2=tf(num2,den2);
g3=tf(num3,den3);
g4=tf(num4,den4);
g5=tf(num5,den5);
h1=parallel(g1,g2);
h2=feedback(g4,g5);
h3=series(h1,g3);
h4=series(h3,h2);
ans=minreal(h4)

Output:
Transfer function:
0.001429 s^4 + 0.005717 s^3 + 0.004303 s^2 + 3.143e-005 s + 1.714e-005
----------------------------------------------------------------------------------------------------
s^5 + 2.001 s^4 + 0.01286 s^3 + 0.02 s^2
EXPERIMENT NO 2:-
Implement Signal Flow graph to obtain transfer function a control
system.
Program
% Define transfer functions
G = tf([1], [1, 1]); % G(s) = 1 / (s + 1)
H = 1; % H(s) = 1

% Compute overall transfer function T(s)


T = G / (1 + G*H);

% Display transfer function T(s)


disp('Transfer Function T(s):');
disp(T);

% Plot the Signal Flow Graph (SFG)


sfg = [0 G; 0 1];

% Visualize the SFG (Optional)


view(sfg)

% Alternatively, you can display the SFG matrix


disp('Signal Flow Graph Matrix:');
disp(sfg);

Output:
EXPERIMENT NO 3:-
Simulation of poles and zeros of a transfer function.
Program:
num=[1 2];
den=[1 7 12];
H=tf(num,den);
Z=zero(H);
P=pole(H);
pzmap(H);
sgrid

Output:
EXPERIMENT NO 4:-
Implement time response specification of a second order Under
damped System, for different damping factors.
Program:
zeta=0.5;
wn=6;
num=[36];
den=[1 6 36];
g=tf(num,den);
wd=wn*sqrt(1-zeta*zeta);
theta=atan(sqrt(1-zeta*zeta)/zeta);
tr=(pi-theta)/wd;
tp=pi/wd;
mp=exp(-zeta*pi/sqrt(1-zeta*zeta))*100;
ts=4/(zeta*wn);
step(g);
xlabel('time (t)');
ylabel('Response c(t)');
title('step response of second order system');
Output:
EXPERIMENT NO 5:-
Implement frequency response of a second order System.
Program
num=[10];
den=[1 6 10];
w=0:0.01:pi;
h=freqz(num,den,w);
mag=abs(h);
phase=angle(h);
figure
subplot(2,1,1);
plot(w,mag);
xlabel('frequency');
ylabel('Magnitude');
title('frequency response of control system');
grid on
subplot(212);
plot(w,phase)
grid on
xlabel('phase');
ylabel('Magnitude');
title('phase response of control system');

Output:
EXPERIMENT NO 6:-
Implement a frequency response of a lead lag Compensator
Lead compensator:
Design a lead compensator for a unity feedback system with open
loop transfer function G(s)= K/(s(s+1)(s+5)) to satisfy the following
specifications (i) velocity error constant Kv=50, (ii) Phase margin =20
degrees.
% Given open-loop transfer function
num = [250];
den = [1 6 5 0];
G = tf(num, den);

% Bode plot of the uncompensated system


figure(1)
bode(G)
grid on
title('Bode plot of uncompensated system')

% Obtain the phase margin of the uncompensated system


[Gm, Pm, Wcg, Wcp] = margin(G);

% Desired phase margin and phase shift


Pmd = 20; % Desired phase margin in degrees
Phi_m = Pmd - Pm + 30; % Required phase shift in degrees
Phi_mr = Phi_m * (pi / 180); % Phase shift in radians

% Calculate alpha and compensator gain


alpha = (1 + sin(Phi_mr)) / (1 - sin(Phi_mr));
Mc = -10 * log10(alpha); % Compensator gain in dB

% Adjust the crossover frequency (wm) as needed


wm = 28.5; % Desired crossover frequency
p = wm * sqrt(alpha); % Pole of the compensator
z = p / alpha; % Zero of the compensator
gain = alpha; % Gain factor
% Define the lead compensator
numc = [1 z];
denc = [1 p];
Gc = tf(numc, denc);

% Implement the lead compensator into the system


Gt = gain * Gc * G;

% Bode plot comparison


figure(2)
bode(G, '--r', Gt, '-')
grid on
legend('Uncompensated system', 'Compensated system')
title('Comparison of compensated and uncompensated bode plots')

% Step response comparison


Gc1u = feedback(G, 1); % Uncompensated closed-loop transfer function
Gclc = feedback(Gt, 1); % Compensated closed-loop transfer function

figure(3)
subplot(2, 1, 1)
step(Gc1u, '--r')
grid on
title('Uncompensated system step response')

subplot(2, 1, 2)
step(Gclc, '-')
grid on
title('Compensated system step response')
Outputs:
Lag compensator:
The open loop transfer function of certain unity feedback control
system is given by G(s)=K/(s(s+4)(s+80)). It is desired to have the
phase margin to be atleast 33 degree and the velocity error
constant =30/sec. Design Lag compensator.

% Given open-loop transfer function


num = [9600];
den = [1 84 320 0];
G = tf(num, den);

% Bode plot of the uncompensated system


figure(1)
bode(G)
grid on
title('Bode plot of uncompensated system')

% Design parameters for the lag compensator


Pmd = 33; % Desired Phase Margin (PM)
Pmn = Pmd + 5; % Phase margin after compensation
Phigcn = Pmn - 180; % Phase angle for the new PM
Wgcn = 4.45; % Desired gain crossover frequency
Agcn = 12.2; % Desired magnitude in dB

% Calculate beta and T for the Lag compensator


beta = 10^(Agcn / 20);
T = 10 / Wgcn; % Time constant for lag compensator

% Define the Lag compensator


numc = [1 1 / T];
denc = [1 1 / (beta * T)];
Gc = tf(numc, denc);

% Compute the overall forward transfer function


Gain = 1 / beta;
Gt = Gain * Gc * G;

% Bode plot comparison of compensated and uncompensated systems


figure(2)
bode(G, '--r', Gt, '-')
grid on
legend('Uncompensated system', 'Compensated system')
title('Comparison of compensated and uncompensated bode plots')

% Closed-loop transfer functions


Gc1u = feedback(G, 1); % Uncompensated closed-loop TF
Gclc = feedback(Gt, 1); % Compensated closed-loop TF

% Step response comparison


figure(3)
step(Gc1u, '--r', Gclc, '-')
grid on
legend('Uncompensated system', 'Compensated system')
title('Comparison of compensated and uncompensated step responses')

Outputs:
EXPERIMENT NO 7:-
Analyze the stability of the given system using Routh stability
criterion.
% define the coeffient of the characteristics equation
coeff=[1,3,2,1,5];
% length of the characteristics eqation
n=length(coeff);
%initialize the routh array
routh=zeros(n,ceil(n/2));
% fill in the first two rows of the routh array
routh(1,:)= coeff(1:2:end);
if n>1
routh(2,1:length(coeff(2:2:end)))= coeff(2:2:end);
end
% fill the rest of the routh array
for i=3:n
for j=1:ceil(n/2)-1
routh(i,j)=-det([routh(i-2,1) routh(i-2,j+1); routh(i-1,1) routh(i-1,j+1)])/ routh(i-
1,1);
end
%specila case when the element in the first column becomes zero
if routh(i,1)==0
routh(i,1)=eps;
end
end
% stability based on the routh array
stable=all(routh (:,1)>0);
% display stability result
disp('Routh array');
disp(routh);
if stable
disp('The system is stable (all elements in the first column are positive ).');
else
disp('The system is unstable ( there are no positive element in the next
column.)');
end

Output:
Routh array
1.0000 2.0000 5.0000
3.0000 1.0000 0
1.6667 5.0000 0
-8.0000 0 0
5.0000 0 0

The system is unstable ( there are no positive element in the next


column.)
EXPERIMENT NO 8:-
Analyze the stability of the given system using Root locus.
Program
num=[1];
den=[1 3 0];
g=tf(num,den);
rlocus(g)
EXPERIMENT NO 9:-
Analyze the stability of the given system using Bode plots.
Program
num=[1 ];
den=[1 2];
g=tf(num,den);
bode(g)
EXPERIMENT NO 10:-
Analyze the stability of the given system using Nyquist plot.
Program
num=[10];
den=[1 6 10];
sys=tf(num,den);
num1=[1 1];
den1=[1 2 4];
sys1=tf(num1,den1);
num2=[3];
den2=[1 5 12];
sys2=tf(num2,den2);
nyquist(sys,'g',sys1,'r--',sys2,'b+')
EXPERIMENT NO 11:-
Obtain the time response from state model of a system.
A = [-0.2516 -0.1684;2.784 0.3549];
B = [0;3];
C = [0 1];
D = 0;
Ts = 0.05;
sys = ss(A,B,C,D,Ts,'StateName',{'Position' 'Velocity'}, 'InputName','Force');
step(sys)
EXPERIMENT NO 12:-
Implement PI and PD Controllers.
Program
num = [1];
den = [1 3 1];
g = tf(num,den);
h = [1];
m = feedback(g,h);
step(m)
hold on
kp = 24;
ki = 0;
kd = 8;
G = pid(kp, ki, kd);
mc = feedback(g*G,h);
step(mc)
grid on

Output:

You might also like