Stepper Motor Driver 2.3

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

Stepper Motor Driver v2.3

Overview

Jump to the Index / Table of Contents

<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

See our IDC cable construction page for info on how to make the IDC cables.

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.


C3 - .22uF Ceramic Capacitor
<div class="thumb tright">
Cache-3314049457 9e57b1460e.jpg
</div>

This capacitors should be marked with a red pen to differentiate them from the other capacitors. It can be placed in any orientation.


C1, C4, C6, C8, C12 - 100nF Ceramic Capacitor
<div class="thumb tright">
Cache-3314048073 ffbbc27a06.jpg
</div>

These capacitors can be placed in any orientation.


R3, R16 - 0.25 ohm resistors
<div class="thumb tright">
Cache-3314046765 591b595e55.jpg
</div>

These resistors can be placed in any orientation.


R15 - 10K ohm resistor
<div class="thumb tright">
Cache-3314045359 4a9b9c68b0.jpg
</div>

This resistor can be placed in any orientation.


R5, R7, R8, R17 - 1K ohm resistor
<div class="thumb tright">
Cache-3314868230 7c4cd6f281.jpg
</div>

These resistors can be placed in any orientation.



R6 - 2.2K ohm resistor
<div class="thumb tright">
Cache-3314866862 ca0456c673.jpg
</div>

This resistor can be placed in any orientation.



Red LEDs - A/D
<div class="thumb tright">
Cache-3314041233 b0a54ca7a5.jpg
</div>

These LEDs need to be placed in the right orientation. The green marking on one side needs to match up with the white dot on the silkscreen.


Green LEDs - B/C/Power
<div class="thumb tright">
Cache-3314038677 d62c6d215d.jpg
</div>

These LEDs need to be placed in the right orientation. The green marking on one side needs to match up with the white dot on the silkscreen.


IC3 - 7805 - 5V regulator
<div class="thumb tright">
Cache-3314861586 d8d3591357.jpg
</div>

The 7805 really only fits one way. Its easiest to grab it by the middle half-pin that sticks out.


A3982 - Stepper Driver
<div class="thumb tright">
Cache-3314035935 2fdb630694.jpg
</div>

This is the guy that does the heavy lifting. It might be tricky to grab with tweezers, but you can do it. Once you have it placed, then gently nudge it into alignment (if its not already perfect).



C10, C11 - 100uF electrolytic capacitors
<div class="thumb tright">
Cache-3314858636 2cba71cc31.jpg
</div>

These must match up with the silkscreen. One edge of the capacitor has a black line on it. Match this up with the corresponding white line on the silkscreen.



Hot Plate Reflow

<div class="thumb tright">
Cache-3314857240 354eb154f6.jpg
</div>

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 with tweezers or other non-finger device. Wait until you see the largest component leads go silver (usually the big capacitors). If it starts to smell really bad, kill the power and solder the rest by hand. Sometimes the capacitors wont fully solder, so just hit the exposed pad with a soldering iron after the fact.

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

For detailed instructions on how to do hotplate reflow soldering, please see the Hotplate Reflow Technique guide.


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.


IDC Cable
<div class="thumb tright">
Cache-2528437562 41f033df82.jpg
</div>

See our IDC cable construction page for simple instructions for how to build the IDC cable.


Test Your Board

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

Connect Power to Board

<div class="thumb tright">
Cache-3314977742 1b6fce154e.jpg
</div>

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!


Attach a Stepper Motor

<div class="thumb tright">
Cache-3314976644 16a0db7367.jpg
</div>

You'll need a stepper motor to drive at this point. You'll want to make sure you've wired it up correctly.

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 a 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.


Attach your opto endstops

<div class="thumb tright">
Cache-3314973420 591354258c.jpg
</div>

Using a short Cat5 patch cable, you just wire up the endstops to the stepper motor driver. Plug and play, baby!


Give it a test drive.

Connect Board to Sanguino

<div class="thumb tright">
Cache-3314150511 814f89ba76.jpg
</div>

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

Function Stepper Pin Sanguino Pin
STEP 3 15
DIR 4 18
ENABLE 5 19
MIN 6 20
MAX 7 21
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 Sanguino will restart and the exerciser will begin shortly. You should hear a familiar tune. Proceed to celebrate.

#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 some steps in the forward direction
  • The stepper will take some steps in the reverse direction
  • We vary the stepping frequency to play a little song.
  • If you trigger the min or max endstops (depending on direction) it will abort that direction and switch directions.

Even if you don't have a stepper motor, 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!

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. ;)
  • 2.3-r1: fixed a bug that prevented the max endstop from working properly.

Previous Versions

Index