Motor Driver Basics
How Do Motors Work?
Motors, as we all know, make things turn. A motor is a transducer that converts from electrical to mechanical (rotational) energy. A DC motor operates with a constant supply voltage that can be adjusted to allow for variable speed/torque of the motor. The higher the voltage across the motor, the faster it will turn, and the more torque it will be able to produce (torque is actually more directly related to current, but for our purposes voltage is what matters). In robotics, motors allow an otherwise stationary control unit (in our case, the Arduino) to interact with its environment. The Arduino controls this interaction by adjusting the voltage delivered to the motors in an intelligent manner.
Why Do I Need a Motor Driver?
An Arduino’s output pins are not designed to work with a large amount of current (they operate at 40mA max), so if you want your motors to have any appreciable power output, you’ll need to draw power directly from a battery, computer USB port, or AC adapter. The motor driver receives control signals from an Arduino and outputs the same voltage, but powered (drawing current from) a separate source.
How Do Motor Drivers Work?
When you tell your 5V Arduino to analogWrite(127), it tries to output ~2.5V to the pin (255 is the maximum input value of analogWrite, corresponding to the Arduino’s HIGH voltage, 5V). Unless you have an Arduino Due, which has two digital-to-analog converters (DACs), you are actually generating a square wave (PWM signal) with a duty cycle of ~50%. What that means is that the Arduino turns the pin on and off at a high enough frequency to allow it to simulate any voltage between 0V and 5V. The amount of the time the pin is on is called the duty cycle, so a 50% duty cycle will yield an average output voltage of 50% of 5V, or 2.5V.
A motor driver is essentially a few switches that open and close according to this PWM signal to copy the input square wave into an identical (same duty cycle) output square wave, whose power source is whatever you hook up to it.
Motor Driver Comparisons
We have two motors on our robot, so we needed a dual motor driver (two motor drivers on one board). Our robot drives around on flat ground and doesn’t need to go very fast, and it is also powered by a small battery, so we weren’t looking for a very high-current motor driver (~1A max). After looking around at various sites, we discovered that Pololu has a nice selection of inexpensive, simple motor drivers. Here’s a summary of their four basic Dual Motor Drivers:
Motor Driver Chip:
Continuous Current Output (per Motor):
Peak Current Output (per Motor):
0.7in x 0.4in
0.8in x 0.5in
0.8in x 0.6in
0.8in x 0.6in
Inverted PWM Inputs Required:
* The 2130 board boasts a customizable current limit on each channel, and also does not require a logic voltage input.
** The 2135 board allows either Phase/Enable operation (one pin sets direction, one sets magnitude) or dual-PWM (inverted) operation. Mode is selectable through a control pin.
*** The 713 board has three inputs per channel. For normal operation, the two constant control pins set direction (and are inverted from each other) and the PWM pin sets magnitude.
All of these driver boards accept both 3.3V and 5V input levels, and all of them except the 2137 board work within an Arduino’s normal voltage and current range. For our robot, we decided on the 2135 board for a few reasons: most intuitive configuration, tiny size, good voltage range, and lowest price. We have had zero problems with this product while using a battery as a power source (we use a 7.2V NiMH 6-cell pack).
However, when using the computer’s USB port for robot power, our Arduino would occasionally reset while reversing the direction of the motors, presumably because the inductive flyback of the motors attempted to push too much current through the port, changing its voltage enough to trigger a reset (this is unverified, however seems to be the most plausible case, and is repeatable).
Using Your Pololu 2135 Motor Driver
The pinout of the board in Phase/Enable mode (the easiest one to set up) is described in this diagram from Pololu:
Please refer to Pololu’s product page for more information on using this board.