Stepper motor wiring tutorial
Occasionally you may come across an old stepper motor salvaged from a printer, or an ancient floppy drive. If you are lucky, there will be a part number on the motor and after some digging around, you will come up with a datasheet. Often though, you will have a motor with no markings whatsoever and four, or six colourful wires sticking out. First, you need to figure out how the wires are paired to form coils within the motor. Trial and error may work, but there is a better way! All it takes is a multimeter.
How to identify four-wire stepper motor coil pairs with a multimeter
If your stepper motor has 4 wires, it is a bipolar stepper motor. Bipolar stepper motors have two windings, which are not connected to each other, wired internally like this:
Since coils A and B on the diagram above are not connected, the resistance between leads A1 and B1, or between A1 and B2 will be infinite. The resistance between A1 and A2, or between B1 and B2 will be a definitely less than infinite (though more then zero), as they are part of the same winding. The physical location of the wires, or the colours may sometimes suggest the pairing, like in the photos below. Still, a simple check with a multimeter, set at its resistance measurement option can save you a lot of time troubleshooting your code and wiring.
Image 1: The black and yellow wire are not part of the same coil, as the multimeter shows high (infinite) resistance
Image 2: The orange and yellow wire are part of the same coil, as the multimeter shows resistance of approximately 18 Ohms.
Now that we have determined which wires belong to each coil, how do we determine the proper stepper polarity? No way to do that with a multimeter, unfortunately…Connect the motor to your motor driver of choice. Connect power and run the code to spin the motor clockwise. If the motor spins in the expected direction, you have the correct polarity. If it spins in reverse, you need to switch the polarity of one of the two pairs (it does not matter which one).
How to identify six-wire stepper motor coil pairs with a multimeter
Stepper motors with six wires are unipolar and have one winding per phase (like the bipolar steppers) but with a center tap. The internal wiring of these motors looks like this:
Looking at the diagram above, we can assume that the resistance between A1 and AC will be half of that between A1 and A2. This is because there is less wire between AC and A1 than between the two ends of the A coil, A1 and A2. The same applies to the resistance between BC and B1, or B2. Simillar to the case with the bipollar, 4-wire stepper motor, there is no connection (infinite resistance) between any of the wires from coil B and coil A. Time to put the theory to the test!
Image 3: The Black and Brown wires are obviously part of the same coil (resistance is approximately 194 Ohms)
Image 4: The Black and the top Red wire (there are two red wires on this stepper) are also part of the same coil (resistance of approximately 97 Ohms).
The top Red must be the center tap of the coil with the Black and the Brown wires, as the resistance between the Red wire and the Black wire is half that of the resistance between the Black and the Brown wire. For a good measure you should also measure the resistance between the top Red and the Brown wire, to confirm it is also around 97 Ohms.
Image 5: The Yellow wire must not be part of the same coil as the Black, Brown and the top red wire. Multimeter shows no electrical connection between the Yellow and the black wires.
To make sure, I also double-checked the resistance between the bottom Red wire and the Yellow wire, as well as the resistance between the Yellow and Orange wires. Another measurement confirmed that the two Red wires are also not connected.
One coil is Black and brown wires, with the top Red wire as the center tap
The other coil is the Yellow and the Orange wires, with the bottom Red wire as a center tap.
If your motor has 5 wires test to see if one of the wires is not connected to the casing of the motor. If it is, then mark it and then proceed with the same test as with the four wire stepper motor. If no, then you are looking at a unipolar motor, where the two center tabs are connected. The cheap 28byj-48 stepper motor (see tutorial) is an example of that.
You can still use the resistance test to determine the center tap, but the resistance between the other 4 wires will be the same, due to the common center tap. Some trial and error, or good documentation will be useful here.
If your motor has 8 wires, the internal wiring should look like this.
I never had on one of these type of steppers yet, so can’t speak from experience here, but using the multimeter and testing the wires in pair, should give you the pairs (eventually). You will need to do some extra work to determine which pairs are on the same coil. Likely this will require some trial and error, using your stepper motor driver.