Lab Experiment 13

download Lab Experiment 13

of 12

Transcript of Lab Experiment 13

  • 7/28/2019 Lab Experiment 13

    1/12

    International Islamic University, IslamabadFaculty of Engineering and Technology

    Department of Electronic Engineering

    CONTROL SYSTEMS LAB

    LAB EXPERIMENT # 13: Root Locus and Bode Plot Analysis using

    MATLAB

    Name of Student:

    Registration No.:

    Section:

    Date of Experiment:

    Report submitted on:

    Marks obtained:

    Remarks:

    Instructors Signature: ...

  • 7/28/2019 Lab Experiment 13

    2/12

    Lab13: Root Locus and Bode Plot Analysis using MATLAB

    Control Systems Lab (EE 360 L) Page 105

    Lab Experiment 13: Root Locus and Bode Plot Analysis using MATLAB

    Objective: The primary objective of this experiment is to learn Root Locus and concepts ofBode Plots, Phase Margin and Gain Margin will addressed using MATLAB.

    List of Equipment/SoftwareFollowing equipment/software is required:

    MATLAB

    Part I: Root Locus

    Introduction:

    Application of the many classical and modern control system design and analysis tools is basedon mathematical model. MATLAB can be used with systems given in the form of transfer

    function description. We are interested in how MATLAB can assist us in determining:

    1) the number of branches.2) the starting and ending points of all the branches.3) the intersections of the root loci with the imaginary axis and the corresponding value ofK.4) the systems oscillating frequency associated with the gain K.5) the breakaway and break-in points.6) the value ofKat breakaway point.

    Root Locus

    The root locus of an (open-loop) transfer function H(s) is a plot of the locations (locus) of allpossible closed loop poles with proportional gain Kand unity feedback:

    The closed-loop transfer function is:()

    ()=

    ()

    1+()

    and thus the poles of the closed loop system are values ofs such that 1 + K H(s) = 0.If we write H(s) = b(s)/a(s), then this equation has the form:

    () + () = 0()

    + () = 0

    Let n = order of a(s) and m = order of b(s) [the order of a polynomial is the highest power of s

    that appears in it].

  • 7/28/2019 Lab Experiment 13

    3/12

    Lab13: Root Locus and Bode Plot Analysis using MATLAB

    Control Systems Lab (EE 360 L) Page 106

    We will consider all positive values of K. In the limit as K 0, the poles of the closed-loop

    system are a(s) = 0 or the poles of H(s). In the limit as K , the poles of the closed-loopsystem are b(s) = 0 or the zeros of H(s).

    Independently from K, the closed-loop system must always have n poles, where n is the

    number of poles of H(s). The root locus must have n branches, each branch starts at a pole of

    H(s) and goes to a zero of H(s). If H(s) has more poles than zeros (as is often the case), m < nand we say that H(s) has zeros at infinity. In this case, the limit of H(s) as s infinity is zero.

    The number of zeros at infinity is n-m, the number of poles minus the number of zeros, and is thenumber of branches of the root locus that go to infinity (asymptotes).

    Since the root locus is actually the locations of all possible closed loop poles, from the root locus

    we can select a gain such that our closed-loop system will perform the way we want. If any ofthe selected poles are on the right half plane, the closed-loop system will be unstable. The poles

    that are closest to the imaginary axis have the greatest influence on the closed-loop response, so

    even though the system has three or four poles, it may still act like a second or even first order

    system depending on the location(s) of the dominant pole(s).

    Example 1: GivenF(s) =

    ( s+2)(s+4)

    (+3)(+6)

    find F(s) at the point s = -7 +j9 the following ways:

    a. Directly substituting the point into F(s)

    b. Calculating the result using vectors

    MATLAB Code:

    s=- 7 + 9j ; G=( s+2) *( s+4) / ( s*( s+3) *( s+6) ) Theta=( 180/ pi ) * angl e( G) M=abs( G)

    Example 2: Given the unity feedback system that has the forward transfer function

    () = (+2)

    (+4+13)

    Do the following:a. Calculate the angle ofG(s) at the point ( - 3 + /0) by finding the algebraic sum of angles of the

    vectors drawn from the zeros and poles ofG(s) to the given point.

    b. Determine if the point specified in a is on the root locus.c. If the point specified in a is on the root locus, find the gain, K, using the lengths of the vectors.

    MATLAB Code:s = - 3 + 0j ;G=( s+2) / ( s*2+4*s+13)Theta=( 180/ pi ) *angl e( G)M=abs( G)K=1/ M

  • 7/28/2019 Lab Experiment 13

    4/12

    Lab13: Root Locus and Bode Plot Analysis using MATLAB

    Control Systems Lab (EE 360 L) Page 107

    Example 3: Sketch the root locus for the system shown in Figure below and findthe following:

    a.The exact point and gain where the locus crosses the 0.45 damping ratio lineb.The exact point and gain where the locus crosses the j-axisc.

    The breakaway point on the real axisd.The range ofKwithin which the system is stable

    SOLUTION: The problem solution is shown, in part, in Figure 8.19(6). First sketch the root locus. UsingRule 3, the real-axis segment is found to be between - 2 and -4. Rule 4 tells us that the root locus starts at

    the open-loop poles and ends at the open-loop zeros. These two rules alone give us the general shape of

    the root locus.

    a. To find the exact point where the locus crosses the = 0.45 line, we can use the root locusprogram discussed in Appendix H.2 at www.wiley.com/college/ nise to search along the line

    i. = 180 - cos-1for the point where the angles add up to an odd multiple of 180. Searching in polar coordinates,

    we find that the root locus crosses the = 0.45 line at 3.4 116.7 with a gain, K, of 0.417.

    (0.45) = 116.7 (8.52)

  • 7/28/2019 Lab Experiment 13

    5/12

    Lab13: Root Locus and Bode Plot Analysis using MATLAB

    Control Systems Lab (EE 360 L) Page 108

    b. To find the exact point where the locus crosses thej-axis, use the root locus program to searchalong the line :

    = 90

    c. for the point where the angles add up to an odd multiple of 180. Searching in polar coordinates,we find that the root locus crosses thej-axis at 3.9 with a gain ofK = 1.5.

    d. To find the breakaway point, use the root locus program to search the real axis between -2 and - 4for the point that yields maximum gain. Naturally, all points will have the sum of their anglesequal to an odd multiple of 180. A maximum gain of 0.0248 is found at the point -2.88.

    Therefore, the breakaway point is between the open-loop poles on the real axis at -2.88.

    e. From the answer to b, the system is stable forKbetween 0 and 1.5.MATLAB Code:

    cl f % Cl ear gr aph on scr een. numgh=[ l - 4 20] ; % Def i ne numer at or of G ( s) H ( s) . dengh=pol y( [ - 2 - 4] ) ; % Def i ne denomi nat or of G ( s) H ( s) .' G( s)H( s) ' % Di spl ay l abel .

    GH=t f ( numgh, dengh) % Cr eat e G ( s) H( s) and di spl ay. r l ocus( GH) % Dr aw r oot l ocus . z=0. 2: 0. 05: 0. 5; % Def i ne dampi ng r at i o val ues : 0. 2

    % t o 0 . 5 i n st eps of 0 . 05 . wn=0: l : 10; % Def i ne nat ur al f r eguency val ues :

    % 0 t o 10 i n st eps of 1. sgr i d( z, wn) % Generat e dampi ng rat i o and

    % nat ur al f r eguency gr i d l i nes f or r oot l ocus . t i t l e ( ' Root Locus' ) % Def i ne t i t l e f or r oot l ocus . pauser l ocus( GH) % Dr aw cl ose- up r oot l ocus . axi s ( [ - 3 1 - 4 4] ) % Def i ne range on axes f or r oot

    % l ocus cl ose- up vi ew. t i t l e ( ' Cl ose- up' ) % Def i ne t i t l e f or cl ose- up r oot l ocus .

    z=0. 45 ; % Def i ne dampi ng r at i o l i ne f or % over l ay on cl ose- up r oot l ocus.

    wn=0; % Suppr ess nat ur al f r equency over l ay cur ves . sgr i d ( z, wn) % Over l ay dampi ng r at i o cur ve on cl ose- up r ootl ocus . f or k = l : 3 % Loop al l ows 3 poi nt s t o be

    % sel ect ed as per Exampl e 8. 7, %( z=0. 45, j w cr ossi ng , br eak away) .

    [ K, p] =r l ocf i nd( GH) % Gener at e gai n, K, and cl osed- l oop% pol es, p, f or poi nt sel ected%i nt er act i vel y on t he r oot l ocus.

    end % End l oop . pause

  • 7/28/2019 Lab Experiment 13

    6/12

    Lab13: Root Locus and Bode Plot Analysis using MATLAB

    Control Systems Lab (EE 360 L) Page 109

    Part II: Bode Plots, Phase and Gain Margin

    Introduction:

    The frequency response method may be less intuitive than other methods you have studiedpreviously. However, it has certain advantages, especially in real-life situations such as modeling

    transfer functions from physical data.

    The frequency response of a system can be viewed two different ways: via the Bode plot or viathe Nyquist diagram. Both methods display the same information; the difference lies in the way

    the information is presented. We will explore both methods during this lab exercise.

    The frequency response is a representation of the system's response to sinusoidal inputs atvarying frequencies. The output of a linear system to a sinusoidal input is a sinusoid of the same

    frequency but with a different magnitude and phase. The frequency response is defined as the

    magnitude and phase differences between the input and output sinusoids. In this lab, we will seehow we can use the open-loop frequency response of a system to predict its behavior in closed

    loop.To plot the frequency response, we create a vector of frequencies (varying between zero or "DC"

    and infinity i.e., a higher value) and compute the value of the plant transfer function at thosefrequencies. If G(s) is the open loop transfer function of a system and is the frequency vector,

    we then plot G(j) vs. . Since G(j) is a complex number, we can plot both its magnitude and

    phase (the Bode plot) or its position in the complex plane (the Nyquist plot).

    Bode Plots

    As noted above, a Bode plot is the representation of the magnitude and phase ofG(j) (wherethe frequency vector contains only positive frequencies). To see the Bode plot of a transfer

    function, you can use the MATLAB "bode" command. For example,

    num = 50;den = [ 1 9 30 40] ;sys = t f ( num, den) ;bode( sys) % To pl ot bode pl ot s[ mag, phase, w] =bode( sys)

    This displays the Bode plots for the transfer function:

    50

    ----------------------------s^3 + 9 s^2 + 30 s + 40

  • 7/28/2019 Lab Experiment 13

    7/12

    Lab13: Root Locus and Bode Plot Analysis using MATLAB

    Control Systems Lab (EE 360 L) Page 110

    Please note the axes of the figure. The frequency is on a logarithmic scale, the phase is given in

    degrees, and the magnitude is given as the gain in decibels.

    Note: a decibel is defined as 20*log10 ( |G(j*w| )

    Gain and Phase Margin

    Let's say that we have the following system:

    where K is a variable (constant) gain and G(s) is the plant under consideration. The gain margin

    is defined as the change in open loop gain required to make the system unstable. Systems withgreater gain margins can withstand greater changes in system parameters before becoming

    unstable in closed loop.

    Note: Unity gain in magnitude is equal to a gain of zero in dB.

    The phase margin is defined as the change in open loop phase shift required to make a closed

    loop system unstable.

    The phase margin also measures the system's tolerance to time delay. If there is a time delaygreater than 180/pcin the loop (where pc

    -100

    -80

    -60

    -40

    -20

    0

    20

    Magnitude(dB

    )

    Bode Diagram

    Frequency (rad/s)

    10-1

    100

    101

    102

    -270

    -180

    -90

    0

    Phas

    e(deg)

    is the frequency where the phase shift is 180 deg),

  • 7/28/2019 Lab Experiment 13

    8/12

    Lab13: Root Locus and Bode Plot Analysis using MATLAB

    Control Systems Lab (EE 360 L) Page 111

    the system will become unstable in closed loop. The time delay can be thought of as an extra

    block in the forward path of the block diagram that adds phase to the system but has no effect onthe gain. That is, a time delay can be represented as a block with magnitude of 1 and phase

    *time_delay (in radians/second).

    The phase margin is the difference in phase between the phase curve and -180 deg at the point

    corresponding to the frequency that gives a gain of 0dB (the gain cross over frequency, gc).Likewise, the gain margin is the difference between the magnitude curve and 0dB at the point

    corresponding to the frequency that gives a phase of -180 deg (the phase cross over frequency,

    pc

    ).

    We can find the gain and phase margins for a system directly, by using MATLAB. Just use themargin command. This command returns the gain and phase margins, the gain and phase cross

    over frequencies, and a graphical representation of these on the Bode plot. MATLAB candetermine the phase margin using margin(sys).

    >>margin(sys)

  • 7/28/2019 Lab Experiment 13

    9/12

    Lab13: Root Locus and Bode Plot Analysis using MATLAB

    Control Systems Lab (EE 360 L) Page 112

    Bandwidth Frequency

    The bandwidth frequency is defined as the frequency at which the closed-loop magnitude

    response is equal to -3 dB. However, when we design via frequency response, we are interested

    in predicting the closed-loop behavior from the open-loop response. Therefore, we will use asecond-order system approximation and say that the bandwidth frequency equals the frequency

    at which the open-loop magnitude response is between -6 and - 7.5dB, assuming the open loop

    phase response is between -135 deg and -225 deg. For a complete derivation of thisapproximation, consult your textbook.

    In order to illustrate the importance of the bandwidth frequency, we will show how the output

    changes with different input frequencies. We will find that sinusoidal inputs with frequency lessthan Wbw (the bandwidth frequency) are tracked "reasonably well" by the system. Sinusoidal

    inputs with frequency greater than Wbw

    Let's say that we have the following closed-loop transfer function representing a system:

    are attenuated (in magnitude) by a factor of 0.707 or

    greater (and are also shifted in phase).

    1-------------------

    s^2 + 0.5 s + 1First of all, let's find the bandwidth frequency by looking at the Bode plot:

    num = 1;den = [ 1 0. 5 1] ;sys = t f ( num, den) ;bode ( sys)

    -100

    -80

    -60

    -40

    -20

    0

    20

    Magnitude(dB)

    10-1

    100

    101

    102

    -270

    -180

    -90

    0

    Phase(d

    eg)

    Bode Diagram

    Gm=13.3 dB (at 5.48 rad/s) , Pm=101 deg (at 1.85 rad/s)

    Frequency (rad/s)

  • 7/28/2019 Lab Experiment 13

    10/12

    Lab13: Root Locus and Bode Plot Analysis using MATLAB

    Control Systems Lab (EE 360 L) Page 113

    Since this is the closed-loop transfer function, our bandwidth frequency will be the frequencycorresponding to a gain of -3 dB. looking at the plot, we find that it is approximately 1.4 rad/s.

    We can also read off the plot that for an input frequency of 0.3 radians, the output sinusoid

    should have a magnitude about one and the phase should be shifted by perhaps a fewdegrees(behind the input). For an input frequency of 3 rad/sec, the output magnitude should be

    about -20dB (or 1/10 as large as the input) and the phase should be nearly -180 (almost exactly

    out-ofphase). We can use the "lsim" command to simulate the response of the system to

    sinusoidal inputs.First, consider a sinusoidal input with a frequency lower than Wbw

    w = 0. 3;

    . We must also keep in mind

    that we want to view the steady state response. Therefore, we will modify the axes in order to see

    the steady state response clearly (ignoring the transient response).

    num = 1;den = [ 1 0. 5 1] ;sys = t f ( num, den) ;t = 0: 0. 1: 100;u = si n( w*t ) ;[ y, t ] = l s i m( sys, u, t ) ;pl ot ( t , y, t , u)axi s( [ 50, 100, - 2, 2] )

  • 7/28/2019 Lab Experiment 13

    11/12

    Lab13: Root Locus and Bode Plot Analysis using MATLAB

    Control Systems Lab (EE 360 L) Page 114

    Note that the output (blue) tracks the input (purple) fairly well; it is perhaps a few degrees behind

    the input as expected.

    However, if we set the frequency of the input higher than the bandwidth frequency for thesystem, we get a very distorted response (with respect to the input):

    w = 3;num = 1;den = [ 1 0. 5 1] ;sys = t f ( num, den) ;t = 0: 0. 1: 100;u = si n( w*t ) ;[ y, t ] = l s i m( sys, u, t ) ;pl ot ( t , y, t , u)axi s( [ 90, 100, - 1, 1] )

    Again, note that the magnitude is about 1/10 that of the input, as predicted, and that it is almost

    exactly out of phase (180 degrees behind) the input. Feel free to experiment and view theresponse for several different frequencies w, and see if they match the Bode plot.

    90 91 92 93 94 95 96 97 98 99 100-1

    -0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

  • 7/28/2019 Lab Experiment 13

    12/12

    Lab13: Root Locus and Bode Plot Analysis using MATLAB

    Control Systems Lab (EE 360 L) Page 115

    Exercises

    Exercise 1: Given a unity feedback system that has the forward transfer function

    G(s) =(2)(4)

    (2+6+25)

    do the following using Matlab.a. Sketch the root locus.b. Find the imaginary-axis crossing.c. Find the gain, K, at thej-axis crossing.d. Find the break-in point.e. Find the point where the locus crosses the 0.5 damping ratio line.f. Find the gain at the point where the locus crosses the 0.5 damping ratio line.g. Find the range of gain, K, for which the system is stable.

    Exercise 2: For the system shown in Figure 10.10, where

    () =

    ( + 5)( + 20)( + 50)

    do the following using MATLAB:

    a. Draw the Bode log-magnitude and phase plots.b. Find the range ofKfor stability from your Bode plots.c. Evaluate gain margin, phase margin, zero dB frequency, and 180 frequency from your Bode

    plots forK=10,000.

    d. Find the bandwidth of the system and system response at =2.5 rad/s.