0% found this document useful (0 votes)
87 views

Control System Lab Manual

Uploaded by

vanizeh54
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views

Control System Lab Manual

Uploaded by

vanizeh54
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

GURU NANAK DEV ENGINEERING COLLEGE, BIDAR

(ISO Certified Institute ISO 9001/2015)

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

Control Systems (IPCC)


(BEC403)
B.E –IV Semester

Name :

USN :

Batch : Section :

1
VISION OF THE INSTITUTE

To be a premier technological institution that fosters humanity, ethics and


excellence in education and research towards inspiring and developing future
torch bearers.

MISSION OF THE INSTITUTE

M1 To impart quality educational experience and technical skills to students


that enables them to become leaders in their chosen professions.

M2 To nurture scientific temperament and promote research and


development activities.

M3 To inculcate students with an ethical and human values so as to have big


picture of societal development in their future career.

M4 To provide service to industries and communities through educational,


technical, and professional activities.

VISION OF THE DEPARTMENT

To be a premier department known for quality education and research in the field of
Electronics and Communication Engineering for the benefit of mankind.

MISSION OF THE DEPARTMENT

M1 To provide State-of-art education and skills in the field of Electronics and


Communication Engineering
M2 To promote research culture and life-long learning to meet the challenges
of rapid technological change in their chosen professional field.
M3 To provide service to the society through engineering solutions.

2
Program Outcomes as defined by NBA (PO) Engineering Graduates will be
able to:

1. Engineering knowledge: Apply the knowledge of mathematics, science,


engineering fundamentals, and an engineering specialization to the solution of
complex engineering problems.

2. Problem analysis: Identify, formulate, review research literature, and analyze


complex engineering problems reaching substantiated conclusions using first
principles of mathematics, natural sciences, and engineering sciences.

3. Design/development of solutions: Design solutions for complex engineering


problems and design system components or processes that meet the specified
needs with appropriate consideration for the public health and safety, and the
cultural, societal, and environmental considerations.

4. Conduct investigations of complex problems: Use research-based


knowledge and research methods including design of experiments, analysis and
interpretation of data, and synthesis of the information to provide valid
conclusions.

5. Modern tool usage: Create, select, and apply appropriate techniques,


resources, and modern engineering and IT tools including prediction and
modeling to complex engineering activities with an understanding of the
limitations.

6. The engineer and society: Apply reasoning informed by the contextual


knowledge to assess societal, health, safety, legal and cultural issues and the
consequent responsibilities relevant to the professional engineering practice.

7. Environment and sustainability: Understand the impact of the professional


engineering solutions in societal and environmental contexts, and demonstrate
the knowledge of, and need for sustainable development.

8. Ethics: Apply ethical principles and commit to professional ethics and


responsibilities and norms of the engineering practice.
3
9. Individual and team work: Function effectively as an individual, and as a
member or leader in diverse teams, and in multidisciplinary settings.

10. Communication: Communicate effectively on complex engineering


activities with the engineering community and with society at large, such as,
being able to comprehend and write effective reports and design documentation,
make effective presentations, and give and receive clear instructions.

11. Project management and finance: Demonstrate knowledge and


understanding of the engineering and management principles and apply these to
one’s own work, as a member and leader in a team, to manage projects and in
multidisciplinary environments.

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

PROGRAM EDUCATIONAL OBJECTIVES

PEO Statements

PEO1 Apply fundamentals and skills needed for a successful professional


Electronics & Communication Engineer and to pursue higher studies

PEO2 Adapt latest technologies needed for addressing real world problems.

PEO3 Embed self-learning abilities, humanitarian and ethical values for a


successful professional career.
PROGRAM SPECIFIC OUTCOMES

PSOs Statements
To analyze, design and develop various types of integrated
PSO 1
electronics systems.

PSO 2 To apply their knowledge and skills to develop an application in


communication systems

4
INDEX

Laboratory Experiments:

S.No Name of the Experiment Page.No


Write Mat Lab code for
1. Implement Block diagram reduction 9-11
technique to obtain transfer function a
control system
2. Implement Signal Flow graph to obtain 12-13
transfer function a control system.
3. Simulation of poles and zeros of a 14-15
transfer function
4. Implement time response specification 16-18
of a second order Under damped
System, for different damping factors
5. Implement frequency response of a 19-20

