Designing a PID Controller Using the Ziegler-Nichols Method

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone and welcome to another video today I'd like to talk about the Ziegler Nichols method it's for tuning a PID controller if you've been following our discussion on PID controllers you know the architecture and you know why these things are so attractive and the reason they're so attractive is because they're fairly simple to implement and understand because one reason primarily is that they are parameterised by only three values namely a proportional gain and integral gain and a derivative gain so there isn't a whole ton that goes on with a PID controller so the architecture is pretty simple and you see that again your job as a control systems engineer when you're trying to design this PID controller is really just to pick these three values of KP ki and KD so on a very simplistic level the goal as a control systems engineer is to choose KP ki and KD in a quote unquote appropriate fashions or choose them appropriately we'll talk a little bit more about what appropriately means maybe in a future lecture but on the surface this actually doesn't look like that hard of a problem right all you need to do is pick three of these real numbers and then you can go off to lunch but in practice right you don't want to just be simply shooting in the dark and just shotgunning KP ki and KD values and seeing and crossing fingers and hoping it works right for example what if this system this plant you're controlling is very very expensive like a like a rocket or a satellite well you probably need a more intelligent way to get the KP ki and KD values so zeigler nichols is one technique that's going to allow you to do this in an iterative online fashion so well maybe we should write that down Ziegler Nichols let me put this on the board is an iterative online meaning we can do this direct plant without needing a model here so it's an inner of online method to choose these values of KP ki and K do okay so what the method will produce is three values so we're gonna go into the algorithm a little bit later but maybe let's just write it like this so Ziegler Nichols procedure and I think procedure is maybe a better word than algorithm because we're gonna see you have to do a couple of steps but at the end of these steps what you're gonna get out are three numbers you're gonna get KP which is definitely the proportional control that we're looking for but you'll also get these other two sort of time constants let's call it a TI at a TD so if you read a lot of older literature about Ziegler Nichols this is what it says it produces it gives you these three numbers and what it tells you then to do with these three numbers is you can then compose a control law that looks like this you can get U of T is equal to KP times e of T plus 1 over TI integral from 0 to t of a of tau d tau plus TD times the e of T DT and we're going to put it in parentheses here to close this parentheses maybe we should label I guess in this picture here's your reference here's your output and then here is the error and then here's the control U of T right your standard architecture okay so ah this is a control law that it says you should implement well if you if you distribute this KP through you see that this is a KP times e of t plus KP time or over TI times integral 0 to t e of tau d tau plus KP times TD d e of T DT right so again it says the control is the error times some number so this is definitely a proportional gain plus the integral the error times some other number so this quantity right here is actually your ki value all right and similarly over here here's you have the derivative of the error and you have some other constant in front so this entire product here is what we think of as our traditional KD value so in other words Ziegler Nichols the alternative way you could think about this is okay ki is just going to be KP all over TI and KD is just going to be KP times TD right so these two equations you could actually use to transform TI and TD well to say these equations maybe we should have labeled them and my notes I call these equations three and four so this is equation 3 and this is equation 4 in my notes so equations 3 & 4 you could also use this to translate and I guess technically you actually need KP here but you could get ki and KD so the other way you could think about this is that again Ziegler Nichols will also yield KP ki and KD so a lot of forms and a lot of tables you're going to see in a second sometimes they list ti and TD as the output of the Ziegler Nichols method sometimes they list ki and KD okay so let's talk about the procedure for Ziegler Nichols it's actually not that bad so tell you what let's give me a second I'll pause the video erase the board and let's list out the algorithm and the procedure okay so the Ziegler Nichols procedure is actually pretty straightforward so the first thing we're going to do here is start with KP equal to something small and set the ki and the KD to be zero okay so basically in this situation you knock out the integral and derivative and you only have a proportional controller controlling the system okay and then what you're going to start doing is you're going to start increasing KP until you achieve neutral stability so what that means is you're going to take your system and you're going to perturb it and hopefully it's trying to hold a reference of say zero we're using only in this proportional controller and you reach neutral stability when you perturb it and the system oscillates and the oscillation is neither decay back to zero nor explode right this is a situation where you have neutral stability so this is what you're gunning for okay so once you achieve neutral stability you're gonna go ahead and record what is called the critical or the ultimate ultimate gain K U which is just this KP at neutral stability so whatever KP you used to get this neutral stability situation just call this K u this ultimate gain and also not only are you get the game but you're also going to record the critical size ultimate period of oscillation and let's call this T u so again the picture goes along here is you just want to find the period of this oscillation and call that T u in seconds right okay so once you have both of those two parameters K U and T u what you can then do is look up the Associated KP TI and TD right those three parameters from the Ziegler Nichols so this is something that people have derived and you can find it in a table that basically says all right here's the KP here's the TI and here's the TD values and in this case if you are just doing let's say classic PID right that's the whole point of Ziegler Nichols if you want to just define the PID gains well the way you find KP is you take K U and you multiplied by 0.6 the way you get TI is you take the period of the oscillations and divide by two the way you get TD as you take the period of oscillations sorry T U and divided by eight so it's just the formulaic look up at that point right people have already established these relationships between the ultimate game and the period of oscillations to get you the KP the TI and the TD now these numbers for kpti and TD could change depending on what type of control scheme you're or performance you're looking at so the 95% of the time I think you'll see these numbers spit out or this relationship because you're just doing normal PID but people have also done things for say just plain ol proportional control so in that case you would use 0.5 times K you and these two are not applicable you could also do say just P I so in this case just P I would be 0.45 K U and then this would be tu over 1.2 and this is not applicable and etc etc right there are different schemes and different relationships for different types of controllers I'm able to do one last one how about if you want no overshoot so in the majority of cases if you use a KP of 0.2 times K you so really back off of that gain and you use tu / - for the TI variable and then you finally use tu over 3 for the TD variable hopefully that gets you know overshoot okay um so let's maybe this is one more step that we could do here so like we said earlier I personally don't like thinking about TI and TD I really like thinking about these three gains KP ki n KD so what you could do in step 5 is you could compute a kid the ki gain and KD from what we called earlier was I think we said equation 3 and equation 4 is how we we had labeled those right so what you could do is you could augment this table maybe I'll make another two columns on the far side and you could basically get ki which I think we said the formula for that was it was KP divided by TI and you can also compute the derivative gain which we said was TD times K KP right so in this case I think if you just did this Matthew come up with 1.2 you over tu and this one would be 0.075 que you x tu and etc etc you could fill out that relationship for all of these different parameters so it in fact instead of me writing out this table and maybe making errors and making it hard to read here why don't I just go ahead and flash up the completed table that I've typed up and written down in a nice fashion so that's hopefully what you should be seeing on the screen right now is a nicer version of the table we were trying to draw there okay so with that being said uh now that we have the procedures set up I think what might be helpful is let's talk about some advantages and some disadvantages of this Ziegler Ziegler Nichols technique so obviously some advantages or pros of this technique here is well first off if you look at this it really doesn't require a lot of understanding of control systems or dynamic systems right so let's just write down does not require expert knowledge right it's basically a formulate five-step process where you walk through it and nothing in here says you need to have a master's degree in control systems or differential equations right you just walk through these five steps and it will spit out a KP ki and KD that you can try on your system sort of related to this is also you know what you don't even need a differential equation or any kind of model for the plant at all so here we can say that an advantage is it does not require a model or even a simulation of the system right so you don't need to know anything about Simulink if you've got the piece of hardware sitting there in front of you again you don't need to know anything about OD es or a simulation or anything you just run this procedure on the actual system okay and the other the main advantage of this here is that it often produces a reasonable set of gains here and it's a good point for starting a good starting point for other techniques so let's just write down that and the other advantage is it it often produces good initial KP ki and KD right again that was the whole point of Ziegler Nichols it's just getting a reasonable point of our KP k and KD that might work for your system okay now that is some of the advantages let's talk about some of the disadvantages of this technique obviously I think probably the thing that's sticking in the back of your head here is it's not very mathematically robust here so this is not let's say not mathematically rigorous right so there's no guarantee this is going to work for every system here it works for a lot of systems but I can't prove to you or guarantee that the poles are going to go to location if I if I use this technique the other thing is this requires let me erase some of this a little bit so I don't spill over if you look at the procedure right it requires a stable system right if your system was unstable to start with there's no way you're even going to be able to perturb this and try to get this neutrally stable system because it's just going to blow up the second you give it any perturbation right so you've got to start with a stable system in order to do this okay what else is kind of interesting well one thing that could be a disadvantage is if you don't have a model or simulation of the system it requires that you actually conduct this experiment on the real Hardware which might be it might be expensive so let's just say if you do not have a model / simulation all right real experiments could be costly right if this is your 747 aircraft and you're telling the the company that hey you know what I want to do is I want to go over there and I want to screw around with it and do a lot of these tests here and I want to change KP every single time and see when does the aircraft start pitching up and down unstable e I bet you'd get laughed at right because doing that in real life is expensive and dangerous right ah the other thing that you might want to think about is this also it requires a system that you could actually drive to neutral stability all right so let's just say it requires a system that can be driven basically I guess we could say it could be driven unstable with increasing gain or increasing proportional gain right because in order to get K you we've got to get it to this sits the situation where you have neutral stability if you think about this long enough neutral stability implies that what that some of the poles end up on the imaginary axis right so if we look here at the real imaginary axis I've got some system I need to be able to drive it so that the root locus eventually starts to cross this well what if you had a system that looked like you know you could for example here's a counter example how about G of S is 1 over s plus 1 right that thing is just going to pull here at minus 1 right what does the root locus for that system look like it is just this right so as you keep jacking up ok this pole just keeps going further for the left you'll never ever get to the situation where you have these oscillations occurring so in that case this K you'd parameter is undefined so yeah I think that's a pretty good discussion on the procedure as long as some of the pros and cons why don't we jump into a an example to start we're actually gonna look at two examples let's start off with a with a purely thought experiment academic type example to start with alright so why don't we start with an example this is actually a plant that we looked at before it are sketching the root locus discussion so this here was a plant of one over s plus 1 s plus 2 s plus 3 something really really simple so in this case instead of just having some engineering plant I now have a linear transfer function ordinary differential equation effectively representation of my system and I want to go ahead and try to find the KP ki and KD values for this ok so if you remember this system let's go ahead and plot its poles the open-loop poles on the real imaginary axis I think this was really really simple you got something here at minus 1 minus 2 minus 3 right and if we wanted to look at what the root locus for this system looked like it was something like I think you got to the left here and then this pole is actually going out that way these two are gonna come together and then go off to asymptotes sort of here I think at 60 degrees and then something like this right so here's what the root locus looked like and in fact in our discussion of sketching the root locus as well as I think in our video on Roth Hurwitz actually is you could actually use Ralf Hurwitz to find exactly the scenario we're looking for it right because in all of these cases I want to look at where do some of these poles start crossing the imaginary axis right as soon as that happens we have neutral stability so with this system what we could say is let's go ahead and use Ralf Hurwitz and in fact again this is the exact example I think we looked at in the Ralf Hurwitz video which is right over here feel free to refer to that video if you'd like to get this same solution but I'm gonna skip all of that just because I'll assume you've seen that video already and we saw that a K of 60 over here or I guess a K I guess it's now K you right that's what we call the is the ultimate gain K you have 60 if I plug it in here with these two is equal to zero that will get us a neutrally stable system so the next thing is we need to go ahead and find T you right that was the period of oscillations so in order to do that what I think we should do is we should probably jump over to simulate can just heck simulate this system where you've got this transfer function here for the plant and then a KP of 60 there we'll look at the oscillations and we'll just direct measure the period from the simulation all right so here we are in MATLAB and I've already started a script just so you don't have to watch me punch in all of this one line at a time so the first thing we should do is let's define the plant transfer function which we said was 1 over s plus 1 s plus 2 s plus 3 which when you expand out you can write in polynomial format as such therefore here's the numerator coefficient and the denominator coefficient vector to represent that transfer function so let's just go ahead and run this to get genome and G den into the workspace also to save us a little bit of time I've already pre-built a Simulink model which has the plant controlled by our PID controller now we already know what the ultimate gain is from Ralph her wits but I thought it might be helpful just to pretend that this is a system where maybe we didn't know this and we want to walk through the full Ziegler Nichols procedure so we said the way we're gonna do this is start off with a small KP let's say 5 and we're gonna set the other ki and KD to 0 and what we can do is just start running this simulation so I'm gonna run this and I'm gonna pull up the scope and we see well nope that does not look neutrally stable yet so let's keep on cranking up the the KP gain so let's go up to 25 run this thing again and yep it's getting a little more oscillatory how about 45 OOP that's looking better and let's finally go up to 60 which we know should give us neutral stability and yeah there we go this thing looks neutrally stable so we validated that K U of 60 is the ultimate gain we're looking for so now all we need to do is just measure the period of these two waves so you can see it's about two seconds and actually if you spend the time to zoom in and look at this link it's a little less than two seconds I think we're using a value of 1.9 for the period so coming over to the script lets us go ahead and define K U which we know is 60 and we now know T U is 1.9 and these we got the K u from Ralph Hurwitz for simulation and we got the T U value from simulation okay so the next step in the process is once we have K U and T U we're pretty much home free we can go ahead and look up the valid or the appropriate value of KP TI and TD right so I think for this scenario where we are trying to do just a normal PID controller we said KP was going to be 60% of K U and then we said T I was gonna be tu / 2 and T V was going to be tu divided by 8 great so once we have those we also said that you know you don't have to deal with these time constants TI and TD it might be more useful to compute now what the ki and KD values are using again what we called equation 3 and equation 4 so that was ki was KP divided by TI and then KD was going to be TD time whoops T lowercase D times KP great so if we run this uh whoops okay I should have used the same variable T capital u there we go all right there so now we have a KP a ki and a KD that was designed via Ziegler Nichols so if we come back to our Simulink model we can see if that works so let's just go ahead and put in our KP ki and KD so go and run this again look at the scope and look at that we get a reasonable response just to maybe make a note of this um if you think about this long enough all of this is just begging to be plugged into a function this is basically a table lookup with a very simple calculation so here's a little plug for my function that I ended up making called Ziegler Nichols which all this does is if you think about it Ziegler Nichols this whole procedure right the only thing you need to know is K U and T U and I guess you also need to know what type of controller are you looking to do are you trying to do classic Pei D just a p just a PI PD over shooting no overshoot all of these different types right if you have those three pieces of information you should be able to calculate KP ki + KD with no problem so what I've done is I've wrapped this into a that I call Ziegler Nichols and I'll put a URL to this function so you can download it yourself surprisingly I didn't find it natively in MATLAB maybe it is natively supported in MATLAB just so please shoot me a message or please leave a comment down below so we could all learn but I ended up just coding this up in a couple of minutes and I thought I would share this with you guys so alternatively what you could do is let's just use the custom Ziegler Nichols Nichols function alright so the other thing we could do is just call the custom Ziegler Nichols function and you pass it Kay U and T U and maybe let's say we want to do classic PID and what my function will easily compute for you is just the KP ki + KD gains that are necessary now before we run this maybe what we should do is let's scroll back up and see what we got earlier right this is when we manually computed them ok thirty-six thirty-seven point nine and eight point five five so now if we were to run this script you see that we basically get the exact same values so the nice thing about the Ziegler Nichols function that I provided is that it supports not just like we said not just classic P I but what if you wanted to do just R sorry not just a classic PID but if you want to do something simple at just P I you could get another set of gains or you could do like no overshoot and get yet another set of gains so I think it's pretty helpful so you don't have to do that manual table lookup and calculation by yourself so again there's a URL to download this in the description of the video what might be helpful now is let me flash up a picture that shows the system response using a bunch of different sets of games for all these different conditions like classic PID P I know overshoot etc just so we can get a feel for how the system behaves and to make sure that the Ziegler Nichols technique gets us a reasonable controller for this system alright so here's a MATLAB figure that is basically the simulation we were just running here but just using all of those different permutations of PID controllers that were derived using Ziegler Nichols and these different types of methods so as you can see they all give you know halfway reasonable responses they all look like they're tracking to the desired reference with 0 steady state error and as you can see some of these things where if you want maybe some overshoot or no overshoot like these these green and purple lines they do seem to follow that behavior in general so this is sort of a heuristic anecdotal example showing the viability of using Ziegler Nichols to design a control system for a situation where you've got a nice mathematical plant model already sitting there waiting for you alright so we saw that Ziegler Nichols worked pretty well for designing a PID controller for this transfer function but actually you know if you think about this long enough if you've already got a mathematical model of the system and you're using Ziegler Nichols I kind of think you're doing it a little bit wrong it's it's almost like you've got a can opener and instead of using the nice normal way and the proper way of opening the can with a candle but you're gonna sit here and you're gonna try to bash the can open with the handle of the can opener there are better ways to design PID controllers for systems where you already have a mathematical model the system and in fact we're going to look at that in a couple of these other videos where we talk about using root locus to design it now that being said Ziegler Nichols in my opinion one of the place where it really shows its versatility and power is where you want to design a PID controller directly with an experimental system without ever needing to develop a transfer function or simulation of the system so we're gonna want to do this iteratively and online so the example I like to look at now is let's walk over to the lab and see if we can design a PID controller for a DC motor and if you remember we talked about developing models for a DC motor in some of our other videos but again the the Hat I want you to put on right now let's think about what if we didn't have these models here of the DC motor and we have a system that I can play with let's see if we can just go into the lab and see does DC does Ziegler Nichols allow us to to synthesize a PID controller for that system iteratively and online let's start with a proportional gain of 15 the constant of reference signal is simply zero degrees so when we introduced some error by manually disturbing the wheel the system attempts to return to zero as you can see there's a few oscillations but for the most part the system response is more limp than a wet noodle because the gain is relatively low all right so let's pump up k 225 and try again and as you can see we're definitely moving in the right direction the oscillations are increasing although the system is still reasonably stable so we're not quite there yet all right so let's increase K to 40 and try again and oh that's close but no cigar you can see that the system is still barely stable so we just need to push it a little bit harder so let's increase the gain again up to 45 and now it looks like we finally pushed the system to neutral stability as evidenced by the persistent oscillations at constant amplitude so now we know that K U is equal to 45 to get T U let's just zoom into a section of this trace and then simply measure the period of the oscillation which appears to be around zero point nine six seconds all right so let's run back to MATLAB and maybe we'll start a new section let's call it an example to experimental DC motor um and now it's really just a simple matter of inputting our K u and T u values that we obtained in the lab and then doing the Ziegler Nichols lookup slash calculation and again to save myself the busy work I'm going to use my custom-made Ziegler Nichols function and we are going to do let's let's do this with classic PID how about and just re running the script now we get a new set of games that are tuned for this specific system so why don't we run back to the lab and see how these set of games perform on the real DC motor system so in this case we're going to command a step change in motor position when the step is introduced pay attention to both the system output which is the motor position and the control signal which is the voltage to the motor so in this case we use a step from 0 to 0.09 radians which is about five degrees we use a small deflection in an attempt to avoid controller saturation the power supply on our experiment can only supply plus or minus 10 volts despite our small step magnitude at the introduction of the step the controller requests 30 volts I've adjusted the axis of the plot to plus or minus 10 volts so the scale isn't blown out of proportion by the spike when the controller saturates the Ziegler Nichols design PID controller is effectively acting nonlinearly so all bets are off while we're talking about nonlinearities we should probably mention that another source of significant non-linearity in the system is the friction you've got viscous friction Coulomb friction and stiction all acting on the system these nonlinearities are most predominant at low velocities which is exactly where we're operating combining this with the finite resolution of the position encoder explains some of these jitters you're seeing in the position and therefore in the control signal as well we do get a little bit more lucky when we do the step back to zero degrees despite all of these non-linearity effects we see that the PID controller does its job respectably and actually works quite well for this system all right so hopefully that convinces you that Ziegler Nichols is a reasonable way to go about designing a PID controller for a system either where you have a model of it or you don't so that being said I think that wraps up the discussion today I hope you'll join us at a future video where we're actually going to continue our discussion on PID controllers and look at other ways to synthesize PID controllers along those lines I've also got a library of other videos on the channel related to other engineering topics which are also relevant and related to the discussion today if you'd like a more comprehensive look at the curriculum check out the link in the description of this video for a link to a syllabus of all of these different videos where you can kind of see a more summary high-level overview of how they all tie together so with that being said I hope you enjoyed the discussion today and I hope to catch you in one of these future videos so until then calculator bye
Info
Channel: Christopher Lum
Views: 117,457
Rating: undefined out of 5
Keywords: Ziegler-Nichols, PID controller, tuning PID controller, online tuning PID controller, experimental tuning PID controller
Id: n829SwSUZ_c
Channel Id: undefined
Length: 33min 0sec (1980 seconds)
Published: Sun May 19 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.