CS Lab Manual

Download as pdf or txt
Download as pdf or txt
You are on page 1of 81

LAB-MANUAL

V SEMESTER

5EE4-22
Control System Lab

DEPARTMENT OF ELECTRICAL ENGINEERING

Arya College of Engineering


Main Campus, SP-40, RIICO Industrial Area
Delhi Road, Kukas, Jaipur – 302028
www.aryacollegejpr.com
Department of Electrical Engineering
PROGRAM EDUCATION OBJECTIVE (PEO)

I. Preparation: To prepare undergraduate students with appropriate blend of


theoretical foundations, experimentation & technical implementation to
comprehend and pinpoint problems in the field of electrical Engineering to
excel in postgraduate programs or to succeed in industry / technical profession.
II. Core competence: To provide students with a solid foundation in
mathematical, scientific and engineering fundamentals required to solve
electrical engineering problems and also to pursue higher studies. Student will
be able to employ his knowledge along with necessary techniques & tools for
modern engineering applications.
III. Breadth: To train students with good scientific and electrical engineering
breadth so as to comprehend, analyze, design, and create novel products and
solutions for the real-life problems in the present electrical system.
IV. Professionalism: To inculcate in students professional and ethical attitude,
Communication Skills, teamwork Skills, computer programming skill and an
ability to relate electrical engineering issues to broader social context.
V. Learning Environment: To provide student with an academic environment
aware of excellence, leadership, and the life-long learning needed for a
successful professional career through independent studies, thesis, internships
etc.
PROGRAM OUTCOMES (POs)
PO-1 Engineering Knowledge: Apply knowledge of mathematics and science,
with fundamentals of Engineering to be able to solve complex engineering
problems related.
PO-2 Problem Analysis: Identify, Formulate, review research literature and
analyze complex engineering problems and reaching substantiated conclusions
using first principles of mathematics, natural sciences and engineering sciences
PO-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.
PO-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.
PO-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.
PO-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.
PO-7 Environment and Sustainability: Understand the impact of the
professional engineering solutions in societal and environmental contexts
sustainable development.
PO-8 Ethics: Apply Ethical Principles and commit to professional ethics and
responsibilities and norms of the engineering practice
PO-9 Individual and Team Work:
Function effectively as an individual and as a member or leader in diverse teams
and in multidisciplinary Settings
PO-10 Communication: Communicate effectively on complex engineering
activities with the engineering community and with society at large such write
effective reports and design documentation, make effective presentations and
give and receive clear instructions.
PO-11 Project Management and Finance: Demonstrate knowledge and
understanding of the engineering management principles and apply these to
one’s own work, as a member and leader in a team, to manage projects and in
multi-disciplinary environments.
PO-12 Life-Long Learning: Recognize the need for and have the preparation
and ability to engage in independent and life-long learning the broadest context
of technological change.
Department of Electrical Engineering

PROGRAM SPECIFIC OUTCOME (PSO)

PSO-1 Ability to utilize logical and technical skills to model, simulate and
analyse electrical components and systems.
PSO-2 Empowering to provide socially acceptable technical solutions to real
time electrical engineering problems with the application of modern and
appropriate techniques for sustainable development.
Department of Electrical Engineering
Control System Lab
Course Outcomes (COs):

• CO1: Simulate, and analyze system behaviour using software

simulator/hardware.

• CO2: Design compensators, filters, and controllers to meet the desired

performance of the system.

• CO3: Design, and analysis of Ist and 2nd order Electrical circuits.

MAPPING OF COURSE OUTCOME WITH PROGRAM OUTCOMES AND PSO

COURSE PROGRAM OUTCOME PSO


OBJECTIV PO PO PO PO PO PO PO PO PO PO PO PO
PSO PSO
E -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12
-1 -2

I 3 3 3 3 2 - - 2 3 3 - 2 - -

II 3 3 3 3 2 - - 2 3 3 - 2 - -

III 3 3 3 3 2 - - 2 3 3 - 2 - -

Average 3 3 3 3 2 - - 2 3 3 - 2 - -

• Note: Correlation levels 1, 2 or 3 as defined below:


• 1: Slight (Low) 2: Moderate (Medium) 3: Substantial (High)
DO’S AND DON’T’S

DO’S
• Maintain strict discipline in the Lab.
• Lab-apparatus must be handled properly.
• Before switching on the power supply, get it be checked by the faculty.
• Switch off the mobile.
• Be a keen observer while performing the experiment.

DON’TS
• Do not touch or attempt to touch the mains power points directly with bare hands.
• Do not manipulate the experiment results.
• Do not overcrowd the experiment tables.
• Do not tamper the equipment.
• Do not leave the lab without prior permission from the faculty.
INSTRUCTIONS TO THE STUDENTS
GENERAL INSTRUCTIONS
• Maintain separate observation copy for each laboratory and carry it regularly.
• Observations or readings should be taken only in the observation copy.
• Measured readings must be signed by the faculty after the completion of the experiment.
• Maintain Index column in the observation copy and get the signature of the faculty before
leaving the lab.

BEFORE ENTERING THE LAB


• The previous experiment should have been written in the practical file, without which the
students will not be allowed to enter the lab.
• The students should have the details of the experiment in the observation copy that they
are supposed to perform in the lab.
• The experiment should have aim, apparatus required, circuit diagram/algorithm, blank
observation table (if any), formula (if any), calculation, program (if any), model graph (if
any) and space for result.

WHEN WORKING IN THE LAB


• Necessary equipment/apparatus should be taken only from the lab technician by making
an issuing slip, which would contain name of the experiment, names of batch members
and apparatus or components required.
• Never switch on the power supply before getting the permission from the faculty.

BEFORE LEAVING THE LAB


• The equipment/components should be returned back to the lab technician in good
condition after the completion of the experiment.
• The students should get the signature from the faculty in the observation copy.
• They should also check whether their file is checked and counter signed in the index.
5EE4-22: Control System Lab
List of Experiments

1) (a) Plot step response of a given TF and system in state-space. Take different values of
damping ratio and wn natural undamped frequency.
(b) Plot ramp response.
2) To design 1st order R-C circuits and observe its response with the following inputs and
trace the curve.
(a) Step
(b) Ramp
(c) Impulse
3) To design 2nd order electrical network and study its transient response for step input and
following cases.
(a) Under damped system
(b) Over damped System.
(c) Critically damped system.
4) To Study the frequency response of following compensating Networks, plot the graph
and final out corner frequencies.
(a) Leg Network
(b) Lead Network.
(c) Leg-lead Network.
5) Draw the bode plot in real time for a Non-Inverting amplifier.
6) Draw the bode plot in real time for an Inverting amplifier.
7) Draw the bode plot for second order transfer function.
8) Draw the bode plot for first order transfer function.
9) Design and analyse Tow- Thomas biquad filter.
10) Design and calculate Kp, Ki for PI controller.
11) Design PID controller and also calculate Kp, Ki, Kd for it.
Department of Electrical Engineering
Control System Lab
LAB ROTOR

DATE/EXP. No. 1 2 3 4 5 6 7 8 9 10 11 12

First Lab slot G1 G2 G3 G4 G5 G6


Second Lab slot G6 G1 G2 G3 G4 G5
Third Lab slot G5 G6 G1 G2 G3 G4
Forth Lab slot G4 G5 G6 G1 G2 G3
Fifth Lab slot G3 G4 G5 G6 G1 G2
Sixth Lab slot G2 G3 G4 G5 G6 G1
Seventh Lab slot G1 G2 G3 G4 G5 G6
Eighth Lab slot G6 G1 G2 G3 G4 G5
Ninth Lab slot G5 G6 G1 G2 G3 G4
Tenth Lab slot G4 G5 G6 G1 G2 G3
Eleventh Lab G3 G4 G5 G6 G1 G2
slot
Twelve Lab slot G2 G3 G4 G5 G6 G1
Experiment No. 1
OBJECT: (a) Plot step response of a given TF and system in state-space. Take
different values of damping ratio and wn natural undamped frequency.
(b) Plot ramp response.

