Skip to main content
Loading Explore guides…
Control Design Principles · Acedra
Home
Explore
Engineering
Control Design Principles
Sign in to save
Chat
If YouTube asks you to sign in, open the video on YouTube.
Watch on YouTube
Reload player
Transcript
59 segments
Copy
Hide video
0:00
Hello and welcome everybody. This is again the MATLAB and Simulink Racing Lounge. In today's episode, we are going to talk about the principles of control design. And when it comes to control design, I need an expert, I need a specialist. So thanks very much to have you aboard. — Hi Daniel. — Hi everyone. Could you say some words about yourself, just introduce yourself briefly? My name is Daniel. I am electrical engineer. I am application engineer now at the MathWorks
0:24
here in Germany, and I am doing control design — and focus on physical modeling. — Okay. Well, control design is important for today's episode. So what are we going to do? We are going to talk about the classic control design workflow. So for that we've just chosen a device. In that case you can see it, it's a throttle. We will set up a plant model of that throttle and then directly dive into creation and tuning of a controller. And we will touch two more topics,
0:51
which are creating a robust controller that is able to withstand all the uncertainties that might happen, and secondly to tune the response of the controller to a certain requirement. Well, we've already introduced this throttle example. You should not be scared about the equations we present here. So what we simply assumed is we have a throttle valve and there are three torques acting on that. First, the spring that always pulls the throttle back to the initial position.
1:20
Secondly, the torque of the motor that acts on the throttle. And third, we have introduced a damping behavior, something like friction which can occur in every mechanical system. What you see here is all the equations written down. Then they are resolved for theta double dot. You will see why this is important. You will also see the parameters. And the resolution for the equation to theta double dot is important to set up the model. Well, setting up a Simulink model is very easy.
1:49
What you see, we have theta double dot. So the double dot time derivative of our angle. We integrated twice. Afterwards we get the angle. And this allows us also to introduce all the parameters that we have defined. I think starting from that model, which is a pretty basic and easy assumption of a throttle, I will hand it over to Daniel who will show us how to control that system. Okay, so let's start from this point, from Christoph here, we see the plant model.
2:17
Now I'm going to change to Simulink, and you're going to see the same model. So let's change to MATLAB Simulink. Here you see the same model again. Starting from the left side, we have here the voltage applied to our device. And the angle is the reaction of the throttle. First thing we're going to do before we do the control design, we select all the blocks and create a subsystem which makes it a lot easier. I really recommend to do this, because this hierarchical structure
2:52
makes it so much easier to model and to understand your system especially if someone else is looking at your system. Well just to recap on how you do it, just select everything, all the blocks, yeah. And then you see a blue mark here, and just click on create subsystem. And then you can create another subsystem. Okay perfect. So we come in here with the voltage. We go out with an angle. — Yep. — Okay so far. We also can change the name of this one. Let's say this is the plant.
3:25
The next thing I want to present is a very cool feature from the actual release which is 2015A. You just click to add, we now want to add a block to the model, a controller. We want to use a PID controller for this plant because it's the typical controller used for things like that. And I just click into there and type PID. And now it gives me all the blocks in the Simulink library which are some kind connected with PID. I want the first one, the Simulink PID controller.
3:57
Just hit enter. Okay, here's the block. Now I connect it to my model. Just drop it in, and that's it. Okay, that's our PID controller. Next step is that's not any more the voltage which is applied. That will be the reference. Or better to say, when to do a control, we have to close the control loop, we get here the reference in, do here a sum with the reference, go to the control, then to the plant, and then the way back. So first thing is, we need the sum.
4:26
— Again, click on canvas. — Same approach here. Sum okay. Now we get an option, list of signs. We get the reference in, which is positive. But we want the feedback from our plant, we want to subtract that. Subtract the arrow in the thing. Subtract the arrow to get the arrow, yeah. So we subtract from our reference signal. We subtract the current status and then we get the arrow. And for that, I first use those signs. The first one means there's no connection. This means above.
5:00
Then will come our plus Plus. And then we'll want to subtract. That's minus. Hit enter. That's the plug we want. Cool. Connect this one. Quite easy. We don't need the angle anymore. And just delete those plugs here. Select them and delete. Okay, what we're now going to add is, we need now a reference for our signal. In order to be flexible and to create — maybe we want to do different scenarios of things. For that we use a very flexible tool, which is a signal builder block.
5:35
So I type in signal builder. So that's this block. We also could use a classical step function. But let's have a look at that signal builder and the additional capabilities. The nice thing of the signal builder block, you can group your signals. You cannot only have one signal. You have multiple signals. You can also have different scenarios and simulate them all or only simulate one of those. You can also import spreadsheets, Excel spreadsheets or data, which makes it easy.
6:09
For example, drive cycle, which is—you can directly import it and work with this one. But you can also interact with, change your signal as you want to have it or if you want to have this dot like this. You see it's quite easy. And now we want to replace a signal with a step, because you should use a step for control this side. Introduce the step. Now here, our maximum signal, this one is the reference angle. We want to go from a closed position to a fully open position in our example.
6:43
Simple example. You can also use more— Well in that case I think it makes perfect sense, and we go up to 90 degrees, complete open throttle. Yeah, put it here to 90. So I can also move it upstairs, but then this way I have exactly the 90. — Perfect, makes sense. — Okay this is our signal. Let's close it. Now, let go back here. You have here the reference signal. We subtract in order to get the arrow for our plant signal. Then we do the control, the plant, and that's it.
7:15
Okay, now we could simulate the model but we want to also see our simulation results. In order to do that, we could add a scope clock to this, but this makes the model more complicated. We want to avoid this, and that's why we click on the signal we want to look at, create and connect the viewer, and create a new scope for that. Well, which is also a scope. I think the advantage of that feature is you can add multiple signals to the same scope. That's the same. There's also signal scope manager.
7:47
We won't look at this one but where you can manage all your signals. But here you see there's a scope. We also want to look how our plant behaves, so we also create here one and connect this one to the scope. To the view. So now we have the two signals in this one. Let's simulate and let's have a look at our signal. Okay. That's our current. So we have about the right behavior. So we start with a closed throttle, then apply the step until full opening.
8:17
What we see—we're zooming in a bit to the signal— we have quite blurry behavior, some overshoot and then some vibrations. And this is actually what we are going to improve now. We want to fix this problem to have the system behavior we really want to have and not like this. We want to define it. Now let's see. Okay, first we go into this block. Here we can influence our system behavior. Just a question at that point then. You mentioned it before, but why at that point
8:47
is the PID controller the classical choice? Could we have taken other choices? Or why did we choose that one here? The PID controller, let's say it's the typical or the mostly used controller. The good thing about this one is you can use linear control theory. So you can say okay, in this working plant, our system is stable. It's more easy to say something about robustness. And the problem of nonlinear control design is it's very specific for application. So the good thing about PID
9:22
is you can almost apply it for, let's say, 90% of applications. So then it's a good starting point. We can summarize it like that for linear controls, and in that episode we are actually focusing on linear controls, PID is pretty common. PID is standard. It's the mostly used. Now we want to change our system behavior. In order to do this, we change the parameters of this block, which are the proportional, integral and derivative. That's why it's called PID.
9:52
Those three parameters, we want now to optimize them. We want now to change them. First I define and notice values. I want to use a work space variable which are predefined, so I predefine for the proportional a value of P, which is one in the work space. The same for the integral one. You pretty much specify the same values but as parameters and not as fixed values. So we have more options, and we can later save it and whatever. Makes perfect sense here. Apply, okay. Now we have those values.
10:23
Now we could change those values to things to have another system behavior but the most convenient thing is, as you see here, a button which is called Tune. — We just used this button. — Yeah, let's try it out. If you have MATLAB Simulink, just try it out. It's a cool feature. It's a really cool feature. In fact, click on this one. Now it's starting the linearlization. After linearization, here the plot shows a suggestion of a new tuned response and it shows the current response.
10:53
Okay, so dotted line is the current system, and full line is the tuned system. So how are we actually tuning a system? You see here the two slider bars, which are in a time domain? So here you can directly tune and gather different behavior. Perfect. Okay. You see also here the parameters of this, so you have also some performance and robustness. You see it here directly the comparison between the current and the tuned one. In order to talk about those where you slide gain and phase margin,
11:27
let's have a look on the frequency behavior. For that we add a plot, a bode plot and an open-loop plot of our system. Okay, now you see it here. Again we see our plot response and a tuned response. And now the way it's shown here, the gain margin and phase margin, are the margins of the tuned and the block response of our plant. So we can say here, okay, phase margin 69 is quite a good value. You see it's also saying it's stable. The same with gain margin.
12:04
Looks quite good, so we have a stable controller. And the good thing is an algorithm here guarantees us a stable plot except depending on our— if you see at the phase margin and gain margin, everything looks always good. Makes sense, perfect. Okay, now let's look if we also have it in the time domain. Let's make it maybe a little bit faster, and let's go with this value. Now if it's not for you it's okay. No, let's go with that updated block. It means our PID controller is automatically tuned.
12:36
Now those values are applied to the variables in our work space. And we can close our model. They're applied to both values. Let's close this one, and let's do a simulation again. — Look at the values. — Open up as the scope again. Well, what we see is a much smoother behavior, and it's reaching 90 degrees a lot faster. It's faster but where for high overshoot, now we can change the overshoot behavior of things. Well, this is the way how we can tune actually our controller.
13:07
So now, let me ask one question— and we have talked about that— uncertainties. Basically imagine that we have a model that is not 100% right. For example, if we go back to the model, Let's say it's all right, but if it's uncertain, if the value's not exactly known. So do we have a workflow to overcome that? Yeah, I already prepared something for that. It's for the damping. Here for this coefficient it's 0.04. But you know, you're not always knowing it. And it also depends—
13:40
But in that case it's actually a very good example because friction is involved in every throttle, and depending on the dirt that accumulates in the throttle, that damping value might actually change. So how can we model that uncertainty that might happen and also might affect our control quality? In order to show one possible way to how you can do this in linear control theory, we now apply here to this block we can also say for the linear analysis we have a specific block linearization.
14:12
Okay, let's try this one. We highlight, we use this one. And we use the MATLAB expression. This one which I prepared is an uncertainty of the parameter, Kd, which is nominal. Those 0.04. But the tolerance is 20%. This means we don't know the value exactly, but we know it's in the range of 20%. — Block's minus 20%. — And that's what— That's a pretty realistic case. I would use the tested values in your case, but just to show the workflow it's a pretty good example.
14:47
And you can also say, okay it's not only in percent. You can also specific range or things like that. Yeah, and we can do that for every parameter where we are not really sure. And this way we can include those uncertainties in our model. Okay cool. So let's try that. We were talking about linearization. In our PID control, we did it implicitly. And we did the tuning of our parameter. Now we want to do a linearization of our plant— well, of our whole system from this signal to this one.
15:20
In order to get that we can do that, we have to define here and analysis point. Here we want to check. We want to do an input perturbation. Here we apply our signal for the linearization. And after the plant here, we say okay. We measure in summation. Okay, outward measurement. So now we have the plant behavior between those two points. And we actually want to model those uncertainties between our input and the output. And now the next step is the control design, linear analysis. This one.
15:56
Let's start the user interface. Now we have here some options. We can do a step, a bode, impulse, or different things. Let's start with the step. Let's stick to the step function. And now it's doing the linearization between the two points. And already here in the workspace we see an uncertain system. Yeah. We see this one, USS. If it's here it's an uncertain state-space model with one output, one input, four states. That's our system. Now, these are the values between, but we don't know
16:35
if this one really is the worst case. Which one is worst case scenario? For example, let's talk about the overshoot of this one. We actually see the worst case. What we see, one curve is probably the one with the most overshoot. But we don't know the parameters behind, so which uncertainty or which parameter is exactly fulfilling that curve? In order to do this, we have this model here, the uncertain state-space model. We can input it directly to the MATLAB work space.
17:05
Oh really? You just drag it over? Drag and drop, and it's now in the MATLAB work space. And so now we have all possibilities in the MATLAB to find all those values. — Great, well let's do that. — Yeah, let's change to MATLAB. Okay, now we have the command window. Here you can apply functions and do calculations. The good thing about this, later you can all script it. Just write a script, and then you can run it directly without having to enter everything. Let's start first.
17:34
We want to find the worst case. The worst case, which you said in this case for the gain, which means where is the highest overshoot? Let's do that. You use a certain function that's called wcgain. Yeah. This one is applied on our linsys, and we get back from this function the maximum gain and the worst case values, which are the worst case values for our uncertainties. Okay, let's see. So what we already get here and we have the Kd value of 0.048.
18:16
And this is exactly the upper bound of our uncertainty. So the more friction we have, the more we run into the worst case scenario. In this case it looks quite simple. But if you have more uncertainties and if it's getting more complex, in this way you can really include all effects, not only the effects you understand. You also get—if they are connected in some way or things— so you get really the worst case. Especially when you're working on a more complex system, you have more uncertainties.
18:48
I think this feature pretty much gives you great confidence in your system because at the end, you cannot check every variable. And this truly can tell you the worst case. Okay, in the next step I want to show how you can also plot those worst case in comparison to the existing ones. In order to do that, there's also a function which we have to use. It's this one. It's the usubs function, also from robust control toolbox. You apply on the linsys1. It looks with those values
19:22
and gives you back the system for worst case. Okay, now we have our system. Next step, you see it also here in the MATLAB work space. — That's the system worst. — Worst case. And we have here all the systems. Next step is now we can plot those too. For example, in the step function, do you want to the bode? No, we have a step function here anyway, so it would be cool to have it in the same plot. Okay, let's do a step function. You see here now what I entered
19:53
is a step from linsys and this is worst. — Let's go with this. — And we get our step response. So it's the red curve. Let's zoom in to have a better view of it. But this is exactly what we expected. So we wanted the scenario with the most overshoot, with the most gain. Well, that's a pretty nice proof of concept. And I can see the power behind that for more complex systems. It really helps, makes life easier in that case. And it makes the system more robust.
20:24
And in that case you really can be sure, in terms of overshoot or in terms of gain, this setting is actually your worst case. It means all other settings are not harmful to your system. Especially if you have some experience. Based on temperature, we have the experience that this value can be in this range. You can directly apply it to your control design workflow and hence, we have a stable control and robust. We've also promised you to talk a bit about optimization.
20:57
So the classical scenario here is we queued our controller and we are pretty sure that we can overcome the worst case scenario. But what if we have certain restrictions? How could I model certain restrictions so that the controller doesn't violate those restrictions? That's a new thing you're talking about, a new aspect which we can use, as well. We are now leaving the linear analysis. Besides linear analysis, we have also the possibility to use optimization.
21:27
And optimization is very powerful, because as you said, if you have restrictions on more general— if you have requirements, you can define requirements for your system. For example, you want to have the overshoot not to be more than 10%. — Or you have the rising time. — Let's exactly try that. Let's do that in the model. I am changing for that back to the Simulink model. And now the tool where I was talking about is response optimization. It's analysis, response optimization. Let's start this.
21:59
Okay. And now we see again here the design variables and also the uncertain variables set which we can define here. So we are not losing the uncertainty information. No, we can do this as well. Now I'm going to define our design variables set by clicking on this one, and say let's define some new variables. And for this we select all of our controls. Makes sense because we want to optimize all. They are listed all here, and let's okay. Let's close this, apply.
22:36
And now we talked about requirements of our system. Here you see the requirements you can define. You can do it in the time domain different but you can also define customer requirements and also the frequency domain. A pretty big variety of requirements or restrictions that you can apply. As we're talking about principles, we stick only to some simple examples. What do you want? Some step response or some signal bound? I think for me it's important to have a realistic case.
23:10
What about—I am an electrical engineer— now, about the models. You have always also a maximum voltage of a model. Yeah, for example? What about that? Okay, let's go back to the model. Here you see this one is the voltage which comes out. And at the moment we have no idea what's the value of this one. Let's for that first connect a new viewer, simulate, and check out what's the value. What we see here, it's going up to 18 volts. Well, this is a very realistic case. Great thinking Daniel.
23:48
What we see that the voltage applied to the throttle is going far beyond the value that it actually needs at the end. So just imagine a situation where we have a maximum voltage that we can apply on this throttle of 15 or 16 volts. That means we have to optimize our controller behavior so that when it controls it, it doesn't reach that maximum limit. — Okay, in order to do this— — Sounds realistic to me. Yeah. Yeah, let's do it. Stick with the 15 volts. Let's say it's 15 volts.
24:19
For example, we only have based on our battery— we have only the 2 volts, 12 volts maximum. It might be an option. Let's go with this. So back to the response optimization tool. Let's define our signal bound. In that case a bound. Now we have constraint should be less than this value. And here we can also give— In the time domain it also specifies the amplitude. Let's define here the 15 volts. And in 10 seconds the same. And then have your linear behavior. And it's a linear bound, so yeah.
24:57
Looks good. Now we have to select the signal. So how do you select the signal? Press the plus sign. There's nothing. No signals have currently been selected. So you just go to Simulink, select your signal. — Let's do that. — Cool. Select the signal. Go back. And there it is. Let's go with this one. Hit OK. So basically now we have specified— I think I forgot here. I put only the one. Let's change this one too. — Okay, the amplitude. — Yeah. Well this is just an assumption.
25:35
The voltage amplitude is the same at any time. A pretty realistic case here. So that means now we have defined our optimization problem. Do we have to specify anything else? No, but what we can do is we can evaluate the requirements. If we have more than one it makes sense but for one it makes no sense. But let's plot the model's points. It makes sense to see if it's really the way we thought in the simulation. What we see here, it's actually violating that restriction.
26:05
So now the next step is do the optimization. There are some options. We can do parallelization or different algorithms, but let's start with optimization. We start with the default set, but for you it's important if you want to have a certain solver being applied, a certain method that can be specified within the options. Let's start optimization. The nice thing about this tool, you do not only see what's happening here with iteration and the counts and the signal counts.
26:34
You also see directly the influence of how the requirements are met and what's working. And we see now it already converged. Just two iterations were necessary in order to have the signal that fulfills all the requirements. Let's have a look at it. Yeah, here we see directly. We can also do a zoom, but okay. We have it here. The optimization so far finished. Now we can have also a look in the model if it's really the case. Exactly, so let's have again a look at what you've scoped.
27:10
Well, and for me it seems to work. The signal stays at the 15 volts or below the 15 volts. So let's have a look at how the controller behavior, or the plant behavior actually, is impacted by that. Now you see here. Well we have the same or similar smooth behavior. Might be that the controller is a bit slower compared to the previous one, but still we are stable. We are able to overcome all the uncertainties. And we have an optimized signal. Perfect. I think, Daniel, thanks a lot at that point.
27:43
And we have learned a lot. This is the classical Simulink workflow so let's just get back to the slides. First of all let me recap what we've done so far. We've chosen a model. We've set a plant model. Then we've created and tuned the controller. And then we have done two additional things. We've ensured that our controller even works for uncertain signals. So for changes in the model. And secondly, we have optimized our system to fulfill certain requirements. Exactly.
28:12
For me that's pretty impressive, and that brings us to the key takeaways of today's session. So Daniel, would you just go through them and say some words about them? So what do you think about that? The first thing is control design is not magic. What I want to say with this one is even if there's a lot of mathematics behind the things I've shown. There's a lot of stuff behind. But it's not magic. You can use it. Those tools are for to use. You don't have to have a PhD in control design
28:38
in order to have a stable and robust control. It's the first thing. And the design workflows are straightforward and usually very similar always. So you can always use the same workflow in order to get a robust and stable design. Okay perfect. And another thing, I really like this. It's the worst case analysis. So maybe you know the worst cases already from experience, but in this way, you can even enhance it automatically. You can define it properly. And maybe you find a worst case,
29:11
which you, in the history until now, didn't find yet. And so the good thing is if you already know them, you don't have problems in the future if you might find them without knowing them. So well the last point we are mentioning here is the optimization capabilities, which are really bridging the control model to the real world. But in reality you have restrictions. As we have introduced, you have a voltage maximum, and you make sure by the optimization toolbox
29:39
that your control system behaves in a compatible way. Perfect. At that point, thanks again Daniel. I enjoyed the episode. It was really cool. Me too, thanks for being here. Okay great. And at that point, well we have done an episode called Principles of Control Design. I think there's many, many materials to come up, so we have talked about parameter estimation or different topics that we could cover that are, for example— Yeah, let's—more robust control,
30:08
a lot to talk about model predictive control — is quite interesting as well. — Perfect. So there are many topics to come up. Let us know whether you liked that session or whether you liked that episode. And we are happy to do further topics just for you. This brings us already to the end of today's episode. Just for recap, if you want to have a look at all the MATLAB Simulink Racing Lounge videos, just go over to the dedicated learning page, which is mathworks.com/racinglounge.
30:36
If you are interested in new information about your Formula Student Competition, just go to the dedicated webpage there. And as already mentioned, we are really happy to receive your feedback, comments, questions. Let us know your feedback using the team email address. It's formulastudent@mathworks.com. And just for those who are not aware of our Formula Student software offer, we have a software offer for your teams. You can access all our tools that we use for free.
31:01
And if you do use our software, we would be happy if you use our logo on your cards and on your reports as well. Thanks again. So please do it at home all the things we just showed here. Our recommendation is definitely to try all out and if it works let us know. If it doesn't work, also let us know. Thanks for watching and see you next time. Okay bye.
Here to help you learn
Sign in to keep a private conversation with your course tutor.
Ask me anything about the material…
Sign in to chat