Csfile Final Shubham

You might also like

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

University Institute of Engineering & Technology

Kurukshetra University, Kurukshetra

CONTROL SYSTEM LAB

SUBMITTED TO: SUBMITTED BY:

Ms. Priya Mayank


Shubham Parvat
ECE DEPARTMENT 252101120
252101169
UIET,KUK ECE-B
INDEX

Sr.no
. Experiment names Signature

1 Introduction to Matlab

2 To obtain the pole , zeros and gain values from a given


transfer function

3 To plot the pole zero map of the transfer function

4 Determination of step and impulse response for a first


order unity feedback system

5 Determination of step and impulse response for a second


order unity feedback system

6 Determination of step and impulse response for a type


0,1,2 system

7 To obtain the root locus of a given transfer function

8 Determination of bode plot for a second order system

Determination of Nyquist plot for a given transfer


9 function

10 Under damped, overdamped, critically damped system


EXPERIMENT NO. 1

AIM: - Introduction of MATLAB.

What is MATLAB?
MATLAB is widely used in all areas of applied mathematics, in education and
research at universities, and in the industry. MATLAB stands for MATRIX
LABORATORY and the software is built around vectors and matrices. This makes
the software particularly useful for linear algebra but MATLAB is also a great tool
for solving algebraic and differential equations and for numerical integration.
MATLAB has powerful graphic tools and can produce nice pictures in both 2D
and 3D. It is also a programming language and is one of the easiest
programming languages for writing mathematical programs. MATLAB also has
some toolboxes useful for signal processing, image processing, optimization, etc.

What is GNU OCTAVE?

GNU Octave is a high-level language, primarily intended for numerical


computations. It provides a convenient command line interface for solving linear
and nonlinear problems numerically, and for performing other numerical
experiments using a language that is mostly compatible with MATLAB. It may
also be used as a batch-oriented language.

Octave has extensive tools for solving common numerical linear algebra
problems, finding the roots of nonlinear equations, integrating ordinary functions,
manipulating polynomials, and integrating ordinary differential and differential
algebraic equations. It is easily extensible and customizable via user-defined
functions written in Octave’s own language, or using dynamically loaded modules
written in C++, C, Fortran, or other languages.

GNU Octave is also freely redistributable software. You may redistribute it and/or
modify it under the terms of the GNU General Public License (GPL) as published
by the Free Software Foundation.

Octave was written by John W. Eaton and many others. Because Octave is free
software you are encouraged to help make Octave more useful by writing and
contributing additional functions for it, and by reporting any problems you may
have.
Figure - Editor Window

Figure - Command Window


EXPERIMENT NO. 2

AIM: - To obtain Pole, zero, gain values from a given transfer function
THEORY -
The pole-zero gain of a transfer function is the product of its poles, zeros, and gain constant.

For example, consider the transfer function:

H(s) = (s + 1) / (s^2 + 2s + 5)

To find the pole-zero gain of H(s), we first need to factorize it in terms of its poles, zeros,
and gain constant. In this case, we have one zero at s = -1 and two poles at s = -1 + 2i
and s = -1 - 2i. The gain constant is K = 1.
Therefore, the pole-zero gain of H(s) is:

K * (s - (-1)) / [(s - (-1 + 2i)) (s - (-1 - 2i))]


= 1 * (s + 1) / [(s + 1 - 2i) (s + 1 + 2i)]
To find the value of this expression at s = 0, we substitute s = 0 and simplify:

pole-zero gain at s = 0 = (0 + 1) / [(0 + 1 - 2i) (0 + 1 + 2i)]

= 1 / (-5) = -0.2

Therefore, the pole-zero gain of H(s) at s = 0 is -0.2. This value gives an indication of the
overall gain or attenuation of the system at low frequencies.
CODE-
pkg load control

g1=tf ([2 2], [2 0 3])

pkg load signal

num =[-4 -2];

den=[2 6 4];

[ z,p,k] = tf2zp( num, den)


OUTPUT -

Figure - Pole , Zero , Gain values of transfer function


EXPERIMENT NO. 3

AIM - To plot the pole-zero map of the transfer function

THEORY -
A pole-zero map is a graphical representation of the location of poles and zeros of a
transfer function in the complex plane. Poles and zeros are the values of s that make
the transfer function H(s) infinite or zero, respectively.

To construct the pole-zero map of a transfer function, we first factorize the transfer function in
terms of its poles and zeros. For example, consider the transfer function: H(s) = (s + 1) / (s^2
+ 2s + 5)