THEORY

Step Response: This is the response of the system when subjected to a step input. A step
1
input in the Laplace domain is represented by 𝑠 The step response can be obtained by taking
1
the inverse Laplace transform of G(s)⋅ 𝑠

Fig.2 Step Response

Ramp Response: This is the response of the system when subjected to a ramp input. A ramp
1
input in the Laplace domain is represented by 𝑠2 The ramp response can be obtained by taking
1
the inverse Laplace transform of G(s)⋅
𝑠2
.
Fig.1 Ramp Response

PROGRAM: Step and Ramp Responses for second order transfer function.
clc
clear all
close all

% Define a set of different damping ratios and natural frequencies


zeta_values = [0.1, 0.5, 0.7, 1]; % Damping ratios (underdamped, critically damped)
wn_values = [1, 3, 5]; % Natural frequencies (rad/s)

% Define the time vector for simulation


t = 0:0.01:10; % Time from 0 to 10 seconds with 0.01s step size

% Loop through different combinations of damping ratios and natural frequencies


for i = 1:length(zeta_values)
for j = 1:length(wn_values)
% Define the damping ratio and natural frequency for this case
zeta = zeta_values(i);
wn = wn_values(j);

% Define the transfer function for the second-order system


num = wn^2; % Numerator: omega_n^2
den = [1 2*zeta*wn wn^2]; % Denominator: s^2 + 2*zeta*omega_n s + omega_n^2
sys = tf(num, den); % Create transfer function

% Plot the step response for this system


figure;
subplot(2,1,1); % Create subplot for step response
step(sys,t); % Step response plot
title(['Step Response (zeta = ', num2str(zeta), ', wn = ', num2str(wn), ')']);
xlabel('Time (seconds)');
ylabel('Amplitude');
grid on;
% Plot the Ramp response for this system

ramp_input = t; % Ramp input is the same as time (since ramp = t)


[y_ramp, t_ramp] = lsim(sys, ramp_input, t); % Simulate the system's response to the ramp input
subplot(2,1,2); % Create subplot for ramp response
plot(t_ramp, y_ramp);
title(['Ramp Response (zeta = ', num2str(zeta), ', wn = ', num2str(wn), ')']);
xlabel('Time (seconds)');
ylabel('Amplitude');
grid on;
end
end

OUTPUT: We will get total 12 graphs for different different values of zeta and wn, here only 4 shown.
PROGRAM 2: Step and Ramp Responses for state space system
clc
clear all
close all

% STate Space Model


% Define a set of different damping ratios and natural frequencies
zeta_values = [0.1, 0.5, 0.7, 1]; % Damping ratios
wn_values = [1, 3, 5]; % Natural frequencies (rad/s)

% Define the time vector for simulation


t = 0:0.01:10; % Time from 0 to 10 seconds with 0.01s step size

% Loop through different combinations of damping ratios and natural frequencies


for i = 1:length(zeta_values)
for j = 1:length(wn_values)
% Define the damping ratio and natural frequency for this case
zeta = zeta_values(i);
wn = wn_values(j);

% Define the state-space matrices for the second-order system


A = [0 1; -wn^2 -2*zeta*wn]; % State matrix
B = [0; 1]; % Input matrix
C = [wn^2 0]; % Output matrix
D = 0; % Feedthrough matrix

% Create state-space system


sys_ss = ss(A, B, C, D);

% Step Response
figure;
subplot(2,1,1); % Create subplot for step response
step(sys_ss, t); % Step response plot
title(['Step Response (zeta = ', num2str(zeta), ', wn = ', num2str(wn), ')']);
xlabel('Time (seconds)');
ylabel('Amplitude');
grid on;

% Ramp Response
ramp_input = t; % Ramp input is the same as time (since ramp = t)
[y_ramp, t_ramp] = lsim(sys_ss, ramp_input, t); % Simulate the system's response to the ramp input
subplot(2,1,2); % Create subplot for ramp response
plot(t_ramp, y_ramp);
title(['Ramp Response (zeta = ', num2str(zeta), ', wn = ', num2str(wn), ')']);
xlabel('Time (seconds)');
ylabel('Amplitude');
grid on;
end
end
OUTPUT: We will get total 12 graphs for different different values of zeta and wn, here only 2 shown.

Result: We succesfully plot the step response and ramp response of a given TF and system in state-space by
taking the different values of damping ratio and wn natural undamped frequency.
5EE4-22 CONTROL SYSTEM Lab
Practical No:-1
Objective:-
Object: (a) Plot step response of a TF & system in state space. (b) Plot
ramp response.

S.No. Viva Questions (to be answered in the Lab file)

1. Where we used Servomechanism in control system?

2. Define system and denote various type of system?

3. Explain control system?

4. What is step response in control system?

5. Explain ramp response with suitable diagram?

6. Why we use negative feedback in control system?

7. What is the effect of positive feedback system on stability?

8. Define damping ratio?

9. Define damping frequency?

10. What is state space model?


EXPERIMENT- 2
OBJECT: To design 1st order R-C circuits and observes its response with the
following inputs and traces the curve. (a) Step (b) Ramp (c) Impulse

THEORY:
Modeling First Order Systems in Simulink

The RC Circuit is schematically shown in Fig. 1 below.

The differential equation for this is as show in (1) below.

Where (ẋ) is the time rate of change of the output voltage, R and C being
constants, f(t) is the forcing function (Input voltage), and x is the output voltage.
We are now going to take this piece by piece. First, we examine what is in the
brackets and we notice that we are subtracting the term x from the term f (t).
MATLAB CODE:

clc
clear all
close all

% Define RC circuit parameters


R = 1e3; % Resistance (1 kOhm)
C = 1e-6; % Capacitance (1 µF)
tau = R * C; % Time constant

% Define the transfer function for the RC circuit


num = 1; % Numerator coefficients (constant term)
den = [R*C 1]; % Denominator coefficients (RCs + 1)
H = tf(num, den); % Transfer function

% Define the time vector for simulation


t = 0:0.01:0.1; % Time from 0 to 0.1 seconds with 0.01s step size

% Define the inputs


step_input = ones(size(t)); % Step input
ramp_input = t; % Ramp input
impulse_input = [1; zeros(length(t)-1, 1)]; % Impulse input

% Simulate responses
[step_output, t_step] = lsim(H, step_input, t); % Step response
[ramp_output, t_ramp] = lsim(H, ramp_input, t); % Ramp response
[impulse_output, t_impulse] = lsim(H, impulse_input, t); % Impulse response

% Plot the responses


figure;

% Step response
subplot(3,1,1);
plot(t_step, step_output, 'b', 'LineWidth', 1.5);
title('Step Response of First-Order RC Circuit');
xlabel('Time (seconds)');
ylabel('Output');
grid on;

% Ramp response
subplot(3,1,2);
plot(t_ramp, ramp_output, 'r', 'LineWidth', 1.5);
title('Ramp Response of First-Order RC Circuit');
xlabel('Time (seconds)');
ylabel('Output');
grid on;
% Impulse response
subplot(3,1,3);
plot(t_impulse, impulse_output, 'g', 'LineWidth', 1.5);
title('Impulse Response of First-Order RC Circuit');
xlabel('Time (seconds)');
ylabel('Output');
grid on;

OUTPUT:

Result: We Succesfully designed 1st order R-C circuits and observe its response with the step, ramp and
impulse inputs.
5EE4-22 CONTROL SYSTEM Lab

