Stepper wiring

From RepRap
Jump to: navigation, search

About all RepRap stepper drivers are bipolar (as opposed to unipolar), 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 these two common wires on each coil connected internally and exposed as only one wire. This configuration won't work for the standard RepRap electronics. Short of opening the stepper an re-wiring it internally, you have to get another motor. The BrickRap is using five wire motors the 28BJY-48 driven by a Pololu motor driver. The 28BJY-48 motor has one of the wires removed/cut, look for the 'bipolar motor hack on google, instructables, hackaday etc.

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 an independent wire on each end of those four coils. You connect the inner endings of the coils to each other to make a six-wire motor, then you ignore them to look at a four-wire motor. Wiring is tricky, see below.

Connectors, Crimping & Re-Pinning

A common connector used on Stepper Motors is the JST-PH Series, specifically the JST-PH6 (JST style, PH Series, 6 positions), Digikey part# 455-1162-ND. Pins for these connectors are available at suppliers like DigiKey, and the correct part # for common 24AWG wire is 455-2148-1-ND, see the associated products for other gauges. For those who don't have a crimping tool, or don't want the hassle, JST now had an IDC(Insulation Displacing Connector) which doesn't require the use of any specialized tools. DigiKey part number for 6pin JST-PH(man ref# 06KR-6H-P) compatable connector is 455-2687-ND

For crimping it is not advised to do it by hand with pliers, or to buy the manufacturer's $1,500 tool, instead you can easily use a non-ratcheting tool such as the Sargent Tools 1026CT, which is $30, or the Waldom/GC Electronics W-HT-1921 which is $20 from DigiKey.

Re-pinning the connector is possible and somewhat easily accomplished by delicately bending the plastic retainer tab for the individual pin on the header while gently tugging the wire away from the connector body. Do not tug on the wire before lifting the retaining tab as the locking spur on the pin itself may get hung up on the header tab making the whole process more difficult. Re-inserting the pin requires only enough force to get the locking spur past the retainer tab so it clicks into position.


Can be 26AWG, describe as used in various Wantai motors, or 24AWG, mentioned below, and at [[1]]. Ethernet cable and 28AWG wire are likely not good for high power motors. You want stranded wire rather than single wire, that way the strands can stretch slightly in order to relieve sudden pulling.

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

To get the stepper just moving, polarity of each coil doesn't matter, nor does it matter which coil is which. So make sure each pair of wires for a coil are together on one side of the plug (or the other side for the other coil), and plug it in.

Motor moving the wrong direction

To get the motor moving in the right direction, is actually does matter which coil is which and what the polarity of the coils are. However, if they're wrong, the motor just turns the wrong way, it's easy to fix that by swapping wires. Pick one of the following in order to reverse the stepper's direction:

  1. Switching the polarity of either (one) coil, like changing ABCD to BACD or ABCD to ABDC.
  2. Swapping the coils, like changing ABCD to CDAB.
  3. Stepper direction can also be reversed in the firmware.
  4. Plugging the plug in backwards (in case your electronics' plugs allow that). This swaps the coils, and reverses 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. Only few electronics allow that, because you have to figure the right way not once, but each time you connect the stepper.

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.
  • Motor control loop defines different motor control loop systems
  • NEMA Motor describes the NEMA standards for stepping motors -- in particular, what "NEMA 17" means.