The poles of this transfer function are the roots of the denominator polynomial s^2 + 2s +
5. We can find these roots by using the quadratic formula:
s = (-2 ± sqrt(2^2 - 4*1*5)) / (2*1) = -1 ± 2i So, the poles
H(s) are located at s = -1 + 2i and s = -1 - 2i.

The zeros of the transfer function are the roots of the numerator polynomial s + 1. We can find
this root by setting the numerator equal to zero:
s + 1 = 0 So, the zero of H(s) is
located at s = -1.
Now, we can plot the poles and zeros on the complex plane. The poles are marked with an "x"
and the zeros are marked with an "o". In this example, the pole-zero map of H(s) is:

x
|
o |

x
The pole-zero map provides important information about the behavior of the system. For
example, the distance of the poles from the imaginary axis determines the damping of
the system, while the frequency of oscillation is determined by the imaginary part of the
poles. The location of the zeros can affect the stability of the system and the frequency
response.
CODE -
pkg load control;
num =[1 2 3];
den =[4 5 6 7];
h =tf(num,den);
pzmap(h);
tf(h) ;

OUTPUT -

Figure - Pole zero map of transfer function


EXPERIMENT NO. 4

AIM - DETERMINATION OF STEP & IMPULSE RESPONSE FOR A FIRST ORDER


UNITY FEEDBACK SYSTEM

THEORY -
The step and impulse response of a first-order system can also be analyzed using its transfer
function: H(s) = K / (s + τ) where K is the system gain, τ is the time constant, and s is the Laplace
variable.

The step response of the system is the output of the system when the input is a step function, u(t) =
U0 for t >= 0. The Laplace transform of a step function is U0/s, so the output can be found by taking
the inverse Laplace transform of the product of the transfer function and the input:

y(s) = U0 H(s) = U0 K / (s + τ) Taking the


inverse Laplace transform, we get:
y(t) = U0 (1 - e^(-t/τ))

This equation describes the response of the system to a step input. The step response rises
exponentially from zero to the steady-state value of U0 with a time constant τ.

The impulse response of the system is the output of the system when the input is an impulse function,
δ(t). The Laplace transform of an impulse function is 1, so the output can be found by taking the
inverse Laplace transform of the product of the transfer function and 1:

y(s) = H(s) = K / (s + τ) Taking the


inverse Laplace transform, we get: y(t) =
(K/τ) e^(-t/τ) u(t)

This equation describes the response of the system to an impulse input. The impulse response is a
decaying exponential with time constant τ. The impulse response is useful for analyzing the frequency
response of the system and identifying resonant frequencies.

In summary, for a first-order system, the step response rises exponentially to the steady-state value
with a time constant τ, while the impulse response is a decaying exponential with the same time
constant.
CODE -
pkg load control
clc
clear
R=3 u=2
s=tf('s')
G=1/(s+R)
step(u*G)
figure(1) impulse
(u*G) figure(2)
step(u*G/s)

OUTPUT-

Figure - Impulse response

Figure - Step Response


EXPERIMENT NO. 5

AIM- DETERMINATION OF STEP & IMPULSE RESPONSE FOR A SECOND ORDER


UNITY FEEDBACK SYSTEM

THEORY -
The step and impulse response of a second-order system can be analyzed using its transfer function:

H(s) = K / (s^2 + 2ζωn s + ωn^2) where K is the system gain, ζ is the damping ratio, ωn is the natural

frequency, and s is the Laplace

variable.

The step response of the system is the output of the system when the input is a step function, u(t) =
U0 for t >= 0. The Laplace transform of a step function is U0/s, so the output can be found by taking
the inverse Laplace transform of the product of the transfer function and the input:

y(s) = U0 H(s) = U0 K / (s^2 + 2ζωn s + ωn^2) Taking the inverse

Laplace transform, we get: y(t) = U0 [1 - e^(-ζωn t) (cos(ωd t) +

(ζ/sqrt(1-ζ^2)) sin(ωd t))] where ωd = ωn sqrt(1-ζ^2) is the damped

natural frequency.

This equation describes the response of the system to a step input. The step response is initially zero,
then rises to the steady-state value of U0 with a settling time that depends on the damping ratio and
natural frequency. For a critically damped system (ζ = 1), the response reaches the steady-state value
without any overshoot, while an underdamped system (ζ < 1) exhibits overshoot before reaching the
steady-state value, and an overdamped system (ζ > 1) has a slower response with no overshoot.