Practical No:-2
Objective:-
Object: To design 1st order RC circuit and observe its response and trace
the curve (a) Step (b) Ramp (c) Impulse.

S.No. Viva Questions (to be answered in the Lab file)

1. Define first order system?

2. What is the effect of step signal on 1st order system?

3. What is the effect of ramp signal on 1st order system?

4. What is the effect of impulse signal on 1st order system?

5. What is the function of integrator in MATLAB?

6. Define various advantage of open loop system?

7. Define various disadvantage of open loop system?

8. What is the function of scope in MATLAB?

9. What is the function of Gain Block in MATLAB?

10. What is MATLAB API in control system?


EXPERIMENT 3

OBJECT: For a given 2nd order system plot step response and obtain time response
specification for step input and following cases.

(a) Under damped system

(b) Over damped System.

(c) Critically damped system.

THEORY:

A second-order system is characterized by a differential equation of the form:

Depending on the value of the damping ratio ζ, the system can exhibit different types of
behavior:

1. Underdamped System (0<ζ<1)

An underdamped system is characterized by oscillatory behaviour with the oscillations


gradually dying out over time. The step response of an underdamped system shows
oscillations before it settles at its final value.

Time Response Specifications for Underdamped Systems:


• Rise Time (𝒕𝒓 ) The time taken for the response to rise from 0% to 100% of its final
value.
• Peak Time (𝒕𝒑 ) The time taken for the response to reach the first peak of the
overshoot.
• Overshoot (𝑴𝒑 ) The amount by which the response exceeds its final value, usually
expressed as a percentage.
• Settling Time (𝒕𝒔 ) The time taken for the response to remain within a certain
percentage (commonly 2% or 5%) of its final value.

2. Overdamped System (ζ>1)

An overdamped system does not exhibit oscillations and takes a longer time to reach its final
value compared to a critically damped system. The step response is slower and does not
overshoot.

Time Response Specifications for Overdamped Systems:

• Rise Time (𝒕𝒓 ): The time taken for the response to rise from 0% to 100% of its final
value.
• Settling Time (𝒕𝒔 ) The time taken for the response to remain within a certain
percentage of its final value.

3. Critically Damped System (ζ=1)

A critically damped system returns to equilibrium as quickly as possible without oscillating.


The step response reaches the final value quickly and without overshooting.

Time Response Specifications for Critically Damped Systems:

• Rise Time (𝒕𝒓 ) The time taken for the response to rise from 0% to 100% of its final
value.
• Settling Time (𝒕𝒔 ) The time taken for the response to remain within a certain
percentage of its final value.
PROGRAM:

To analyze a given second-order system and plot its step response for underdamped,
overdamped, and critically damped cases, we need to define the system parameters for each
damping condition and then simulate the responses.

A standard second-order system can be represented by the transfer function:

𝜔𝑛2
𝐺(𝑠) = 2
𝑠 + 2ζ𝜔𝑛 𝑠 + 𝜔𝑛2

where:

• 𝜔𝑛 is the natural frequency.


• ζ is the damping ratio.

MATLAB Script

Here is a MATLAB script to plot the step response for underdamped, overdamped, and
critically damped cases and obtain the time response specifications:

% MATLAB Script to analyze a 2nd order system

% Define the natural frequency


omega_n = 1; % Natural frequency (rad/s)

% Define damping ratios for different cases


zeta_underdamped = 0.5; % Underdamped system (0 < zeta < 1)
zeta_overdamped = 1.5; % Overdamped system (zeta > 1)
zeta_critical = 1; % Critically damped system (zeta = 1)

% Define transfer functions for each case


sys_underdamped = tf(omega_n^2, [1 2*zeta_underdamped*omega_n
omega_n^2]);
sys_overdamped = tf(omega_n^2, [1 2*zeta_overdamped*omega_n
omega_n^2]);
sys_critical = tf(omega_n^2, [1 2*zeta_critical*omega_n
omega_n^2]);

% Time vector for simulation


t = 0:0.01:10;

% Step responses
[y_underdamped, t_underdamped] = step(sys_underdamped, t);
[y_overdamped, t_overdamped] = step(sys_overdamped, t);
[y_critical, t_critical] = step(sys_critical, t);

% Plotting the step responses


figure;

% Underdamped system
subplot(3, 1, 1);
plot(t_underdamped, y_underdamped, 'b');
title('Step Response of Underdamped System');
xlabel('Time [s]');
ylabel('Amplitude');
grid on;

% Overdamped system
subplot(3, 1, 2);
plot(t_overdamped, y_overdamped, 'r');
title('Step Response of Overdamped System');
xlabel('Time [s]');
ylabel('Amplitude');
grid on;

% Critically damped system


subplot(3, 1, 3);
plot(t_critical, y_critical, 'g');
title('Step Response of Critically Damped System');
xlabel('Time [s]');
ylabel('Amplitude');
grid on;

% Obtain time response specifications


info_underdamped = stepinfo(sys_underdamped);
info_overdamped = stepinfo(sys_overdamped);
info_critical = stepinfo(sys_critical);

% Display time response specifications


disp('Time Response Specifications:');
disp('Underdamped System:');
disp(info_underdamped);

disp('Overdamped System:');
disp(info_overdamped);

disp('Critically Damped System:');


disp(info_critical);

Explanation:

1. Define Natural Frequency and Damping Ratios:

• ωn is set to 1 rad/s for simplicity.


• Different damping ratios (ζ) are defined for underdamped (0.5), overdamped (1.5),
and critically damped (1.0) cases.
2. Transfer Functions:

• Define the transfer functions for each damping condition using the tf function.

3. Simulate Step Responses:

• Use the step function to simulate the step responses of the systems over a specified
time vector.

4. Plotting:

• Create a figure with three subplots to show the step responses of underdamped,
overdamped, and critically damped systems.

5. Time Response Specifications:

• Use the stepinfo function to obtain time response specifications (like rise time,
settling time, overshoot, etc.) for each case and display them.

Result waveform:

Time Response Specifications:

Underdamped System:

RiseTime: 1.6390
SettlingTime: 8.0759
SettlingMin: 0.9315
SettlingMax: 1.1629
Overshoot: 16.2929
Undershoot: 0
Peak: 1.1629
PeakTime: 3.5920

Overdamped System:

RiseTime: 5.8584
SettlingTime: 10.6547
SettlingMin: 0.9012
SettlingMax: 0.9999
Overshoot: 0
Undershoot: 0
Peak: 0.9999
PeakTime: 25.9983

Critically Damped System:

RiseTime: 3.3579
SettlingTime: 5.8339
SettlingMin: 0.9000
SettlingMax: 0.9994
Overshoot: 0
Undershoot: 0
Peak: 0.9994
PeakTime: 9.7900
Result: The waveform has been plotted successfully
5EE4-22 CONTROL SYSTEM Lab

Practical No:-3
Objective:-
Object: To Design 2nd order electrical network and study its
transient response for the input.

S.No. Viva Questions (to be answered in the Lab file)

1. Define second order system in control system?

2. What is the effect of step signal on 2nd order system?

3. What is the effect of ramp signal on 2nd order system?

4. What is the effect of impulse signal on 2nd order system?

5. How many components are used in feedback control system?

6. Define linear time-invariant system?

7. Write down advantages of block-diagram?

8. Define non-touching loops?

9. Define the condition for negative damped system in 2nd order system?

10. Define the condition for under damped system in 2nd order system?
EXPERIMENT -4
OBJECT: To Study the frequency response of following compensating Networks, plot the
graph and final out corner frequencies. (a) Lag Network (b) Lead Network (c) Lag-lead
Network.

THEORY:

Generally, the purpose of the Lead-Lag compensator is to create a controller which has has an
overall magnitude of approximately 1. The lead-lag compensator is largely used for phase
compensation rather than magnitude. A pole is an integrator above the frequency of the pole.
A zero is a derivative above the frequency of the zero.

