I. Bode Plots [ Gain and phase margin | Bandwidth frequency | Closed loop response ]
II. The Nyquist Diagram [ The Cauchy criterion | Closed loop stability | Gain margin | Phase margin ]
In order to see how the frequency vector contributes to the Nyquist diagram more clearly, you can view our movie.
However, if we have open-loop poles or zeros on the jw axis, G(s) will not be defined at those points, and we must loop around them when we are plotting the contour. Such a contour would look as follows:
Please note that the contour loops around the pole on the jw axis. As we mentioned before, the MATLAB nyquist command does not take poles or zeros on the jw axis into account and therefore produces an incorrect plot. To correct this, please download and use nyquist1.m. If we have a pole on the jw axis, we have to use nyquist1. If there are no poles or zeros on the jw-axis, or if we have pole-zero cancellation, we can use either the nyquist command or nyquist1.m.
When studying feedback controls, we are not as interested in G(s) as in the closed-loop transfer function:
G(s) --------- 1 + G(s)
Therefore, the behavior of the Nyquist diagram around the -1 point in the real axis is very important; however, the axis on the standard nyquist diagram might make it hard to see what's happening around this point. To correct this, you can add the lnyquist.m function to your files. The lnyquist.m command plots the Nyquist diagram using a logarithmic scale and preserves the characteristics of the -1 point.
To view a simple Nyquist plot using MATLAB, we will define the following transfer function and view the Nyquist plot:
0.5 ------- s - 0.5
sys=tf(0.5,[1 -0.5]); nyquist(sys)
s + 2 ----- s^2
num = [1 2]; den = [1 0 0]; sys = tf(num,den); nyquist(sys)
Note that the nyquist plot is not the correct one, the nyquist1 plot is correct, but it's hard to see what happens close to the -1 point, and the lnyquist plot is correct and has an appropriate scale.
Consider the negative feedback system:
Closed Loop Stability
Consider the negative feedback system:
The Nyquist criterion then states that:
Z = P + N
Note: This is only one convention for the Nyquist criterion. Another convention states that a positive N counts the counter-clockwise or anti-clockwise encirclements of -1. The P and Z variab remain the same. In this case the equation becomes Z = P - N. Throughout these tutorials, we will use a positive sign for clockwise encirclements.
It is very important (and somewhat tricky) to learn how to count the number of times that the diagram encircles -1. Therefore, we will go into some detail to help you visualize this. You can view this movie as an example.Knowing the number of right-half plane (unstable) poles in open loop (P), and the number of encirclements of -1 made by the Nyquist diagram (N), we can determine the closed-loop stability of the system. If Z = P + N is a positive, nonzero number, the closed-loop system is unstable.
Another way of looking at it is to imagine you are standing on top of the -1 point and are following the diagram from beginning to end. Now ask yourself: How many times did I turn my head a full 360 degrees? Again, if the motion was clockwise, N is positive, and if the motion is anti-clockwise, N is negative.
We can also use the Nyquist diagram to find the range of gains for a closed-loop unity feedback system to be stable. The system we will test looks like this:
The first thing we need to do is find the number of positive real poles in our open-loop transfer function:
roots([1 -8 15]) ans = 5 3The poles of the open-loop transfer function are both positive. Therefore, we need two anti-clockwise (N = -2) encirclements of the Nyquist diagram in order to have a stable closed-loop system (Z = P + N). If the number of encirclements is less than two or the encirclements are not anti-clockwise, our system will be unstable.
Let's look at our Nyquist diagram for a gain of 1:
sys = tf([ 1 10 24], [ 1 -8 15]); nyquist(sys)
There are two anti-clockwise encirclements of -1. Therefore, the system is stable for a gain of 1. Now we will see how the system behaves if we increase the gain to 20:
The diagram expanded. Therefore, we know that the system will be stable no matter how much we increase the gain. However, if we decrease the gain, the diagram will contract and the system might become unstable. Let's see what happens for a gain of 0.5:
The system is now unstable. By trial and error we find that this system will become unstable for gains less than 0.80. We can verify our answers by zooming in on the Nyquist plots as well as by looking at the closed-loop steps responses for gains of 0.79, 0.80, and 0.81.
The open-loop system represented by this plot will become unstable in closed loop if the gain is increased past a certain boundary. The negative real axis area between -1/a (defined as the point where the 180 degree phase shift occurs...that is, where the diagram crosses the real axis) and -1 represents the amount of increase in gain that can be tolerated before closed-loop instability.
If we think about it, we realize that if the gain is equal to a, the diagram will touch the -1 point:
GM = 20*log10(a) [dB]
sys = tf(50, [1 9 30 40 ]); nyquist(sys)
As we discussed before, all that we need to do to find the gain margin is find 'a', as defined in the preceding figure. To do this, we need to find the point where there is exactly 180 degrees of phase shift. This means that the transfer function at this point is real (has no imaginary part). The numerator is already real, so we just need to look at the denominator. When s = j*w, the only terms in the denominator that will have imaginary parts are those which are odd powers of s. Therefore, for G(j*w) to be real, we must have:
-j w^3 + 30 j w = 0
w=sqrt(30); polyval(50,j*w)/polyval([1 9 30 40],j*w)You should get the following output from MATLAB
ans = -0.2174
We found that the 180 degrees phase shift occurs at -0.2174 + 0i. This point was previously defined as -1/a. Therefore, we now have 'a', which is the gain margin. However, we need to express the gain margin in decibels,
a = 4.6 nyquist(a*sys)
Let's analyze the previous plot and think about what is happening. From our previous example we know that this particular system will be unstable in closed loop if the Nyquist diagram encircles the -1 point. However, we must also realize that if the diagram is shifted by theta degrees, it will then touch the -1 point at the negative real axis, making the system marginally stable in closed loop. Therefore, the angle required to make this system marginally stable in closed loop is called the phase margin (measured in degrees). In order to find the point we measure this angle from, we draw a circle with radius of 1, find the point in the Nyquist diagram with a magnitude of 1 (gain of zero dB), and measure the phase shift needed for this point to be at an angle of 180 deg.