Stepper Motor Driver 2.3

From RepRap
Revision as of 19:31, 17 February 2009 by ZachSmith (talk) (version migrated from twiki)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Stepper Motor Driver v2.3

Overview

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

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


Files

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

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.


Schematic

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

Configuration

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.


Interface

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
</div>

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.


Output

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

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
</div>

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.

Components

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

<iframe src="http://parts.reprap.org/embed/module/Stepper+Motor+Driver+v2.3" width="600" height="800" frameborder="0">Visit http://parts.reprap.org/embed/module/Stepper+Motor+Driver+v2.3</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
</div>

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
</div>

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
</div>

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
</div>

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
</div>

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
</div>

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
</div>

NOT FOR ETHERNET! NOT FOR ETHERNET! NOT FOR ETHERNET!

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
ENABLE 5 6
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 4 #define dirPin 5 #define enablePin 6 void setup() { Serial.begin(9600); Serial.println("Starting stepper exerciser."); pinMode(stepPin, OUTPUT); pinMode(dirPin, OUTPUT); pinMode(enablePin, OUTPUT); digitalWrite(dirPin, HIGH); digitalWrite(stepPin, LOW); digitalWrite(enablePin, HIGH); //disable } void loop() { int i, j; for (i=1650; i>=600; i-=150) { Serial.print("Speed: "); Serial.println(i); for (j=0; j<2000; j++) { digitalWrite(stepPin, HIGH); delayMicroseconds(2); digitalWrite(stepPin, LOW); delayMicroseconds(i); } digitalWrite(enablePin, HIGH); //disable delay(500); Serial.println("Switching directions."); digitalWrite(dirPin, !digitalRead(dirPin)); digitalWrite(enablePin, LOW); //enable for (j=0; j<2000; j++) { digitalWrite(stepPin, HIGH); delayMicroseconds(2); digitalWrite(stepPin, LOW); delayMicroseconds(i); } digitalWrite(enablePin, HIGH); //disable delay(1000); Serial.println("Switching directions."); digitalWrite(dirPin, !digitalRead(dirPin)); } }

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. ;)

Troubleshooting

  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)


History

Changelog

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

Previous Versions