Let's Make Robots! | RobotShop

Very low cost 2A dual DC motor driver with cool features

Use A4988 stepper driver to drive two DC motors instead. Make use of currentlimit to control speed.
A4988RobotV2.txt3.3 KB

EDIT: Some speed control, new code example and video added 21.2.2014 See below " SOME IDEAS" section for more information.



I ordered some well known pololu style A4988 stepper driver modules for a project. However it came to my mind that could one use these very cheap, small and nice modules to drive DC motors too?

I remembered the times i started playing with arduinos PICAXEs and stuff and for a poor hobbyist it seemed to be very wasteful to use two h-bridges to drive one stepper motor when one can drive two DC-motors as well. Now I know better the steppers have some use two but nevertheless DC motors are nice choise for a small nice wandering robot.

I googled around and was told not to try it. Reading the datasheet of A4988 reveled that there isn't any reason why it shouldn't work. When two motors are plugged to A4988 module (instead  of steppers coils) they can be driven by manipulating stepping sequency.

Pros for using A4988 as dual h-bridge:

- Cheap and widely available ( 1.4 $, ebay FEB, 2015)


-2A, (many modules can't do that really, depends on heatsinking and current sense resistors)

- Only 3 datalines needed (or only two)

-small voltage drop comapred to many older h-bridges

-current limit that can be adjusted

- Speed control possible without external pwm

-Sleep mode

-Controlled decay modes for coil current reversing and crossover protection.

- Ability to run DC motors above their rated voltage and get some benefits of it



-Not so easy logic

-Harder to control speed of individual motors (but not impossible)

-something i didn't realize

-needs 7.5-8v motor supply


Steppers are driven by pulsing step pin and direction is changed by setting dir pin hig or low. Every time use pulse step, current in one of the coils chnages its direction. This is picture from ST micoelectronics application note.


I made a little code that makes right number of steps to right direction depending on current state of motors. Its nothing very fine and  optimal but works as you can see in the video. I had no ready platform to try this out and improvised this little fellow. My 6-years old daughter made the cardboard boxes as I promised to show them here :)

Schematic is so obvious that I only refer to pololu minimal setup quide:



Only differences are that arduino pin 8 is connected to enable and motor windings are in separate motors. I couldn't find in datasheet  whats the undervoltage lockout limit for module but I run motors wit 7.4lipo which is under the recomnded 8v but worked fine (besides the motors are rated 12V so they run little slow). I think with current limit you can run motor with voltage above its rated,   what gives faster response and even better torque in startup?

Some guts:




This code doens't show it but i tried also control speed of motor by pulsing enable (its won't affect stepping translator) and it seemed to work fine. I plan to try individual motor speed control by changing to half-step sequency and changing fast between two coil ON and one coil OFF.     I found that A4988 has internal pwm to set different current levels in microstepping modes. These modes can be used to control speed of motors independetly. Example video uses 8-step-mode. 



As you can see both motors have 70% of maximum current when in starting position. When another motors current increases, ohters decreases.This may be handy when you only need to make motors run same speed and they have little difference when both have same current. (quite common situation)

If you want to only slow another motor down you can set currentlimit with potentiometer so that 70% of it is you motors max current. So motorB speed won't increase when you slow motorA down.

Best resolution would be achieved in 16-step mode. How ever any speed combination of motors is possible when PWM on enable pin is combined to this approach.

I realized that my example code is crappy. It would be more reliable and easy to use reset to put motors in known state before telling them to change direction.   Now there is a new code and video with PWM speed control and reset of states. Also DIR pin isn't needed anymore so it could be only tied to VCC.

Also it came to my mind that one could get away with only two data lines by pulling DIR pin low/high and making proper amount of steps in one direction. If you don't want to stop your motors but only change the direction, then pulsing step-pin is enough. Quite minimal setup :)


Next project to make minibot with these 3-5v wormgear motors and a pro mini.




Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

These drivers got really cheap with the boom of 3d printers; if used well they would dissipate less heat than l298, have better control, overcurrent, undercurrent and overtemp protection and smaller footprint.
The dr8835 is made for both dual channel drive and stepper mode, but isn't popular as the drv8825 which it's more specialized for steppers.

Ooo, that's a great idea. Would be nice to see if steering could also be possible with these motors. Regards
Matija from Polabs http://blog.poscope.com/stepper-motor-driver/

I wish you would elaborate on the connection from A4988 driver to motors


It has 1A, 1B, 2A, 2B

do I connect 1A, + 2A = motor 1??

Do you think it's possible to drive 5v laser this way?