Gain and Phase Margins Explained!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome back to control system lectures in this video we're going to cover gain and phase margins or sometimes referred to as just stability margins now you've probably heard the term gain and phase margin before may have been confused by one part of it or another I know I didn't really understand the topic when I was first taught it and I think it was because all of the important parts were spread out over multiple lectures and it was left up to me to tie it all together well I'll try to tie it all together here so that hopefully you'll get the whole picture and in doing so you'll understand why we use them before we can understand gain and phase margin we first need to understand gain and phase now I cover this in the first few minutes of the introduction to bode plots video but I'll sum it up here for completeness let me draw a linear time-invariant system G of S which acts on an input and generates an output when a sine wave is played through it it's distorted based on the properties of G of s that distortion for an LTI system comes in two ways the magnitude of the system can change and the phase of the signal can change gain is the proportion of the magnitude of the output to the magnitude of the input at steady state so if the output is twice as high as the input we'd say that this system has a gain of two because it multiplied the input by 2 and similarly phases the shift of the signal measured in angle or just fractions of a wavelength so in this case this signal is shifted a quarter of a wavelength which is minus PI over 2 radians or minus ninety degrees sine convention and such that a delay in the signal is a negative phase shift so the output for a single input frequency is a combination of gain and phase shift but here's the thing the gain and phase can be different at different frequencies and they usually are and this is exactly what a bode plot shows you it shows you the gain and phase of a system across the entire frequency spectrum so when we're talking about how much gain and phase margin we have we need to consider all of the frequencies and that's one of the reasons bode plots are so popular for this now there's one other thing i want to mention on gain the word gain is used all the time to indicate a scaling term now while this makes some sense it can be confusing at first to someone trying to learn gain margin let's see if I can clear it up with a series of simple diode ramps let's say G of s equals five now it's obvious that the gain is five at all frequencies because you're just multiplying the input by five but if I add a scaling term here of two then I would say that I've increased the gain by a factor of two and that the system gain is now ten however let's look at a slightly more complex system the gain of the top path is five and the gain of the bottom half is three now the total system gain is five plus three or eight however if I increase the gain of the top path only by two it doesn't increase the system gain by two if we did want to increase the system gain by two we'd have to move the block forward so that it gets applied to all paths but then if I add feedback into this system this game no longer affects the whole system equally again the point that I'm trying to make is that once you determine the gain margin of your system you need to understand exactly which scaling terms can be increased to take advantage of that margin it's not just any path in your system I'll try to be explicit about which gain I'm talking about for the rest of this video especially when I'm talking about the open-loop system versus the closed-loop system okay now let's talk about margin margin is the extra amount of something that you can use in case you need it for example when we're talking gain and phase margin we're referring to the extra gain or phase in the system that we can use before the system starts to oscillate and go unstable this is sort of like our safety net in this design and can also answer the question of how stable is stable designs that have less margin can be considered less stable in a sense because smaller variations in the system could cause instability now I have a real quick sidenote now I don't know if the margins on your paper are derived from the same word but if you think about it that's the part of the paper that you aren't planning on writing in but you could use before you run off the edge and draw on your desk in case it wasn't clear in this analogy drawing on your desk as having your system go unstable so now you might wonder why we design a system with margin built in in the first place well usually when you're designing a control system you're doing so based on a model of the system with mathematical equations or you're testing a control system on physical Hardware under known conditions and then making some sumption 'he's about the way that your physical system will behave beyond the test environment and the problem is that things don't always behave the way you expect for example if you're building a brushless DC motor controller gain and phase errors can come from multiple places if you include the rotor inertia oh could be different than what you predicted so that the commanded torque generates a slightly different acceleration than what you wanted maybe you find out that the voltage regulator is sensitive to temperature changes so when you run the motor in hot weather the power to the motor isn't what you expected perhaps the lubrication on the bearings generate more friction than you expected and so the motor is slower to respond to commands or the digital computer that is pulling in sensor readings and generating commands runs a few milliseconds slower than you thought it would and adds more delay into the system all of these variations plus others can occur when you operate your controller in a real system we call these process variations and typically you want a design to be robust to them you can't know your system perfectly therefore you have to build in margin to account for it so the bottom line is that you'll have uncertainty and how these process variations will affect your system and the more uncertainty you have in your system the more margin or more stability you should design in but to really understand stability margins we first need to understand what makes the system unstable in the first place if you have a system G of S then it's unstable if at least one pole or a root of the characteristic equation is in the right half plane but as I've explained in my video stability of closed-loop systems it sometimes impractical to design a system in closed-loop form and you're much better off designing the open-loop system and then using tools like bode root locus and Nyquist plots to assess the closed-loop stability and performance so let's talk about what characteristics of the open-loop system creates an unstable closed-loop system let's once again start with an open-loop transfer function G of s and when we close the loop around this system with unity feedback the closed-loop transfer function becomes G of s divided by 1 plus G of s so for the closed-loop system to be unstable we need a pole in the right half plane we can also think about it this way an unstable system has a gain of infinity because unstable systems will grow unbounded ly which is infinite gain in order for this transfer function to have a gain of infinity the denominator needs to go to zero and for that to happen G needs to equal minus one aha so we just need to keep our open-loop system G of s away from minus one and our closed-loop system will be stable the minus one point should sound familiar to you because it's the exact same minus one point that you're also trying to avoid on a Nyquist plot and the gain of a minus one system is one or zero decibels because it doesn't scale the input by any factor and the phase is minus 180 degrees because it flips the input upside down which is a phase shift of half of a wavelength so the minus 1 point can be represented by zero DB gain and minus 180 degrees phase and if any one frequency across the spectrum hits that point the entire system is unstable so we need to stay away from that point at all frequencies so now we can finally quantify what we mean by margin margin tells us how far away from the minus 1 point or 0 DB and minus 180 degrees phase we really are so now we can finally talk about the bode plot and let me draw a blank one here and you can clearly see the zero DB line on the gain plot and the minus 180 degree line on the phase plot we're trying to avoid this combination in our system at every frequency now draw an arbitrary set of lines on the plot just to illustrate my point this doesn't relate to any specific transfer function just yet let's start with gain first when I increase the gain this adjusts the gain curve up and down uniformly by the amount of the gain in decibels but it has no effect on the phase plot remember also that this is the gain for the open loop system G of s which means I'm talking about a gain block that applies to the entire system G of s which goes right here and in this case when we move the gain up the zero DB point called the crossover frequency moves more to the right and closer to the frequency that has minus under and degrees phase shift therefore it becomes less stable and if we increase the gain such that the crossover frequency matches the minus 180 degree phase frequency we hit that dreaded minus one point and we go unstable and you should be able to clearly see that the gain required for this is exactly the gain at the minus 180 degree phase frequency because that's how much we have to increase it before it gets to zero decibels and that is called the gain margin similarly delay in the system like the delay in digital computers only affects the phase and doesn't adjust the gain plot and you can use a similar technique for the phase margin at zero DB gain how much phase delay would it take to reach minus 180 degrees and this is the phase margin in the case that I just drew it might take 150 degrees more delay before the system went unstable and you can see it's fairly straightforward to pull them off of a bode plot we can also pull these numbers very easily from MATLAB let me show you first let me define a state variable s it just makes it a little bit easier to define transfer functions later on and now I'll define my open-loop transfer function G of s and finally we can use the bode function to plot it and define phase margin we just look at the gain crossover frequency and go down to the phase plot and we can see that we have about 120 degrees of phase and then similarly we can look at where the phase plot crosses the minus 180 degree point and look up at the gain plot and see that we have about 10 decibels of gain margin of course the simpler thing to do is just to plot all stability margins in MATLAB and then you can double check and see that the phase margin is actually 120 degrees but the gain margin is more like around 12 decibels now while these numbers tell us a lot and they are important they don't tell us the whole stability margin story if any one thing happens either change in gain only or change in phase only we know how much our system can handle before it goes unstable but remember when I said it matters where the gain is applied if the term in your system that you're unsure about is this one then adjusting it does change the phase also let's cut it in half and see how it affects our system and the plot looks very different in fact reducing it made our system have almost no margin at all which at first might seem a little incredible because why would reducing a number cause our system to almost go unstable but the key is that it's important to note that gain and phase margin only refers to margin in the whole open-loop system and uncertainty in one particular parameter might affect you more than you think and finally let me show you another example of an open-loop system that might mislead you into thinking that your system is very very stable when actually it isn't let's use this as our G of s we can plot the bode plot in MATLAB and make a few statements right off the bat when the system has infinite gain margin because the phase plot never crosses minus 180 degrees and that means you can add any gain you want and the closed-loop system will never go unstable and - the system has about 70 degrees of phase margin which is actually pretty good and if I plot the gain and phase margins in MATLAB they'll confirm this but look at this dip in the phase plot that means that if we add just a small amount of phase lag into the system then we would be very close to an unstable system because of how close the gain plot is to zero dB at that frequency so instead of 70 degrees of phase margin realistically we only have a few degrees these are the types of situations you need to be careful about when you're designing a system let me plot the Nyquist plot for this exact same open-loop transfer function and see if we can deduce another metric that will help us inform stability okay this is a funky shaped Nyquist plot but if I draw the minus 1 point here you can see that there's no amount of gain that will cause us to reach that point and that's because the gain is 0 when it crosses the real axis also you can see that it would take about 70 degrees of phase lag or rotation of this plot to get to the minus 1 point however like the dip we saw in the bode plot Nyquist plot has this logo over here that's very close to the minus one point and that's the danger zone so in addition to the gain and phase margin we could also look at the closest point the curve makes to minus 1 and make some claim that the closer the two are the less stable the system is that metric is called the sensitivity of the system and I'm going to talk about that in the next video alright it got a bit crazy there at the end but I hope this helped clear up a few things regarding gain and phase margin and if you still have questions please leave them in the comments below and I or another viewer can answer them don't forget to subscribe so you don't miss any future videos and thanks for watching
Info
Channel: Brian Douglas
Views: 468,925
Rating: 4.9664569 out of 5
Keywords: Feedback, Control System Lectures, Theory, Flight Controls, Education, Lecture, Lesson, Brian Douglas, Automatic Control, Control Theory (Field Of Study), Control System Tutorial, Laplace Transform, Linear Control, robot, robotics, closed loop control, technology, electronics, physics, modeling, step response, planetary resources, PID, tuning, root locus, gain margin, phase margin, stability, nyquist, Space
Id: ThoA4amCAX4
Channel Id: undefined
Length: 13min 54sec (834 seconds)
Published: Sun Jan 18 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.