Adding a pole to the system changes the phase by -90 deg and adding zero changes the phase
by +90 deg. So, if the system needs +90 deg added to the phase in a particular frequency
band then you can add a zero at a low frequency and follow that zero with a pole at a higher
frequency.

Lead or Lag Control

Lead and lag control are used to add or reduce phase between 2 frequencies. Typically, these
frequencies are centered around the open loop crossover frequency. A lead filter typically has
unity gain (0 dB) are low frequencies while the lag provides a no unity gain at low
frequencies

Lead-Lag Control
This is an extension of the Lead and Lag network described above. We can always stick a
gain in front of something so reformulate above to look like this

Then a lead-lag controller would have the form

PROGRAM:

To study the frequency response of compensating networks such as Lag, Lead, and Lag-Lead
networks, we can follow these steps:

1. Define the Transfer Functions:


o Lag Network: Introduces a phase lag at certain frequencies.
o Lead Network: Introduces a phase lead at certain frequencies.
o Lag-Lead Network: Combines both lag and lead characteristics.
2. Plot the Bode Plots: Use Bode plots to analyze the frequency response of these
networks.
3. Determine Corner Frequencies: Identify the corner (break) frequencies where the
slope of the magnitude plot changes.

MATLAB Script

Here is the MATLAB script to analyze and plot the frequency response of Lag, Lead, and
Lag-Lead compensating networks:
% MATLAB Script to analyze the frequency response of
compensating networks

% Parameters for Lag Network


R1_lag = 1e3; % 1 kΩ
C1_lag = 1e-6; % 1 μF
R2_lag = 10e3; % 10 kΩ

% Transfer Function for Lag Network


numerator_lag = [R1_lag*C1_lag, 1];
denominator_lag = [R1_lag*C1_lag + R2_lag*C1_lag, 1];
lag_network = tf(numerator_lag, denominator_lag);

% Parameters for Lead Network


R1_lead = 1e3; % 1 kΩ
C1_lead = 1e-6; % 1 μF
R2_lead = 100; % 100 Ω

% Transfer Function for Lead Network


numerator_lead = [R1_lead*C1_lead + R2_lead*C1_lead, 1];
denominator_lead = [R1_lead*C1_lead, 1];
lead_network = tf(numerator_lead, denominator_lead);

% Parameters for Lag-Lead Network


R1_laglead = 1e3; % 1 kΩ
C1_laglead = 1e-6; % 1 μF
R2_laglead = 10e3; % 10 kΩ
R3_laglead = 100; % 100 Ω

% Transfer Function for Lag-Lead Network


numerator_laglead = conv([R1_laglead*C1_laglead +
R3_laglead*C1_laglead, 1], [R1_laglead*C1_laglead, 1]);
denominator_laglead = conv([R1_laglead*C1_laglead +
R2_laglead*C1_laglead, 1], [R1_laglead*C1_laglead, 1]);
laglead_network = tf(numerator_laglead, denominator_laglead);

% Plotting Bode plots


figure;

% Bode plot for Lag Network


subplot(3, 1, 1);
bode(lag_network);
title('Frequency Response of Lag Network');
grid on;

% Bode plot for Lead Network


subplot(3, 1, 2);
bode(lead_network);
title('Frequency Response of Lead Network');
grid on;

% Bode plot for Lag-Lead Network


subplot(3, 1, 3);
bode(laglead_network);
title('Frequency Response of Lag-Lead Network');
grid on;

% Finding corner frequencies


[mag_lag, phase_lag, wout_lag] = bode(lag_network);
[mag_lead, phase_lead, wout_lead] = bode(lead_network);
[mag_laglead, phase_laglead, wout_laglead] =
bode(laglead_network);

% Convert wout to frequency in Hz


frequencies_lag = wout_lag / (2*pi);
frequencies_lead = wout_lead / (2*pi);
frequencies_laglead = wout_laglead / (2*pi);

% Corner frequencies are typically where the phase shift is -


45 degrees (lag) or +45 degrees (lead)
% For simplicity, we will approximate by finding where the
phase is closest to these values

% Find corner frequencies for Lag Network


[~, idx_lag] = min(abs(squeeze(phase_lag) + 45));
corner_freq_lag = frequencies_lag(idx_lag);

% Find corner frequencies for Lead Network


[~, idx_lead] = min(abs(squeeze(phase_lead) - 45));
corner_freq_lead = frequencies_lead(idx_lead);

% Find corner frequencies for Lag-Lead Network


[~, idx_laglead_lag] = min(abs(squeeze(phase_laglead) + 45));
corner_freq_laglead_lag =
frequencies_laglead(idx_laglead_lag);

[~, idx_laglead_lead] = min(abs(squeeze(phase_laglead) - 45));


corner_freq_laglead_lead =
frequencies_laglead(idx_laglead_lead);

% Display corner frequencies


disp('Corner Frequencies:');
disp(['Lag Network: ', num2str(corner_freq_lag), ' Hz']);
disp(['Lead Network: ', num2str(corner_freq_lead), ' Hz']);
disp(['Lag-Lead Network (Lag Corner): ',
num2str(corner_freq_laglead_lag), ' Hz']);
disp(['Lag-Lead Network (Lead Corner): ',
num2str(corner_freq_laglead_lead), ' Hz']);
Explanation:

1. Define Component Values:

• The values for resistors and capacitors in the Lag, Lead, and Lag-Lead networks are
chosen.

2. Transfer Functions:

• Transfer functions for each network are defined using the tf function.

3. Bode Plots:

• The bode function is used to plot the frequency response of each network.
• Subplots are used to visualize the frequency responses of the Lag, Lead, and Lag-
Lead networks separately.

4. Corner Frequencies:

• Corner frequencies are identified where the phase shift is around -45 degrees for the
Lag network and +45 degrees for the Lead network.
• For the Lag-Lead network, both lag and lead corner frequencies are identified.
• The corner frequencies are displayed in the MATLAB command window.

Result Waveform:

Corner Frequencies:

Lag Network: 18.9473 Hz

Lead Network: 151.7483 Hz

Lag-Lead Network (Lag Corner): 18.9473 Hz

Lag-Lead Network (Lead Corner): 15915.4943 Hz


RESULT: We have successfully studied the frequency response of following
compensating Networks.
5EE4-22 CONTROL SYSTEM Lab

Practical No:-4
Objective:-
Object: To study frequency response of following compensating
networks, plot the graph and find out corner frequencies (a) Lag
network (b) Lead network (c) Lag-Lead network.

S.No. Viva Questions (to be answered in the Lab file)

1. Define lag compensation in control system?

2. Define Lead compensation in control system?

3. Define Lag- Lead compensation in control system?

4. Explain the function techcho-generator?

Write down difference between static and dynamic response in control


5. system?

6. Define the various controller used in control system?

7. Define various advantages of PI controller?

8. Define dominant Pole pair?

9. What is corner frequency in bode plot?

10. Distinguish between TYPE and order of a system transfer function?


EXPERIMENT 5

Object: Draw the Bode plot for a non- inverting amplifier

Theory:

A non-inverting amplifier is a type of operational amplifier (op-amp) configuration where the


input signal is applied to the non-inverting input of the op-amp. This configuration provides a
positive voltage gain, meaning the output signal is in phase with the input signal. The gain of
the amplifier can be precisely controlled using two resistors.

Key Components:

• Op-Amp: The operational amplifier is the active component used to amplify the input
signal.
• Rin: The input resistor connected between the input signal and the non-inverting input
of the op-amp.
• Rf: The feedback resistor connected between the output and the inverting input of the
op-amp.

Voltage Gain

The voltage gain Av of a non-inverting amplifier is given by the formula:

