74*245
Motor Driver
H-Bridge
Driver
Simple
PWM Gen.
Handy
Method Measuring RPM
Measuring
RPM via Photo reflector
Introduction
to Robotic
DC,
Stepper,and Servo Motor
Microcontroller
Tutorial
Computer
Interface
Tutorial
.............more
links
|
|
BACK NEXT
Obstacle-Avoiding Robot.
by Pololu
1. Introduction
One of the biggest challenges in building your own
robot is controlling its motors. You can find new or surplus motors
and gearboxes in many places, and low-cost microcontrollers and books
on how to use them abound. However, microcontrollers cannot directly
drive DC motors, leaving robotics beginners with the possibly overwhelming
challenge of building their own motor controller. This task is even
more complicated if the motors require bidirectional operation and speed
control.
This project demonstrates how easy it is to make a
simple robot controller using the micro dual serial motor controller
with a Microchip PIC16F628 microcontroller. We then use the circuit
with the Pololu robot chassis to create a small, obstacle-avoiding robot
that can serve as a starting point for more advanced projects. The low-voltage
operation of the motor controller allows a small, 3.6 V cordless telephone
battery pack to power the entire robot. Since the motor controller only
requires two of the PIC's 13 I/O lines, there is plenty of opportunity
for expansion.
2. Materials and Tools
Here are the essential parts you will need if you
want to build a similar robot. These items are available either from
Pololu or from most electronic component distributors.
- Motor controller
- Robot chassis plate
- Parts to build the robot chassis, which come with
our chassis combination kits:
-Tamiya dual gearbox (Tamiya #70097)
-Tamiya ball caster (Tamiya #70144)
-Tamiya truck tires (Tamiya #70101)
-
PIC16F627 or PIC16F628 microcontroller
in a DIP (dual in-line package) from Microchip. The 16F62X microcontrollers
are the only 18-pin PICs that have a built in UART (universal asynchronous
receiver and transmitter), which makes transmitting data serially
(to the motor controller) very simple. The code presented in this
project should be portable to any other PIC with a hardware UART;
with the other PICs, you would have to write your own serial routines
(which isn't that bad since you only need to transmit, and the motor
controller should handle any baud rate you come up with).
-
Clock source for the PIC. We
used a 4 MHz ceramic resonator with built-in capacitors; any crystal,
resonator, or oscillator in the 1-20 MHz range should be fine.
-
18-pin DIP socket for the PIC.
You may also want a socket for your motor controller; a crude way
of obtaining a 9-pin SIP (single in-line package) socket is to cut
an 18-pin DIP socket in half.
-
Two long-lever, snap-action
switches for use as bumpers switches.
-
3.6 V, 650 mAh cordless telephone
battery pack (or three AA size NiCd or NiMH batteries in a battery
holder). Cordless phone batteries are available in many consmer
electronics stores (e.g. Radio Shack, Best Buy) and discount stores
(e.g. Wal-Mart) for around $10, making them a great power source
for small robots.
-
General-purpose prototyping
PC board (or proto board) with space for two 18-pin DIP sockets,
the ceramic resonator, and whatever other electronics you might
want to fit. Such boards are available from most electronics component
stores, including Radio Shack (e.g. part number 276-150A). To avoid
soldering, this project could also be done using a small wireless
breadboard, such as the one used in project 2.
-
Hook-up wire and solder for
making all of your connections.
-
Double-sided foam tape provides
a quick way of temporarily mounting items such as the battery pack.
Alternatively, you could use standard mounting hardware or cable
ties for fixing your components to the chassis.
3. Hardware Construction
Begin by assembling the robot chassis. You should mount the battery
pack on the rear of the robot, above the ball caster, to balance the
weight of the motors. Double-sided foam tape is a convenient method
of attaching the battery pack; it can also be secured with cable-ties
by using the rectangular holes on both sides of the ball caster. If
you are using a battery holder, you can easily drill mounting holes
through the holder or the chassis if existing holes do not line up.
When soldering to the motor leads, be careful not to damage them. Soldering
a small capacitor across the motor leads can improve the performance
of the motor controller and lower interference with other electronics
on your robot. We used a 0.1 uF ceramic capactitor.
The picture to the right shows a resistor in series
with the capacitor. In general, such a resistor limits the current wasted
by the PWM (pulse width modulation) in charging and discharging the
capacitor. However, the relatively low, 600 Hz PWM frequency of the
motor controller makes this resistor unnecessary; we saw no added benefit
when we added the resistor.
Because the motor leads are fragile, it is important to provide strain
relief for the wires you connect to the motor. For our example, we hot-glued
the leads to the side of the gearbox, as shown in the picture. Securing
the wires this way will allow you to manipulate the other end of the
wires without worrying about breaking off the motor leads. Note that
the glued wires prevent removal of the motors from the gearbox. Hot
glue has the advantage of not being entirely permanent; if necessary,
it's not too difficult to free the wires.
We have kept the motor capacitor exposed for the purposes
of these pictures, but it's a good idea to protect them as much as possible,
especially since they are low to the ground and on the front end of
the robot.
To keep this project as simple as possible, we limit
our sensors to two snap-action swtiches for front collision detection.
Of course, you can add more sophisticated sensors for more interesting
behavior.
As you can see in the picture to the below, there isn't much to the
electronics. We soldered the circuit on a small perforated board, but
you can also use a solderless breadboard. The small pushbutton switch
on the top right and the resistor below it make up an optional reset
circuit. The only other components are the PIC, the resonator (lower
right), and the motor controller. No additional resistors are required
for the bump switches because we use the PIC's internal pull-up resistors
on port B.
BACK NEXT
|