second order System


6. Implement frequency response of a 21-23
lead lag compensator
7. Analyze the stability of the given 24-25
system using Routh stability criterion.
8. Analyze the stability of the given 26-28
system using Root locus
9. Analyze the stability of the given 29-30
system using Bode plots.
10. Analyze the stability of the given 31-32
system using Nyquist plot
11. Obtain the time response from state 33-34
model of a system
12 Implement PI and PD Controllers. 35-37
Implement a PID Controller and hence
realize an Error D

5
‘Safety precautions / Do’s and Dont’s’

O Leave your footwear outside.

O Be present in the lab on time.

O Maintain silence and discipline in the lab.

O Maintain a separate observation note book for the lab experiments.

O Come prepared for a minimum of a next one set of program and


execute them.

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 (MATrix LABoratory):


MATLAB is a software package for high-performance language for technical
computing. It integrates computation, visualization, and programming in an easy-
to-use environment where problems and solutions are expressed in familiar
mathematical notation. Typical uses include the following

Math and computation



Algorithm development

• Data acquisition

Modeling, simulation, and prototyping

Data analysis, exploration, and visualization

Scientific and engineering graphics

Application development, including graphical user interface building

The name MATLAB stands for matrix laboratory. MATLAB was


originally written to provide easy access to matrix software developed by the
LINPACK and EISPACK projects. Today, MATLAB engines incorporate the
LAPACK and BLAS libraries, embedding the state of the art in software for
matrix computation.

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.

The main features of MATLAB

1. Advance algorithm for high performance numerical computation


,especially in the Field matrix algebra

2. A large collection of predefined mathematical functions and the ability


to define one’s own functions.

3. Two-and three dimensional graphics for plotting and displaying data

4. A complete online help system

5. Powerful, matrix or vector oriented high level programming language


for individual applications.

6. Toolboxes available for solving advanced problems in several


application areas

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

% Perform block diagram reduction


H1 = feedback(series(G1,G2),1) % Connect G1 and G2 in series and
perform feedback
H2 = series(H1,G3) % Connect the result of H1 with G3 in series

% Display the transfer function of the reduced block diagram


disp('Transfer function after reduction:');
disp(H2);

% Plot the step response of the reduced system


figure;
step(H2);
title('Step Response of the Reduced System');

9
RESULT:
Transfer function:
1
-------------
s^2 + 5 s + 7

Transfer function:
1
----------------------
s^3 + 6 s^2 + 12 s + 7

Transfer function after reduction:


tf object: 1-by-1

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

% Define the signal flow graph


A = [0 1 0; 0 0 1; -1 -2 -3]; % Coefficients of the signal flow graph
B = [1; 0; 0]; % Input vector
C = [0 0 1]; % Output vector

% Calculate the transfer function using Mason's gain formula


[num,den] = ss2tf(A,B,C,0); % Convert state-space to transfer
function

% Display the transfer function


G = tf(num, den);
disp('Transfer Function:');
disp(G);

12
RESULT:
num = 0 0 -1.0000 0.0000

den = 1.0000 3.0000 2.0000 1.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

% Extract poles and zeros


p = pole(H); % Poles
z = zero(H); % Zeros

% Plot poles and zeros


figure;
subplot(1,2,1);
plot(real(p), imag(p), 'rx', 'MarkerSize', 10); % Plot poles
title('Poles');
xlabel('Real');
ylabel('Imaginary');
grid on;

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

% Compute time response for each damping factor


for i = 1:length(zeta_values)
zeta = zeta_values(i);
sys = tf(omega_n^2, [1, 2*zeta*omega_n, omega_n^2]); %
Transfer function

% 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)

% Compute frequency response


H = omega_n^2 ./ (omega.^2 - 2*zeta*omega_n*1i*omega +
omega_n^2); % Transfer function

% Plot frequency response


