One feature that you will find in almost every control system is hysteresis and
proportional feedback, and if you're like many people, you don't even know that
you're using it every day when you drive a car. If you don't drive a car, then you've
been a passenger in a car and I'll tell the story from that viewpoint.
Have you even been in a car or bus where the driver alternately floors the accelerator
and jams on the brakes? At the end of the ride, you either had a sore neck or an
upset stomach or both because the driver was not using physical cues to regulate or smooth
out the riding experience for his passengers.
That's what hysteresis and proportional feedback are for, and it's what makes
cruise control such an effective way to smooth out the ride and to save on gas
too. Let's get some basic definitions sorted out...
Any non-trivial control system has the following minimal characteristics, and I'll
continue with the cruise control example to make things clear.
There, I've just explained in very simple terms how a closed loop control system
works, and you really need to understand this part or the rest of your robot building
carreer will be filled with clumsy and jerky creations. So keep reading.
As you might have guessed, all of the magic is really in the last item, the control
algorithm. By making effective use of hysteresis and proportional feedback, the
control algorithm allows the cruise control to smoothly accelerate and decelerate
as the measured speed changes from the set speed. The sample period also has an
effect which some examples will make clear.
Imagine a control algorithm that does the following: If the speed is less than the
set point press the gas pedal all the way down. If the speed is more than the
set point release the gas pedal completely.
OK. Some of you actually drive like this. And it's dumb. It's dumb because it
wastes gas and makes you and your passengers feel sick. And it's hard on the
engine and transmission. As soon as the actual speed is less than the set speed,
the accelerator gets jammed down. The engine revs higher, the transmission may
kick down a gear and the car will accellerate.
Eventually, the speed is just above the set point, and the gas pedal is released.
Now the car is actually pushing the motor, and eventually the car slows down and
the cycle starts all over again.
And that's why it's called bang bang control. The gas is either fully pressed
or fully released and the ride is pretty jerky. This type of control is used
in only the simplest systems, such as older thermostats for furnaces and air
conditioners.
To smooth things out a bit, and to make the on/off cycle take a bit longer, the
designers generally add hysteresis, which we'll discuss next.
You can think of hysteresis as a sort of "guard band" around the desired set
point of the system. In other words, the algorithm is changed so that the
accelerator is pressed when the actual speed is less than the set point
minus a small constant. Similarly, the accelerator is released when the
actual speed is greater than the setpoint plus a small (possibly different)
constant.
If you think about it, the ride will still be jerky in this case, and in
fact it's going to feel even worse because the car will change speeds less
often, but with a greater range of speed at each change.
How is hysteresis helping here? Well, it's not. For systems with a large
lag between application of a control signal and the resulting output (like
a furnace or air conditioner) the hysteresis reduces the number of control
cycles by making each cycle longer. For short lag systems like cars, the
result is an even jerkier ride.
We can add another refinement to the system that will smooth things out
for everyone, called proportional control.
As you might guess, the next step is to apply a more sophisticated
control signal to the gas pedal, one that allows the pedal to be set to
a specific value depending on the error signal. More precisely, after every
sample of the error or difference signal, we'll apply a little more or
a little less gas.
Depending on how big the error signal is, we'll change the gas pedal
setting by bigger or smaller ammounts. That's how this control method
gets the proportional part of its name.
It's pretty clear then how the cruise control will work. If the car is
standing still and we set the speed to 100 km/hr, the control algorithm
will add more gas initially, and then less and less until the error signal
approaches zero, at which point the gas setting will not change.
That's fine as long as the car is on a level roadway. If there is a hill,
the speed will go down a little, at which point the algorithm adds a little
more gas. Eventually, the speed goes back up to 100 km/hr and the gas pedal
is pressed down a bit further.
Sooner or later, the car will get to the crest of the hill, and then it
will pick up speed as gravity helps the engine. Now the control algorithm
will back off the gas pedal, and eventually the speed will equalize.
Finally, the road levels out again, and the car slows down, so the control
system adds gas. The end result is that the speed transitions should be
so smooth you don't even realize they are happening. A happy by-product
of letting the cruise control do the speed regulation is that you will
save gas by avoing excessive acceleration and braking as you try to
keep the car going at a constant speed.
We've gone over the basics of control systems, but how does this apply
to building LEGO Mindstorms robots? Simple. By understanding how the
robot can use the basic ideas in this article, you too can build robots
that will operate smoothly do their jobs with a minimum of wasted energy.
I'll show many of these principles in action in the article on
Using the Light Sensor to do
basic navigation.
Hysteresis and Proportional Feedback
Bang Bang Control
Adding Hysteresis
Adding Proportional Control
Conclusion