testing I couldn’t get the EZ1 to “see” my hot sauce bottle
if it was more than six feet away until I realized that I had
failed to clear a six foot wide path in front of the TankBot.
(MaxBotix reports a maximum beam width of about 5. 5
feet for the EZ1.) As soon as I pushed a few things farther
back to widen the path, the EZ1 was able to detect the
bottle up to a distance of about 10. 5 feet, which is right in
line with the MaxBotix specifications.
Finally, I also confirmed that the EZ1 does have a
minimum ranging capability of six inches. Any object closer
than that is reliably detected. Overall, I’m very impressed
with the accuracy of these results and I think the EZ1 is an
amazing sensor.
TankBot, Fetch My Hot Sauce!
Now that we have our EZ1 ranging system functioning
properly, it’s time to take the TankBot out for a spin. Before
we actually do that, though, there are a couple of points
about our second program ( EZ1HotSauce.bas) that we
need to discuss. First of all, the basic idea of the program is
a simple one. As you can see in Figure 5, we’re going to
place the TankBot on the floor in an area clear of objects
for at least a three foot radius and then place our hot sauce
70 SERVO 07.2009
bottle (or your favorite object) to either side or behind the
TankBot, about two feet away. When we power-up the
TankBot, its task is to turn until it detects the object and
then get as close as possible to it.
Keeping that overview in mind, let’s take a look at
the EZ1HotSauce.bas program. I have added a second
set of constants to define “slow” forward and backward
speeds for the servomotors. This turned out to be
necessary because the “fast” speeds that we have been
using thus far resulted in the TankBot turning too quickly
for the EZ1 to receive the echo and detect my hot sauce
bottle — the TankBot just kept spinning in place. With the
TankBot turning more slowly, the EZ1 system functions
effectively.
I also had a problem getting the TankBot to approach
the hot sauce as closely as I wanted because — as I
mentioned earlier — the EZ1 can’t measure distances less
than six inches. My solution was to experimentally adjust
the length of the final “pause 1500” statement before the
TankBot stops. The value of 1500 works fine for me, but it
may cause your TankBot to crash into your favorite object.
If that happens, just adjust the value until you get the result
you want.
Finally, you may want to adjust the value of 400 in the
last “pause” statement of the “sonar” subroutine. Besides
controlling how long the LED is off, this value also has an
impact on exactly when the TankBot stops turning and
starts heading for the hot sauce bottle. Since the EZ1’s
beam width is fairly large (about two feet at a distance of
two feet), it actually detects the hot sauce bottle well
before the TankBot is directly facing it. Therefore, the final
pause (before exiting the first do…loop and stopping) allows
the TankBot to turn a little more so that it faces the bottle
directly. Again, you’ll need to tweak this value a bit to
obtain the results you want.
With all that in mind, it’s time to download the
EZ1HotSauce.bas program to your TankBot and try it
out. Experiment with different durations for the pause
statements we discussed until you are satisfied with the
results. When your TankBot is effectively meeting your
expectations, you’re ready to start thinking about your
homework assignment. (You didn’t forget about that,
did you?)
What’s for Dessert?
Since we still have all the IR object detection circuitry
on the breadboard, your assignment is to write and debug
a program that combines the TankBot’s IR object detection
and EZ1 range finding capabilities. If you have trouble
getting started, here’s one scenario to experiment with.
See if you can use the TankBot’s EZ1 module to find its
way out of a room and its IR obstacle detection system to
avoid banging into things as it does. Most importantly,
have fun with your TankBot! SV