Using the Control System Designer in Matlab

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone and welcome to another video so today I'd like to continue our exploration on how to effectively and efficiently design linear controllers if you've been following our discussions so far you know that we've covered a lot of different topics regarding linear control design and I want to start off today by maybe quickly recapping some of these techniques because I think they're both critical prereqs to this discussion as well as they help motivate and frame the current discussion for today so let's quickly just make a quick table here talking about the different analysis or concepts that we've covered maybe in the first column and then let's also look at what is the analytical tool that is needed for this concept and then lastly let's also think about what is the MATLAB tool that will help us implement this idea or understand it better okay and then in the far side of the screen here I'm gonna pop up a couple of the relevant videos that we talked about that cover some of these discussions earlier so let's start off with maybe the easiest one so if you remember we had a lot of discussion here on performance metrics like percent overshoot settling time rise time etc right and we saw that ok the analytical tool that helps us understand these concepts were you basically look at things like the step response and we also saw that you know what you could also understand the percent overshoot and settling time for some systems namely second order systems or second order dominant systems by looking at regions of the complex plane basically where do the poles land and again over here on the side are the three of the YouTube videos that discuss these concepts and these tools here and we saw that MATLAB actually provides different sets of tools to do this type of analysis so there's things like the step function the L sim function there's the actually the linear system analyzer is another tool that allows us to do this and many more here so I just wanted to list a few of these okay so this was one concept that we saw was critical for designing control system what else did we see we had a discussion actually on DC game all right and we saw that all right if you want to understand the DC gain of the system what you're really thinking about is looking at the bode plot specifically at low frequencies and MATLAB has a nice tool for this and it has a bode function right which will allow us to do that okay what other types of concepts did we cover we also looked at system bandwidth and we saw that okay if you want to look at bandwidth again you're looking at a bode plot but you're looking at a bode plot of the closed-loop system right and again the thing that's relevant here is the bode function while we're still talking about bode plots remember we also had a discussion here on gain and phase margin okay and we saw that gain and phase margin the idea was again you still look at a bode plot but now you're looking at a bode plot of the loop transfer function not the closed loop system right and again you could use bode or also MATLAB has a margin tool for this and again as I discuss all these I'm going to flash up the relevant videos over here on the other side of the board so again I will also leave descriptions to all of these videos in our sorry you leave URLs to all of these videos in the description of this video here what else do we talk about why we were designing controllers oh how about root locus that turned out to be a very critical concept and the idea is with root locus here where obviously you could well plot the root locus that's kind of a self explanatory but there are other tools like Roth Hurwitz which also allowed us to help understand this concept a little better here and again now I've had tools for this like our locus okay so the reason I wanted to put up this list here is because we've had a lot of good discussions so far talking about all of these different topics here and I want to make sure that you've watched all these and understand these concepts because again we're gonna make use of them here and it really helps understand that if you look at this it looks a little bit like you can see it's a pretty healthy list of topics but they require a somewhat scattered set of tools to deal with right you've got the linear system analyzer you've got margin and bode and you have to do all these different types of analysis to see the whole picture right because we saw all of these different concepts feed into designing a linear control systems so I bet you're thinking right now in wishing gosh wouldn't it be swell if there was just one tool that would allow me to do all of this analysis together at once well I hope you live in Agrabah with your pet monkey a boo because today I'm going to be your genie and make all of your dreams come true we're gonna introduce what's called the control system designer which is a tool in MATLAB which is gonna allow us to do all of these tasks and and more so it's gonna allow us to do all kinds of things like for example it's gonna allow us to view the root locus it's gonna allow us to manipulate the root locus it's gonna allow us to think about modifying a controller structure in real time so as a modifying controller structure and actually and seeing the results slash ramifications in real time it's going to allow us to look at the time domain response of the system it's gonna allow us to look at the frequency domain response of the system so it's all of these things put together in one tool that if we understand how to use this effectively it's going to really help our control system design workflows so isn't this great and you know what you still have two wishes left so if you'll chase them anywhere and you've got time to spare then let me share this whole new world with you okay so before we dive into MATLAB I want to talk a little bit about just the workflow for using the control system designer we're gonna see that it's a little bit different so it might behoove is to quickly discuss a relevant way to use this effectively um just as a quick note the control system designer you may have heard this by other two other monikers in the past I think when I was using this or when I first learned about it I learned about it as a seaso tool so maybe there should maybe make a quick note that it used to be called sisa there was a thing called seaso tool there was also a thing called RL tool and I think these got renamed back in like MATLAB are 2015 a or something like that and everything now that's newer is called the control system designers so just FYI if if you hear people talking about C so tool or RL tool that's basically the same thing so with that being said the workflow for using the control system designer here it's I think of it as a seven step process so the first thing that you're going to do here is you're gonna generate a dynamic model of your system usually the plant so things that are helpful is you could use things like the TF function the zpk function etc the state space function all those things in MATLAB could help you generate just basically a dynamic system model of your plant that we can then load into the control system designer so that's the second step so step two here is go ahead and start the control system designer and load in the plant model that's the thing that we developed in step one alright so again the the helpful command here is obviously it's going to be control system designer and I apologize for my handwriting this should be a capital S and a capital D and a lowercase C okay so that will get the the the system started we'll look at another way to get it started as well and we'll also look at how to load in the plant but once you have this all set up what's really nice about the control system designer is you can add design requirements so these are things like percent overshoot you know pole locations frequency domain response time domain response all those different requirements can be all captured and codified in the one spot okay the next few thing is once you have that all set up step four is now that you have your plant in there you have your design requirements you can basically try to go ahead and just design your controller or your a compensator however you want to look at it directly in the control system designer we're going to take a look at how to do that once you're happy with your controller that you've done design we're gonna have to export that compensator back to the main MATLAB workspace so step five it's export your controller slash compensator to two MATLAB workspace we're gonna see what this means in a little bit you you might think everything is one giant workspace but it's not really okay then once you're done with that and you have it in the main mal that workspace what I would do is I would save your controller and possibly save your session and again this will make a little bit more sense what we're talking about what is your session once we get into it so again maybe the relevant files in met and mal that are helpful obviously save at that point okay and then the last thing that I would do he is once you have all of this controller design and saved I would go ahead and make sure that I simulate my system to validate performance simulate system to validate performance and in this case I would basically think about building a Simulink model that represents this plant and this controller that I've designed and make sure that it actually performs the way that you expect it to okay so let's think about using an example I always like concrete examples so with this workflow in mind let's think about an example that we can use and see if this control system designer will help us in this scenario so the scenario I want to look at here is our good old friend the DC motor so again if you haven't had a chance we have a video talking about how to derive the transfer function or a dynamic system model for a DC motor if you don't care about that and all you want to do is just look at this as just some third order transfer function that's great as well but what I want to look at is how can we do DC motor position control and in this case we are just going to be using proportional control we're gonna have videos later that look at more complicated control architectures but let's keep it simple when we're just introducing this tool okay so the way we want to think about this is if you remember the plant let's call it G P of s this is the motor position or the motor angle over the armature voltage or voltage applied to the DC motor we said that this transfer function you know it's it's a bunch of constants but at the end of the day when you plug in numbers here's here's some transfer function you could think about this as just a system that is dropped into your lap if you want alright some other team and your job has gone ahead and said here's the model of your plant go ahead and build me a controller that will deal with it so here's what it looks like for eight four five so again in case this is hard to read in the denominator sq+ 1021 s squared plus 4845 s this is just your transfer function okay so what we want to think about now is okay here's my system G P of s right and you give it a control signal U which is in this case the the voltage to the motor and it spits out the angle of the motor of how far the it's turned and what we want to think about now is using our specific classical control architecture where all I want to do is design a controller C of s where all this C of s is just a game K it's a constant game we're gonna look at again well look at something more complicated a little bit later but this is the game plan the game plan is find a value of K that will make this thing behave desirably so we now need to think about what does desirably mean let's assume that maybe your manager drops some performance requirements onto your lap along with this system here so let's talk about performance requirements okay so let's say that they say you gotta have less than 40% overshoot that's the maximum little tolerate you have to have a rise time of one second or better you need a settling time of less than three seconds and this is to within two percent of final value that's our band for how much we consider it to be don't okay you need a gain margin oops gain margin of 20 DB or better and a phase margin of 30 degrees or better and then finally you the system better have a bandwidth of greater than five radians per second so at this point I guess hopefully it makes sense why I say you you want to make sure you watch all those other previous videos because if you watched all the other previous videos all of these requirements should make sense to you right they she you should understand physically what does the system have to do in order to meet all of these or what should it behave like in order to meet all these so our game plan now is design a controller Kay that will simultaneously meet all of these right and what we saw earlier is sure you've got the tool set that you could do this right now by hobbling together all of these different types of analysis like loop transfer function bode plots closed-loop transfer function bode plots root locus pole locations all of that kind of stuff I'm sure you could do it but I want to make the case for this control system designer is going to make this workflow a lot easier so with that being said let's jump over to MATLAB get the control system designer fired up build this transfer function and basically walk through these seven steps and see if we can use that to effectively and efficiently design that can that proportional controller kay so here was our seven steps let's just start with step one which is generating a dynamic model of the plant so to do that let's go over to MATLAB and go ahead and start ourself a new script I'm going to say we are using this to explore how to use the control system designer to create a proportional feedback controller okay so we'll start with our normal clear CLC close all and maybe before we get started let's go ahead and save this script so ctrl s to save and what I'm gonna do is I'm gonna put this someplace I have a folder already and whatever you do do not call this control system designer because that's the name of a function we're gonna use to start the designer so you can call it control some designer script or something like that if you really want to okay now what we're gonna do is let's just go ahead and start off with step one right generate plant model okay so we're gonna do this the same way we did earlier we're just gonna go ahead and create a numerator coefficient a vector for the numerator coefficients and then oops I should cuz I just call that GP numerator and then GP denominator is a vector of the coefficients of the numeron Amin ATAR polynomial so that was I think something like that great and then the overall transfer function for our system is just going to be Jeep TF of Noom and then then great so if we go ahead and run this I'll change the folder to this current location and here is our transfer function between the armature voltage and the position of the motor okay so next let's go on to I believe we are on to now step two right step two was we need to start the control system designer and then load in the plant model okay so hopping back to MATLAB there's a couple of ways we can do this step to start the control system designer so one of the ways you can do this is you come up here to the Apps tab in your MATLAB window and you come here there's all these different abs so I'm gonna hit this little drop down here and I'm gonna look for the control system design and analysis and you see here are all these different apps and here's the one we're interested in the control system designer I can go ahead and start at actually because it's kind of helpful so that we'll move that up here to my favorites but one way you can do this is you can just click on this icon and what it will do is it's going to start what's called a control system designer and we'll give that a second to populate and I'm gonna show you actually a second way to get this as well and it actually pops up for me on a different window so let me go ahead and drag it over here it's still initializing you're seeing it's popping up a whole bunch of different plots and here we go this is a control system designer let me close this real quick and I'll look at a different way to open it and just get to this exact same spot so the other way you can do this when you try to close this you get this little save session notification I'm gonna hit no because I don't care about this for now the other way you can do this is if you just go ahead and type help control system designer you see that basically you could call it like a function in fact you can call it like a function and pass it in the plant model if you'd like I'm not going to do that let's just go ahead and open the control system and designer programmatically and I'm gonna say without loading in the plant model because I want to do this manually just so we can get some experience so I'm gonna say control system designer like that and I guess you can call it with empty parentheses if you really want to or not but now if we run this when we hit line 16 it's going to initialize the control system designer so here it goes it's pulling up and why don't I go ahead and maximize this just so we can get a better understanding of what's going on so the control system designer it looks like a lot initially and and it really is it has a lot of function and features in here but really at its heart it's a root locus design tool where it's going to show you the root locus of a given architecture of a system and it will also show you things like the step response of the system as well as frequency domain analysis of that system so the question that's probably on your head is what system are we talking about here so to answer that and to finish up our step number two I'm going to come up here to this tab which says control system and you see there's a tab that says edit architecture so you can click on either this drop-down and then select edit architecture or you can just click on this upper half of the button either way what its gonna do is when you click on that if you give it a second here this window will pop up and it shows you all of the different architect cheers that are available for this system so it's quite robust there's a lot of different architectures and block diagrams that you can analyze let's go here with this one here at the very top because if you look at this this is the classical system that we're looking at you have a plant G you have a potential to add a compensator or controller C it also has a model for you allowing to model a sensor dynamics which are which are denoted here as H as well as a pre-filter which is denoted as F so we're gonna ignore F and H for our purposes and just focus on G and C so the first thing I want to do is you remember that back in our MATLAB workspace we made this variable called GP which our trip was the transfer function of the system I need to load that in as the plant model here so in order to do that I'm gonna come over here and icg and I'm gonna click on this import button and when I click on the import button it brings up this other dialog which is gonna allow you to look in the base workspace which is the MATLAB workspace for any available models like transfer function Z PKS state spaces things like that so we only had one so this is the only thing available I'm gonna click on it and when I click on import what that's gonna do is that's going to jam that transfer function for our DC MA or DC motor into this G block so when I hit OK watch all of these plots in the back should update now so now what we should see is this is the root locus for our system with that architecture we had earlier that we showed maybe I'll bring on this back up so we can see with this particular architecture now the next thing you're probably wondering is what the MATLAB throw in here for FC and H so to get that you can come over to the left side of the control system designer and you see it's got all of these listed here so if I click on F it actually tells you that oh it's just a static gain of value 1 which is perfect we don't want a pre-filter in here I want it to be like it's not even there or it's a gain of 1 same thing for H if you look at H it's just a value of 1 that's perfect I don't have a sensor model in here now how about C C is also of gain of 1 so right now what we have is again let me pull up this architecture diagram is all of FC and HR all ones now the place where it makes a difference is G if you click on this look at this it has now loaded in the G that we defined in the MATLAB workspace so we're ready to start working we've completed step two where we have gone ahead and imported the transfer function model for the plant into the control system designer and we've set the architecture to be the classical inner loop single loop on feedback control system that we want so let's go ahead and think about moving on to the next step alright so moving on to step number three that was where we are going to add design requirements now before we think about adding them let's review what were the design requirements so if you remember we said there had to be less than 40 percent overshoot a rise time of less than one second settling time to within two percent of three seconds or better we have more than 20 decibels of gain margin and 30 degrees of phase margin and we wanted the system to have a bandwidth of greater than five radians per second now these are the requirements maybe what we should think about is translating these into what types of plots or analysis do we need to do or view so that we can verify that these requirements are met so the first three I think you will all agree that if we look at the step response of the system we should be able to understand all those things like percent overshoot rise time settling time all that kind of good stuff also we could look at trying to understand where the poles need to be in the complex plane so we could look at the root locus of the system to try to tease out those percent overshooting those other types of performance metrics notice that there's an asterisk there and I feel like it's my duty to remind you that the root locus is actually it's only accurate and precise for second order systems or systems which are second-order dominant if you have higher order dynamics the root locus although we might be able to sketch areas of the complex plane where poles should fall it's not going to be a 100% foolproof and we'll look at an example that actually in one of our future videos so really the step response is the fire way to make sure that you satisfy the percent overshoot rise time and settling time the root locus is a nice to have and we'll look at it but I just want to make sure we're all on the same page that it's maybe a starting point or such a suggestion and it's really the step response is what you want to look at okay let's move on to the gain margin and phase margin how are we going to analyze that well if you remember what we need to do then is make a bode plot of the loop transfer function or the loop gain right so in this case it would just be the transfer function G times C for bandwidth that's another story bandwidth we actually want the bode plot of the closed-loop system from the reference input to the actual output so these are all the different types of plots that we're going to need to make and we're going to see that the control system designer can handle all of these so with that being said let's go ahead and pop back over the control system designer and think about adding these so we see that by default we've actually got almost everything we need we've got the root locus up here in the upper right we've got a step response and if you look at this very closely it says r2y and again if we come here to the architecture diagram you'll see that this is indeed the closed-loop step response from the reference input to the output right so down here is where we're going to want to be looking at performance metrics like percent overshoot and things like that finally we also have a bode plot of the loop transfer function so great this plot will be very useful for understanding gain and phase margin now we need to add a couple of things so one of the plots that were missing from our list is we need the closed-loop transfer function bode plot from R to Y so in order to do that so we can get bandwidth I'm going to come up here to the control system tab and you see this thing that says new plot let's click on new plot there's a whole bunch of different plots you can put let's say I want a new bode and again we see our nice diagram and now I want the bode plot from R to Y right the entire closed-loop bode plot so if I click on this little drop down I can pick the transfer function here IO transfer R to Y that's exactly what I'm looking for if I hit plot now what we're going to see is another bode plot that shows up which is now the closed-loop bode plot and this might be helpful if we grab and dragon on the show you can actually draw pull this apart and you kind of rearrange as appropriate so here we go this looks awesome so now I think we've got all of the plots we're looking for I do want to add one extra plot I want to add another step response so I'm gonna come here to the plot and I'm gonna say a new step and what I want to look at now is during all of this analysis I want to make sure that the control signal or the input to the plant doesn't exceed a large ridiculous values so what I actually want here is I want the step response from R to you here so again all you got to do is click on this drop down and look for here we go R to you this is should be the plot now showing in order to get this step response here's the control authority that's needed or the control signal that's needed and you can see this is getting a little complicated so let me let me move this over here I'll put all the step responses maybe together there we go so I can look at both the input to output as well as input to control signal okay so now I think we're ready to go let's start thinking about adding design requirements so the first thing we're gonna want to do and the one that I think is probably the the most helpful is let's start thinking about those performance metrics like percent overshoot and things like that so if you come here to your step response plot if you just right-click anywhere and you can now come down here to say design requirements new so I want to enforce you get this nice little dialog that comes up I want to enforce it I want a rise time of one second or better I want a settling time of whoops three seconds and I want less than 40% overshoot great and now if I go ahead and hit okay this is really cool because you see I don't know if it's gonna show up too well but there are now white and yellow section so the yellow sections are inadmissible the white are admissible this is where we want the system to be in so this looks actually great it looks like we're actually um well actually we should take a look here yeah this looks like it's satisfying the system right now one other thing that we may want to do is you see I would like to see the actual percent overshoot and the actual rise time and all of that stuff as well not just which regions are allowed or not so what I can do is I can again right-click on the white space and I'll come here to characteristics and I'm gonna click on peak response and we get a little dot here and if you click on the dot it talks about here here's your percent overshoot great so we're sitting at a little more than 30 percent overshoot um we could also continue this pattern and I can come here to characteristics I could look at settling time and I guess if I move this out you can see the other dot and let's do rise time as well so this is great we've decorated our plot now and we now can see given the controller that we have right now which is a controller of value 1 these are are the performance metrics that we're getting so this looks great let's continue um coming up here to the root locus maybe what we should do is let's also add those requirements to the root locus so if I come here and right-click on the root locus now I can also come here to say design requirements new and we'll do the exact same thing so I want a settling time of less than three seconds and you get the white regions and and yellow regions I also want there we go design requirement new I want a percent overshoot of less than forty percent and we should see those diagonal lines yep the diagonal eyes pop up and then finally we should be able to say design requirements new and actually there isn't a it remember there's not a mapping from of rise time to pole locations so that's not available but if you want any of these other things you're free to add them ok so uh let's see where else do we need to add some requirements so you can see already we got gain and phase margin already being directly read off so we can see those now down here in the closed-loop bode plot we need to make sure that we are meeting the bandwidth requirement and if you remember from our lecture on bandwidth we're basically wanting to make sure that we the frequency at which the amplitude decreases by 3 D B's from the from the DC gain is greater than 5 so we see here that the DC zero let me just zoom in just to convince yourself of that right so this looks great the DC gain is zero so really what I'm looking for on this bode plot of the closed-loop system is where does it cross negative three decibels so what I can do is let me deselect the zoom tool and again if you right click now when you have no other tool selected just right click on the bode plot and same thing we're gonna come here to design requirements new and what I'm gonna say is I want the system to be I want it to be above a specific bound and you can see right here you can you can define what this bound is we can talk about what at what frequency do I need a what specific magnitude so I need this thing to be negative three decibels and I'm gonna draw a line from negative three decimal at negative three decimals going from one Radian per second up to ten radians per second which is perfect because the critical one that I'm looking for is five radians per second it's in this range so if I hit OK you see we get this other yellow region and if i zoom in maybe it would be a little bit helpful because again with the bandwidth requirement I'm just looking at five radians per second so I'm gonna zoom into here okay so this looks fairly great actually um and interestingly it looks like we're almost satisfying the desire requirements right away let me look here at one more thing remember we had the step response R to you so here we go this is the other one we can look at so we could see that yeah it's only taking one volt to achieve this design so let's actually take a closer look at the root locus so this is the root locus for the closed-loop system and you remember this is our DC motor which has mechanical dynamics which are a little bit slower right nearer to crossing the imaginary axis and electrical dynamics which happened very very fast here so you can see here there's this pole out at minus a thousand so most of the action is happening near the origin so I want to zoom in on that so if you click on the root locus I'm gonna just click here on the root locus and you see as soon as you do that you get this extra tab up here which says root locus editor so if I click here there's all these tools to help me manip the root locus so I'm gonna click on the zoom tool and let's zoom in to where all the action is happening so here we go this looks a little bit more interesting right so what we see is the magenta items in the root locus are parameters of your controller that you're able to change so notice that there are it might be a little bit hard to see but there are blue items like here's a blue X and another blue X over here those are poles of the plant which were not able to manipulate but since we can change the controller we move the poles of the plant to closed-loop locations which are these magenta squares and the magic of the control system designer is that it's going to allow us to change the controller in real time and then watch how all of the different results change in response to that modification so let me pull up the step response so we can see what this looks like and I will come back to the root locus editor and I need to click on it again to get my tab to show up whoops sorry I had that I have the zoom tool selected so it actually moved on me let me grab a couple these tools and reposition the root locus where I'd like it and now what I'm gonna do is I want to click on this little arrow tool and now if you come back to the root locus with your arrow - and hover over any of these magenta items it could be poles which are these magenta squares later on we're gonna see that you can add zeros or other types of objects like complex poles or zeros to your compensator and you can also move those but what I'm trying to get at is anything magenta is something you can grab and drag and manipulate so I'm gonna sit here click on the pole and here's the magic I can just drag these poles to any other new location on the root locus so for example if I want to increase the gain I can push them push them up and look at this here's the magic notice how everything else changes in response to this modification so my step response is changing all my bode plots are changing etc etc so here here's a design and you might notice this is a maybe a design you'd like to consider you we see that it doesn't quite satisfy what I'm looking for so maybe tell you what let's back off a little bit let's let's bring the polls down and again I'm looking at the route sorry I'm looking at the step response to understand what are the performance metrics because I don't have a second order system I have a third order system although it's second-order dominance so you're seeing that these bit basically these two poles are what matter we're gonna look at the situation later where that's not the case so again I just want to bring your attention that you really should be staring at the step response kind of ignore all the white and yellow regions in the root locus there they don't matter quite as much but here we go let's say this is a design I'd like to consider right and we can come over to this side of the control system designer click on C and we see that here a gain of K is equal to 1.3 862 arm will yield all of this behavior let me show you a real neat feature of the control system designer the whole point of the control system designer is to allow you to rapidly iterate on control designs to try to find one which meets your needs so if you come here to control system designer what you may want to do is periodically store or remember different controller designs so for example maybe I really like this this controller of K is equal to one point three eight instead of me having to whip out a piece of paper and write that number down and try to remember what all the performance metrics associated with it were you can just come up to this button that says store and if I click on the store watch this little fit this window that says designs if I click on store I get this thing that's called design one design one is this controller so now let's say I want to move these polls and try a different design maybe I don't like how much overshoot this there is let's let's pull this down a little bit more keep going I don't know maybe whoops let's go how about I want all the way down to the real axis here we go okay so this is another design that I maybe would like to consider so again I will just hit store and now I get designed number two and what I can quickly do is now flip between design one or design two so for example I can go ahead and say all right actually I don't really like design number two that I'm sitting at right now because I noticed oh look at this we don't meet the rise time requirement right it takes us too long to so I really want to go back to design number one so I'll just click on retrieve design number one and whoa BAM we're back to where we were earlier this is actually even cooler you could even compare multiple designs let's let's get a third design how about somewhere in between those two design 1 and design 2 I'll make a happy middle ground how about something like oops I want to look K 0.55 is just because there okay this is pretty close k of 0.55 ish and look this seems also reasonable so let's go ahead and store this so now what if I want to compare all these designs well just go and click on this compare button and maybe I will compare you know we can do all three if we really want to and look at this this is really awesome because it will now overlay all of those different designs in all of the different plots and you can understand how they have advantages or disadvantages over one or the other so in this case what I want to look at is let's clear all oh sorry I somehow didn't clear I missed the clicking on design number three um because that's the one I actually want so tell you what let's clear all of our compares and let me go ahead and retrieve design number three okay so design number three here we are this is the K of 0.55 and let's go ahead and double check that this matches and meets all of our design requirements so coming here to the step response between the reference and the output we see that yes the rise time is better than one second the percent overshoot is less than forty percent and the settling time is less than three seconds that looks awesome let's also while we're here in the step response double-check the control signal so this is great it only uses a little more than a half volt in order to achieve this type of performance let's come here to the bode plot of the loop transfer function so we see yeah we've got more than twenty decibels of gain margin and we have more than thirty degrees of phase margin so that satisfies and finally let's check our bandwidth requirements so here we need a bandwidth of five radians per second or better so I need to check where does this thing cross our negative three DB line so this is a little bit harder to read I think here's one Radian per second and this is logarithmic so here's two three four five six so somewhere between six and seven so I would guess the bandwidth of this is you know about six and a half radians per second so great this design looks awesome design three looks like the one we want to go with because it meets all of the the affer mentioned requirements so we should maybe think about moving on to the next step right is Step five is I like this requirement or this controller let's make sure we save it so we don't lose it okay so now that we've completed step number four which was designing the controller which we saw was basically grabbing and dragging magenta items in the root locus to meet your requirements we can start thinking about trying to save our controller that we've designed so the next step step five is I need to export the controller out of the control system designer and into the MATLAB workspace so what I mean by that is if you come back over here to the control system designer um notice there's all these things that we've made we we actually made the the C that's actually what we design here the control system designer that's our controller now if you come back to MATLAB you'll notice it doesn't exist over here in the MATLAB workspace so that I can't go ahead and say save my controller dot mat C right because there's there's no severe you'll see here all of these variables right now only exist in the control system designer so what I need to do is I need to get those back out to to MATLAB so in order to do that I'm just going to come over here to the export and if I hit this little drop down I'm gonna say export tune blocks and when you do that you get this little window which allows you to export whatever you'd like all of these different things well the only thing I really care about is the the model C in the control system designer which was my controller and we can change what I want to call this we could say that it call this maybe let's call it proportional controller and if I now hit export and come back to MATLAB you see that it has made this thing called proportional controller so if I look at this here it is I've got this now export the MATLAB workspace this is the controller that I want to use okay so now let's go ahead and move on to step 5 excuse me step 6 now that we've exported the controller we can go ahead and save it both the controller and the session this is what I the workflow I usually like to follow so what I mean by that is let's come over to MATLAB and now we can go ahead and save whoops here and I guess we didn't call it C we called it proportional controller so it's it's really this simple I'm gonna do is just save this zpk object into a file and when I do that here it is here's my controller dot mat so I've saved the variable but all of this work that we did back in the control system designer right moving all the poles around setting up all these plots this was a fair bit of work you might want to save that as well so what I mean is you can come up here to then click on save session and what will that will end up doing is it will create a mat file which should hopefully be loadable in the future so let me go ahead and call this control system designer session maybe let's call this underscore proportional controller dot mat and it will just save that in the current directory so let me just illustrate that for you where is my current directory here it is so here it here's the controller that had only the variable C and here is our mat file which contains the control system designer session so a word of warning with this you might think this saves everything perfectly but let me go ahead and show you what happens so let's pretend that we're done for the day let's close the control system designer and we want to come back and boot this back up again so let me go ahead and just clear everything maybe that's a good way to do this let's start from scratch so everything is gone I can go ahead and go start my control system designer like we did earlier and bring it up and here we go it's loading up our blank control system designer so let's go ahead and open a session that we just saved if I come here to here it is here's the the session we just saved and if I open this up give it a second here to load it will get most of the items correct it will load in all the objects but notice here that it really didn't save my layout too well so you may have to play around with this a little bit to get this exactly back to where you want it to so for example I think we had the bode plot of the loop transfer function was over here I think we had actually yeah this bode plot was down here I had we had this over here come on and then we had our root locus on top ok now we're now we're getting a little bit closer to where we were but again notice you might have to go ahead and add these characteristics back so it's not a completely foolproof method but look it did save a lot of the items like it definitely saved the plant it saved the controller and it saved all of our other designs that we had built earlier in case we wanted to go back to one of these other systems right ok so this is looking great I think we've done step 6 ok so the last step in our workflow is step 7 where we want to simulate this system to validate performance so what you could easily do is one option is come over to MATLAB and just start up Simulink and build yourself a blank model that represents this system with the controller and all of the stuff that we had earlier so I will get a transfer function here and make this G of a GP of s and then I guess we could come in here and call this GP new manned GP den and then we could go get another gain which represented the controller which was 0.55 I think was what we had and you could start hooking this up and building the system and hitting simulate to make sure that you got the performance that you you design in a control system designer and this is a perfectly viable way to go right you could go and make all of these blocks yourself and hook everything up but as the systems get more complicated and you want to rapidly iterate I think you can see why this is a little bit cumbersome of having to build the Simulink model yourself so what's super awesome about this is let's go back to the control system designer and this is the system Oh a sorry actually no this is not the system we want and we better go back and retrieve design number three this was the system we wanted now with the yeah let me do triple check yeah with a K of 0.55 let me show you a really awesome button that the control system designer has so if we come here to the export tab and there's this other thing that says look at this create Simulink model so instead of me grabbing and dragging blocks by myself if I click on this it knows what type of architecture we're using so it knows all of the blocks and knows the architecture so if I click on this I get this little warning here maybe we should read this quickly and what it says is it's going to create this Simulink model and it's going to export all these things like FC gh to the MATLAB workspace so you better make sure you don't have any other variables called FC G or H because it's gonna overwrite them I know I don't so I'm just gonna go ahead and hit continue and yes and if you give this a second what it's going to do is basically Auto gen here it is it popped up on another window I'll drag it over here look at this this is amazing right it automatically generated the appropriate architecture let me just compare this maybe I'll pull this up on one side and pull the Simulink model up on the other side notice it it it did almost perfect I want to say almost perfect because oh the one thing you might want to notice here and I feel like I should call out is that the input block here if you double-click on this for some reason whatever it decides to use a sine wave as an input I like to look at the step response so I'm gonna make a very very minor modification to this auto-generated system and basically input a step instead so I'm going to get a step function and I'm gonna make it go at how about how about two seconds let's go yeah unit step value and let's put in a manual switch just so I can quickly change between these two different inputs and connect this up connect this up here we go flip the switch two down and let's also make me put an additional scope on the control signal because that's always something that's interesting to note is to see how much control authority are you actually exerting so if I go ahead and hit run this Simulink model ran and I can look at the output let me pull this up here we go and I can look at the control authority here we go here they're the two and these look exactly like what was predicted in the control system design and let me see we can pull all these up maybe side by side let me pull this to the this come on there we go okay so we got the step response of the actual output and the control authority so let's line these two up and look at this they look perfect right great so with that I hope you've seen how the control system designer is a really powerful tool to help us design and iterate on linear controllers of course in this case we used it to synthesize a very very simple controller just a proportional controller but this sets the stage and I wanted to just show how this tool can be used because in our future video we're actually going to be talking about how to design P I or P I pseudo d-- controllers using this this workflow so for those of you who have been with us a while thanks for watching and if you're new to the channel please subscribe and let me know what you think in the comments below I hope to catch you at one of our future videos where we're gonna look at applying this control system designer to a more complicated system so until then I'll catch you next time bye
Info
Channel: Christopher Lum
Views: 56,512
Rating: undefined out of 5
Keywords: Matlab, Matlab Tutorial, Matlab Control System Designer Control System Designer, sisotool, rltool, design linear controller, design control system, control requirements, design requirements
Id: RPzFLzKkQGs
Channel Id: undefined
Length: 53min 4sec (3184 seconds)
Published: Sat May 18 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.