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

exp-4,Bode_plot

The document outlines an experiment to obtain Bode magnitude and phase plots of transfer functions using MATLAB, focusing on system stability analysis. It includes prerequisites, objectives, theoretical background on Bode plots, and procedures for generating plots and calculating gain and phase margins. The experiment aims to enhance understanding of system stability through practical application in MATLAB with various transfer functions.

Uploaded by

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

exp-4,Bode_plot

The document outlines an experiment to obtain Bode magnitude and phase plots of transfer functions using MATLAB, focusing on system stability analysis. It includes prerequisites, objectives, theoretical background on Bode plots, and procedures for generating plots and calculating gain and phase margins. The experiment aims to enhance understanding of system stability through practical application in MATLAB with various transfer functions.

Uploaded by

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

S. Y. B.

Tech Trimester: VI Subject: Control


System
Name: Class:
Roll No: Batch:

Experiment No:4

Name of the Experiment: To obtain Bode magnitude and phase plot of the transfer
function using MATLAB.

Marks Teacher’s Signature with date


Performed on:

Submitted on:

Aim: To obtain Bode magnitude and phase plot of the transfer function using
MATLAB.

Prerequisite:
 knowledge of various types of signals
 Idea about software MATLAB

Objective:
 To judge the stability of the system from its open loop transfer function.
 To find the margin of the system both in terms of gain &phase in which
system parameters can be varied to work in stability mode.

THEORY:

1. Introduction: In practice the time response curves of systems higher than


second order is through computer simulation. This experiment shows us the
computational approach to the transient-response with MATLAB. In particular
step and ramp responses are discussed in detail.

MATLAB is a high-performance language for technical computing. It


integrates computation, visualization, and programming in an easy-to-use
environment where problems and solutions are expressed in familiar
mathematical notation. Typical uses include Mathematical computation,
Algorithm development, Data acquisition Modeling, simulation, and
prototyping, Data analysis, exploration, and visualization Scientific and
engineering graphics, Application development, including graphical user
interface building.

MATLAB is an interactive system whose basic data element is an array that


does not require dimensioning. This allows you to solve many technical
computing problems, especially those with matrix and vector formulations, in
a fraction of the time it would take to write a program in a scalar non-
interactive language such as C or Fortran. The name MATLAB stands for
matrix laboratory.

MATLAB features a family of add-on application-specific solutions called


toolboxes. Very important to most users of MATLAB, toolboxes allow you to
learn and apply specialized technology. Toolboxes are comprehensive
collections of MATLAB functions (M-files) that extend the MATLAB
environment to solve particular classes of problems. Areas in which toolboxes
are available include signal processing, control systems, neural networks,
fuzzy logic, wavelets, simulation, and many others.

2. Bode plot: The transfer function of a system is:

Putting s = j for sinusoidal excitation:

Taking natural logarithms on both sides:

The real part is the natural logarithm of the magnitude measured in


“nepers”, while the imaginary part is the phase measured in degrees or radians.

Similarly, taking logarithms on both sides:

Therefore the Bode plot representation of the transfer function of a LTIV


system comprises of two plots viz.:

(i) log magnitude vs logarithm of frequency


(ii) phase vs logarithm of frequency
In practice, the logarithmic magnitude is plotted as in
decibels (dB) vs frequency in Hz on a logarithmic scale on semi-log graph
paper, using the linear scale for (Y axis) and the log scale for frequency (X
axis). Similarly, the phase plot is drawn on semi-log graph paper using the
linear scale for  and the log scale for frequency.

A unit change in corresponds to or f2 = 10 f1 . This


range of frequencies is called a decade. Similarly, the range of frequencies f2
= 2 f1 is called an octave.

For a simple pole, the log magnitude plot at frequencies much lower than the
corner frequency
can be approximated by the constant (horizontal) 0 dB line, while at
frequencies

much higher than , it can be approximated by a straight line having a slope


of –20 dB/decade or –6 dB/octave. Using this asymptotic approximation, the
maximum error of –3 dB occurs at the corner frequency. Similarly, the phase
plot at very low and at very high frequencies can be approximated by the
constant (horizontal) 0 line and constant (horizontal) --90 line, respectively,
while for frequencies between 0.1 and 10 it can be approximated by a
straight line having a slope of –45 dB/decade passing through (-45, ).
Using this asymptotic approximation, the error at frequencies 0.1 and 10
is –5.7 and +5.7, respectively.

For a simple zero, the log magnitude plot at frequencies much lower than the
corner frequency
can be approximated by the constant (horizontal) 0 dB line,

while at frequencies much higher than , it can be approximated by a straight


line having a slope of +20 dB/decade or +6 dB/octave. Using this asymptotic
approximation, the maximum error of –3 dB occurs at the corner frequency.
Similarly, the phase plot at very low and at very high frequencies can be
approximated by the constant (horizontal) 0 line and constant (horizontal) -
+90 line, respectively, while for frequencies between 0.1 and 10 it can be
approximated by a straight line having a slope of +45 dB/decade passing
through (+45, ). Using this asymptotic approximation, the error at
frequencies 0.1 and 10 is +5.7 and -5.7, respectively.

The main application of the Bode plot is to determine the relative stability of
closed loop systems. The stability of these systems can be investigated by:
(i) phase margin PM
(ii) gain margin GM

