Teaching Introduction to Controls with MATLAB and Control 101 Toolbox - MATLAB
Video Player is loading.
Current Time 0:00
Duration 26:52
Loaded: 0.62%
Stream Type LIVE
Remaining Time 26:52
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected
    Video length is 26:52

    Teaching Introduction to Controls with MATLAB and Control 101 Toolbox

    Dr. Anthony Rossiter, University of Sheffield

    Modern technology and software have opened new doors for academic staff, empowering us to create interactive learning resources that are not only quick and easy to develop but also incredibly cost-effective. These resources are invaluable for our students, offering them a platform to learn through hands-on experimentation, visualize complex engineering concepts, and dive deep into detailed problem analysis. What’s more, these resources seamlessly complement laboratory activities, providing students with the freedom to experiment and iterate rapidly, both before and after their lab sessions.

    Dr. Anthony Rossiter (University of Sheffield), MathWorks, and others collaborated in the development of a “community toolbox for a first course on control.” In this demonstration, educators can learn how to integrate the Control 101 toolbox into their curriculum and better engage students with hands-on examples and apps. In order to maximize accessibility to worldwide users, the toolbox is available through File Exchange and GitHub®.

    Published: 7 Mar 2024

    So what I'm going to talk about, as you can see, is the MATLAB control101 Toolbox. And the idea, as you'll see, is to encourage students' engagement. So we'll go straight on, and you can obviously interfere as necessary.

    So what's the context? The main focus is an introduction to Control. So a first course in Control. And one of the historic issues is that students often do a first course in Control and they think it's all about mathematics. And they finish the course. They have no idea what feedback really is about. They think, I've just learned lots of maths, lots of algorithms, lots of Laplace. And we want to try and convert that, and we want the students to actually understand what is Control, what is feedback, why is it important, why does it change behavior, and so forth.

    So we're more interested in the students' finishing the course, actually really understanding what Control is about, and get a bit less worried about the maths details, which can easily come later on, when they're more urgent. So what's the underlying philosophy?

    I'm going to use MATLAB to do the number crunching. So we're going to try and text students initially-- I emphasize "initially," ultimately, they have to do it-- but from the number crunching so that we can get them to focus on learning and understanding the important concepts. Once they're motivated and they understand the concepts, hopefully they will then deal with the maths as and when they need it. OK?

    So this is what the Control Toolbox is about. Now, if you want to find it-- and I've got a slide coming-- all you need to do is search for "control101" under the add-ons. So I think that's the next slide. So you can see here the MATLAB slide. If you go to that Add-ons button and you basically press Get add-ons-- and after you've done that-- actually, it's not showing you here-- once you've done Get add-ons, you'll get a Search button and you search for "control101," and it will come up. And you just go Install. And it takes about one minute.

    If people find that difficult, we hopefully will have time in the Q&A to do a live demonstration. And then what you'll find is it will automatically populate your MATLAB window with lots of the tools. There's only one tool in that window. So if I just bring my MATLAB window across briefly-- and you'll see here at the top-- you can see here My Apps-- you can see all these tools that have come from the Toolbox. So they automatically get populated.

    So it's the same for the students. They just download. And automatically, within about a minute, all the tools are available for them. So it's very, very quick. I've used it in this past semester, and it really is very, very quick. So not too difficult to do.

    So what we want to show you is what's in this Toolbox so that you can decide, might this be useful for you? Now, you'll notice what I've put here-- there are slower overviews on YouTube, and the links are all on my website. So if you want to say to the students or if that was a bit too quick, go and look at this YouTube video, most of them are I think about five minutes for each app. So not too long. So students can see what's the app about, why is it important, how do I use it. So you can easily point them there if you want to.

    Now, if you want a compact list and summary of all the current files, they are available on my website. But also you can see this command here-- I've put doc control101 Toolbox-- so that window has just disappeared. Let me just find it for you and I'll show you what that window looks like. So if you do that command-- and that should work in MATLAB even if you haven't installed the Toolbox-- what it will do is it will basically give you a quick summary of what's in the Toolbox. And you'll notice it lists all the files and it's got a brief discussion of what's in each file. So there's livescripts. And here are the virtual labs down here.

    So that command, it's very, very simple to do. So as you can see, doc control101 Toolbox. Notice the capitals. They're quite critical. It will open that separate window, and away you go. And I've just made one critical mistake there. I'll just reopen that.

    The other thing about this doc one is, if you've installed the Toolbox, anywhere you can see is blue-- if you click that, it will actually run the file. So all these blue things are actually shortcuts. So if you've got MATLAB open and you just want to run the file, you can do this doc command. And then you can just basically use all these shortcuts. So the students don't-- oh, what's the name of the file? I need to type the file name. I need to search for it. Basically, I tell the students, just remember this doc command. Type it in your command window. Open this window. And then, whatever file you want, just click the link and it will open and run. So you've got these nice, convenient shortcuts.

    Oh, I went the wrong way there. I've got too many windows open.

    So how's this Toolbox designed? So there's two different types of file in the Toolbox. We've got virtual laboratories, which I'm going to go through second, not first. So I'm going to do them first-- get myself straight. So these are a bit like interactive GUIs, or user interfaces, where users can enter their choices through buttons, drop-downs, and sliders. So you really are protecting them from the mathematics. What you're saying is, what do you think will happen if you change the maths? What do you think will happen if you change the wind? What will happen if you change this?

    So they're meant to be intuitive-type environments, where you can encourage the students to engage with, how does the real world behave? What's the impact of feedback, and so on? And you'll notice, each of them comes with a manual. So the manual has all the mathematical and technical details in the background. And I will show you that. So you can point students to the manual and say, if you want to know what's going on behind the scenes, want to know the ODEs, it's all in the manual.

    We've also got livescript files. And the livescript files are more to focus the students on, how do I code MATLAB to do specific skills relevant to a control101 course? So the apps are limited. They do the scenarios they do. But you might say to the student, here's a coursework assignment. You need to go and study such and such a system. And now the students need to generate their own code to analyze the system.

    So the idea of the livescript apps is basically to step the students through the core skills they might need for a control101 course. So they've got code snippets that they can use as templates for using in assignments and elsewhere. And again, I'll illustrate that and you'll see.

    So we'll start with the apps. That's just a bit of my website, which shows you that if you want a quick summary of what the apps are, it's very, very quick to have a look and see roughly what they look like, roughly what they do. But what I'm going to do is basically demonstrate a few-- obviously, not all because we don't have time-- and that will give you an idea.

    And a reminder, each lab comes with a manual. So what I'll do first is I'll show you the manuals. Let's find my mouse. So when you run any of these virtual labs, the manual will open automatically. You don't have to look for it. The moment you open the app, the manual will open in the livescript environment.

    So the one you can see at the moment is the manual that goes with Car model and behavior. And what you can see is it gives some background here on the modeling assumptions behind the app. It gives a little bit of code so students can do things-- a bit more code down here. So basically, the manual talks through what's going on behind the scenes of this app.

    So if you want the students to do a slightly deeper study of what's going on or if you want them to have a bit more flexibility with the numbers that they use, you can point them to the app. And you can say, look, it's got code snippets in there. You can go and steal those code snippets. You can put in your own numbers, do your own investigation. So they're not having to reinvent the wheel. OK?

    So I'll put that back out of the way again. So let's show you the first app. I've got too many windows open. It can be confusing. All right.

    So what do I ask students to do? I use these in lectures. And in fact, if students have got MATLAB and they've got the software on their laptops, they can do it in lectures at the same time. You can say, you've all got your laptops with you. You've all got MATLAB open. I want you to run this app. Spend three or four minutes. Talk to your neighbor. Investigate what happens if you do this. What happens if you do that? Let's have a conversation.

    So what I'll do now is I'll demonstrate a few apps. And you'll see why that's what you can do. So here, this one is Car model and behavior. And I apologize that the pictures are very cartoonish. I'm not much of an artist, but it's good enough. So if I refresh the screen. So the idea is you can say what happens if you have-- you can see here, a massive-- what is it-- about 800 friction of a certain bit and a particular engine power? And this is how the car behaves.

    And then you can say to the students, OK, what do you think would happen if I made the car heavier? Would it accelerate faster or slower? Would it get to the same speed? Would it go to a different speed? And you can have a discussion with the students. Say, all right, let's try it. Let's make the car a bit heavier. So I've made it heavier now. Let's run it again.

    And what you're doing now is you're doing concepts with the students. You're basically saying, OK, has it done what you've expected? What would happen if you change the engine power? Well, I can change the engine power, have a discussion, and investigate. And you'll notice that the figure keeps track of the different choices so that the students can see all the different choices simultaneously.

    So if you want to do a systematic investigation of changing one parameter at a time, or gradually increasing or decreasing a parameter, you can see all the responses. You can see what happens if I go up a hill. So I can add a hill. And you see it will basically give you the different behavior. So it's a very, very simple app. I'm not going to basically go through everything. But hopefully you get the point, that you can use it to have a conversation with the students and ask questions. What do you think will happen? And investigate conceptual learning with the students.

    It is fairly limited in what we'll cover. It's got wind as well. So you can have a headwind. If you get fed up with the animations, you switch the animation off, and then, basically, the simulation is instantaneous. So the animation is there to help them reflect-- so this is a real engineering scenario. But you can switch it off if it's taking too long and you've got through that step. So that's the car. We'll get rid of that one.

    So which one have we got next just to show? I'm just going to show a few. But obviously, you'll see on the website, there's several. So Control of tank level with PI. So here, you can see you can change things like the size of the tank and simulate. So I've got a PI compensator. And you can say to the students, is that doing a good job? All right. And you can see the behavior I've got. And say, oh, what if I make the integral bigger? And simulate.

    And you can see that's failed pretty catastrophically. But hopefully, you get the point. The animation is allowing students to engage with, hey, this is representing a real engineering process. This is what's happening when I'm changing the parameters. So, again, you can engage the students in a conversation of, what should I do with these PI parameters? How should I choose them?

    Or you could say, what do you think would happen if I make the outlet much bigger? So you can see there, I've made the outlet much bigger. What's going to happen? And you run it. And you see you're now getting quite different behavior.

    You can investigate-- you see this red block is a blockage-- what would happen if I have a 90% blockage? How will that change behavior? And you can simulate and you can see. So the whole point is not overly complicated, but it's enough that, if you went into a lab and tried to do this in a lab, it would take you hours-- because you know what fluid systems are like. They're really quite slow.

    So this allows you to focus on the concepts with the students very, very quickly, and get them to engage. And then you can move them on to the detailed analysis and other things at a later stage. So that's the tank level one.

    So if we move on to a different example. So this is a frequency response one. And this one really is just to investigate, what is frequency response? What does it mean? So here, I've got a particular system you can see down here. And I'm exciting it with a particular frequency. What would happen if I change the frequency? So change the frequency and try. And you can see how the frequency response has changed. And it's giving you the gain and the phase.

    You can add a delay. What happens if I add a delay? And you'll see there's two curves. There's with delay and without delay. So students can see what's the impact of a delay on the gain and the phase. You've got a number of different systems you can choose-- different types. It's relatively limited. You can see that that one is giving very different behavior. But it's another example of a very simple interface.

    So if you're trying to explain to students, what is frequency response? What do we mean when we say gain and phase change as we change frequency and so on? You can do some very simple illustrations and then move them on to the maths and say, if you want to code it yourself and so forth, how might they do it.

    And so one final example I was going to show-- obviously, there's many more in the Toolbox-- so this one does lead-lag design. Now, I have a particular way of doing it. But you can see here, in the green box, you put your specifications. What do you want? What phase margin do you want? What bandwidth do you want? What offset do you want? And then we can do a systematic design. So I'll start with K-p.

    Now, these green lines show my specifications. So that's telling me the bandwidth I want and it's telling me the phase margin I want. And down here, you can see it's telling me the offset that I want. So I can see my specifications. So I can start by playing with K-p. Or I could overlay several K-p. And you can see here which sort of K-p is going to give you the correct bandwidth. So looking at that, it looks like something like 2.8. So let's-- I'm sorry because I've had to shrink this a bit to fit into the window; you can usually see the numbers better-- but you can see I've got K-p roughly right. So I've got roughly what I want.

    Now, next question-- what phase margin do I want? And you can see here, it's showing me where I want the phase margin. And I can see there's a big gap. So I can see what phase uplift am I going to need. And you can see here the phase uplift I need, the current phase margin, 20 degrees-- about 40 degrees. So I need a pole zero ratio of about 4. Put it in. And you can see, after I've added the lead component, it's given me roughly, OK, the phase margin that I want.

    And this red circle and red cross are basically showing me this is where the lead zero and pole have gone. Actually, there's one that's going to be hidden behind here. I do apologize. There it is-- that cross and that circle there. So that's showing me where it's put the pole and zero. And then I could look at the offset requirement and put in the lag bit. So I'm just going to do 4 now to show-- keep it very simple.

    And you can see, it's put in here's the lag, pole and zero. And you get your overall design. So the idea is that you can-- I've done it too quickly here, obviously-- but you can step through with the students and get them to see the different steps of a lead-lag design and what you're trying to do in order to meet your specifications. So you're hiding them from the detailed calculations, but you're showing them the conceptual steps that they need to take, which is the most important thing in the first instance. So let's skip on those.

    There are other apps, which I won't talk about more now. You can talk to me about those separately. So hopefully, we've illustrated the potential of apps. And the key thing is we're removing the need for tedious number crunching and focusing on concepts. And I'm not saying number crunching isn't important. I'm saying it has a place. But when you're really trying to motivate students and get them to understand, you don't want to distract them by having to spend 20 minutes doing detailed calculations. There's time enough for that later.

    So what's the role of livescripts? Well, the livescripts are actually talking about the calculations. So what I've done is I've set up a number of livescripts, which sort of go through a first course in control. So what skills do the students need roughly in order. So they need to be able to plot with MATLAB. Otherwise, you're stuck. So we do plotting first.

    And then we start talking about, how do you analyze ODEs with MATLAB-- 1st order models, 2nd order models? So we start by looking at behaviors. How does the world behave? And we show how to use the MATLAB tools so that you can save yourself time.

    A bit on Laplace-- partial fractions. And you can see, we then get transfer functions and poles, general behaviors, step responses, move on to closed-loop behaviors, and finishing up at PID. So basically, there's a different livescript to build you through the skills you might need. I'm not pretending this is exclusive. And if you think there's gaps, let me know.

    So why livescripts? So let's go straight to that. I'll skip these slides and go straight to, what is a livescript? So the key thing is this. What you'll see is you have code and explanation on the left and the results on the right. OK? So it's very, very easy for students to see, here's the code and there's the result. Now, I'll show better examples as we come.

    You also can have section markers. So you can see I've marked here with this blue line the sections. So what students can do is they can change the numbers in this MATLAB code. And then they press where it says "run section." And it will only run that little MATLAB snippet. And here it will update the figure and do whatever it needs.

    So here's an example of one of the livescripts in the Toolbox on 1st order ODEs. And you can see what this one is doing is saying, how do I solve a 1st order ODE? So you can see the first bit is your explanation-- what are we trying to do? You can see, here's the ODE we're trying to solve. So I'm going to give an example. Here's the example, you can see nice and neatly. And then, beneath, in this gray shaded bit, what's the MATLAB code that will solve that for me? Oh, that's been changed. That's a bit naughty. That's a 7 instead of 3.

    And then, over on the right, there's your solution. And the student can go and say, oh, I've got a different ODE. I'll change the numbers in this code, press "run section," and it will update the solution for them. So you can see explanation and notes and the code snippet and the answer.

    So this is with plotting. So you can see the code is slightly more complex now. So it basically says, I've got an ODE and I also want to plot the solution. So the code has been slightly elaborated so that you can actually see numerical solutions and the plot. OK? 1st order modeling.

    So this one here I think George talked about this. You can add interactive elements in a different way if you want. So here, we're emphasizing to the student, I want you to guess the gain and the time constant. And their guess is going to be this dashed brown line here. So you're encouraging the students to say, all right, have a guess, run section, are you correct? Have another guess. Run section. Are you correct?

    So the code is done for them and they can focus on the concepts. Do I understand what gain is? Do I understand what time constant is?

    This is an example from under-damped systems. And again, you see, you can put quite elaborate explanations. You can see this is a semi-neat type of note, explaining we've got a 2nd order differential equation, time domain, Laplace domain, et cetera, et cetera, and then going on down to the code snippets to do some of the solutions.

    Closed-loop transfer functions-- so, again, you can see, what are the relationships we're looking for? There's obviously more in this; I'm just showing you a tiny bit of the livescript-- and what's the code? So the students can go here to line 20-21. They can change the G. They can change the M. They go and they press "run section," and it will automatically update their closed-loop transfer function. So they can focus-- they don't have to do all the boring number crunching on pen and paper.

    Proportional design with Bode-- this is a different example. And there are many more. That's lead compensator design.

    So in other words, livescripts have a different role. They're getting students to engage a lot more closely with the detailed maths and the detailed code, which gives them what they need if you sent them an assignment. And you're basically saying to them, here's a problem you've not got. I want you to go and analyze this, solve this, and do whatever.

    And they can look in the livescripts and say, oh, here's a code snippet that shows me how to do X. Understand this snippet, and then I can use it for my assignment. And it's supposed to bridge the gap for the students, make it a bit easier for them, because many really struggle if you just give them a blank page.

    And you'll notice-- I say this over and over again-- I'm not a great believer in what I call tedious, paper-based number crunching. The students should do it once to make sure they can do it. But once they've done it once, they don't need to do it 10 times because that doesn't prove anything. Once you can do it once, then get them to use the computer. And focus on the higher-level skills, the understanding and the concepts.

    And my experience-- certainly with livescripts-- is once students realize they're there and see what they can do, they really start using them quite actively and they get it. So they've been quite successful, I would say.

    So, in summary-- hopefully I've not gone too long-- you can see, in this Toolbox, there's a large suite of livescripts and virtual labs. They're all open source. If you want to download them and edit them and say, well, that's OK, but I want it to be slightly different, just edit it. No problem. Download it, edit it, do what you want. There's no protections, copyrights, things like that. I'm very relaxed about that. Everybody's got different requirements. Just edit for what you need.

    If you want students to use them, you obviously do need to curate them into your plan. I use them in lectures. I add bits in tutorial sheets-- Tutorial Sheet 3, Question 4. Look at this livescript. Investigate X. Investigate Y. If you don't curate it, some students won't use them.

    So the final bit to say-- this is really important-- all right, I'm one person. And I've got very limited time, limited experience, limited X, Y, and Z. So if the Toolbox is only ever me, it's not going to meet international needs. It's not going to meet personal needs. So I'm really keen for contributions from other people to actually look at what's there and say, oh, I noticed you haven't got a resource that looks at this particular concept. Do you want me to help you create one?

    And I'm really relaxed with that. Yeah, do that. I've been working with Professor and recently on trying to produce one on PID tuning, which is recently released. There are other people I'd like to work with. If you've got ideas, we can work. It's not a problem. And once we got it working, we add it into the Toolbox and the whole world can use it.

    I've got lots of templates. The templates are freely available so that people don't need to rediscover the wheel. They can focus on the concepts, not on the coding. There's loads of things missing because I've got finite time. So obviously, what we need is, if we're going to produce something, we've got to know what's the key concept, what's the underpinning maths, et cetera, et cetera. But I probably don't need to teach any of you that. You probably know that already.

    OK. So I think I will stop there.