The impulse response of the system is the output of the system when the input is an impulse function,
δ(t). The Laplace transform of an impulse function is 1, so the output can be found by taking the
inverse Laplace transform of the product of the transfer function and 1:
y(s) = H(s) = K / (s^2 + 2ζωn s + ωn^2)

Taking the inverse Laplace transform, we

get: y(t) = (K/ωn^2) e^(-ζωn t) sin(ωdt )

u(t)

This equation describes the response of the system to an impulse input. The impulse response is a
decaying sine wave with frequency ωd and damping factor ζωn. The impulse response is useful for
analyzing the frequency response of the system and identifying resonant frequencies.

CODE -
pkg load control
clc;
clear;
r=3;
u=2;
s=tf('s');
g=1/(s*s+2*s+r);
figure(1);
step(u*g);
figure(2);
impulse(u*g);

OUTPUT -
Figure - Impulse response

Figure - Step Response


EXPERIMENT NO. 6

AIM- DETERMINATION OF STEP & IMPULSE RESPONSE FOR A TYPE ‘0’, TYPE
‘1’, TYPE ‘2’ SYSTEM

In control system theory, a system is classified as Type 0, Type 1, or Type 2 based on the number of
integrators (or poles at the origin) in its transfer function.

A Type 0 system has no integrators in its transfer function, meaning that the output of the system is
proportional to the input. Examples of Type 0 systems include a simple gain block or an amplifier with
no feedback.

A Type 1 system has one integrator in its transfer function, meaning that the output of the system is
proportional to the integral of the input. Examples of Type 1 systems include a simple first-order
lowpass filter or an integrator with unity feedback.

A Type 2 system has two integrators in its transfer function, meaning that the output of the system is
proportional to the double integral of the input. Examples of Type 2 systems include a simple
secondorder low-pass filter or a cascaded integrator-comb filter.

The type of a system is important in control theory because it determines the system's steady-state
response to a step input. A Type 0 system will have a non-zero steady-state output for a non-zero
step input, while a Type 1 system will have zero steady-state error for a step input, but non-zero
steadystate error for a ramp input. A Type 2 system will have zero steady-state error for both step and
ramp inputs.

Knowing the type of a system is also important in designing controllers, as it affects the controller's
performance and stability. For example, a Type 0 system may require a proportional (P) controller,
while a Type 1 system may require a proportional-integral (PI) controller, and a Type 2 system may
require a proportional-integral-derivative (PID) controller for optimal performance.

CODE - TYPE 0

pkg load control


num = [1];
den = [1 1 4];
g=tf(num,den);
t=feedback(g,1);
figure(1);
step(t,'r');
figure(2);
impulse(t,'r')
OUTPUT -

Figure - Impulse Response of type 0 system

Figure - Step Response of type 0 system


TYPE 1 -
pkg load control num = [1]; den = [0 1 1 4];
g = tf (num,den);
t = feedback(g,1);
figure(1);
impulse(t,'r');
figure(2);
step(t,'r');

Output -

Figure - Impulse Response of type 1 system

Figure - Step response of type 1


CODE – TYPE 2
pkg load control
num = [1];
den = [0 0 1 1 4];
g = tf (num,den);
t = feedback(g,1);
figure(1);
step(t,'r');
figure(2);
impulse(t,'r');

OUTPUT -

Figure - Impulse response and step response of type 2 system


EXPERIMENT NO. 7

AIM - TO OBTAIN THE ROOT LOCUS OF THE TRANSFER FUNCTION

THEORY -
Root locus is a graphical method used to analyze the stability of a system in control theory. It is a plot
of the locations of the closed-loop system poles as a parameter, such as the gain or a controller
parameter, is varied.

The root locus is typically drawn on the complex plane, with the real and imaginary parts of the
closedloop system poles plotted as a function of the parameter being varied. By analyzing the root
locus, one can determine the stability of the system and design a controller that satisfies specific
requirements, such as gain margin and phase margin.

The root locus method is based on the concept that the stability of a system depends on the location
of the closed-loop poles. Specifically, if all the poles of the closed-loop system lie on the left-hand side
of the complex plane, the system is stable, and if any of the poles lie on the right-hand side of the
complex plane, the system is unstable.

The root locus is used to find the values of the parameter for which the poles of the closed-loop
system lie on the imaginary axis. These are called the breakaway and re-entry points, and they
represent the limits of the region of stability for the system. The root locus can also be used to find the
gain and phase margins of the system.

Overall, the root locus is a powerful tool for designing controllers and analyzing the stability of
systems in control theory.

