How do you explain something like a Microcontroller to a layman?
John A. Zoidberg
Posts: 514
My sibling has been learning how to brew and to percolate coffee, and there he went on finding stuff in the 'net and he got terms like PID controller and Arduino.
As I can expect this, he came and ask what's a PID controller. As he is not an EEE graduate (Biology teacher) and searching in the internet for the PID only gives him mathematics, I have to explain the PID really really slowly.
How do you guys explain something high-tech and complicated to a non EEE or students in high school?
As I can expect this, he came and ask what's a PID controller. As he is not an EEE graduate (Biology teacher) and searching in the internet for the PID only gives him mathematics, I have to explain the PID really really slowly.
How do you guys explain something high-tech and complicated to a non EEE or students in high school?
Comments
P = The further something is away from where you want it to be the harder you push it.
I = The longer something is away from where you want it to be the harder you push it.
D = The faster something moving away from where you want it to be the harder you push it.
Be sure to push in the right direction!
PID itself is just the common name given to the reactive maths used in such a closed loop control system. So, it's important to name and explain the mathematical terms, namely Proportional, Integral, and Differential. And if he starts to appreciate what those terms are then also make sure to say they are not hard and fast, as in P,I and D aren't the only options.
Worse still none of it is really explaining anything in an intuitive, physical way that they could relate to.
Worse still when you write the code there is no differentiating and integrating to be seen only adding subtracting and multiplying.
I believe you can take an interested kid who only knows his arithmetic and walk him through the ideas step by step, building up a simple program and experimenting with how it works as you go.
Starting from the simplest possible control program, the "bang-bang" controller. Let's say we want to position a train on a track. In pseudo code: For a total beginner this simple program has a lot of new concepts in it already. Like:
0) Wow, that's a program and I can run it and it does stuff!
1) Programs can do arithmetic
2) They can make decisions.
3) They can do the same thing many times.
4) Programs have variables and can remember things
5) What's that "measurePosition()" thing. Hmm...subroutines.
This is already sophisticated enough for the first 3 lessons!
Lesson 4 is the proportional control...
P = strength of the suspension springs
I = speed of height adjustment/clearance
D = hardness of the shock absorbers
Direct (or Proportional) action is the suspension spring itself, while the Proportional gain Kp is the strength of that spring.
Accumulative (or Integral) action is the amount of wheel clearance, while the Integral gain Ki is the speed of change in clearance.
Differential (or Derivative) action is the shock absorber, while the Derivative gain Kd is the hardness of the shockie.
If you want to get your brother started with a microcontrollers -- Parallax has long had its 'What's a Microcontroller?' Kit. Save PID for later or get a Scribbler2 that uses PID for wheel control.
https://www.parallax.com/sites/default/files/downloads/28123-Whats-a-Micro-v3.0.pdf <==== read the book for free!
Try a Wikipedia article for a more realistic presentation.
PID has been around since the 1890s to control steam engines and automatic ship steering, and Newton created calculus long before that.
PID is a formal presentation of feedback control that presumes a knowledge what is a differential and what is an integral, and how these apply to systems in physics. Some desire to learn engineering is certainly helpful.
https://en.wikipedia.org/wiki/PID_controller
Or microcontroller
https://en.wikipedia.org/wiki/Microcontroller
In all honesty, to cover the subject in depth is roughly a whole year of univeristy subjects. And usually, one would learn the maths, before the Physics, and then learn the rest.
Umm. PID can be and is often done with analog, or mechanically, or by other means.... so I really can't figure out why everyone thinks explaining feedback loops, industrial control, Physics, and Calculus concepts applied to control are going to explain a micro-controller.
There is a wonderful site of robots that includes balancing bots built with all analog PID control. Dale's Homemade Robots.
http://www.wa4dsy.net/robot/balancing-robot/analog-balancing-bot
If your brother wants to learn PID, skip the microcontroller later.
If your brother wants to learn microcontroller, skip the PID until later.
There are all sorts of systems that inherently use part of PID or all of it for feedback and control.
So narrow down to the examples that apply. Is this about motor control for a coffee maker or temperature control?
P: When you turn the burner on, it starts heating up. Over time, the heating element cycles off and on. Initially, the heating element is on more than off. As the temperature of the water gets closer to the target temperature, the on/off ratio gradually changes (less on, more off) until some point where it is only on long enough to maintain the temperature. This ratio change, if plotted on a graph, would be a straight line with a fixed slope. The P value affects how steep the slope is.
I: If you are heating a small pot (e.g. 1 quart) of water, it will take some amount of time to heat up. If you are heating a big pot (e.g. 1 gallon) of water, it would take more time (4 times as long, in this case). In order to heat up the larger quantity of water faster (without changing the P factor), an "I" factor can be used. In this case, you would still see the heating element cycle on and off. However, you would see the heating element stay on for longer periods for the larger pot (because it was taking longer for the water to reach the set temperature). As you approach the target temperature, you would still see the ratio change (as in P above), but the ratio change will not be linear like it was when just using the "P" factor. A plot will make the line look like it's bulging, with the severity of the bulge indicating the influence of the "I" factor.
For an electric stove, you are not likely to encounter this. This would normally be used as a dampening factor. However, as a stove is not also actively cooling the water, there's not much point in dampening. However, I would not be surprised if advanced brewing systems like the Clover also used the "D" factor.
Note: You often have a "dead zone" around the set point. Think of this as the "close enough" zone. It prevents a PID from constantly cycling the heating element on and off to try to maintain an exact value. Instead, the PID will be suppressed while the temperature is in the "good enough" zone. If the temperature drops below that zone, then the PID will kick back in and heat the water back up.
Being a Biology teacher, he may have a quick answer......NOT.
https://en.wikipedia.org/wiki/Metabolism
+++++++++++++
Both topics are equally wonderful, but they do take more than superficial effort.
The bottom line here is that any high school student today should try to learn Calculus, Geometry, Trig, Statistics, and all the maths he can get -- even if he a pre-med student or wants to study business law. Our whole world is being driven by technology and science that is still finding new ways to apply what Newton resolved in one miraculous year so long ago.
I like the idea of relating the problem to a physical and intuitively easy thing like controlling temperature. And it is appropriate give that John mentioned percolating coffee. Problem is it's a bit confusing because PID wants to drive the thing it's controlling both positively and negatively. Generally in temperature controllers you only drive on way, it's either heating and cannot cool. Or cooling and cannot heat.
@Loopy,
The reason we are describing micro-controllers amd PID is because that is what John's question was about.
I don't believe it is necessary to have years of maths and physics behind you in order to have a good intuitive and useful understanding of PID. When us kids were building amplifiers and oscillators it was years before we did any calculus or serious Physics in school. As soon as you apply feed back round a tube or transistor with a resistor you are into proportional control. If there is a coil or capacitor in that feed back network you are into differential and integral control. We had no idea what those terms even meant, if we had heard them at all, but still we had a useful grasp of what was going on and could make things with that intuition. Those guys who first put regulators on steam engines knew nothing of feed back control theory, it had not been invented yet!
@John,
What is the major part of your question? Explaining micro-controllers and programming or the PID thing or both ?
In the 1930s, it seems PID was using pneumatics, only much later did the microcontroller come into play.
And in many cases, one doesn't have to have all three... take a look at Dale's Balancing Robot.
Trying to explain both microcontroller and PID at the same time to a rank beginner is just making it all the harder. My gut feeling is the Arduino presentation is just a black box with a series of tweaks that work in one context.
Try this... http://playground.arduino.cc/Code/PIDLibaryBasicExample
Read the HISTORY secton of PID and it becomes obvious that the two are best separated from each other or you get into all sorts of questions about how do microcontroller perform calculus.
++++++++
Above all, a good foundation in maths makes this much easier to learn. Trying to avoid that and it all gets pretty mushy and messing very quickly. It is Englineering, that's the reality. (Microcontroller don't really perform calculus to create PID control, they just do a fast series of iterations and loops to maintain control within the system.)
With great difficulty and lots of patience. Best to use something simple to start with (like an on/off thermostat for PID) and proceed from there.
You need to correct error.
P, I, and D are representations to three very different kinds and amounts of error in a dynamic system.
The controller gets feedback of overshoot or undershoot for a given period of time.
Then the microcontroller estimates the Perror, the Ierror, and the Derror for appropriate compensation.
++++++++++
The average person just thinks that Error only has one component, but that is an over-simplification.
The whole idea is to have a model that combined P, I, and D to get just as near to perfect correction as possible. In some case, one element might be zero or near zero and can be ignored.
From there you have to look at what each one is, and how the feedback provides useful info to apply to the solution.
http://learn.parallax.com/pid-control
Some of its information may be relevant to what you are trying to explain.
If a ball is in the wrong position you will soon learn to give it a harder push the further it is a way from where you want it to be. Think golf or pool. That is "proportional" control.
If you are pushing on a heavy object, like a rock, to move it to where you want it may not move. So you push harder, and harder and harder until it does move. That is "integral" control.
If a guy is running at you fast you might brace yourself to apply a lot of force to stop him. If he is only ambling up to you you won't. That is "differential" control.
The only challenge then, assuming your student is a little familiar with programming, is to show how to represent those verbal descriptions as variables in the code, position, error, error accumulated over time, velocity, and how to add them up to get the required "push".
But John mentioned a couple of specific cases:
1) A biology teacher. I would hope he/she has a rudimentary understanding of calculus and perhaps an even more rudimentary understanding of Physics. How can one ever become a biology teacher without having been through that?
2) Someone very young with none of the above. History shows that ten year olds are quite capable of picking up the basics of programming. Used to be BASIC back in the day. I maintain one only needs those basics and some trial and error experiments to get an idea of what goes on with PID.
Then there is the vast ocean of people who don't have the curiosity, drive, patients, tenacity to fight with these things for hours and hours. It's perhaps best to not waste ones time trying to do anything about that.
A. Branch
B. Loop
C. Jump
D. Test
E. Add
F. Subtract
G. Shift left
H. Shift right
But PID is inherently an engineering topic that evolved out of applying Calculus to the problem.
A. Historically PID came first and its application to microcontrollers is a special case of a more general and formal practical math.
B. Sugar-coating PID for young children may be counter-productive. Why not explain that it is a separate topic and teach it as such?
C. There is nothing wrong with separating the two topics, and there may be a lot wrong with just trying not to.
Can a biology teacher learn PID? Well, I seem to feel that an intelligent person can learn anything if they so desire. Other more mundane people specialize.
It is empowering to allow a child to explore any subject. Just make sure his teachers and mentors know what they are teaching.
You are in the elevator and want to go to "X" floor, and are currently on "Y" floor; "Y" changes as the elevator moves.
The further "X" and "Y" are apart, the faster the elevator has to move to get between them, up to its maximum speed.
The closer "X" and "Y" are to each other, the slower it must travel so it doesn't over-shoot the desired floor.
The elevators rate of travel, "Z", changes with respect to how close or far apart "X" and "Y" are, until when "Z" equals zero, "Y" should equal "X".
Of course if you actually controlled an elevator with a PID like that the passengers would lose their lunch
Where is the need to maintain a constant interval of time between start and arrival?
PID is predominantly used to maintain speed control or position control. It might apply to arriving even with the floor.
The only error that an elevator is concerned with is the match between the building's floor and the elevator's floor when the doors open.
It would help to mention that in Physics, velocity and accelleration are different things and their relationship is clearly defined by Calculus.
++++++
My main point is that the basics of microcontrollers need to be taught before we get off into applications of microcontroller that convert prior bodies of knowledge to being applied by microcontrollers.
The fact that microcontroller can do the maths so quickly means that there are tons of mathematical applications that have migrated over. But without the basics, and without the formality of the maths, it gets kind of difficult to really help someone understand.
I am sure that their control includes PID in a very sophisticated manner.
It is just not the right example for a beginner. I suppose PID would better be applied to an escallator, where no matter how much the actual number of riders vary, the steps are supposed to arrive at a precise rate.
You have a "desired state", a "current state" and a rate of change. The rate of change can be constrained to a value, being either positive or negative dependent upon the relationship between current and desired states, but it doesn't have to be so constrained, with the exceptions of desired rate of change or physical limitations of the system itself.
In the elevator example you probably want a comfortable acceleration, a comfortable deceleration, and perhaps a stable maximum speed on the way.
So if you are using a PID anywhere in there it will not be controlling elevator position directly. But it might be used to control the desired accelerations and velocities.
The servo is not the profile generator, be careful to make that distinction in the discussions.
I am simply concerning the presentation in the simplest form for a first effort.
A good presentation would then move on to the typical cases, and maybe some unsual ones as well.
I guess it would be up to John, the OP, to give more information. Right now we are all speculating since John has not chimed in since the original posting.
The subject is "how to teach a begineer" and "how to introduce the same to PID".
I am just trying to make it clear that teachers do struggle with getting down to the level of their students and that the first thing that comes to mind is often not the best. One really has to look for entry points and how to clarify misconceptions.
In this case, it is a big misconception to simply associate PID with basics of microcontrollers.
Obviously one can borrow a bit of code and make it work (and we often do), but actually learning what underlies the whole by design requires more than superficial demonstrations.