figure;
subplot(2,1,1);
semilogx(omega, 20*log10(abs(H)), 'LineWidth', 1.5);
title('Magnitude Response');
xlabel('Frequency (rad/s)');
ylabel('Magnitude (dB)');
grid on;
subplot(2,1,2);
semilogx(omega, angle(H)*180/pi, 'LineWidth', 1.5);
title('Phase Response');
xlabel('Frequency (rad/s)');
ylabel('Phase (degrees)');
grid on;
19
Magnitude Response
0

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)

% Compute lead-lag compensator transfer function


num_lead = [1 alpha*omega_c];
den_lead = [1 omega_c];
G_lead = tf(num_lead, den_lead);

num_lag = [1 omega_c];
den_lag = [1 alpha*omega_c];
G_lag = tf(num_lag, den_lag);

G_compensator = G_lead * G_lag;

% Compute frequency response


[magnitude, phase] = bode(G_compensator, omega);

% Plot frequency response


figure;
subplot(2,1,1);
semilogx(omega, 20*log10(squeeze(magnitude)), 'LineWidth', 1.5);
21
title('Magnitude Response');

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];

% Check if all coefficients are non-negative


if any(coefficients < 0)
error('All coefficients of the characteristic equation must be non-
negative for Routh criterion.');
end
% Length of the coefficients
n = length(coefficients);
% Create the Routh array
routh_array = zeros(n, ceil(n/2));
% Fill the first two rows of the Routh array
routh_array(1, :) = coefficients(1:2:end);
routh_array(2, 1:length(routh_array(1, 1:floor(n/2)))) =
coefficients(2:2:end);
% Compute the rest of the Routh array
for i = 3:n
for j = 1:ceil(n/2)-1
routh_array(i, j) = -1/(routh_array(i-1, 1)) * det([routh_array(i-1, 1)
routh_array(i-1, j+1); routh_array(i-2, 1) routh_array(i-2, j+1)]);
end
end
% Check for sign changes in the first column
sign_changes = 0;

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

% Define the range of gains (K) for root locus plot


K_range = linspace(0, 10, 1000);
% Compute and plot root locus
figure;
rlocus(G, K_range);
title('Root Locus Plot');
xlabel('Real');
ylabel('Imaginary');
grid on;
% 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 root locus
figure;
rlocus(G);
title('Root Locus Plot');
xlabel('Real Part');
ylabel('Imaginary Part');
grid on;

26
RESULT: Transfer function: 1
-------------
s^2 + 2 s + 5

Root Locus Plot


4
4
0.28 0.2 0.15 0.1 0.065 0.03 3.5
3
3 0.42
2.5
2
2
1.5
0.7
1
1
0.5
Imaginary

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

% Create a transfer function object


G = tf(numerator, denominator);

% Plot the Bode plot


figure;
bode(G);
title('Bode Plot');
grid on;

% Calculate gain and phase margins


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

% Display gain and phase margins


disp(['Gain Margin (dB): ', num2str(Gm)]);
disp(['Phase Margin (degrees): ', num2str(Pm)]);
disp(['Crossover frequency for Gain Margin (rad/s): ',
num2str(Wcg)]);
disp(['Crossover frequency for Phase Margin (rad/s): ',
num2str(Wcp)]);

29
RESULT: Transfer function: 1
-------------
s^2 + 2 s + 5

Gain Margin (dB): Inf


Phase Margin (degrees): Inf
Crossover frequency for Gain Margin (rad/s): Inf
Crossover frequency for Phase Margin (rad/s): NaN

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

% Define the initial condition


x0 = [0; 0]; % Initial state

% Define the input signal (if any)


t = 0:0.01:5; % Time vector
u = ones(size(t)); % Step input signal

% Compute the time response using lsim


[y, t, x] = lsim(ss(A, B, C, D), u, t, x0);

% Plot the time response


figure;
subplot(2, 1, 1);
plot(t, y);
title('Output Response');
xlabel('Time');
ylabel('Output');
grid on;

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));

% Update previous error


e_prev = e;
end

% Plot results for PD controller


subplot(2,1,2);
plot(t, r, 'r--', t, y);
title('PD Controller');
xlabel('Time');
ylabel('Output');
legend('Reference', 'Output');
grid on;

37

You might also like