By Martin Weiss
A Dual Serial
When I got started in hobby robotics a couple of years
back, my robots (probably like those of most beginners)
were single microcontroller designs. While I had a
fair bit of success tinkering with “one-chip wonders,”
lately I’ve been steering more toward designs involving
Using a single microcontroller to control all aspects of a
robot is often impractical. For example, a low-level task like
motor control can tie up a significant amount of resources
driving PWM channels, speed control algorithms, etc.
Consider, on the other hand, a robot comprised of several
microcontrollers — one that serves as the “master” and
controls high-level decision making, and one (or more)
additional controllers dedicated to specific tasks like motor
control. This latter “distributed” approach allows each
individual microcontroller to be better optimized for its
particular task, in principle making the overall system more
capable (albeit at the cost of more hardware).
This article will focus on creating one of the core
components of this architecture: a dedicated motor
controller. A serial interface will be used to facilitate
communication between the master and the motor
controller making this project useful as a generic building
FIGURE 1. The
inside the red
received from the
master into PWM
signals to drive
the motors via
block in a wide variety of applications.
The Key Ingredients
I’ve chosen to use Atmel’s ATtiny2313 microcontroller
as the brain of the motor controller. Although the
ATtiny2313 is indeed relatively tiny — with only 2K of Flash
and 128 bytes of SRAM — it does have a full duplex USART
and four PWM channels which makes it ideally suited for
our purposes here.
The “brawn” to actually drive the motors will be
provided by the Toshiba TA8428K5S H-bridge which is a
little beefier than some of the more commonly used
H-bridges like the SN754410, LM293D, and TA8050P.
The TA8428K5S can source a fair bit of current (1.5 amps
average, 3.0 amps peak) and should work great for
controlling small motors. It comes in a seven-pin in-line
package which allows easy mounting on a printed circuit
board (PCB), as well as attachment of a heatsink. Each
TA8428K5S can control a single motor.
Putting It Together
Speaking of software, when we eventually get
around to writing the code for this project, it would
be handy if the hardware design lent itself to graceful
software control without requiring undue complexity.
Some H-bridges have direct inputs for speed and direction
(i.e., rotate clockwise/counterclockwise) which simplifies
the software design. Unfortunately, the TA8428K5S — like
54 SERVO 10.2009