𝑅𝑓
𝐴𝑉 = 1 +
𝑅𝑖𝑛

where:

• Rf is the feedback resistor.


• Rin is the input resistor.

This formula shows that the gain is always greater than or equal to 1. The term "1" in the
formula represents the unity gain component, which is due to the direct path from the input to
the output through the op-amp.
Input and Output Relationship

The input signal Vin is applied to the non-inverting input of the op-amp. The output voltage
Vout is given by:

𝑅𝑓
𝑉𝑜𝑢𝑡 = 𝐴𝑉 . 𝑉𝑖𝑛 = ( 1 + ) . 𝑉𝑖𝑛
𝑅𝑖𝑛

Frequency Response

For an ideal op-amp, the gain is constant across all frequencies. However, in practical
scenarios, the frequency response is limited by the bandwidth of the op-amp. At higher
frequencies, the gain starts to roll off due to the internal compensation of the op-amp.

The Bode plot for an ideal non-inverting amplifier would show a flat magnitude response and
a zero-phase response across all frequencies.

Advantages of Non-Inverting Amplifier

1. High Input Impedance: The input impedance of a non-inverting amplifier is very


high, which means it does not load the source driving it.
2. Stable Gain: The gain is precisely determined by the resistors Rf and Rin, providing
stable and predictable amplification.
3. Phase Relationship: The output signal is in phase with the input signal.

Applications

Non-inverting amplifiers are widely used in various applications, including:

• Signal conditioning
• Buffering
• Voltage followers
• Analog computing
• Audio amplification
PROGRAM:

To draw the Bode plot for a non-inverting amplifier, we need to derive the transfer function
of the amplifier circuit and then use MATLAB to plot its Bode plot. Here is a step-by-step
guide to achieve this.

Non-Inverting Amplifier Transfer Function

The transfer function H(s) of a non-inverting amplifier can be derived as follows:

Since the transfer function is a constant gain, its frequency response is flat, and the phase is
zero degrees across all frequencies.

MATLAB Code

Here's the MATLAB code to plot the Bode plot of a non-inverting amplifier:
% MATLAB Script to plot Bode plot of a non-inverting amplifier

% Define component values


Rf = 10e3; % Feedback resistor (10 kΩ)
Rin = 1e3; % Input resistor (1 kΩ)

% Transfer function of the non-inverting amplifier


H = 1 + Rf / Rin;

% Define the transfer function in MATLAB


sys = tf(H, 1); % H(s) = 11

% Plot the Bode plot


figure;
bode(sys);
title('Bode Plot of Non-Inverting Amplifier');
grid on;

Explanation:

1. Define Component Values:

• The feedback resistor Rf and input resistor Rin are defined.

2. Transfer Function:

• The transfer function H(s) of the non-inverting amplifier is calculated.

3. MATLAB Transfer Function:

• The transfer function is defined using the tf function. Since it is a constant gain, the
numerator is H and the denominator is 1.

4. Bode Plot:
• The bode function is used to plot the Bode plot of the transfer function.
• The title of the plot is set to "Bode Plot of Non-Inverting Amplifier", and the grid is
enabled for better readability.

Result Waveform:

Result: we have successfully studied bode plot for a 2nd order system and find GM and PM.
5EE4-22 CONTROL SYSTEM Lab

Practical No:-5
Objective:-
Object: Draw the bode plot for a Non-Inverting amplifier.

S.No. Viva Questions (to be answered in the Lab file)

1. Define CMRR.

2. What is an op-amp?

3. Write the Gain formula for a non-inverting op-amp.

4. Define the slew rate.

5. Explain various stability condition in the bode plot?

6. Explain types of two types of frequency in bode plot?

7. Define Ultimate Gain.

8. How can you draw Bode phase plot?

9. What is the condition of stability in control system?

10. Write down various advantages of Bode Plot?


EXPERIMENT 6

Object: Draw the bode plot for an Inverting amplifier

THEORY:
An inverting amplifier is a type of operational amplifier (op-amp) configuration that provides
a negative voltage gain. It is commonly used in analog circuits to invert and amplify an input
signal.
Key Components:
• Operational Amplifier (Op-Amp): The active component used to amplify the input
signal.
• Rf: Feedback resistor connected between the output and the inverting input of the op-
amp.
• Rin: Input resistor connected between the input signal and the inverting input of the
op-amp.
Voltage Gain
The voltage gain Av of an inverting amplifier is given by the formula:

𝑅𝑓
𝐴𝑉 = −
𝑅𝑖𝑛

where:
• Rf is the feedback resistor.
• Rin is the input resistor.
This formula indicates that the gain of the amplifier is negative, meaning the output signal is
inverted relative to the input signal.
Input and Output Relationship

𝑅𝑓
𝑉𝑜𝑢𝑡 = 𝐴𝑉 . 𝑉𝑖𝑛 = (− ) . 𝑉𝑖𝑛
𝑅𝑖𝑛

Frequency Response
For an ideal op-amp, the gain is constant across all frequencies. However, in practical
scenarios, the frequency response is affected by the op-amp's bandwidth limitations. At
higher frequencies, the gain might roll off due to the internal compensation of the op-amp.
The Bode plot of an ideal inverting amplifier would show:
𝑅𝑓
• Magnitude Plot: A flat response at a gain of − , which is a constant gain in dB.
𝑅𝑖𝑛

• Phase Plot: A constant phase shift of -180 degrees across all frequencies.

Advantages of Inverting Amplifier


1. High Input Impedance: The input impedance of the amplifier is high, which
prevents it from loading the source signal.
2. Stable Gain: The gain is determined by the resistors Rf and Rin, which can be
precisely controlled.
3. Phase Inversion: The output signal is inverted relative to the input signal, which can
be useful in various signal processing applications.

Applications
Inverting amplifiers are widely used in various applications, including:
• Signal Processing: For amplifying and inverting signals.
• Analog Computing: For performing mathematical operations on signals.
• Audio Amplification: To amplify audio signals while inverting them.
• Active Filters: In the design of active filter circuits.
• Voltage Followers: To provide buffering and impedance matching.
The inverting amplifier is a fundamental op-amp configuration that provides a precise and
predictable negative voltage gain. Its high input impedance, stable gain, and phase inversion
properties make it a versatile tool in analog circuit design and signal processing.

PROGRAM:

To draw the Bode plot for an inverting amplifier, we need to derive the transfer function of
the amplifier circuit and then use MATLAB to plot its Bode plot. Here's a step-by-step guide
to achieve this.
Inverting Amplifier Transfer Function

The transfer function H(s) of an inverting amplifier can be derived as follows:

Since the transfer function is a constant gain with a negative sign, its frequency response is
flat, and the phase is -180 degrees across all frequencies.

MATLAB Code

To obtain the Bode plot of an inverting amplifier and observe its response to a sinusoidal
input in MATLAB, you can follow these steps:

1. Define the transfer function of the inverting amplifier.


2. Generate a sinusoidal input signal.
3. Simulate the system response to the sinusoidal input.
4. Plot the input and output signals.
5. Plot the Bode plot of the system.

Here's the MATLAB code to achieve this:

MATLAB Code

% MATLAB Script to plot Bode plot of an inverting amplifier


with sinusoidal input and output

% Define component values


Rf = 10e3; % Feedback resistor (10 kΩ)
Rin = 1e3; % Input resistor (1 kΩ)

% Transfer function of the inverting amplifier


H = -Rf / Rin; % Gain

% Define the transfer function in MATLAB


sys = tf(H, 1); % H(s) = -10

% Define the sinusoidal input signal


f = 1; % Frequency of the sinusoidal input (1 Hz)
t = 0:0.01:10; % Time vector
Vin = sin(2*pi*f*t); % Sinusoidal input signal

% Compute the output signal using the transfer function


