Stepper Motor Driver 2.3

From RepRap
Revision as of 14:20, 27 February 2009 by ZachSmith (talk) (version migrated from twiki)
Jump to: navigation, search

Stepper Motor Driver v2.3


<div class="thumb tright">
Cache-3218206144 6461b3e2c0.jpg

This board allows you to control one stepper motor, as well as receive input from two limit switches. It is based around the Allegro A3982 Stepper Motor Driver with Translator. The A3982 is capable of driving up to 2A per coil. This board was designed to improve upon and replace the v1.x series of stepper drivers which are based upon the venerable L297/L298 stepper drivers. The A3982 offers a number of improvements:

  • Only one chip to solder, as opposed to the two chip L297/L298 combo
  • Superior DMOS technology (no heatsink required!)
  • Built-in diodes and synchronous rectification (no large diode array!)
  • Much cheaper and smaller than the L297/L298 (about $10 cheaper, total!)

The downside is that the board is mostly SMT, although we made a conscious design decision to stick with some of the largest and easiest to solder SMT components on the market. We used 1206 sized resistors and the A3982 itself is in a SOIC package. The board is very easy to put together, even for a beginner. Using a technique such as solder paste + hot plate, the board becomes ridiculously easy to solder. I found that it is much easier to solder SMT boards in this fashion than to solder pin after pin manually with through-hole components.

Get It!

Full Kit

  1. Coming soon!

Raw Components

  1. Buy the components with ease


<div class="thumb tright">
Cache-3289138574 55f1cca7e4.jpg

You can download the release file from SourceForge that has a bunch of helpful files for this board. It contains:

  • GERBER files for getting it manufactured
  • PDF files of the schematic, copper layers, and silkscreen
  • Eagle source files for modification
  • 3D rendered image as well as POVRay scene file
  • exerciser code to test your board.


<div class="thumb tright">
Cache-3289138606 21a91faea7.jpg


Current Adjustment

The board allows you to control the amount of current flowing through the coils by adjusting a trimpot located on the board next to the 'Interface' connector. Simply turn the trimpot one direction to get the minimum current, and the other direction to get maximum current. Generally this will be clockwise/counter clockwise, but it will be obvious which is which as you adjust the current with the motor running. Adjusting it to the lowest setting will cause the motor to stop turning. Generally, you will want to adjust this to the lowest setting you need that will still turn the motor. That will reduce power usage, and will prevent your motor from overheating.


IDC Connector

Pin Name Function
1 N/C Not Connected to anything
2 GND Connect this to your uC to share a common ground.
3 Step A pulse on this line will make the stepper motor advance one step in the desired direction.
4 Dir If this pin is high, the motor will rotate forward, low it will rotate backwards.
5  !Enable This pin allows you to turn the motor on and off. It is an inverted pin to avoid noise turning the driver on. By default it is disabled (pulled high). A high signal means off, low signal means on.
6 Min This is the signal from the 'min' sensor. The definitions of high/low are determined by your opto endstop.
7 Max This is the signal from the 'max' sensor. The definitions of high/low are determined by your opto endstop.
8 GND Connect this to uC to share a common ground.
9 GND Connect this to uC to share a common ground.
10 GND Connect this to uC to share a common ground.

Minimum and Maximum Connectors

Say it with me:

The Stepper Motor v2.3 design does not support ethernet!
The Stepper Motor v2.3 design does not support ethernet!
The Stepper Motor v2.3 design does not support ethernet!

What we are doing is hijacking a common and very cheap connector for our own purposes. RJ45 patch cables and jacks are ubiquitous, versatile, robust, and cheap. We've considered and rejected many other connector technologies (RJ11, 3.5mm audio cables, etc) but in the end, RJ45 is the best for our needs. If you have another source of high quality premade cables (that we have not already rejected) please bring it to our attention in the forums. Please do not complain about being forced to use these cables, as there is a simple on-board alternative (see below).

Below you will find a pin out table containing the pin-out information on a standard RJ45 patch cable.

Pin Color Function
4 and 5 Blue and Blue/White 5V supply
6 Green Signal
7 and 8 Brown and Brown/White Ground

.100" Spaced Header

<div class="thumb tright">
Cache-2947047493 d8317e3e9f.jpg

In order to maintain backwards compatibility, as well as giving the user the freedom to chose their desired connector technology, we have included a standard, .100" pitch connector footprint that you may populate as desired. The pins are clearly labeled, and you may wire it however you like. You can solder wires directly to the board, solder in right-angle headers, normal headers, or any other number of technologies. Its up to you as a user to decide. Shown here is an example of using a right-angle .100" spaced header.

Note: No, that's not the board we're talking about, but the footprint is exactly the same.


