Tune in each month for a heads-up on
where to get all of your “robotics
resources” for the best prices!
Small Brains
for Your Bot
As a child, I imagined robots being
governed by tubes and relays — not
an unusual image given the science
fiction movies of the time, like Robbie
the Robot in Forbidden Planet. Today,
fictional robots are depicted with miniature microelectronic brains, with “
emotion chips” the size of a fingertip. And
no wonder, because these things actually exist! Far from science fiction, with
today’s technology you can build a robot
with a brain no larger than a caterpillar.
What’s more, these brains are
designed to interface with the outside
world. These so-called microcontrollers are
part computer, part input/output. In one
chip-sized package is an affordable
programmable computer with a multitude
of I/O for connecting to a robot’s various
motors and sensors. The best news is that
these microcontrollers are inexpensive.
Some are as cheap as a dollar each; versions that come with a complete development kit are $50 to $150. In all, a bargain.
This month, we’ll explore a variety
of options for inexpensive microcontrollers suited for small robotics. Though
the microcontroller is basically a
generic, universal device, some of these
products are expressly designed for use
in amateur robots. And those that
aren’t are still very capable of the job, as
they have the core ingredients needed
to control most any real-world device.
Under the Hood
Microcontrollers are single-chip
computers, capable of running user-defined programs, accepting input from
switches and other devices, and control-
ling the state of one or more outputs.
Microcontrollers are expressly designed
to be used in so-called embedded applications, where control of some external
device is the main goal. Typical uses for
embedded chips include the on-board
computer in your car, the “smarts” in a
modern-day television, even the control
circuitry in a coffee maker.
For the typical robot application,
the microcontroller uses previously
prepared custom programming to read
one or more sensors. Based on the
condition of those sensors, the
controller then activates or deactivates
outputs connected to motor drivers.
For example, suppose you’ve built a
robot that senses the brightest light in
the room. The robot is “trained” to go to
that light. You’ve built your bot with two
light sensors, both of which point
straight ahead like headlamps on a car.
These light sensors are connected to two
analog inputs of the microcontroller (not
all microcontrollers have analog inputs;
this is just for illustration purposes). The
program — which you’ve written and
which constantly runs in the microcontroller — reads the intensity of the sensors. The controller will activate either of
the robot’s two motors in order to steer
the vehicle into the direction of the light.
The brains on board your bot know
the light is straight ahead when the
reading of the two sensors is the same.
At that point, the controller activates
both motors at the same time, causing
the vehicle to move toward the light.
This is just one of many possible
applications for microcontrollers in robotics. As you work with microcontrollers and
various types of sensors — be they optical,
ultrasonic, or whatever — new and
creative uses for your robot emerge. For
instance, if you can interface an electronic compass to your robot, you can write a
routine for the microcontroller that tells
the robot which direction it’s facing.
A tilt sensor could be used on a
self-balancing robot (two wheels, like a
Segway); a GPS could inform the robot
where it is on the Earth down to the
nearest few feet; an optical distance
sensor could tell the bot how far away
it is from the nearest object, and so on.
Variations in Design
and Features
Not all microcontrollers are the
same. Sure, they all contain some kind of
computational unit, some place to hold
your program (microcontrollers retain
their programming when switched off or
disconnected from power), and some
working RAM to run everything. But they
do vary in things like the number and type
of inputs and outputs, internal timers,
and the amount of space for programs.
The most basic microcontroller has a
small handful (four or five) of connecting
pins that can be used as either inputs or
outputs. These I/O pins — or lines — are
purely digital. That is, as inputs, the lines
can be low or high (0 or five volts, respectively). Same if the pins are acting as
outputs. This means you can read on/off
type sensors such as switches, and control
on/off devices such as LEDs and motors.
Many types of sensors are analog;
that is, they don’t just provide on or off
states. A good example is the light
SERVO 01.2008 71