Vout = lsim(sys, Vin, t);

% Plot the input and output signals


figure;
subplot(2, 1, 1);
plot(t, Vin);
title('Sinusoidal Input Signal (Vin)');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;

subplot(2, 1, 2);
plot(t, Vout);
title('Output Signal (Vout)');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;

% Plot the Bode plot


figure;
bode(sys);
title('Bode Plot of Inverting Amplifier');
grid on;

Explanation:

1. Define Component Values:

• The feedback resistor Rf and input resistor Rin are defined.

2. Transfer Function:

• The transfer function H(s) of the inverting amplifier is calculated as -Rf / Rin .

3. MATLAB Transfer Function:

• The transfer function is defined using the tf function.

4. Sinusoidal Input Signal:

• A sinusoidal input signal is generated with a frequency of 1 Hz.

5. Compute Output Signal:


• The lsim function is used to simulate the output signal of the system in response to
the sinusoidal input signal over time.

6. Plot Input and Output Signals:

• The input and output signals are plotted on separate subplots for comparison.

7. Bode Plot:

• The bode function is used to plot the Bode plot of the transfer function.

Result waveform:

Result: We have successfully studied bode plot for a 2nd order system and find GM and PM.
5EE4-22 CONTROL SYSTEM Lab
Practical No:-6
Objective:-
Object: Draw the bode plot for An Inverting amplifier.

S.No. Viva Questions (to be answered in the Lab file)

1. What is Matlab?

2. Explain various application of Matlab in control system?

3. How can you draw Bode phase plot?

4. Which types of loops are provided by Matlab?

5. Which types of operators are allowed in Matlab?

6. Define Simulink in Matlab?

7. Define four basic functions to solve ordinary differential equations?

8. Define CMRR.

9. What is an op-amp?

10. Write the Gain formula for an inverting op-amp.


EXPERIMENT 7

OBJECT: To Plot bode plot for a 2nd order system.

THEORY:

A Bode plot is a graphical representation of a system's frequency response, typically showing


both the magnitude and phase of the system as functions of frequency. For a 2nd-order
transfer function system, the Bode plot helps to analyze how the system responds to different
frequencies and provides insight into its stability and performance.

2nd-Order Transfer Function


A standard 2nd-order transfer function can be expressed as:

𝐾
𝐻(𝑠) =
𝑠2 + 2ζ𝜔𝑛 𝑠 + 𝜔𝑛2

where:
• K is the system gain.
• ωn is the natural frequency (in radians per second).
• ζ is the damping ratio.

Frequency Response Analysis


To understand the Bode plot, we need to analyze the frequency response of the system:
1. Magnitude Response:
• The magnitude response of the transfer function H(jω) is given by:

• This represents how the magnitude of the output signal varies with frequency.
2. Phase Response:
• The phase response of the transfer function H(jω) is given by:

• This represents how the phase of the output signal shifts relative to the input signal
with frequency.

Key Characteristics of 2nd-Order Systems


1. Underdamped System (ζ<1):
• The system exhibits oscillatory behavior.
• The magnitude response has a peak (resonance) near the natural frequency ωn
• The phase response shows a phase lag that approaches -180 degrees as the frequency
increases.
2. Critically Damped System (ζ=1):
• The system returns to equilibrium as quickly as possible without oscillating.
• The magnitude response does not have a peak; it smoothly decreases with increasing
frequency.
• The phase response is smooth and does not approach -180 degrees abruptly.
3. Overdamped System (ζ>1):
• The system returns to equilibrium without oscillating and slower compared to the
critically damped case.
• The magnitude response has no peak and decreases smoothly.
• The phase response approaches -180 degrees more gradually compared to the
underdamped case.

Bode Plot
The Bode plot consists of two separate plots:
1. Magnitude Plot:
• This plot shows the gain (in dB) of the system as a function of frequency.
• The plot typically includes a flat region, a slope indicating the roll-off, and a
resonance peak (for underdamped systems).
2. Phase Plot:
• This plot shows the phase shift (in degrees) of the system's output relative to the input
as a function of frequency.
• The phase plot usually starts at 0 degrees, drops to -90 degrees, and then to -180
degrees as the frequency increases.

The Bode plot of a 2nd-order transfer function provides a clear visualization of how the
system responds to different frequencies. By analyzing the magnitude and phase plots, you
can gain insights into the system's stability, resonant behavior, and overall performance. This
analysis is crucial for designing and tuning control systems to ensure they meet the desired
specifications.

PROGRAM:

To plot the Bode plot for a 2nd-order transfer function system in MATLAB, you'll first need
to define the transfer function of the system. A typical 2nd-order transfer function can be
expressed as:

𝐾
𝐻(𝑠) =
𝑠2 + 2ζ𝜔𝑛 𝑠 + 𝜔𝑛2

where:

• K is the system gain.


• ωn is the natural frequency (in radians per second).
• ζ is the damping ratio.

Here's a step-by-step MATLAB code to plot the Bode plot for such a system:
MATLAB Code

% MATLAB Script to plot Bode plot for a 2nd order transfer


function system

% Define system parameters


K = 1; % System gain
omega_n = 5; % Natural frequency (rad/s)
zeta = 0.5; % Damping ratio

% Define the transfer function


% H(s) = K / (s^2 + 2*zeta*omega_n*s + omega_n^2)
numerator = K; % Numerator coefficients (constant gain)
denominator = [1, 2*zeta*omega_n, omega_n^2]; % Denominator
coefficients

% Create the transfer function


sys = tf(numerator, denominator);

% Plot the Bode plot


figure;
bode(sys);
title('Bode Plot of 2nd Order Transfer Function');
grid on;

Explanation:

1. Define System Parameters:

• K is the system gain.


• omega_n is the natural frequency of the system.
• zeta is the damping ratio.

2. Define the Transfer Function:


• The transfer function is defined using the tf function in MATLAB.
• The numerator and denominator coefficients are specified. For a 2nd-order system,
the denominator is constructed using the coefficients for s2, s, and the constant term.

3. Create the Transfer Function:

• tf(numerator, denominator) creates the transfer function model of the


system.

4. Plot the Bode Plot:

• The bode function is used to plot the magnitude and phase response of the transfer
function.
• The title and grid on commands are used to label the plot and make it easier to
read.

You can modify the values of K, omega_n, and zeta to analyze different 2nd-order
systems. For example:

• Underdamped System: Use ζ<1.


• Critically Damped System: Use ζ=1.
• Overdamped System: Use ζ>1.
Result Waveform:

Result: Bode plot of a transfer function 2nd order system has been successfully plotted.
5EE4-22 CONTROL SYSTEM Lab
Practical No:-7
Objective:-
Object: Draw the bode plot for second order transfer function.

S.No. Viva Questions (to be answered in the Lab file)

1. Define the various types of order of system?

2. Which type of program file we use for simulation in MATLAB?

3. What is the function of time response of the control system?

4. How can we divide time response of the system?

5. What is system response for different values of damping ratios?

6. Define Pole of the system in control?

7. Define Zero of the system in control?

8. Define basic properties of signal flow graph?

9. Define various type of signals and their significant?

10. Define response of second order system?


EXPERIMENT 8

OBJECT: Draw the bode plot for first order transfer function

THEORY:

A Bode plot is a graphical representation of a linear, time-invariant system transfer function.


It consists of two plots: one for magnitude (in dB) and one for phase (in degrees) versus
frequency (on a logarithmic scale). For a first-order transfer function, the Bode plot helps in
understanding the frequency response characteristics of the system.

First-Order Transfer Function

A first-order transfer function can be represented in the form:

𝐾
𝐻(𝑠) =
𝜏𝑠 + 1

where:

• K is the system gain.


• τ is the time constant.
• s is the complex frequency variable.

Steps to Plot the Bode Plot