<div class="thumb tright">
Cache-3217355391 89e845875f.jpg

The A3982 is rated for 2A per coil, so if your stepper motor drives more than that, you should adjust the chopper so that it delivers less current than that.

Pin Function
A This is the 'positive' end of coil 1
B This is the 'negative' end of coil 1
C This is the 'positive' end of coil 2
D This is the 'negative' end of coil 2

We have a page with full info on wiring your stepper motor for use with this board.

Circuit Board

<div class="thumb tright">
Cache-3217365813 7bab907309.jpg

You can either buy this PCB from a supplier, or you can make your own. The image above shows the professionally manufactured PCB ready for soldering.


<div class="thumb tright">
Cache-3218216616 14219f73c9.jpg

<iframe src="" width="600" height="800" frameborder="0">Visit</iframe>

Build Process

This board contains surface mount parts. Trust me when I tell you that it is really, really, really easy! The hardest part about SMT soldering is getting over your fear and staying calm. I've shown complete beginners how to do it, and they had no problems.

There are four parts to building a surface mount board using the Hotplate Reflow Technique:

  1. Apply solder paste to every exposed SMD pad
  2. Place each SMD component on its appropriate pad
  3. Place populated board on a cold hotplate. Turn hotplate on. Board solders itself!
  4. Solder in remaining through hole components.

Apply Solder Paste

<div class="thumb tright">
Cache-3217363597 fb76fd7e15.jpg

Okay, so this part is pretty easy: get your solder paste syringe and start applying solder paste to every SMD pad. I like to use a squeeze/tap method. That is, I squeeze a bit of solder paste out, then tap the place where it goes, rinse and repeat for every exposed pad. Do not put solder paste on pads with holes in them. You'll solder those in step #4.

Place Components

<div class="thumb tright">
Cache-3218214538 bea910c6c2.jpg

This is probably the trickiest part. Its easiest with tweezers and some sort of magnification. A bit of patience and you'll get it no problem. Since nothing gets soldered yet, you can easily try and try again if you mess up.

TODO: Show pictures of each individual component placement.

Hot Plate Reflow

I prefer to start with the hotplate off. I burned a few boards one time by putting them on when it was already hot. Instead, carefully place the board on the cold hotplate, thn turn the heat up to a low temperature. Wait a few minutes for things to get cooking, and you'll see the small components begin to 'pop' as the solder goes molten. Keep an eye out for components that stick together. If that happens, simply nudge them apart. Wait until you see the largest component leads go silver. Usually the capacitors are the last to go.

Once they have soldered, simply turn the hotplate off and let it cool down.

Solder Through Hole Components

This board has a few extra non-SMT components. Now that you're a SMT pro, it will be easy. Here they are, step by step:

10K Trimpot
<div class="thumb tright">
Cache-3217358291 6cbf322195.jpg

This has 3 leads and will only fit in one direction. Solder it into place and trim the leads.

Molex Power Connector
<div class="thumb tright">
Cache-3218209166 93936c9ed6.jpg

The notches on the inside of the connector match up with the notches on the silkscreen. Make sure you insert it properly. It helps if you solder it flush to the board as well.

IDC Header
<div class="thumb tright">
Cache-3217356581 fbb17bca69.jpg

There is a notch on the part that lines up with the 'notch' on the silkscreen. It should face the outside of the board. Make sure to solder it in the proper orientation.

Stepper Header
<div class="thumb tright">
Cache-3217355391 89e845875f.jpg

This is the connector for the stepper. Put the 'locking ramps' towards the inside of the board. Make sure to solder it in straight.

RJ45 Jacks
<div class="thumb tright">
Cache-3218206144 6461b3e2c0.jpg


These is the connector for the minimum / maximum switches. The connectors snap into place and stay put for easy soldering. Do them both at the same time.

Test Your Board

Now we have to test the board. Its very easy, and consists of a few steps.

Connect Power to Board

Always turn your power supply off before plugging it in. It won't fry things most of the time... but all it takes is once to damage things.

Simply take your AT power supply and plug a power connector into the board, and turn it on. The green LED next to the connector should light up. If it doesn't, check its polarity and bust out your multimeter!

Turn your power supply off while you plug boards together!

Give it a test drive.

Connect Board to Arduino / Sanguino

If you have a RepRap Motherboard, simply plug it into the X axis header! Otherwise hook it up as described below:

This part is very easy. Use the table below to determine what pins to hook up to what. Plug the IDC cable into the blue socket on the stepper controller board. If you look into the holes of the IDC plug, with the red stripe away from you, the top-right pin is #1. The pin to its left is #2. The pin one row closer to you from #1 is #3. The pin closer to you from #2 is #4. Plug three jumper wires from the IDC connector into the associated Arduino pin:

