CS Lab Manual - Merged
CS Lab Manual - Merged
Prepared by
M4: To sensitize the Students regarding Social, Moral and Professional ethics.
PEO2: To make the students capable of managing their profession based on existing as
well as new emerging technologies in the area of Electronics and Communication
Engineering.
PSO1. Graduates will have the ability to mould the technology in the areas of Analog and Digital
Scenario.
IV Semester
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
Course objectives: This course will enable students to:
1. Understand basics of control systems and design mathematical models using block diagram
reduction, SFG, etc.
2. Understand Time domain and Frequency domain analysis.
3. Analyze the stability of a system from the transfer function
4. Familiarize with the State Space Model of the system.
Module-2
Block diagrams and signal flow graphs: Transfer functions, Block diagram algebra and Signal
Flow graphs. (Textbook 1: Chapter 2.4, 2.5, 2.6)
Teaching- Chalk and Talk, YouTube videos, Any software tool to implement block diagram
LearningProcess reduction techniques and Signal Flow graphs
RBT Level: L1, L2, L3
Module-3
Time Response of feedback control systems: Standard test signals, Unit step response of First
and Second order Systems. Time response specifications, Time response specifications of second
order systems, steady state errors and error constants. Introduction to PI, PD and PID Controllers
(excluding design). (Textbook 1: Chapter 5.3, 5.4, 5.5)
Teaching- Chalk and Talk, YouTube videos, Any software tool to show time
LearningProcess response for various transfer functions and PI, PD and PID controllers.
RBT Level: L1, L2, L3
Module-4
Stability analysis: Concepts of stability, Necessary conditions for Stability, Routh stability
criterion, Relative stability analysis: more on the Routh stability criterion.
Introduction to Root-Locus Techniques, The root locus concepts, Construction of root loci.
(Textbook 1: Chapter 6.1, 6.2, 6.4, 6.5, 7.1, 7.2, 7.3)
Teaching- Chalk and Talk, YouTube videos, Any software tool to plot Root locus for
LearningProcess various transfer functions
RBT Level: L1, L2, L3
Module-5
Frequency domain analysis and stability: Correlation between time and frequency response,
Bode Plots, Experimental determination of transfer function. (Textbook 1: Chapter 4: 8.1, 8.2, 8.4)
Mathematical preliminaries, Nyquist Stability criterion, (Stability criteria related to polar plots are
excluded) (Textbook 1: 9.2, 9.3)
State Variable Analysis: Introduction to state variable analysis: Concepts of state, state variable
and state models. State model for Linear continuous –Time systems, solution of state equations.
(Textbook 1: 12.2, 12.3, 12.6)
Teaching- Chalk and Talk, YouTube videos, Any software tool to draw Bode plot
LearningProcess for various transfer functions
RBT Level: L1, L2, L3
Course Outcomes
The theory portion of the IPCC shall be for both CIE and SEE, whereas the practical
portion will have a CIE component only. Questions mentioned in the SEE paper shall
include questions from the practical component.
• The minimum marks to be secured in CIE to appear for SEE shall be the 12 (40% of
maximum marks-30) in the theory component and 08 (40% of maximum marks -20) in
the practical component. The laboratory component of the IPCC shall be for CIE only.
However, in SEE, the questions from the laboratory component shall be included. The
maximum of 04/05 questions to be set from the practical component of IPCC, the total
marks of all questions should not be more than the 20 marks.
SEE will be conducted for 100 marks and students shall secure 35% of the maximum marks to
qualify inthe SEE. Marks secured out of 100 shall be reduced proportionally to 50.
Suggested Learning Resources:
Text Books
1. Control Systems Engineering, I J Nagrath, M. Gopal, New age international Publishers, Fifth
edition.
SEMESTER & YEAR: 4th EVEN 2025 FACULTY NAME: Dr. Basavanna M, Smt. Spoorthi Y and
Mr. Yuvaraju T
Course Outcomes
Students will be able to deduce transfer function of a given physical system,
C 218.1 from differential equation representation or Block Diagram representation and
SFG representation.
Students will be able to calculate time response specifications and analyze the
C 218.2
stability of the system.
Students will be able to draw and analyze the effect of gain on system behavior
C 218.3
using root loci.
Students will be able to perform frequency response Analysis and find the
C 218.4
stability of the system.
Students will be able to represent state model of the system and find the time
C 218.5
response of the system.
IMPORTANT INSTRUCTIONS TO THE STUDENTS
1. You should come prepared for the experiments to be done in the lab.
2. Data sheet should be complete with theoretical calculations and the program.
3. Lab record should be complete with theory, theoretical calculations, program, and
observations.
4. You should try to analyze and understand the solved problems and then solve the
unsolved problems of the experiment in the lab.
5. Results of all the problems solved in the lab should be properly noted down in the
data sheet and the output must be plotted on the graph sheet in the lab.
6. You have to get your results verified and observation copies checked by the
instructor before leaving the lab for the day.
7. You should maintain a folder of all the programs you do in the lab in the computer
you use by your name/roll no.
9. You will be evaluated in every lab you attend, based on your performance,
observation copy and behavior in the lab.
DO’S AND DON’T’S OF THE LABORATORY
DO’S:
1. Laboratory regulations and procedures for conduction of experiments are to be
followed strictly.
5. Get the connection checked by the staff before switching on the supply.
8. Use all apparatus carefully & replace the same in proper place.
9. For any alteration and change of connection get the approval by the staff.
10. Switch off the supply and remove all the connection made to the Machine / System
after completion of the experiment.
DONT’S:
1. Do not spread unwanted connecting wires on the table.
3. Do not leave the experiment table unattended while the experimental set up supply
is on.
LIST OF EXPERIMENTS
Control Systems Laboratory
Sl. Page No
Name of Experiment
No
Implement Block diagram reduction technique to obtain transfer 1-3
1
function a control system.
Implement Signal Flow graph to obtain transfer function a control 4-6
2
system.
3 Simulation of poles and zeros of a transfer function. 7-9
Implement time response specification of a second order Under 10-13
4
damped System, for different damping factors.
5 Implement frequency response of a second order System. 14-16
6 Implement frequency response of a lead lag compensator. 17-19
Analyze the stability of the given system using Routh stability 20-23
7
criterion.
8 Analyze the stability of the given system using Root locus. 24-26
9 Analyze the stability of the given system using Bode plots. 27-29
10 Analyze the stability of the given system using Nyquist plot. 30-32
11 Obtain the time response from state model of a system. 33-36
12 Implementation of PI, PD Controllers. 37-41
13 Implement a PID Controller and hence realize an Error Detector. 42-45
Demonstrate the effect of PI, PD and PID controller on the system 46-50
14
response.
Control Systems Lab (IPCC) BEC403
EXPERIMENT NO 1
Aim: To implement the block diagram reduction technique in order to obtain the transfer
function of a control system using Matlab.
Theory: A block diagram is a graphical representation of a control system, illustrating the flow
of signals and the relationships between system components. Block diagram reduction involves
simplifying a complex system into a single transfer function, which represents the relationship
between the input and output.
Program:
% Define transfer function G1(s)
numerator_G1 = [1];
denominator_G1 = [1, 2];
G1 = tf(numerator_G1, denominator_G1);
% Define transfer function G2(s)
numerator_G2 = [1];
Result:
Transfer Function of the System after Block Diagram Reduction:
tf with properties:
Numerator: {[0 0 0 1 4 3]}
Denominator: {[1 11 45 87 86 40]}
Viva Questions:
4. What is the formula for the equivalent transfer function of a feedback loop?
EXPERIMENT NO 2
IMPLEMENT SIGNAL FLOW GRAPH TO OBTAIN TRANSFER
FUNCTION A CONTROL SYSTEM.
Aim: To implement a signal flow graph (SFG) in order to obtain the transfer
function of a control system using MATLab
Program:
% Define the Signal Flow Graph (SFG) represented as an adjacency
matrix
sfg = [
1, 2, 1; % Node 1 to Node 2 with gain 1
2, 3, 1; % Node 2 to Node 3 with gain 1
3, 4, 1; % Node 3 to Node 4 with gain 1
4, 2, -1; % Node 4 to Node 2 with gain -1 (negative feedback)
];
% Create the transfer function from the SFG
[numerator, denominator] = sfg2tf(sfg);
% Display the transfer function
sys_tf = tf(numerator, denominator);
disp('Transfer Function of the System:');
disp(sys_tf);
Result:
EXPERIMENT NO 3
Aim: To simulate and analyze the poles and zeros of a given transfer
function using MATLab.
EXPERIMENT NO 4
Program:
e1=0.2;
wn=5;
n1=[wn^2];
d1=[1 2*e1*wn wn^2];
c1=tf(n1,d1);
t=0:0.01:5;
subplot(2,2,1);
step(c1,t);
grid;
e2=0.5;
wn=5;
n2=[wn^2];
d2=[1 2*e2*wn wn^2];
c2=tf(n2,d2);
t=0:0.01:5;
subplot(2,2,2);
step(c2,t);
grid;
e3=0.7;
wn=5;
n3=[wn^2];
d3=[1 2*e3*wn wn^2];
c3=tf(n3,d3);
t=0:0.01:5;
subplot(2,2,3);
step(c3,t);
grid;
e4=0.9;
wn=5;
n4=[wn^2];
d4=[1 2*e3*wn wn^2];
c4=tf(n4,d4);
t=0:0.01:5;
subplot(2,2,4);
step(c4,t);
grid;
figure(2)
step(c1,c2,c3,c4,'r--');
title('comparision of all the under damped responses');
legend({'e1=0.2','e2=0.5','e3=0.7','e4=0.9'});
legend('boxoff');
grid;
EXPERIMENT NO 5
EXPERIMENT NO 6
Result:
enter the value of time constant 5
enter the value of the constant 2
Result:
enter the value of time constant 5
enter the value of the constant 0.2
Program:
T1=input('enter the value of time constant T1:');
T2=input('enter the value of time constant T2:');
b=input('enter the value of the constant b:');
a=input('enter the value of the constant a:');
n1=[1 1/T1];
n2=[1 1/T2];
num=conv(n1,n2);
d1=[1 1/(b*T)];
d2=[1 1/(a*T)];
den=conv(d1,d2);
c=tf(num,den);
step(c);
bode(c);
xlabel('Time');
ylabel('Magnitude');
title('Frequency responce of Lead Lag Compensator');
Result:
enter the value of time constant T1:5
enter the value of time constant T2:5
enter the value of the constant b:2
enter the value of the constant a:0.5
EXPERIMENT NO 7
Program:
%%%Routh Hurwitz Automatically
clear
clc
close all
%%%%%%INPUT COEFFICIENTS OF CHARACTERISTIC POLYNOMIAL HERE%%%%%
%coeff = [1,-6,-7,-52];
%coeff = [1,2,1];
%coeff = [1,6,11,7,200];
%coeff = [1,10,31,1030]
syms K % - hey if you have the symbolic toolbox try this
%coeff = [1,18,77,K];
%or this
%coeff = [1,9,(K-10),2]
coeff=[1,9,8,K]
%%%%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
%Thanks Sumit Godara for pointing that out
%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
%%%Grab the first column
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
Result:
Unstable
EXPERIMENT NO 8
Result 1:
enter the value of Numerator1
enter the value of Denominator [1 8 36 8 0]
Result 2:
enter the value of Numerator1
enter the value of Denominator [1 2 3 8 2]
Result 3:
enter the value of Numerator1
enter the value of Denominator [1 2 8 12 20 16 16]
EXPERIMENT NO 9
Program:
num=input('enter the value of Numerator');
den=input('enter the value of Denominator');
sys=tf(num,den);
bode(sys);
[gm, pm, wpc, wgc]=margin(sys);
margin(sys);
if(wpc>wgc)
disp('system is stable')
else
disp('system is unstable')
end
Result 1:
enter the value of Numerator1
enter the value of Denominator [1 8 36 80 0]
system is stable
Result 2:
enter the value of Numerator1
enter the value of Denominator [1 2 3 8]
system is unstable
EXPERIMENT NO 10
Program:
num=input('enter the value of Numerator');
den=input('enter the value of Denominator');
sys=tf(num,den);
nyquist(sys);
Result 1:
enter the value of Numerator1
enter the value of Denominator [1 64 320 20 1]
system is stable
Result 2:
enter the value of Numerator1
enter the value of Denominator [1 2 8 12 20 16 16]
system is unstable
EXPERIMENT NO 11
Result :
EXPERIMENT NO 12
Program: PI CONTROLLERS
% Define system parameters
setpoint = 10; % Setpoint
Kp = 1; % Proportional gain
Ki = 0.1; % Integral gain
dt = 0.1; % Time step
t_end = 20; % Simulation end time
initial_value = 0; % Initial value of the system
% Initialize variables
time = 0:dt:t_end;
error = zeros(size(time));
output = zeros(size(time));
integral = 0;
% Simulate system with PI control
for i = 1:length(time)
% Calculate error
error(i) = setpoint - output(i);
% Calculate proportional term
P = Kp * error(i);
% Calculate integral term
integral = integral + error(i) * dt;
I = Ki * integral;
% Calculate control signal
control_signal = P + I;
% Update system output (for simplicity, assume a first-order system)
output(i+1) = output(i) + dt * (control_signal - output(i));
end
% Plot results
figure;
subplot(1,1,1);
plot(time, output(1:end-1), 'b', 'LineWidth', 1.5);
hold on;
plot(time, setpoint*ones(size(time)), 'r--', 'LineWidth', 1.5);
xlabel('Time');
ylabel('Output');
legend('Output', 'Setpoint');
title('System Response with PI Control');
Result:
Program:
PD CONTROLLERS
% Define system parameters
setpoint = 10; % Setpoint
Kp = 1; % Proportional gain
Kd = 0.1; % Derivative gain
dt = 0.1; % Time step
t_end = 20; % Simulation end time
initial_value = 0; % Initial value of the system
% Initialize variables
time = 0:dt:t_end;
error = zeros(size(time));
output = zeros(size(time));
prev_error = 0;
% Simulate system with PD control
for i = 1:length(time)
% Calculate error
error(i) = setpoint - output(i);
% Calculate proportional term
P = Kp * error(i);
% Calculate derivative term
D = Kd * (error(i) - prev_error) / dt;
% Calculate control signal
control_signal = P + D;
% Update system output (for simplicity, assume a first-order system)
output(i+1) = output(i) + dt * (control_signal - output(i));
% Update previous error
prev_error = error(i);
end
% Plot results
figure;
subplot(1,1,1);
plot(time, output(1:end-1), 'b', 'LineWidth', 1.5);
hold on;
plot(time, setpoint*ones(size(time)), 'r--', 'LineWidth', 1.5);
xlabel('Time');
ylabel('Output');
legend('Output', 'Setpoint');
title('System Response with PD Control');
EXPERIMENT NO 13
Program:
% Define system parameters
setpoint = 10; % Setpoint
Kp = 1; % Proportional gain
Ki = 0.1; % Integral gain
Kd = 0.01; % Derivative gain
dt = 0.1; % Time step
t_end = 20; % Simulation end time
initial_value = 0; % Initial value of the system
% Initialize variables
time = 0:dt:t_end;
error = zeros(size(time));
output = zeros(size(time));
integral = 0;
derivative = 0;
prev_error = 0;
% Simulate system with PID control
for i = 1:length(time)
% Calculate error
error(i) = setpoint - output(i);
% Calculate proportional term
P = Kp * error(i);
% Calculate integral term
integral = integral + error(i) * dt;
I = Ki * integral;
% Calculate derivative term
derivative = (error(i) - prev_error) / dt;
D = Kd * derivative;
% Calculate control signal
control_signal = P + I + D;
% Update system output (for simplicity, assume a first-order
system)
output(i+1) = output(i) + dt * (control_signal - output(i));
% Update previous error
prev_error = error(i);
end
% Plot results
figure;
subplot(2,1,1);
plot(time, output(1:end-1), 'b', 'LineWidth', 1.5);
hold on;
plot(time, setpoint*ones(size(time)), 'r--', 'LineWidth', 1.5);
xlabel('Time');
ylabel('Output');
legend('Output', 'Setpoint');
title('System Response with PID Control');
subplot(2,1,2);
plot(time, error, 'g', 'LineWidth', 1.5);
xlabel('Time');
ylabel('Error');
title('Error Signal');
% Error detection
acceptable_error = 0.3; % Define acceptable error threshold
if max(abs(error)) <= acceptable_error
disp('System is within acceptable error bounds.');
else
disp('Error detected: System is outside acceptable error bounds.');
end
Result:
Error detected: System is outside acceptable error bounds.
EXPERIMENT NO 14
Program:
n=[1];
d=[1 10 20];
%PD Controller
kp=500;
kd=10;
C=pid(kp,0,kd);
P=tf(n,d);
T1=feedback(C*P,1);
t=0:0.01:2;
subplot(3,1,1);
step(T1,t);
grid;
%PI Controller
kp=30;
ki=70;
C=pid(kp,ki);
P=tf(n,d);
T2=feedback(C*P,1);
t=0:0.01:2;
subplot(3,1,2);
step(T2,t);
grid;
%PID Controller
kp=500;
ki=400;
kd=50;
C=pid(kp,ki,kd);
P=tf(n,d);
T3=feedback(C*P,1);
t=0:0.01:2;
subplot(3,1,3);
step(T3,t);
grid;
figure(2)
step(k,T1,T2,T3,'r--');
title('comparision of all the responses');
legend({'pd_controller','pi_controller','pid_controller'});
legend('boxoff');
grid;
Program:
% Plot unit step response of given transfer function and find peak
overshoot, peak time, rise time and delay time using MATLAB.
% Transfer Function = 25/(s^2+6s+25)
clear all
clc
syms s t
n=[25]
d=[1 6 25]
sys = tf(n,d)
R=roots(d)
'RiseTimeLimits',[0.00,1.00])
25
d=
1 6 25
Transfer function:
25
--------------
s^2 + 6 s + 25
R=
-3.0000 + 4.0000i
-3.0000 - 4.0000i
S=
RiseTime: 0.5538
SettlingTime: 1.1886
SettlingMin: 0.9910
SettlingMax: 1.0948
Overshoot: 9.4778
Undershoot: 0
Peak: 1.0948
PeakTime: 0.7869
EXPERIMENT B
Program:
close all;
h1=tf([9],[1 6 9])
t=linspace(1,15); %STEP RESPONSE%
subplot(3,2,1);
step(h1); %IMPULSE RESPONSE%
subplot(3,2,2);
impulse(h1);
r=sin(t);
s=2*t;
q=5*(t.^2); %SINE RESPONSE%
subplot(3,2,3);
lsim(h1,r,t); %RAMP RESPONSE%
subplot(3,2,4);
lsim(h1,s,t); %PARABOLIC RESPONSE%
subplot(3,2,5);
lsim(h1,q,t);
Result:
h1 =
9
-------------
s^2 + 6 s + 9
Vision
"To become a recognized world class Women Educational Institution, by imparting
professional education to the students, creating technical opportunities through
academic excellence and technical achievements, with ethical values"
Mission
• To support value based education with state of art infrastructure.
• To empower women with the additional skill for professional future carrier
• To enrich students with research blends in order to fulfill the International
challenges
• To create multidisciplinary center of excellence
• To achieve Accreditation standards towards intentional education recognition.
• To establish more Post Graduate & Research course.
• To increase Doctorates numbers towards the Research quality of academics.