1. Magnitude Plot:

• At low frequencies (ω much less than 1/τ), the magnitude is approximately


20 log10 (𝐾) db
• At high frequencies (ω much greater than 1/τ), the magnitude decreases at a rate of
−20 dB/decade.
1
• The corner (or break) frequency is at 𝜔𝑐 = 𝜏
2. Phase Plot:

• At low frequencies, the phase angle is approximately 0 degree.


• At the corner frequency (ω=1/τ), the phase angle is −45 degree
• At high frequencies, the phase angle approaches −90 degree.

PROGRAM:
To draw the Bode plot for a first-order transfer function in MATLAB, you need to define the
transfer function and use the bode function to generate the plot. A first-order transfer function
typically has the following form:
𝐾
𝐻(𝑠) =
𝜏𝑠 + 1
where:
• K is the system gain.
• 𝜏 is the time constant of the system.

MATLAB Code

Here's a step-by-step MATLAB code to plot the Bode plot for a first-order transfer function:

% MATLAB Script to plot Bode plot for a first-order transfer


function

% Define system parameters


K = 1; % System gain
tau = 1; % Time constant (seconds)

% Define the transfer function


% H(s) = K / (tau*s + 1)
numerator = K; % Numerator coefficients
denominator = [tau, 1]; % Denominator coefficients
(tau*s + 1)
% Create the transfer function
sys = tf(numerator, denominator);

% Plot the Bode plot


figure;
bode(sys);
title('Bode Plot of First-Order Transfer Function');
grid on;

Explanation:

1. Define System Parameters:

• K is the gain of the system.


• tau is the time constant, which determines how quickly the system responds to
changes.

2. Define the Transfer Function:

𝐾
• The transfer function H(s) of the first-order system is defined as 𝜏𝑠+ 1

• numerator represents the constant gain K


• denominator represents the polynomial in sss, which is τs+1\tau s + 1τs+1.

3. Create the Transfer Function:

• tf(numerator, denominator) creates the transfer function model in


MATLAB.

4. Plot the Bode Plot:

• bode(sys) plots the magnitude and phase response of the transfer function.
• The title command sets the title of the plot.
• grid on adds a grid to the plot for better readability.
You can modify the values of K and tau to analyze different first-order systems. For
example:

• Increasing K will scale the magnitude response.


• Changing tau will affect the cutoff frequency and the slope of the magnitude plot.

Result Waveform:

Result: Bode plot of a transfer function 1st order system has been successfully plotted.
5EE4-22 CONTROL SYSTEM Lab

Practical No:-8
Objective:-
Object: Draw the bode plot for first order transfer function.

S.No. Viva Questions (to be answered in the Lab file)

1. Define the signal flow graph in control system?

2. What is S domain and define it’s significant?

3. Explain different types of control system?

4. Define open loop control system with suitable diagram?

5. Define closed loop control system with suitable diagram?

6. Derive the characteristics of negative feedback?

7. What are the basic components of feedback control system?

8. Explain transfer function with suitable equation?

9. Define Time Invariant system?

10. Define basic rule for Block Diagram Reduction Technique?


EXPERIMENT 9

OBJECT: Design and calculate Kp, Ki for PI controller.

THEORY:

A Proportional-Integral (PI) controller is a type of feedback controller widely used in


industrial control systems. It combines the proportional control and integral control to
eliminate steady-state error and improve system performance.

Components of PI Controller

1. Proportional Term (Kp):


o Function: Produces an output value that is proportional to the current error
value.
o Effect: Increases the response speed of the system and reduces the rise time.
However, if too large, it can cause overshoot and system instability.
2. Integral Term (Ki):
o Function: Integrates the error over time and produces an output that aims to
eliminate the steady-state error.
o Effect: Eliminates steady-state error and improves accuracy over time. If too
large, it can lead to increased overshoot and oscillations.

Mathematical Representation

The PI controller output u(t)u(t)u(t) is given by:


where:

• e(t) the error signal, e(t)=r(t)−y(t)


• r(t) is the reference input (setpoint)
• y(t) is the measured process variable (output)

Tuning the PI Controller

The process of setting the optimal values of Kp and Ki is called tuning. There are several
methods for tuning a PI controller:

1. Manual Tuning:

• Adjust Kp and Ki manually and observe the system response.


• Increase Kp to decrease the rise time and reduce steady-state error.
• Increase Ki to eliminate the steady-state error, but watch for increased overshoot and
oscillations.

2. Ziegler-Nichols Method:

• Increase Kp until the system oscillates continuously.


• Record the critical gain Kcr and the oscillation period Tcr.
• Calculate Kp and Ki using the Ziegler-Nichols tuning formulas for PI control: Kp=
0.45Kcr

0.54𝐾𝑐𝑟
𝐾𝑖 =
𝑇𝑐𝑟

3. Software Tools:

• Use software tools such as MATLAB's pidtune function to automatically tune the PI
controller based on the system's model and desired performance criteria.
PROGRAM:

Designing a Proportional-Integral (PI) controller involves choosing the proportional gain Kp


and the integral gain Ki to meet the desired performance specifications of your control
system. Here’s a step-by-step guide on how to design and calculate Kp and Ki for a PI
controller in MATLAB:

Steps for Designing a PI Controller

1. Define the Desired Specifications: Determine the performance criteria such as


settling time, overshoot, and steady-state error. These will guide the choice of Kp and
Ki.
2. System Dynamics: Obtain the transfer function or state-space model of the system
you want to control.
3. Controller Design:
o Proportional Gain (Kp): Affects the speed of the response and the system’s
stability.
o Integral Gain (Ki): Eliminates the steady-state error but can affect the
stability and speed of the response.
4. Tuning Methods:
o Manual Tuning: Adjust Kp and Ki manually by trial and error.
o Automated Tuning: Use MATLAB functions like pidtune for automated
tuning based on desired specifications.
o Frequency Domain Analysis: Analyze the system response in the frequency
domain to choose appropriate gains.

Example MATLAB Code for PI Controller Design

% Clear workspace and close all figures

clear;

clc;
close all;

% Define the system transfer function

% Example: Second-order system H(s) = 1 / (s^2 + 2*s + 1)

num = [1]; % Numerator of the transfer function

den = [1, 2, 1]; % Denominator of the transfer function

sys = tf(num, den); % Create the transfer function

% Define desired specifications

% Desired closed-loop system performance

desired_settling_time = 4; % in seconds

desired_overshoot = 10; % in percentage

% Automated tuning using the 'pidtune' function

% Create a PI controller structure

pi_controller = pid(1, 1, 0); % Initial guess for Kp and Ki

% Tune the PI controller to meet the desired performance

[pi_controller_tuned, info] = pidtune(sys, 'PI');

% Extract the tuned gains


Kp = pi_controller_tuned.Kp;

Ki = pi_controller_tuned.Ki;

% Display the results

disp(['Tuned Proportional Gain (Kp): ', num2str(Kp)]);

disp(['Tuned Integral Gain (Ki): ', num2str(Ki)]);

% Create the closed-loop system with the tuned PI controller

sys_cl = feedback(pi_controller_tuned*sys, 1);

% Plot the step response of the closed-loop system

figure;

step(sys_cl);

title('Step Response with Tuned PI Controller');

grid on;

% Plot the Bode plot of the closed-loop system

figure;

