CS Lab Manual
CS Lab Manual
CS Lab Manual
V SEMESTER
5EE4-22
Control System Lab
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):
simulator/hardware.
• CO3: Design, and analysis of Ist and 2nd order Electrical circuits.
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 - -
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.
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
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)⋅ 𝑠
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
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
% 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.
THEORY:
Modeling First Order Systems in Simulink
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
% 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
% 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.
OBJECT: For a given 2nd order system plot step response and obtain time response
specification for step input and following cases.
THEORY:
Depending on the value of the damping ratio ζ, the system can exhibit different types of
behavior:
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.
• 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.
• 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.
𝜔𝑛2
𝐺(𝑠) = 2
𝑠 + 2ζ𝜔𝑛 𝑠 + 𝜔𝑛2
where:
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:
% 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);
% 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;
disp('Overdamped System:');
disp(info_overdamped);
Explanation:
• Define the transfer functions for each damping condition using the tf function.
• 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.
• Use the stepinfo function to obtain time response specifications (like rise time,
settling time, overshoot, etc.) for each case and display them.
Result waveform:
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
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.
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 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
PROGRAM:
To study the frequency response of compensating networks such as Lag, Lead, and Lag-Lead
networks, we can follow these steps:
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
• 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:
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.
Theory:
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
𝑅𝑓
𝐴𝑉 = 1 +
𝑅𝑖𝑛
where:
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.
Applications
• 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.
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
Explanation:
2. 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.
1. Define CMRR.
2. What is an op-amp?
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.
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
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:
MATLAB Code
subplot(2, 1, 2);
plot(t, Vout);
title('Output Signal (Vout)');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
Explanation:
2. Transfer Function:
• The transfer function H(s) of the inverting amplifier is calculated as -Rf / Rin .
• 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.
1. What is Matlab?
8. Define CMRR.
9. What is an op-amp?
THEORY:
𝐾
𝐻(𝑠) =
𝑠2 + 2ζ𝜔𝑛 𝑠 + 𝜔𝑛2
where:
• K is the system gain.
• ωn is the natural frequency (in radians per second).
• ζ is the damping ratio.
•
• 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.
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:
Here's a step-by-step MATLAB code to plot the Bode plot for such a system:
MATLAB Code
Explanation:
• 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:
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.
OBJECT: Draw the bode plot for first order transfer function
THEORY:
𝐾
𝐻(𝑠) =
𝜏𝑠 + 1
where:
1. Magnitude Plot:
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:
Explanation:
𝐾
• The transfer function H(s) of the first-order system is defined as 𝜏𝑠+ 1
• 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:
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.
THEORY:
Components of PI Controller
Mathematical Representation
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:
2. Ziegler-Nichols Method:
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:
clear;
clc;
close all;
desired_settling_time = 4; % in seconds
Ki = pi_controller_tuned.Ki;
figure;
step(sys_cl);
grid on;
figure;
bode(sys_cl);
title('Bode Plot of Closed-Loop System with Tuned PI
Controller');
grid on;
Explanation
• num and den represent the numerator and denominator of the system’s transfer
function.
• tf(num, den) creates the transfer function model.
• Specify the desired settling time and overshoot for the closed-loop system.
• Extract the proportional gain Kp and integral gain Ki from the tuned PI controller.
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
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.
Mathematical Representation
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.
We'll use a second-order system as an example and design a PID controller to meet specified
performance criteria.
MATLAB Code
Explanation
• num and den define the numerator and denominator of the system's transfer function.
• sys = tf(num, den); creates the transfer function model.
• Set the desired settling time and overshoot for the closed-loop system performance.
• 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.
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.