Gain a better understanding of Root Locus Plots using Matlab

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome back to control system lectures in this video let's walk through several ways to draw and analyze a root locus plot in MATLAB and discuss some of the benefits and drawbacks of each method now this video is like the sixth or seventh video in my root locus series so if you'd like to see the previous videos before watching this one you can go to my channel and find the root locus playlist there now this is not a MATLAB tutorial video in terms of how to use the software it's intended to be a video on how to use MATLAB to help you solve your root locus problems and with MATLAB there are plenty of ways to solve a problem and so I'm just going to be going through a few of them alright so what is our problem well one of my followers on Twitter sent me this transfer function from his exam where he was asked to draw the root locus plot and based on how this transfer function is written with a G of S and an H of s we can assume that the form of the block diagram is probably something like this where K is the gain we have control over G of s is the forward transfer function and H of s is the feedback transfer function which are just standard letter nomenclatures now I didn't mean to write K before G of s times H of s here instead what I'm trying to show is that G of H can be thought of as everything other than the gain K now the problem doesn't state which part of this remaining transfer function is G of s and which is H of s but for drawing the root locus it doesn't matter because if you recall the closed-loop transfer function for this system is K times G of s divided by 1 plus K times G of s times H of s and to draw the root locus we only need the characteristic equation in the form that it's already in exactly the way the problem provided it we would need to know G of s by itself if we were concerned with system response and not just the pole locations and the root locus okay so we have our G times H and now before we do anything in MATLAB we should attempt to draw this transfer function by hand just to see how close we get now first thing I do is plot the locations of the poles and zeros of G of H and we can see that there are 4 poles at 0 minus 4 minus 2 plus 4 J and minus 2 minus 4 J and since there are no 0s we'd expect four lines to go off to infinity let me draw the s-plane and then mark out the four open-loop poles and if you watched my other videos you know to fill in the real access to the left of the odd critical frequencies and now we can determine the angle of the four asymptotes which are always 45 135 225 and 315 degrees and that these asymptotes cross the real axis at the center of gravity of the poles of zeros and that's easy for us to figure out since there are so symmetric it's just at minus 2 now we know these lines eventually end up on these asymptotes but how to get to them either require some more math or some more experience in drawing root locus but we do know that the two poles on the real axis crash into each other and leave at 90 degrees and then head towards the other poles where they split off and go to the asymptotes perhaps it's something like this dashed line or perhaps like this solid line but these two different ways to draw the lines aren't actually that different and we still get the general idea so with the hand drawing complete let's go to MATLAB and see how to duplicate it there for this demonstration I'm using MATLAB 2014 B but both slightly older and newer versions of MATLAB should work just fine now I'm going to build up the root locus slowly at first to show you what it's doing behind the scenes and then we'll progress through easier ways to visualize it so please stay with me through it now the first thing we want to do is build our transfer function object and like I've said in past videos there are many ways to do this my favorite is just to define a simple transfer function called s and then I can use that transfer function to build out more complicated functions and here I'm using s to write out our transfer function gh now I've left off the variable K but I essentially assigned K equals 1 as you can see in the numerator but by multiplying gh by again we can adjust what K is for example if I set K equals 2 and multiply gh by K you can see that the numerator is now 2 so by multiplying gh by various K's we can see the impact that the gain has on the system but before we get to that a second way to define the transfer function is by using the T f function let me bring up what our GH was again as a reminder now I define the numerator and denominator polynomial coefficients the numerator is easy it's just 1 and the denominator is 1 8 36 80 and 0 now we can set G H to the transfer function that's built from our numerator and denominator coefficients and we got the same result but it did require us to have to multiply out the polynomial so we can get the coefficients in the first place which is fine if you start with a transfer function in polynomial form at the beginning now the last way I want to show you is to create a transfer function using the function zpk which stands for zeroes poles and gain now you specify where you want your zeros and your poles and what the gain should be and then it just builds the transfer function I'll bring up G H again for reference and we have no zeros so we pass in an empty matrix and we have for poles 0 minus 4 and the roots of the second-order equation which are minus 2 plus 4 I and minus 2 minus 4 I and again it is the exact same transfer function now I'm going to go back to the representation earlier though because I'd like to look a bit more and I want to show you how to find the poles and zeros if you didn't already know where they were so if you have the transfer function you can use the function pole to find the poles and 0 to find the zeros and if we do that we can find that there are 4 poles and no zeros just like we solved for before or if you're not into simple functions like that you could also use the function roots which as you might have guessed solves for the roots of a polynomial you just have to pass in the coefficients of the polynomial exactly like we did for the function TF and no surprise we found the exact same four poles but finally you might not want to solve for the poles and zeros and instead just want to see them visually plotted in the S plane and we can do that with the function PZ map or the pole-zero map let me dock this plot so it's easier to see and increase the line width because they start out so small and here you can see the four poles of the open loop function G H plotted out in the S plane and we can use this function to also plot the poles and zeros for the closed-loop transfer function this requires using the function feedback to show you how to use feedback let's write a really small script to plot the pz map for the closed-loop system as we sweep the game from 0 to 10 I'll write a for loop to cycle through the games now I want to use pz map on the closed-loop system for each of those games the function feedback will take your feed-forward transfer function and your feedback transfer function and create a closed-loop system from them as I explained earlier we don't know how to split up G and H so we have no choice but to assume gh is just the forward transfer function which will multiply by our gain K and the feedback transfer function is 1 or unity feedback I'll hold the figure so I can plot multiple times on it without overwriting the previous plot and then I'll end the for loop and there it is on the plot now it's really hard to see I should have made the markers larger but the poles are starting at K equal 1 and as the gain increases the two poles on the real axis are moving in towards each other and maybe the two imaginary poles are coming down it's too hard to see since we didn't fill in the entire plot so let's try that again but this time from K equals 1/2 a hundred and one jumping every 10th number I'll rewrite the exact same script changing just the for loop part and rerun it ah that's a little better it's starting to take shape and it's starting to look exactly like what we drew at the start of the video but you can see with this method of drawing the root locus it's really hard to figure out the right range of gains so that the entire plot is filled out luckily there is an easier way to draw the root locus and that is with the function our locus first let me unhold the figure so we can erase what's already on there next time we plot and instead of that script I wrote I can just say our locus of GH and like magic the root locus shows up and if i zoom in on the area of action we can see that the locus starts at the four open-loop pole and since there are no open-loop zeros they go off to infinity in the manner that we predicted and that was pretty easy plus we can also add a gain marker to see what value of K it would take to place a root at a certain point and we do that by clicking on the line where we want to see it let me make the font a bit bigger so you can hopefully see it also and this pop-up tells us some important information like the gain the pole location and the damping ratio and if we grab it we can drag it along the locus and watch those values change real time so you can use this to find the game needed for certain damping ratio or to see when the system will go unstable but you can also add more gain markers and move them all individually which is cool but the downside of our locus is that you can't see how all of the roots move at the exact same time you only have control over one root also you can't easily see the effect of your compensator design on the system for this we need to use the sigh so tool which is also called the control system designer to run this isoh tool you're going to need the control system toolbox now there's a few ways to open up this tool one way is through the apps tab now my screen capture cut off the top of the screen but if you click on the apps tab up at the top you can see a list of the applications you have installed and if you have the control system toolbox you should be able to find the control system designer clicking on that brings up the tool and two windows there's the design window on the right and the manager window on the left and I know this looks daunting at first but it's easy to get started with it and then you can explore all of the additional features from there we'll start with the manager window and the architecture tab you can see a block diagram of the architecture that the system designer is using and this matches the one we have for our system there is a compensator C which is just gain K for us there's the feed forward path G which is G times H for us and the feedback path H which is one but if you had a system architecture that's different than the one that we're using you can change it using this control architecture tab to any one of the preset diagrams but we're going to go back to where it was because that's what we had now after you choose your architecture the second step is to assign transfer functions to each block in the diagram you can do that by clicking on system data by default you can see each one is set to one which is a pretty boring system but we can update it for our system by selecting the forward path G and a signing in our transfer function gh and once I hit okay the design window instantly updates to reflect the new system but by default as you can see there are a bunch of plots in the design window that we don't want to look at so we can customize what we see using the graphical tuning tab so it looks like we have three plots turned on and since I'm only concerned with the open-loop root locus I'm going to set the other two plots to none and they'll go away we'll get into how this plot differs from our locus in a second but first I want to show you two more ways to open this tool you can call it directly with the function sigh so tool and again it will default all of the system data to ones or you can pass in the forward transfer function and it will automatically set it for you so you don't need to mess with the system data it's completely up to you how you want to launch the tool okay so now we can finally check out the root locus plot you can see the four roots in this magenta color and when you grab one of them and drag it along the locus all four of them move at the exact same time and once you move it the new gain of the system is displayed in the lower left here it has a value of 116 and as you move the roots the pole location damping and natural frequency are shown in real time so the same information as our locus but here's where the tool really shines you can click on analysis plots and open the number of plot types and up to six different plots I want to see what the step response looks like for my closed-loop system so in plot one I select step which opens up a new figure now I need to select what the input and output is for my step plot and my options have letters like r2 Y and D u 2y to figure out exactly what that means we can go back to the architecture tab open up control architecture and this diagram explains all of the different signal names so for us we want the step from the input R to the output Y which is this first plot and the really cool thing about this analysis plot is that is updates real-time as you move the gain root locus so you can see instantly the affect your compensator changes are having on your system and you can see what your compensator looks like by clicking on the compensator editor tab at the moment I just have a gain of about 89 which I can update from here as well and see everything change accordingly but I can also add poles and zeros to my compensator by right-clicking in the dynamics area and selecting whatever I want to add I've added a real pole at minus 1 and you can see how the root locus and the step response changed because of it also it added the transfer function of the pole to my compensator design and once I add that pole I can drag it dynamically in the root locus or set a new value from the compensator editor and if I delete it everything goes back to its original value but let's add something a bit more complicated like a notch filter again everything updates real time but since a notch filter is a little harder to visualize we can go back to our analysis plots tab and add a bode plot for our compensator design this will allow us to see the frequency response of our compensator and its effect on the step response of the system at the exact same time so now if we go back to the compensator editor and we make a few changes of some of the values you can see the notch width and the depth change in the bode diagram that's pretty cool right ok let me remove that plot and again remove the notch filter from our design so we go back to the way we were at the beginning and finally you can also add poles and zeros directly to the root locus using the X's and O's button at the top of the plot so this is all really cool ways of seeing the relationship between your compensator design your root locus plot and the system response for a single transfer function but let me show you something that is probably my favorite feature of this isoh tool stacked functions i'll start by creating a series of different but similar transfer functions then i can use the stack function to combine them all into a single object that I'll call gh stacked the one in the transfer function just means that I want a table that has width of 1 so basically a column of transfer functions and there you can see we have our transfer function array now you can't see what I'm doing because my screen capture cut off again but I typed size O'Tool and passed it in the new transfer function gh stacked I'll bring up and rearrange my windows once again at this point it might not look that much different than it was before but if i zoom in on the root locus you can see faded dots for all of the poles of all of the different systems and if I move one of the poles all of them move this is because I have multimodal display set but it gets better because I can also set that in my step response either to individual responses where you can see the step response of each transfer function or to bound which just shades in the region between the extreme responses and all of this updates real time the reason this is so cool is that you can use it to design a single compensator that will work for multiple transfer functions sort of like a makeshift robust controller for example you could add design requirements to the step response plot like it must have rise time less than two seconds and settling time less than four seconds with no more than 20% overshoot then you can see graphically whether you're meeting your requirements not just for a single transfer function but across all of your stacked transfer functions here you can see that some of my responses meet the requirement but not all of them so I need to work on my compensator now the first thought might be to adjust gain only so I try that but as you can see as I lower the gain eventually the rise time requirement isn't met on one function before the overshoot is met on the other so perhaps we can solve this with a lead compensator now I have to admit that I'm just trying things based on what I think will work I'm not putting any mathematical effort into designing this system so this is not necessarily the best design just one that might work now I can play with the lead compensator a bit and then adjust the gain until I get something that works and that's pretty close I think you can see that I'm not really meeting my requirements just for a bit but I think I can get an exception for that now I think if you play around with a couple of transfer functions and the sigh so tool you'll gain a better understanding of what the root locus plot looks like for various systems as well as how adding poles and zeros affect the shape of the plot also you get to see real time the affect your compensator design has on the response of the system if you have any questions or comments please leave them below and I or hopefully another viewer will try to answer them don't forget to subscribe so you don't miss any future videos and don't forget to check out the links in the description for more information on these MATLAB demos and thanks for watching
Info
Channel: Brian Douglas
Views: 230,147
Rating: undefined out of 5
Keywords: feedback, control system lectures, theory, flight controls, education, matlab, lecture, lesson, brian douglas, automatic control, control theory, control system tutorial, linear control, robot, robotics, closed loop control, technology, electronics, physics, modeling, planetary resources, root locus, plotting, gain, space, mathematics, siso, sisotool, simulink
Id: pG3_b7wuweQ
Channel Id: undefined
Length: 19min 10sec (1150 seconds)
Published: Mon Jun 15 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.