Stamp
by Jon Williams
Putting the Spotlight on BASIC Stamp Projects, Hints, and Tips
Stamp Applications
Makin’ It Motorized
From discarded toy
— to mobile robot!
Figure 1. The Pololu Motor Controller (right)
with a BS1 module.
Idon't know about you, but I'm
still exhausted by last month's
column — wow, that was a real
workout, wasn't it? I do hope you
found it useful though. This month,
we're going to go a lot easier, but
still have a bunch of fun! And after
its terrific comeback the last couple
of months, we're going to have that fun with the venerable
BASIC Stamp 1.
There's no denying that personal robotics is one of
the fastest growing aspects of hobby electronics. There
are clubs all across the globe devoted to it, and each week
seems to bring another television show with robotics as its
centerpiece. An easy way of getting started in homegrown
robotics is to convert an existing motorized toy. They're all
over the place, in fact, your family may have a few left
over from the holidays that no longer seem interesting.
Why not spice up an old toy with a brain you can program
yourself? Okay, then, let's do it.
There are BS2 examples of this
kind of robot everywhere; I wanted
to see if there was enough space in
the BS1 to pull it off. As it turns
out, there is with room to spare,
which means we can add more
"intelligence" to our robot once we
get in going.
Figure 2 shows the schematic
for our simple robot controller. Two
pins are used to communicate with
the Pololu controller (SMC02), two
others for our bumper inputs
(using our standard "safe" circuit). The first control line to
the SMC02 is the serial connection. The SMC02 will
automatically detect baud rates from 1200 to 19.2 kBaud.
As our top-end limit on the BS1 is 2400, that's what we'll
use. The second line controls the Reset input to the SMC02.
Using the hard reset line will let us stop both motors at once
when required without having to send serial commands.
While interfacing to the SMC02 is simple and straightforward, it is very specific. Let's have a look at the set-up
portion of the program:
Micro Motor Control
E
l
e
c
t
r
o
n
i
c
s
NUTS & VOLTS
F
o
r
E
v
e
r
y
t
h
i
n
g
Since virtually all motorized toys use small DC
motors, and controlling them requires full-time PWM that
we can't do natively with the Stamp, we'll use an external
motor controller. Pololu Corporation makes and sells
components devoted to small robotics and their Micro
Dual Serial Motor Controller is perfect for our task of converting a motorized toy. The SMC02 accepts instructions
through a serial connection and will control two motors
(speed and direction). Motor voltage can be from 1.8 to 9
volts, with currents up to one amp per motor! This little
dude rocks. And little is accurate; you can see what it looks
like in Figure 1 next to a penny and a BS1-IC module.
Let's get right into it. A typical first robotic project is
a "bumper bot" — the kind of robot that when it bumps
into an obstacle will turn away and then keep moving.
28
Setup:
HIGH SOut
GOSUB Reset_SMC
...
Reset_SMC:
LOW Reset
PAUSE 1
HIGH Reset
RETURN
The first line sets the idle state of the serial connection. Since we're using a "true" mode, this is important so
that the start bit (high-to-low transition) of the first transmission is properly detected. Next, the controller is reset
by taking the Reset input low and holding there for a millisecond before retuning it high. The Pololu docs suggest
that one millisecond is overkill, but I found that at least
one millisecond was required for proper operation.
Okay, the robot is now ready to run. Since our only
FEBRUARY 2004