Board Pin IDC Arduino Pin
STEP 3 4
DIR 4 5
GND 2 Ground

Upload Firmware to Arduino

Now, feel free to turn on the power to your power supply. Next, open the Arduino software, copy the code below into your sketch and upload it. After the firmware has compiled and uploaded, the Arduino will restart and the exerciser will begin shortly.

#define stepPin 15 #define dirPin 18 #define enablePin 19 #define minPin 20 #define maxPin 21 void setup() { Serial.begin(19200); Serial.println("Starting stepper exerciser."); pinMode(stepPin, OUTPUT); pinMode(dirPin, OUTPUT); pinMode(enablePin, OUTPUT); pinMode(minPin, INPUT); pinMode(maxPin, INPUT); digitalWrite(dirPin, HIGH); digitalWrite(stepPin, LOW); digitalWrite(enablePin, HIGH); //disable calculate_tones(); } void loop() { Serial.println("Forward!"); digitalWrite(dirPin, HIGH); play_song(maxPin); delay(500); Serial.println("Reverse!"); digitalWrite(dirPin, LOW); play_song(minPin); delay(500); } boolean at_switch(byte pin) { return !digitalRead(pin); } #define TONE_COUNT 16 float frequencies[TONE_COUNT] = { 196.00, //G 0 207.65, //G# 1 220.00, //A 2 233.08, //B- 3 246.94, //B 4 261.63, //C 5 277.18, //C# 6 293.66, //D 7 311.13, //D# 8 329.63, //E 9 349.23, //F 10 392.00, //G 11 440.00, //A 12 466.16, //B- 13 493.88, //B 14 523.25, //C 15 }; int tones[TONE_COUNT]; #define NOTE_COUNT 25 int notes[] = { 5, 5, 7, 5, 10, 9, 5, 5, 7, 5, 11, 10, 5, 5, 15, 12, 10, 9, 7, 13, 13, 12, 10, 11, 10 }; void calculate_tones() { for (byte i=0; i<TONE_COUNT; i++) tones[i] = (int)(1000000.0/ (2.0 * frequencies[i])); } void play_song(byte switchPin) { digitalWrite(enablePin, LOW); //enable for (byte i=0; i<NOTE_COUNT; i++) { if (!at_switch(switchPin)) { play_note(tones[notes[i]], 300000); delay(10); } } digitalWrite(enablePin, HIGH); //disable } void play_note(int note, long time) { int count = round(time / note); for (int i=0; i<count; i++) { digitalWrite(stepPin, HIGH); delayMicroseconds(note); digitalWrite(stepPin, LOW); delayMicroseconds(note); } }

The basic way the motor exerciser works is this:

  • The stepper will take 2000 steps in one direction
  • The stepper will take 2000 steps in the opposite direction
  • The speed will increase or decrease.

The stepper exerciser will gradually increase/decrease the stepper motor to show a wide range of possible speeds and movements. It will do 2000 steps in each direction at each speed.

You can easily visually verify that the stepper motor driver is working after you do this, as the LED's next to the stepper driver will both light up and will flicker. This is because the LED's are switching from on to off very rapidly. If this is happening, then congratulations: your stepper driver board is a success!

Hook up a stepper motor

You'll need a stepper motor to drive at this point.

Find a stepper motor that you have wired up to a .156" pitch connector. You can view wiring diagrams for various stepper motors if you have not wired any up yet.

Make sure the power to your driver board is off and insert the connector. Reset the Arduino board and turn the power on for your power supply. After a few seconds, your stepper motor should spring to life. When it does, do a little dance because you've just cleared the hardest hurdle in making a robot that can do some amazing things*.

You probably want to optimize for minimum power consumption, which stops the chip from getting too hot and cuts down on noise. Adjust the trim potentiometer power all the way anticlockwise, which basically cuts off the drive current. Now tweak it clockwise until the motor performs as desired reliably plus a tiny bit extra. There, done. If you want to get fancy, there's a test point just below the trimpot which you can measure the voltage on. If you know how to do that properly, please write up the process for the rest of us.

  • Maybe. ;)


  1. First, check to see that you have supplied power to the board.
  2. If that doesn't work, check that you have the board wired up correctly to the Arduino.
  3. If the motor does not move at all, then check your circuit for shorts and dry joints.
  4. If your board checks OK and you have power lights, tweak the trim potentiometer briefly to the right. Any improvement?
  5. If the motor does move, but is very jerky, then you have miswired the stepper to the board. Simply reverse the polarity on one coil to make it function properly. (eg. switch A with B)



  • Changed a few capacitor footprints to fit better.
  • Made them red. ;)

Previous Versions