3. Phase margin: It is defined as the amount of additional phase lag at the gain
crossover frequency, required to bring the system on the verge of instability.
The gain crossover frequency is the frequency at which the magnitude, ,
of the open-loop transfer function is unity (0 dB). The phase margin, PM, is
180 plus the phase angle  of the open-loop transfer function at the gain
crossover frequency, or

PM = 180 + 

From the Bode plot, PM is obtained as the vertical distance in degrees between
the phase locus and the  = -180 axis at the gain crossover frequency. PM is
defined as positive if the phase locus is above the  = -180 axis. For a
minimum phase system to be stable, PM must be positive.

4. Gain margin: It is defined as the reciprocal of the magnitude, , of the


open-loop transfer function at the phase crossover frequency i.e. the frequency
at which the phase of the open-loop transfer function is 180. For a minimum
phase system to be stable, GM must be positive.

5.Gain crossover frequency: The frequency at which the magnitude of the


sinusoidal open loop transfer function is unity, is called the gain crossover
frequency, denoted by wgc.
6.Phase crossover frequency: The frequency at which thephase angle of the
sinusoidal open loop transfer function is 180 degrees, is called the phase
crossover frequency, denoted by wpc.

To plot the Bode plot using MATLAB

To plot the bode plot using MATLAB, the functions used are bode and
logspace. The bode function is used to generate a bode diagram and the
logspace function generates a logarithmically spaced vector of frequencies
utilized by the bode function.

a. To obtain the Bode plot:

%................... BODE PLOT OF A SYSTEM...............

%Generate the numerator and the denominator of the transfer function.


%For second order systems, the values of 'wn' and 'zeta' have to be
%entered, while for a general system the numerator & denominator
%Specify the frequency range using the command 'bode(num,den,w)'.
%When invoked with left hand side arguments 'bode' returns the frequency
response of the
%system e.g. [mag,phase,w] = bode[num,den,w], will give the magnitude and
the
%phase of the frequency response in the matrices 'mag' and 'phase'
respectively,
%evaluated at user specified frequency points.
%logspace(d1,d2,n) command generates 'n' number of logarithmically equally
spaced points
%between decades 10^d1 and 10^d2. Therefore 'logspace(-2,3,100)' generates
100 number of
%logarithmically equally spaced points %between decades 0.01rad/sec and
1000rad/sec.
Code:
%Clear all figure windows
%Clear all figure windows

close all;

%Create the first figure window (Figure No.1)

subplot(2,1,1);
num=[0 9 1.8 9];
den=[1 1.2 9 0];
w=logspace(-2,3,100);
[mag,phase,w] = bode(num,den,w);
%convert mag to decibels
magdB = 20*log10(mag);
%Specify the range for magnitude.
dBmax= 50*ones(1,100);
dBmin= -50*ones(1,100);
To plot the magnitude(dB), enter the 'semilogx' command %which selects a
semilog scale on the X axis.
semilogx(w,magdB,’o’,w, magdB,’-’,w, dBmax,’-’,w, dBmin,’-’)
grid %Enter grid, title, xlabel and ylabel.

title(‘Bode magnitude plot of G(s)’);


xlabel(‘frequency(rad/sec)’);
ylabel(‘Gain in dB’);

%Plot the phase plot.


subplot(2,1,2);
semilogx(w,phase,'-',w,phase,'-');
%Specify the range for the phase angle.
pmax=150*ones(1,100);
pmin= -150*ones(1,100);
%To plot the phase plot, enter the
%'semilogx' command, which selects a semilog scale on the X axis.
semilogx(w,phase’o’,w, phase,’-’,w, pmax,’-’,w, pmin,’-’);
grid %Enter grid, title, xlabel and ylabel.

title(‘Bode phase plot of G(s)’);


xlabel(‘frequency(rad/sec)’);
ylabel(‘phase in degrees’);

%To obtain the gain and phase margins use the 'margin' command which
derives
%the gain and phase margins from the Bode magnitude, phase, and frequency
vectors
%'mag', 'phase', and 'w' produced by 'bode'. Interpolation is performed
%between the frequency points to estimate the values.

[Gm,Pm,wgc,wpc] = margin(mag,phase,w);
Gm_dB = 20*log10(Gm);
legend('gainmargin = ',num2str(Gm_dB),'dB','phase margin =
',num2str(Pm),'degrees');

%Create the second figure window (Figure No.2)

figure;

%Display the gain & phase margins graphically

margin(sys);

4. PROCEDURE:
1)Run the program for Bode plot ( named bode_plot.m) by assigning different
values of wn and ζ for a second order system(for example (wn, ζ ) = (1.0, 0.2),
(1.0, 0.4), (1.0, 0.6), (1.0, 0.8), (1.0, 1.0), (1.0, 1.2), (1.0, 1.4), (2.0, 0.6), (2.0,
1.0), (2.0, 1.2) etc.). Observe the output response and note the values of Gain
margin and Phase margin obtained from the program.
2)Run the program for general systems of higher order given below:

a) G(s)H(s) = 16/s(s2+5*s+121)
b) G(s)H(s) = 100(s+4)/s(s+0.5)(s+10)
c) G(s)H(s) = 900(s+1)/s2(s+10)(s+400)
d) G(s)H(s) = 6(s+2)(s+6)/s2(s2+18*s+400)
Note the Gain margin, Phase margin Gain crossover frequency and Phase
crossover frequency for each of the system.

5. CONCLUSIONS:

Post lab questions:


1) How stability of the system can be judged by bode plot.
2) Comment on the systems stability you have checked with
MATLAB.
3) What do you mean by gain margin & phase margin?

You might also like