CODE -
pkg load control
clc;
clear;
num = [1 1]
den = conv([1 0],[.5 1])
g = tf(num,den); rlocus(g)

OUTPUT -
Root locus of transfer function
EXPERIMENT NO. 8

AIM - DETERMINATION OF BODE PLOT FOR SECOND ORDER SYSTEM

THEORY -
A Bode plot is a graphical representation of the frequency response of a system. It is named after its
creator, Hendrik W. Bode. The Bode plot shows the magnitude and phase of the transfer function of a
system, plotted against frequency on a logarithmic scale.

The magnitude plot shows the amplitude ratio between the output and input signals, measured in
decibels (dB), as a function of frequency. The phase plot shows the phase shift between the output
and input signals, measured in degrees, as a function of frequency.

The Bode plot is useful for analyzing the frequency response of a system, including gain and phase
margins. The gain margin is the amount of gain that can be added to the system before it becomes
unstable, while the phase margin is the amount of phase shift that can be added before the system
becomes unstable.

The Bode plot can also help identify the system's poles and zeros, which are the frequencies at which
the system's transfer function has infinite or zero gain, respectively. The location of these poles and
zeros can provide insight into the system's behavior, such as its resonant frequencies and damping
characteristics.

Overall, the Bode plot is a powerful tool for understanding and designing systems in a variety of fields,
including control theory, signal processing, and electrical engineering.

CODE -

pkg load control


clc;
clear;
num = [1 1]
den = conv([1 0],[.5 1])
g = tf(num,den); rlocus(g)

OUTPUT -
Figure - Bode plot of transfer function
EXPERIMENT - 9

AIM - DETERMINATION OF NYQUIST PLOT

THEORY -
A Nyquist plot is a graphical representation of the frequency response of a system, often used in
control theory. It plots the complex plane of the system's transfer function, where the real part of the
transfer function is plotted on the horizontal axis, and the imaginary part is plotted on the vertical axis.

The Nyquist plot is created by sweeping through a range of frequencies, and plotting the
corresponding points on the complex plane. By analyzing the shape of the Nyquist plot, one can gain
insights into the stability and performance of the system.

For example, the Nyquist plot can help identify whether a system is stable or unstable, by checking if
the plot encircles the point (-1,0) in the complex plane. If the plot encircles this point in a clockwise
direction, then the system is unstable. If it does not encircle this point, or if it encircles it in a
counterclockwise direction, then the system is stable.

The Nyquist plot can also be used to analyze the frequency response of the system, including gain
and phase margins. The gain margin is the amount of gain that can be added to the system before it
becomes unstable, while the phase margin is the amount of phase shift that can be added before the
system becomes unstable. These margins can be read off the Nyquist plot and used to optimize the
performance of the system.

CODE -

pkg load control


clc; clear;
num = [1 2];
den= conv ([1 1] , [1 -1]);
g=tf(num,den);
nyquist(g);
OUTPUT -
Figure - Nyquist Plot of transfer function
EXPERIMENT – 10

AIM: Under damped, overdamped, critically damped system

THEORY -

An overdamped system takes much more time to achieve a steady state value. An
underdamped system exhibits overshoot and also takes more time to achieve a steady state
value. A critically damped system achieves steady state value the fastest, and without
overshoot.
If δ > 1, the two roots are real and we have an over damped system.
If δ= 1, the system is known as a critically damped system.

If 0< δ < 1, we have an under damped system.


If δ < 0, we have an undamped system.

CODE -

% Define the natural frequency


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

% Define different damping ratios


zeta_under = 0.5; % Underdamped
zeta_crit = 1; % Critically damped
zeta_over = 2; % Overdamped
zeta_undamp = 0; % Undamped

% Define the transfer functions for each case


sys_under = tf([omega_n^2], [1 2*zeta_under*omega_n omega_n^2]);
sys_crit = tf([omega_n^2], [1 2*zeta_crit*omega_n omega_n^2]);
sys_over = tf([omega_n^2], [1 2*zeta_over*omega_n omega_n^2]);
sys_undamp = tf([omega_n^2], [1 2*zeta_undamp*omega_n omega_n^2]);

% Plot the step response for each case


figure;
hold on;
step(sys_under, 'r');
step(sys_crit, 'g');
step(sys_over, 'b');
step(sys_undamp, 'k');
legend('Underdamped', 'Critically Damped', 'Overdamped', 'Undamped');
title('Step Response of Different Damping Conditions');
xlabel('Time (s)');
ylabel('Amplitude');
hold off;

OUTPUT -

You might also like