LAB MANUAL
CONTROL SYSTEM (BEC403)
For
IV Semester ECE,CBCS Scheme of VTU
VISVESVARAYA TECHNOLOGICAL UNIVERSITY, BELAGAVI
B.E: Electronics & Communication Engineering/B.E: Electronics &Telecommunication
Engineering NEP, Outcome Based Education(OBE) and Choice Based Credit System
(CBCS) (Effective from the academic year 2023– 24)
IVSemester
Control Systems
Course Code BEC403 CIE Marks 50
Teaching Hours/Week(L:T:P) (3:0:2) SEE Marks 50
Total Hours of Pedagogy 40 hours Theory + 12 Lab slots Total Marks 100
Credits 04 Exam Hours 03
PRACTICAL COMPONENT OF IPCC
"Using suitable simulation software (P-Spice, MATLAB, Python, Scilab, OCTAVE, LabVIEW),
demonstrate the operation of the following circuits:"
Sl.No Experiments
1 Implement Block diagram reduction technique to obtain transfer function a control system.
2 Implement Signal Flow graph to obtain transfer function a control system.
3 Simulation of poles and zeros of a transfer function.
4 Implement time response specification of a second-order underdamped system for different
damping factors.
5 Implement frequency response of a second-order system
6 Implement the frequency response of a lead-lag compensator.
7 Analyze the stability of the given system using the Routh stability criterion.
8 Analyze the stability of the given system using root locus.
9 Analyze the stability of the given system using Bode plots.
10 Analyze the stability of the given system using a Nyquist plot.
11 Obtain the time response from the state model of a system.
12 Implement PI and PD Controllers.
CONTROL SYSTEM [BEC403]
1 Implement Block diagram reduction technique to obtain transfer function a control
system.
clc;
close all;
clear;
p = 4;
q = [1 1 2];
disp('Transfer Function a:');
a = tf(p, q)
r = [1 0];
s = [1 2];
disp('Transfer Function b:');
b = tf(r, s)
disp('Series Connection of a and b (c):');
c = series(a, b)
disp('Feedback System (Ans):');
Ans = feedback(c, 1, -1)
OUTPUT:-
Transfer Function a:
a=
s^2 + s + 2
Continuous-time transfer function.
Transfer Function b:
b=
s+2
Continuous-time transfer function.
Page 1
CONTROL SYSTEM [BEC403]
Series Connection of a and b (c):
c=
4s
s^3 + 3 s^2 + 4 s + 4
Continuous-time transfer function.
Feedback System (Ans):
Ans =
4s
s^3 + 3 s^2 + 8 s + 4
Continuous-time transfer function.
Page 2
CONTROL SYSTEM [BEC403]
2 Implement Signal Flow graph to obtain transfer function a control system.
clc;
close all;
clear all;
% Define the Laplace transform variable s
s = tf('s');
% Define the individual transfer functions
P1 = 1/(s+1);
P2 = 2/(s+2);
L1 = -1/(s+3);
L2 = -1/(s+4);
% Calculate the combined loop transfer functions
L12 = L1 * L2;
% Calculate the determinant Delta
Delta = 1 - (L1 + L2) + L12;
% Calculate Delta1 and Delta2
Delta1 = 1 - (L1 + L2); % Assuming the same form for Delta1 and Delta2
Delta2 = Delta1; % Assuming Delta2 is the same as Delta1
% Calculate the overall transfer function using Mason's Gain Formula
TF = (P1 * Delta1 + P2 * Delta2) / Delta;
% Display the overall transfer function
disp('Overall transfer function of the system using Masons Gain Formula:');
display(TF);
OUTPUT:
Overall transfer function of the system using Masons Gain Formula:
TF =
3 s^9 + 94 s^8 + 1293 s^7 + 10243 s^6 + 51460 s^5 + 169827 s^4 + 367528 s^3 + 501696 s^2
+ 390528 s + 131328
s^10 + 33 s^9 + 484 s^8 + 4150 s^7 + 23005 s^6 + 85993 s^5 + 219006 s^4 + 374080 s^3 +
408384 s^2 + 255744 s + 69120
Continuous-time transfer function.
Page 3
CONTROL SYSTEM [BEC403]
3 Simulation of poles and zeros of a transfer function.
% Define the Laplace transform variable s
s = tf('s');
% Define the numerator and denominator of the transfer function
% Example: (s^2 + 2s + 3) / (s^3 + 4s^2 + 5s + 6)
numerator = s^2 + 2*s + 3;
denominator = s^3 + 4*s^2 + 5*s + 6;
% Create the transfer function
G = numerator / denominator;
% Calculate poles and zeros
poles = pole(G);
zeros = zero(G);
% Display poles and zeros
disp('Poles of the transfer function:');
disp(poles);
disp('Zeros of the transfer function:');
disp(zeros);
% Plot poles and zeros on the complex plane
figure;
pzmap(G);
title('Pole-Zero Map');
grid on;
OUTPUT:
Poles of the transfer function:
-3.0000 + 0.0000i
-0.5000 + 1.3229i
-0.5000 - 1.3229i
Zeros of the transfer function:
-1.0000 + 1.4142i
-1.0000 - 1.4142i
Page 4
CONTROL SYSTEM [BEC403]
Page 5
CONTROL SYSTEM [BEC403]
4 Implement time response specification of a second order Under damped System, for
different damping factors.
clc;
clear all;
close all;
% Define the numerator and denominator of the transfer function
num = [8];
den = [1 3 8];
% Create the transfer function
sys = tf(num, den);
step(sys, 0:0.01:10);
title('Step Response of the System');
[r, p, c] = residue(num, den);
natural_frequency = sqrt(den(3));
damping_ratio = den(2) / (2 * natural_frequency);
disp('Damping Ratio:');
disp(damping_ratio);
OUTPUT:
Damping Ratio:
0.5303
Page 6
CONTROL SYSTEM [BEC403]
5 Implement frequency response of a second order System.
clc;
clear all;
close all;
num1 = 1;
den1 = [1 1.414 1];
w = 0:0.01:pi;
h = freqs(num1, den1, w);
mag = abs(h);
phase = angle(h);
figure;
subplot(2,1,1);
plot(w, mag);
xlabel('Frequency');
ylabel('Magnitude');
title('Magnitude Spectrum of H1');
grid on;
subplot(2,1,2);
plot(w, phase);
xlabel('Frequency');
ylabel('Phase');
title('Phase Spectrum of H1');
grid on;
OUTPUT:
Page 7
CONTROL SYSTEM [BEC403]
6 Implement frequency response of a lead lag compensator.
% Define the time constants for the lead and lag components
T_lead = 0.1; % Lead time constant
T_lag = 10; % Lag time constant
% Define the transfer function for the lead-lag compensator
num = [T_lead 1]; % Numerator coefficients
den = [T_lag 1]; % Denominator coefficients
compensator = tf(num, den);
% Define the frequency range for the response
w = logspace(-2, 2, 500); % Frequencies from 0.01 to 100 rad/s
% Calculate the frequency response
[mag, phase, w] = bode(compensator, w);
% Convert magnitude to dB and phase to degrees
magdB = 20*log10(squeeze(mag));
phaseDeg = squeeze(phase);
% Plot the frequency response
figure;
subplot(2,1,1); % Magnitude plot
semilogx(w, magdB);
grid on;
title('Magnitude Response of Lead-Lag Compensator');
xlabel('Frequency (rad/s)');
ylabel('Magnitude (dB)');
subplot(2,1,2); % Phase plot
semilogx(w, phaseDeg);
grid on;
title('Phase Response of Lead-Lag Compensator');
xlabel('Frequency (rad/s)');
ylabel('Phase (degrees)');
Page 8
CONTROL SYSTEM [BEC403]
OUTPUT:
Page 9
CONTROL SYSTEM [BEC403]
7 Analyze the stability of the given system using Routh stability criterion.
coefficients = input('Enter the coefficients of the characteristic polynomial: ');
% Length of the coefficients array
n = length(coefficients);
% Initialize Routh array with zeros
routh = zeros(n, ceil(n/2));
% Fill in the first two rows of the Routh array
routh(1, 1:ceil(n/2)) = coefficients(1:2:end);
routh(2, 1:ceil(n/2)) = [coefficients(2:2:end), zeros(1, ceil(n/2) - length(coefficients(2:2:end)))];
% Compute the rest of the Routh array
for i = 3:n
for j = 1:ceil(n/2)-1
if routh(i-1, 1) == 0
routh(i-1, 1) = 1e-6; % Avoid division by zero by using a small number
end
routh(i, j) = -1/routh(i-1, 1) * det([routh(i-2, 1), routh(i-2, j+1); routh(i-1, 1), routh(i-1,
j+1)]);
end
end
% Check for sign changes in the first column
sign_changes = 0;
for i = 1:n-1
if sign(routh(i, 1)) * sign(routh(i+1, 1)) < 0
sign_changes = sign_changes + 1;
end
end
% Determine stability based on sign changes
if sign_changes == 0
disp('System is stable');
else
disp('System may be unstable');
end
Page 10
CONTROL SYSTEM [BEC403]
OUTPUT:
>> exp7
Enter the coefficients of the characteristic polynomial: [1 4 3 6]
System is stable
>> exp7
Enter the coefficients of the characteristic polynomial: [1 -4 5 6]
System may be unstable
Page 11
CONTROL SYSTEM [BEC403]
8 Analyze the stability of the given system using Root locus.
% Clear all variables and close all figures
clear all; close all; clc;
% Define the numerator and denominator of G(s)H(s)
n = [1]; % Represents s(s+1), expanded to s^2 + s + 0
d = [1 3 2 0]; % Represents s(s+1), which is actually [1 1 0]
% Create the transfer function system
sys = tf(n, d);
% Display the zero-pole-gain form of the system
zpk(sys)
% Plot the root locus
rlocus(sys);
% Add grid lines to the plot
grid;
OUTPUT:
ans =
s (s+2) (s+1)
Continuous-time zero/pole/gain model.
Page 12
CONTROL SYSTEM [BEC403]
9 Analyze the stability of the given system using Bode plots.
% Clear all variables and close all figures
clear all; close all; clc;
% Define the numerator and denominator of the transfer function
n = [450];
d = [1 12 20 0];
% Create the transfer function system
sys = tf(n, d);
% Plot the Bode plot
figure;
bode(sys);
% Hold the current plot to overlay the margin plot
hold;
% Plot the gain and phase margins
margin(sys);
OUTPUT:
Page 13
CONTROL SYSTEM [BEC403]
10 Analyze the stability of the given system using Nyquist plot.
% Define the numerator and denominator of the transfer function
num = [0 20 20 10]; % Numerator coefficients
den = [1 11 10 0]; % Denominator coefficients
% Create the transfer function system
nyquist(num, den);
% Plot the Nyquist plot
v = [-2 3 -3 3];
% Set the axis limits
axis(v);
grid;
% Add title to the plot
title('Nyquist Plot of G(s) = 20(s^2+s+0.5)/[s(s+1)(s+10)]');
OUTPUT:
Page 14
CONTROL SYSTEM [BEC403]
11 Obtain the time response from state model of a system.
% Clear all variables and close all figures
clear all;
close all;
clc;
% Define the state-space matrices
A = [0 1; -2 -3];
B = [0; 1];
C = [1 -1];
D = 0;
% Create the state-space system
mysys = ss(A, B, C, D);
% Define the initial condition vector
q0 = [1; 2];
% Simulate the initial condition response
initial(mysys, q0);
OUTPUT::
Page 15
CONTROL SYSTEM [BEC403]
12A Implement PI Controllers.
clc;
clear;
% Define the PI controller gains
ki = 10;
kp = 10;
% Define the numerator and denominator of the PI controller transfer function
numI = [kp ki];
denI = [1 0];
% Define the system transfer function (Example)
% Replace `num` and `den` with your actual system transfer function coefficients
num = [1]; % Example numerator
den = [1 2 1]; % Example denominator
% Convolve the denominator of the PI controller with the system's denominator
dr = conv(denI, den);
% Display the open-loop transfer function
disp('Transfer function for PI controller without feedback:');
sys2 = tf(numI, dr)
% Create the closed-loop transfer function with unity feedback
disp('Transfer function for PI controller with feedback:');
G2 = feedback(sys2, 1)
% Step response and plot
m = step(G2);
figure;
plot(m);
title('PI control Kp=10 and Ki=10');
xlabel('Time (seconds)');
ylabel('Amplitude');
% Calculate and display the DC gain of the closed-loop system
k = dcgain(G2)
disp(['DC gain of the closed-loop system: ', num2str(k)]);
Page 16
CONTROL SYSTEM [BEC403]
OUTPUT:
Transfer function for PI controller without feedback:
sys2 =
10 s + 10
s^3 + 2 s^2 + s
Continuous-time transfer function.
Transfer function for PI controller with feedback:
G2 =
10 s + 10
s^3 + 2 s^2 + 11 s + 10
Continuous-time transfer function.
k=
DC gain of the closed-loop system: 1
Page 17
CONTROL SYSTEM [BEC403]
12B Implement PD Controllers.
% Define the plant transfer function numerator and denominator
num = [1]; % Example plant numerator
den = [1 2 1]; % Example plant denominator
% PD controller parameters
Kd = 10;
Kp = 10; % Assuming Kp = Kd for simplicity, you can change this as needed
% PD controller transfer function numerator (assuming D = Kd + Kp*s)
numc = [Kd Kp];
denomc = [1]; % PD controller denominator (assumed to be 1 for simplicity)
% Open-loop transfer function of the PD controller
nr = conv(num, numc);
disp('Transfer function for PD controller without feedback:');
sys1 = tf(nr, den)
% Closed-loop transfer function with unity feedback
disp('Transfer function for PD controller with feedback:');
G1 = feedback(sys1, 1)
% Step response
m = step(G1);
figure;
plot(m);
title('PD control Kp=10 and Kd=10');
xlabel('Time (seconds)');
ylabel('Amplitude');
grid on;
OUTPUT:
Transfer function for PD controller without feedback:
sys1 =
10 s + 10
s^2 + 2 s + 1
Continuous-time transfer function.
Transfer function for PD controller with feedback:
Page 18
CONTROL SYSTEM [BEC403]
G1 =
10 s + 10
s^2 + 12 s + 11
Continuous-time transfer function.
Page 19