bode(sys_cl);
title('Bode Plot of Closed-Loop System with Tuned PI
Controller');

grid on;

Explanation

1. Define the System Transfer Function:

• num and den represent the numerator and denominator of the system’s transfer
function.
• tf(num, den) creates the transfer function model.

2. Define Desired Specifications:

• Specify the desired settling time and overshoot for the closed-loop system.

3. Automated Tuning Using pidtune:

• pidtune automatically tunes the PI controller to meet the desired specifications.


• The function returns the tuned PI controller and additional information.

4. Extract and Display Gains:

• Extract the proportional gain Kp and integral gain Ki from the tuned PI controller.

5. Create and Analyze the Closed-Loop System:

• feedback creates the closed-loop system with the tuned PI controller.


• step and bode functions plot the step response and Bode plot of the closed-loop
system.

By using MATLAB to design and calculate Kp and Ki for a PI controller, you can effectively
tune your control system to meet desired performance criteria. Automated tuning functions
like pidtune simplify the process, while manual tuning provides flexibility for specific
adjustments.
Result Waveform:
Tuned Proportional Gain (Kp): 1.9152
Tuned Integral Gain (Ki): 1.0105

Result: We have successfully designed and calculated Kp , Ki for PI controller


5EE4-22 CONTROL SYSTEM Lab
Practical No:-9
Objective:-
Object: Design and calculate Kp, Ki for PI controller.

S.No. Viva Questions (to be answered in the Lab file)

1. Define the integral control action?

2. What is the effect of PI controller on the system performance?

3. What is the effect of PD controller on time response?

4. Define the limit for stable system?

5. What is the condition of stability in control system?

6. What is the condition for relative stability?

7. Write down the necessary conditions for stability?

8. Define minimum phase transfer function?

9. Mention two drawbacks of derivative action.

10. Write down definition of M-circles?


EXPERIMENT 10

OBJECT: Design PID controller and also calculate Kp, Ki, Kd for it.

THEORY:

A PID controller is a control loop feedback mechanism widely used in industrial control
systems. The PID controller calculates an error value as the difference between a desired
setpoint and a measured process variable, and applies a correction based on proportional,
integral, and derivative terms, denoted as Kp, Ki, and Kd respectively.

Components of PID Controller

1. Proportional Term (Kp):


o Function: Produces an output value that is proportional to the current error
value.
o Effect: Larger Kp values decrease the rise time and reduce the steady-state
error but can cause the system to become unstable if too large.
2. Integral Term (Ki):
o Function: Integrates the error over time and produces an output that
eliminates the steady-state error.
o Effect: Larger Ki values eliminate the steady-state error but can cause
instability and oscillations if too large.
3. Derivative Term (Kd):
o Function: Produces an output that is proportional to the rate of change of the
error.
o Effect: Larger Kd values improve system stability and reduce overshoot but
can amplify noise in the error signal.

Mathematical Representation

The PID controller output u(t) is given by:


where:

• e(t) is the error signal, e(t)=r(t)−y(t)


• r(t) is the reference input (setpoint)
• y(t) is the measured process variable (output)

Tuning the PID Controller

The process of setting the optimal values of Kp, Ki, and Kd is called tuning. There are several
methods for tuning a PID controller:

1. Manual Tuning:
o Adjust Kp, Ki, and Kd manually and observe the system response.
o Increase Kp until the output oscillates, then increase Ki to eliminate the
steady-state error, and finally, adjust Kd to achieve desired stability and
performance.
2. Ziegler-Nichols Method:
o Increase Kp until the system oscillates continuously.
o Record the critical gain Kcr and the oscillation period Tcr.
o Calculate Kp, Ki, and Kd using the Ziegler-Nichols tuning formulas.
3. Software Tools:
o Use software tools such as MATLAB's pidtune function to automatically tune
the PID controller based on the system's model and desired performance
criteria.

PROGRAM:

Designing a PID controller involves calculating the proportional (Kp), integral (Ki), and
derivative (Kd) gains to meet the desired performance specifications of a control system.
Here, I'll provide a complete example using MATLAB to design a PID controller and
calculate the gains using the pidtune function.

Designing a PID Controller in MATLAB

We'll use a second-order system as an example and design a PID controller to meet specified
performance criteria.

MATLAB Code

% Clear workspace and close all figures


clear;
clc;
close all;

% Define the system transfer function


% Example: Second-order system H(s) = 1 / (s^2 + 2*s + 1)
num = [1]; % Numerator of the transfer function
den = [1, 2, 1]; % Denominator of the transfer function
sys = tf(num, den); % Create the transfer function

% Define desired specifications


% Desired closed-loop system performance
desired_settling_time = 4; % in seconds
desired_overshoot = 10; % in percentage

% Automated tuning using the 'pidtune' function


% Create a PID controller structure
pid_controller = pid(1, 1, 1); % Initial guess for Kp, Ki, and
Kd

% Tune the PID controller to meet the desired performance


[pid_controller_tuned, info] = pidtune(sys, 'PID');

% Extract the tuned gains


Kp = pid_controller_tuned.Kp;
Ki = pid_controller_tuned.Ki;
Kd = pid_controller_tuned.Kd;

% Display the results


disp(['Tuned Proportional Gain (Kp): ', num2str(Kp)]);
disp(['Tuned Integral Gain (Ki): ', num2str(Ki)]);
disp(['Tuned Derivative Gain (Kd): ', num2str(Kd)]);

% Create the closed-loop system with the tuned PID controller


sys_cl = feedback(pid_controller_tuned*sys, 1);

% Plot the step response of the closed-loop system


figure;
step(sys_cl);
title('Step Response with Tuned PID Controller');
grid on;

% Plot the Bode plot of the closed-loop system


figure;
bode(sys_cl);
title('Bode Plot of Closed-Loop System with Tuned PID
Controller');
grid on;

Explanation

1. Clear Workspace and Close Figures:


• clear; clc; close all; clears the workspace, command window, and closes
all figures.

2. Define the System Transfer Function:

• num and den define the numerator and denominator of the system's transfer function.
• sys = tf(num, den); creates the transfer function model.

3. Define Desired Specifications:

• Set the desired settling time and overshoot for the closed-loop system performance.

4. Automated Tuning Using pidtune:

• pid_controller = pid(1, 1, 1); initializes a PID controller with initial


guesses for Kp, Ki, and Kd.
• [pid_controller_tuned, info] = pidtune(sys, 'PID'); tunes the
PID controller to meet the system's performance requirements.

5. Extract and Display Gains:

• Kp = pid_controller_tuned.Kp;, Ki =
pid_controller_tuned.Ki;, and Kd = pid_controller_tuned.Kd;
extract the tuned proportional, integral, and derivative gains.
• disp commands display the tuned gains.

6. Create the Closed-Loop System:

• sys_cl = feedback(pid_controller_tuned*sys, 1); creates the


closed-loop system with the tuned PID controller.

7. Plot Step Response and Bode Plot:

• step(sys_cl); plots the step response of the closed-loop system.


• bode(sys_cl); plots the Bode plot of the closed-loop system.
Running the Code

To run this code:

1. Copy and paste it into a new MATLAB script (e.g.,


pid_controller_design.m).
2. Run the script in MATLAB.

This code will calculate and display the proportional, integral, and derivative gains of the PID
controller and plot the step response and Bode plot of the closed-loop system, helping you
visualize the system's performance.

Result Waveform:
Tuned Proportional Gain (Kp): 2.0456
Tuned Integral Gain (Ki): 1.454
Tuned Derivative Gain (Kd): 0.69966

Result: We have successfully designed PID controllers and calculated Kp, Ki, Kd for PID
controllers.
5EE4-22 CONTROL SYSTEM Lab
Practical No:-10
Objective:-
Object: Design PID controller and calculate Kp, Ki, Kd for it.

S.No. Viva Questions (to be answered in the Lab file)

1. Define the stability for the system?

2. Write down the application of Nichol’s Chart

3. Explain the function of controller.

4. What is control system compensation?

5. Define the integral control action?

6. What is the effect of PI controller on the system performance?

7. What is the effect of PD controller on time response?

8. Define resonance frequency?

9. When the PID Controller is used in the system?

10. Define the absolute stability?

You might also like