Stepper wiring

From ElectroDragon Wiki
Revision as of 22:19, 10 May 2021 by Chao (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

There are two basic ways to drive a stepper motor, depending on if you can reverse the polarity on a coil or not. The reprap can and does, and this makes the "extra" wires on some stepper motors redundant. See wikipedia and Stepper motor#Bipolar for more detailed information on unipolor vs. bipolor steppers.

About all Reprap stepper drivers are bipolar, so if you're using the standard drivers, you will need a stepper than can be wired as bipolar.

For any stepper motor to be wired up properly, we'll need to determine which wires are "pairs" or connected to the ends of each coil. These are usually referred to as coil "A" and coil "B", but which is which doesn't matter as much as you'd think.

This picture shows how 6-wire steppers are wired:


Four wire motors don't have the common wire. We will use all four wires, and we'll only need to determine which wires make up the two pairs.

Five wire motors have the two common wires on each coil connected internally, and exposed as only one wire. This configuration won't work for the standard reprap electronics, as the coils can't be independently reversed. For unipolar drive, the common wire is usually connected to hot, and the four others are grounded in pairs in turn to energize half of each coil at a time, turning the motor. Some people have tried to take the motor apart and convert these into four-wire motors, but no result report yet. And no, cutting the fifth wire off won't work, as the centerpoints of each coil are still internally connected. While the above information on five wire motors completely makes sense, the BrickRap development is using a five wire motor driven by a Pollullu.

Six wire motors are wired as shown. We won't be using the two common wires, but otherwise it's identical to the four wire version.

Eight wire motors have two common wires for each of those coils, which don't connect. This divides this into four electrically separate coils. Unless you have the datasheet, this can make things tricky. It's fairly simple to determine what the pairs are, but determining which two pairs of half-coils are which and getting the polarity right can be tricky.

Methods and procedures

So how do you determine which wire is which? Here's a process for you.

Note on endstops: some Reprap firmwares (such as Marlin) will be looking for the endstops to be hooked up while testing the motor wiring as noted above. In this case you may see your motor move smoothly in one direction, but not at all in the other (as it thinks the endstop is triggered). If your firmware allows you to disable endstops you should do so for testing motor wiring, or alternatively you can connect the motor to the Extruder stepper motor connector to check that it moves smoothly in each direction.

"pair" wires on 4 wire motors

This is about finding the two pairs of wires which are connected to each of the two coils.

Method with an ohm-meter
Simply measure pairs of wires for their resistance. If the resistance is a few ohms ( < 100 Ω) only, you've found a pair. The other two wires should make up the other pair.
Methods without an ohm-meter
First, try turning the motor with your fingers, and notice how hard it is. Then, stick wires together in pairs. If the motor turns noticeable harder, you've found a pair.
Another method is to use an LED, hold any two wires to the ends of a LED and turn the motor (twiddle in both directions), the LED will light if the wires are a pair, swap wires until you light the LED.
Try-and-error method
(Reproduced from this tutorial by kind permission of Rustle Laidman at
Connect the 4 coil wires to the controller in any pattern. If it doesn't work at first, you only need try these 2 swaps:
Name A B C D
Arbitrary first wiring order 1 2 4 8
Switch end pair 1 2 8 4
Switch middle pair 1 8 2 4
You're finished when the motor turns smoothly in either direction. If the motor turns in the opposite direction from desired, reverse the wires so that ABCD would become ABDC (swap one coil) or DCBA (turn the entire plug around).
This procedure doesn't always work in two steps (e.g, if your setup needs "1" matched with "4"). Swapping the 2nd with the 4th, then the 2nd with the 3rd would be more certain.

"pair" wires on 6 wire motors

On six-wire motors you'll find two groups of three wires in which all three wires are electrically connected to each other. These wires are connected to the same coil, one in the center of the coil, two at their ends. Accordingly, two of the possible pairings have a lower resistance, one pair has a higher one. Take the pair with the higher resistance and ignore the third wire.

The no-ohm-meter method can work here, too. Expect not two, but three stages of turning resistance. You want the two pairs which give the highest turning resistance.

After you found out which two of the six wires to ignore (one in each group), you can proceed as if you had four-wire motors.

match coils for 8 wire steppers

If you have a 8 wire stepper, you'll have 4 coils. You need to determine which pairs of coils are the "same". There are two "pairs" which are essentially the same. You want to hook these two pairs up in series so that you essentially have only two coils, each twice the length. You also need to hook them up so that the two coils "add" to each other - polarity matters.

The simplest way will be to find the datasheet. While other types of steppers make it straightforward to identify the correct coils, it'll probably be easier and faster to read the datasheet for 8-wire motors.

If you can't find the datasheet, all is not lost. Pick two coils at random, plug it in and see if it works. If it turns, you've got two coils that aren't the halves of the same coil. You can then "add" the other coils one at a time, trying different configurations and polarities until you've identified not only which two coils are which, but which way they need to be hooked up. Put some thought into it, it's straightforward, but somewhat involved. Since we don't care which direction the stepper turns, we can eliminate a lot of possibilities and just concern ourselves with the simple question "does it turn?".

Plug it into the stepper driver

The polarity of each coil doesn't matter, nor does which coil is which. So make sure each coil's wire is together on one side or the other of the plug, and plug it in.

It DOES actually matter which coil is which and what the polarity of the coils is, but if they're wrong the motor just turns the wrong way, which is easy to fix. Keep in mind the following:

  1. Switching the polarity of either (one) coil will reverse the stepper's direction.
  2. Swapping the coils will reverse the stepper's direction.
  3. The stepper direction can be reversed in the firmware.
  4. Plugging the plug in backwards swaps the coils, and reversed both coil A and coil B. Thus the effect is to change the direction 3 times, which gives a net effect the same as changing the direction once.

Simplest solution to the stepper turning the wrong way is to turn the plug around, unless you've compiled your own firmware and already know how to reverse the direction in firmware.

Further reading

  • StepperMotor has a list of stepper motors that are known to work, a list of stepper motor drivers that are known to work, and some more tips.
  • NEMA Motor describes the NEMA standards for stepping motors -- in particular, what "NEMA 17" means.


Bipolar and Unipolar Stepper

  • Bipolar 4-wire Stepper

The bipolar stepper motor usually has four wires coming out of it. Unlike unipolar steppers, bipolar steppers have no common center connection. They have two independent sets of coils instead. You can distinguish them from unipolar steppers by measuring the resistance between the wires. You should find two pairs of wires with equal resistance. If you’ve got the leads of your meter connected to two wires that are not connected (i.e. not attached to the same coil), you should see infinite resistance (or no continuity).

  • Unipolar 5-wires Stepper

The simplest way of interfacing a unipolar stepper to Arduino is to use a breakout for ULN2003A transistor array chip. The ULN2003A contains seven darlington transistor drivers and is somewhat like having seven TIP120 transistors all in one package. The ULN2003A can pass up to 500 mA per channel and has an internal voltage drop of about 1V when on. It also contains internal clamp diodes to dissipate voltage spikes when driving inductive loads.To control the stepper, apply voltage to each of the coils in a specific sequence.

The sequence would go like this, the following example code will follow this sequence:

Stepper sequence.jpg