Control System Lab Manual
Control System Lab Manual
Name :
USN :
Batch : Section :
1
VISION OF THE INSTITUTE
To be a premier department known for quality education and research in the field of
Electronics and Communication Engineering for the benefit of mankind.
2
Program Outcomes as defined by NBA (PO) Engineering Graduates will be
able to:
12. Life-long learning: Recognize the need for, and have the preparation and
ability to engage in independent and life-long learning in the broadest context of
technological change
PEO Statements
PEO2 Adapt latest technologies needed for addressing real world problems.
PSOs Statements
To analyze, design and develop various types of integrated
PSO 1
electronics systems.
4
INDEX
Laboratory Experiments:
5
‘Safety precautions / Do’s and Dont’s’
O After executing the program show the result to the concerned staff.
O Before leaving the lab properly shut down the computer system .
O Write the executed program in the file and bring it in the next class.
6
INTRODUCTION TO MATLAB
MATLAB has evolved over a period of years with input from many users.
In university environments, it is the standard instructional tool for introductory
and advanced courses in mathematics, engineering, and science. In industry,
MATLAB is the tool of choice for high-productivity research, development, and
analysis.MATLAB features a family of add-on application-specific solutions
called toolboxes. Very important to most users of MATLAB, toolboxes allow
learning and applying specialized technology. Toolboxes are comprehensive
7
collections of MATLAB functions (M-files) that extend the MATLAB
environment to solve particular classes of problems. Areas in which toolboxes
are available include Image processing, signal processing, control systems, neural
networks, fuzzy logic, wavelets, simulation, and many others.
8
Exp1: Implement Block diagram reduction technique to obtain
transfer function a control system.
% Define the transfer functions of the blocks in the block diagram
G1 = tf([1],[1 2]); % Transfer function of the first block
G2 = tf([1],[1 3]); % Transfer function of the second block
G3 = tf([1],[1 1]); % Transfer function of the third block
9
RESULT:
Transfer function:
1
-------------
s^2 + 5 s + 7
Transfer function:
1
----------------------
s^3 + 6 s^2 + 12 s + 7
10
Step Response of the Reduced System
0.16
0.14
0.12
0.1
Amplitude
0.08
0.06
0.04
0.02
0
0 1 2 3 4 5 6
Time (sec)
11
exp2: 2 Implement Signal Flow graph to obtain transfer function
a control system
% Define the transfer function of each block in the system
G1 = tf([1],[1 2]); % Example transfer function for the first block
G2 = tf([1],[1 3]); % Example transfer function for the second block
G3 = tf([1],[1 1]); % Example transfer function for the third block
12
RESULT:
num = 0 0 -1.0000 0.0000
Transfer function:
-s + 6.661e-016
---------------------
s^3 + 3 s^2 + 2 s + 1
Transfer Function:
tf object: 1-by-1
13
exp3: Simulation of poles and zeros of a transfer function.
% Define the transfer function
num = [1]; % Numerator coefficients
den = [1 2 1]; % Denominator coefficients
H = tf(num, den); % Transfer function
subplot(1,2,2);
plot(real(z), imag(z), 'bo', 'MarkerSize', 10); % Plot zeros
title('Zeros');
xlabel('Real');
ylabel('Imaginary');
grid on;
14
RESULT
num = 1
den =1 2 1
Transfer function: 1
-------------
s^2 + 2 s + 1
p = -1
-1
z = Empty matrix: 0-by-1
Poles Zeros
1 1
0.8 0.9
0.6 0.8
0.4 0.7
0.2 0.6
Imaginary
Imaginary
0 0.5
-0.2 0.4
-0.4 0.3
-0.6 0.2
-0.8 0.1
-1 0
-2 -1.5 -1 -0.5 0 0 0.5 1
Real Real
15
exp4: Implement time response specification of a second order
Under damped System, for different damping factors.
% Time specifications
t_start = 0; % Start time
t_end = 10; % End time
dt = 0.01; % Time step
% System parameters
omega_n = 5; % Natural frequency
zeta_values = [0.1, 0.2, 0.5, 0.7]; % Different damping factors
% Step response
[y, t] = step(sys, t_end);
% Plot time response
subplot(length(zeta_values), 1, i);
plot(t, y, 'LineWidth', 1.5);
title(['Underdamped System, \zeta = ', num2str(zeta)]);
xlabel('Time (s)');
ylabel('Response');
grid on;
end
16
RESULT
Transfer function:
25
------------
s^2 + s + 25
Transfer function:
25
--------------
s^2 + 2 s + 25
Transfer function:
25
--------------
s^2 + 5 s + 25
Transfer function:
25
--------------
s^2 + 7 s + 25
17
Underdamped System, = 0.1
Response
2
1
0
0 1 2 3 4 5 6 7 8 9 10
Time (s)
Underdamped System, = 0.2
Response
2
1
0
0 1 2 3 4 5 6 7 8 9 10
Time (s)
Underdamped System, = 0.5
Response
2
1
0
0 1 2 3 4 5 6 7 8 9 10
Time (s)
Underdamped System, = 0.7
Response
2
1
0
0 1 2 3 4 5 6 7 8 9 10
Time (s)
18
exp5 : 5 Implement frequency response of a second order System
% System parameters
omega_n = 5; % Natural frequency
zeta = 0.7; % Damping ratio
% Frequency range
omega = logspace(-1, 2, 1000); % Frequency range from 0.1 to 100
(log scale)
Magnitude (dB)
-20
-40
-60
-1 0 1 2
10 10 10 10
Frequency (rad/s)
Phase Response
40
Phase (degrees)
30
20
10
0
-1 0 1 2
10 10 10 10
Frequency (rad/s)
20
exp6: Implement frequency response of a lead lag compensator.
% Lead-lag compensator parameters
omega_c = 10; % Crossover frequency
alpha = 0.1; % Lead-lag ratio
% Frequency range
omega = logspace(-2, 2, 1000); % Frequency range from 0.01 to 100
(log scale)
num_lag = [1 omega_c];
den_lag = [1 alpha*omega_c];
G_lag = tf(num_lag, den_lag);
xlabel('Frequency (rad/s)');
ylabel('Magnitude (dB)');
grid on;
subplot(2,1,2);
semilogx(omega, squeeze(phase), 'LineWidth', 1.5);
title('Phase Response');
xlabel('Frequency (rad/s)');
ylabel('Phase (degrees)');
grid on;
RESULT: Transfer function: s^2 + 11 s + 10
---------------
s^2 + 11 s + 10
22
Magnitude Response
1
Magnitude (dB)
0.5
-0.5
-1
-2 -1 0 1 2
10 10 10 10 10
Frequency (rad/s)
-15
x 10 Phase Response
5
Phase (degrees)
-5
-2 -1 0 1 2
10 10 10 10 10
Frequency (rad/s)
23
exp7: Analyze the stability of the given system using Routh
stability criterion
% Define the coefficients of the characteristic equation
coefficients = [1, 3, 4, 2];
24
for i = 1:n-1
if (routh_array(i, 1) * routh_array(i+1, 1)) < 0
sign_changes = sign_changes + 1;
end
end
% Display the results
if sign_changes == 0
disp('The system is stable (No sign changes in the first column).');
elseif sign_changes> 0
disp('The system is unstable (Sign changes in the first column).');
end
% Display Routh array
disp('Routh Array:');
disp(routh_array);
RESULT:
The system is unstable (Sign changes in the first column).
Routh Array:
1.0000 4.0000
3.0000 2.0000
-3.3333 0
-2.0000 0
25
exp8: Analyze the stability of the given system using Root locus
% Define the transfer function or system in state-space representation
% Example: G = tf([1], [1, 2, 1]); % Transfer function
% Example: sys = ss(A, B, C, D); % State-space representation
26
RESULT: Transfer function: 1
-------------
s^2 + 2 s + 5
0.5
-1
1
0.7
1.5
-2
2
2.5
-3 0.42
3
0.28 0.2 0.15 0.1 0.065 0.03 3.5
-4
-1.4 -1.2 -1 -0.8 -0.6 -0.4 -0.2 40
Real
27
Root Locus Plot
5
5
0.23 0.16 0.115 0.08 0.05 0.025
4
4
0.36
3
3
2
2 0.6
1
1
Imaginary Part
-1
1
-2 0.6
2
-3
3
0.36
-4
4
0.23 0.16 0.115 0.08 0.05 0.025
-5
-1.4 -1.2 -1 -0.8 -0.6 -0.4 -0.2 50
Real Part
28
exp9: Analyze the stability of the given system using Bode plots
% Define the transfer function of the system
numerator = [1]; % Numerator coefficients
denominator = [1, 2, 5]; % Denominator coefficients
29
RESULT: Transfer function: 1
-------------
s^2 + 2 s + 5
Bode Plot
0
-20
Magnitude (dB)
-40
-60
-80
0
-45
Phase (deg)
-90
-135
-180
-1 0 1 2
10 10 10 10
Frequency (rad/sec)
30
exp10: Analyze the stability of the given system using Nyquist plot
% Define the transfer function of the system
numerator = [1]; % Numerator coefficients
denominator = [1, 2, 5]; % Denominator coefficients
% Create a transfer function object
G = tf(numerator, denominator);
% Plot the Nyquist plot
figure;
nyquist(G);
title('Nyquist Plot');
grid on;
% Calculate and display the number of encirclements of the point -
1+j0
[re,im] = nyquist(G);
encirclements = 0;
for i=1:length(re)
if re(i) < 0 &&im(i) == 0
encirclements = encirclements + 1;
end
end
disp(['Number of encirclements of the point -1+j0: ',
num2str(encirclements)]);
31
RESULT: Number of encirclements of the point -1+j0: 0
Nyquist Plot
1
2 dB 0 dB -2 dB -4 dB
4 dB
0.8
-6 dB
0.6 6 dB
0.4 10 dB -10 dB
0.2
Imaginary Axis
20 dB -20 dB
-0.2
-0.4
-0.6
-0.8
-1
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4
Real Axis
32
exp11: Obtain the time response from state model of a system
% Define the state-space representation of the system
A = [1, 1; -2, 0]; % System matrix
B = [0; 1]; % Input matrix
C = [1, 0]; % Output matrix
D = 0; % Feedthrough matrix
33
subplot(2, 1, 2);
plot(t, x);
title('State Response');
xlabel('Time');
ylabel('State');
legend('x1', 'x2');
grid on;
RESULT:
Output Response
5
Output
-5
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Time
State Response
10
x1
x2
5
State
-5
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Time
34
exp12: Implement PI and PD Controllers. 13 Implement a PID
Controller and hence realize an Error D
% System parameters
Kp = 1; % Proportional gain
Ki = 0.5; % Integral gain (for PI controller)
Kd = 0.2; % Derivative gain (for PD controller)
% Time parameters
dt = 0.01; % Time step
t_final = 10; % Final simulation time
% Define the transfer function of the plant
numerator = [1]; % Numerator coefficients
denominator = [1, 2, 1]; % Denominator coefficients
plant = tf(numerator, denominator);
% Time vector
t = 0:dt:t_final;
% Reference signal (desired setpoint)
r = 1 + zeros(size(t)); % Step reference
% Initialize variables
e_prev = 0; % Previous error (for derivative term)
integral = 0; % Integral term (for PI controller)
% Output vector
y = zeros(size(t));
% Closed-loop control using PI controller
for i = 2:numel(t)
% Error computation
e = r(i) - y(i-1);
35
% Integral term (for PI controller)
integral = integral + e * dt;
% PID control law
u = Kp * e + Ki * integral;
% Simulate plant
[y(i), ~] = lsim(plant, u, t(i-1:i));
end
% Plot results for PI controller
figure;
subplot(2,1,1);
plot(t, r, 'r--', t, y);
title('PI Controller');
xlabel('Time');
ylabel('Output');
legend('Reference', 'Output');
grid on;
% Reset variables for PD controller
integral = 0; % Reset integral term
e_prev = 0; % Reset previous error
% Output vector for PD controller
y = zeros(size(t));
% Closed-loop control using PD controller
for i = 2:numel(t)
% Error computation
e = r(i) - y(i-1);
% Derivative term (for PD controller)
36
derivative = (e - e_prev) / dt;
% PD control law
u = Kp * e + Kd * derivative;
% Simulate plant
[y(i), ~] = lsim(plant, u, t(i-1:i));
37