Lab-in-a-Box Approach for Teaching Control: Bridging the Gap Between Theory and Practice
Dr. James Pickering, Aston University
Discover how Aston University’s Future Vehicle Technologies MSc course teaches AV control algorithm design. Utilizing a “lab-in-a-box” approach, students master control engineering fundamentals through Model-Based Design with MATLAB® and Simulink®. They develop real-time systems, focusing on DC motor control, including speed control, temperature control, and obstacle avoidance. Students report positively on the transferrable skills that let them apply their learnings from “lab-in-a-box” to the Roboworks Rosbot Plus TX platform.
Published: 16 Oct 2024
So Control-Lab-in-the-Box-- the aim of this is rather than students going straight onto the Rosbot Plus and embedding those algorithms on there, which are commonly found in the automotive or, for example, the Aurrigo Auto-Pod, the aim really is for students to learn fundamental skills using Control-Lab-in-a-Box. So as I introduced, bridge the gap between control theory and practice.
You want the skills from Control-Lab-in-a-Box to be transferable-- so as I said, from the Control-Lab-in-a-Box to Rosbot Plus, And this should be done in a step-by-step manner. So we don't want to go straight on to the complicated or the control algorithms.
We want to slowly introduce the students to the control theory and simulation tools that they need and then get them on to the control and the practical aspects. In terms of the-- the approach should involve using industry-standard processes and also software. So model-based design approach is used. And this involves also embedded control using MATLAB and Simulink.
It should be portable, affordable, and also easy to store. So why is this now possible? So in terms of developing a control system, it's very much plug in and play. The cost of electronic components, such as an Arduino Uno, has significantly reduced over the years. So you can buy one of these for about 20 pounds.
The open access nature of learning and education-- so control engineering as a subject is multidisciplinary-- so software, control design, mechanical systems. But because the nature of the internet, a lot of the material is openly, readily available-- for example, such as scripts, code-- for undertaking some of the embedded control aspects and electronics. Rapid prototyping now is available at a lower cost-- so, for example, 3D printing.
And there is an increased use of controls-- so, for example, electric autonomous vehicles. So there's an increased use of and importance for students to understand feedback control and not just from a theory and simulation perspective but also from an embedded control aspect and a practical aspect. And the tools and software's now available.
For example, generation deployment in MATLAB and Simulink now make this process a lot more doable and efficient. So in terms of the three algorithms that I'm focusing on, there are effectively nine labs within Control-Lab-in-a-Box. The first one is code generation deployment using Simulink. So this is a nice, simple exercise just to get students used to using the GUI for the code generation within Simulink.
So this involves just using an LED to just do an on-off and also ports of modulation. Students will then move on to actuation-- so a DC motor and, again, they'll do on-off pulse modulation. And they'll also do polarity control of the motor. Then moving on to measurement-- so temperature sensor and low pass filter, ultrasonic sensor, and DC motor with an encoder.
And then, finally, system identification and control-- so I'll go on to begin with proportional control design, least squares parameter estimation of a DC motor, then go on to the PI control of the DC motor, and then various safety aspects around the DC motor. So these nine labs are initially what make up Control-Lab-in-a-Box that I used in the classroom.
However, there are benefits that you're not just fix these labs. It can be-- it's very adaptable. You can develop further new labs. Within the next section, I will go over the three highlighted labs here to demonstrate to you the approach.
So in terms of what this looks like within a typical teaching plan, so a first course in control engineering-- so here we've got ID 1, 2, and 3. This could be weeks 1, week 2, week 3. Typically, three hours a week that I'm proposing here or what I used when I was teaching. So you can see in week-- in terms of the theory, you can see we're getting the students into, first of all, feedback control.
So I want them to understand how a feedback control system works then go on to order difference equation, Laplace transformation, and system response analysis. In terms of simulation, the students are using MATLAB and Simulink in these first few weeks. The whole real point is to introduce them to a bit of theory, get their head around Laplace transformations, and then in terms of getting them familiar with using Matlab and Simulink.
To begin with, the students will do Matlab Onramp and also Simulink Onramp. These are self-guided, self-study courses available via MathWorks. So every student that I teach, they will do this. Within the first 2 to 3 weeks, they'll complete this, then move then on to microcontrollers. And then they'll move on to the two initial Control-Lab-in-a-Box exercises.
Week 5 will then get on to discrete time-- so discretizing a continuous time transfer function and then the two exercises, a 10% and ultrasonic. Proportional in terms of proportional control, design theory and simulation-- and at this point, you see DC motor virtual lab. That's what we use. It gives the students a great visualization of an actual DC motor in a virtual world.
And then you can see the exercises there where they get onto the DC motor proportional speed control using the Hall Effect Sensor. So what you're starting to notice at this point is we're now going from week 5 theory, simulation, practice. And in practice, it involves using Control-Lab-in-a-Box.
Week 7 is system identification. And system identification in a first course of control engineering bridges the gap between theory and practice, allowing students to see how abstract mathematical models are used in the analysis and design of physical control systems, making the learning process more engaging and interactive.
Then move on to PID-- so portion into observed control for the DC motor. And then finally, some of the safety aspects around the operation of the DC motor-- so, for example, obstacle avoidance and temperature control. So as you can see, again, DC motor virtual lab is used within Simulink. It's great because what students can do in the Simulink environment in the simulation environment is just test out the initial algorithms.
They can test, well, is it actually operating as I would hope? Is it doing as I planned? before they then move on to the hardware-- great environment for them to test this different stuff. Finally, consolidation week-- so in terms of the skills and the tools that the students are using-- so in terms of MATLAB and Simulink-- there's various tools that you can see listed there and also various soft skills.
And as I introduced the virtual labs within Simulink, so this is a DC motor. It's effectively a representation of the DC motor that we use within the classroom. So you can see the DC motor there spinning. The equivalent transfer function forming continuous time is given there.
So rather than just giving students an abstract mathematical model, the students can see that abstract mathematical model is effectively a representation of the virtual lab or the virtual lab's a representation of the transfer tree. Code generation and deployment-- so this process is made more seamless through the use of Simulink support package for Arduino hardware.
And in terms of applications, the tools used are automotive industry standard. So auto code generation is industry standard. And it's also relevant to other industries, so, for example, automation and robotics. Throughout the teaching I use guest speakers. So I have a guest speaker from Red Bull Formula One team.
And this is fantastic for the students because at this point, the students realize that it gives them a chance also to ask a lot of questions. They realize that the tools that they're taught in the classrooms-- such as continuous and discrete time modeling and simulation for control system design and also the embedded control-- is what tools are being used also in industry.
So in terms of example labs, so this is what Control-Lab-in-a-Box looks like from a top view. You'll see lots of different electronic components. So there we've got an orange pip Mega2560. So it's just an equivalent to an Arduino Uno. We've got there different DC motors with and without an encoder, cooling fan, different sensors, wires, et cetera.
So the rapid prototyping part-- so it's using a laser cutter for the acrylic parts. And you can see there the PLA 3D-printed components, various nuts and bolts, and also tools to assemble the labs. So what the complete Control-Lab-in-a-Box looks like is this here. So this is a computer-aided design visualization.
Again, I haven't included every single component. But there you can see the rapid prototyping components and also the electronics components. These are the ultrasonic sensor, the cooling fan, the wheel, the Arduino Mega in this case, H-bridge components.
So now in terms of exploring the different labs-- so earlier in the talk, I said to you I would cover three labs. The first one I'm going to talk to you around is least squares parameter estimation in DC motor. So this is in the final kind of section of the lab, so on system identification and control.
So this is what the rig would look like-- so the Hall effect sensor, the encoder is on the DC motor, the electronic circuit there. And this is the Simulink diagram. So what we're using here is effectively within Simulink using the Arduino Code Generation Deployment Tool.
So you can see there pin 9. So in this case, we're applying 5 volts to pin 9, effectively the DC motor. We're using the encoder here. And you can see there's various-- in terms of the encoder will give us the number of pulses from the Ulvac sensor. We're then converting the pulses into revolutions per minute.
And then you can see there we can capture the output. So Goto 1 is the output. Goto is the input. In terms of what this looks like on the graph-- so on scope 2, you can see there I've effectively illustrated what it might look like in graphical form. So you can see the input and the output.
Then if we use least squares algorithm, we can then capture a mathematical model. And a mathematical model there is given first order transfer function. Then what the students can do is they've now got a mathematical representation of that physical DC motor. They also would have done the equivalent to this using the virtual lab.
So now they have this. What they can then do is tune their control system-- configure and tune their control system in simulation. Once they've done that, the students will then move on to the actual physical hardware. So in this case, this is the control system for the DC motor. So the big difference is here you can see the reference. You've got some injunction. You form your error based on that. Then you've got your discrete time PI controller.
So this is the rig in operation here. You see that running. So we've a reference of 30 revolutions per minute. The top left scope that you can see here, you can see the reference of 30 RPM. And then you can see the measured output of around 30 RPM, so the rig working very well. And then the graph to the right of that, the scope is the unfiltered data rejection and filtered output.
So this is great because what students can do within Simulink and also the control lab and the box on the desk is they can visualize signals in real time. They can also make alterations. For example, they can change the reference and see how well the control system performs subjective change on the reference. They can tune the PI controller also. If they need to make slight tweaks to it, they can tune that also in real time.
So it's fantastic because going from theory to simulation where you see signals, now they can see signals in actual real time in a practical application. Finally then if we go to the on-off safety aspects of the DC motor-- so what we're using here is an ultrasonic sensor with the Arduino support package.
We've then got a MATLAB function which will effectively turn the DC motor on and off, depending on an object getting within X meters of the DC motor. So you can see it's operational here on the video. We also within this have a MATLAB function for an LED. So you'll notice there's a red LED coming on once the hand gets within X distance, and i.e., the motor stops.
And then the next one is to do with temperature control of the DC motor. So you've seen the previous two labs are to do with speed control. That's the one we wanted to do, obstacle avoidance. And then now we're looking at temperature control. So the temperature sensor effectively hooks underneath the brackets on top of the DC motor.
And in a similar manner to the previous one, when a certain temperature is reached of the motor-- if it exceeds a certain temperature, the DC motor will switch off. Likewise, we also have a cooling fan, and the cooling fan will switch on, given a certain temperature.
And as with the previous one, there's a red LED-- although not shown in this video that I'm showing you now-- that will selectively turn on, given that the temperature has exceeded the threshold. So what you can see here is I've got a hairdryer. So I've just I've just added some extra heat to heat it up. And obviously, when the heat's exceeded the limit, the motor turns off.
In terms of student evaluation-- so these initial five questions that students were asked-- so they're asked prior to Control-Lab-in-a-Box teaching. And the students here-- this is based on a third-year mechanical engineering cohort that had been taught using Control-Lab-in-a-Box. Prior to this, they actually had also gone for a prior course on controls. They had some prior knowledge.
And then they in terms of asking prior and also post teaching of Control-Lab-in-a-Box to also answer the same questions, so in terms of their confidence of how they felt with Laplace, transfer function, control theory, MATLAB and Simulink. And what you'll notice is across the board, we had improvement in all five of the question areas. So the average student response increased.
Then the next question involved the following. So do you believe that you understand the operation of a control system, theory and/or practice? So this involved prior to asking the student the question to Control-Lab-in-a-Box to post-- 56% increase. Question 7, do you believe control engineer is a career option for you? Prior, it was-- maybe 65% said no. Maybe post this, you can see there's only a 13% improvement.
So again, not too much of a change here, which makes for quite an interesting result to look into further. Next question, did Control-Lab-in-a-Box enhance your student experience of control engineering? Majority of people said yes. Did Control-Lab-in-a-Box help bridge the gap between the control theory and practice? Again, the majority said yes.
So students liked this. They liked the following. So theory there is the word that stands out. They like the hands-on experience, the hands-on approach, theory into practice, the practical experience, physical application, Simulink models.
In terms of what students found challenging, surprisingly, it wasn't the theory. It wasn't the control theory. It wasn't the use of-- I'm assuming it was to do with the Control-Lab-in-a-Box and some of the aspects around the batteries and also the wire connections. So just a few considerations to consider for next year.
So in terms of students, I've got here a video that of a student actually using Control-Lab-in-a-Box in his desk at home. The student said the following-- "So this Control-Lab-in-a-Box served as my entry point for applying. my knowledge of system design. Its modular components and seamless integration with Simulink enabled me to devote more time to understanding exploring the impacts of various control techniques. I would highly recommend it to any beginner eager to learn about control systems and system design beyond textbooks."
So what I said to you initially was the student can use Simulink Control-Lab-in-a-Box, and they can view the signals in real time. So what the students got there is around-- is it 5?-- maybe 10 seconds of data-captured signals to the reference, the DC motor speed, and also the distance measurement from the ultrasonic sensor.
So transferable skills-- so as I introduced earlier, these were the three algorithms that the purpose of the control lab-- and the main motivation and purpose of Control-Lab-in-a-Box-- the DC motor speed control, temperature control, and obstacle avoidance. The aim's for these then to be transferable into the Rosbot Plus. So the MSC students' coursework involved these working on the Rosbot Plus
Initially, I provided the students with the data sheets that they needed because the electronics components within Control-Lab-in-a-Box and Rosbot Plus are different. What the students have to undergo is they have to pass various design reviews to be able to effectively-- design review 1, they have to go through a number of tasks before they move on to design review 2.
And then at the end, by the time they get to end of design review 2 in this case, they would have achieved the control items that you can see above. The final design review, although not detailed in this presentation, is the autonomous vehicle aspect. Further labs are being transferable-- so potentiometers, IMU sensor position control, and operation of a servomotor.
And the motivation for these really is to enable more transferable skills in Control-Lab-in-a-Box, the Rosbot Plus, based on what students found difficult this year. So in terms of the transferable skills, you'll see there the Rosbot Plus. And again, it's quite a large platform.
You'll see that you've got the ultrasonic sensor, the cooling fan, the DC motor with the encoder, the temperature sensors. So they're all the same sort of-- it's all the same sort of hardware as we saw on Control-Lab-in-a-Box.
Based on this, one of the students said, "My initial background was mechanical engineering, which meant I initially struggled with the electronics and control engineering. However, I found the theory simulation, hands on experience in term 1 to be helpful for term 2, learning that the knowledge from one device can be easily transferred to another with slight differences. I was also new to using MATLAB and Simulink in term 1, but now I feel comfortable with the package. I feel job options are now open to me beyond mechanical engineering, example, automotive and control engineering."
What you'll also have just seen on that video is the students demonstrating the application of those three key algorithms that I introduced to you. So finally, access material via GitHub and also Matlab File Exchange-- so in terms of the boxes, this is what they look like in my office. So we've got the 24, I think it is-- 4, 8, 12, yeah, 24 boxes.
They do separate as you can see. So you can effectively carry them around four boxes at a time, or you can carry one box around at a time. So they're easily stored in a lab or office. They're easily portable enough to fit in a typical bag.
So that's one thing the students absolutely loved about using Control-Lab-in-a-Box. They said it's fantastic. We can take it home. We can bring it back every week. We can ask questions in tutorials. We can take it away. We can experiment, learn. It's affordable. So it's approximately 100 pounds. So there's not so much concern regarding if parts are broken or lost.
So in terms of accessing this, so the files that you require to be able to use Control-Lab-in-a-Box within the classroom are available on GitHub and also MATLAB File Exchange. So in terms of what's available on there, I've kind set out in terms of the aim of the Control-Lab-in-a-Box setting up. So there's a few considerations. There's a few things to consider.
And also there's considerations there based on my own experience with the batteries and the wires, typical teaching curriculum that you might teach this around. The Control-Lab-in-a-Box exercises, they're available-- trial, and also in terms of the CAD and the computer-aided design so you can actually undertake the rapid prototyping.
If anyone does want to trial Control-Lab-in-a-Box, I'm very willing to post on the boxes to you to trial. So that's for industry and also educators. So anyone does want to trial it, get your hands-on, please feel free to contact me.
So finally, Control-Lab-in-a-Box-- so based on my experiences, it's been used to bridge the gap between control theory and practice, so the initial kind of introduction of the continuous time or discrete time PID. And then students are aware of then how they go about designing, using simulation tools in Simulink, then embedding that then onto a microcontroller.
They are transferable skills, so from, for example, Control-Lab-in-a-Box, the Rosbot. And then, because the students understand the Control-Lab-in-a-Box and the Rosbot, the initial algorithms are very much based on the Aurrigo Auto-Pod.
In terms of step-by-step learning-- so we don't-- I'm not-- we're not going straight into designing the control systems. We're using a model-based design approach, so starting off slowly in terms of teaching the students the maths to do with control theory and also simulation tools. We use industry standard processes and softwares, so MATLAB and Simulink.
So again, just to reiterate-- a model-based design approach and also using embedded control and using code generation deployment within Simulink, using the Simulink support package for Arduino hardware. And final point is that the Control-Lab-in-a-Box is portable, affordable, and easy to store.
So finally, I'd just like to acknowledge the following people that helped me in terms of developing Control-Lab-in-a-Box at Aston University. So thank you for listening. If you any questions, please feel free to contact me.