NEMA 17 stepper motor

The square black motor on every 3D printer's axes: a bipolar hybrid stepper, 17HS4401 style, with two coils, four wires and 200 steps to a turn.

Black and green are one coil and red and blue the other. There is no common wire, so turning it takes current through each coil in either direction, which means two H bridges: an A4988 or a DRV8825, or an L298N driven in full step. A board pin cannot drive it and neither can a ULN2003.

Pins

Pin What it does
A1, A2 Coil A, black and green.
B1, B2 Coil B, red and blue.

Properties

resistance: ohms per coil, 1.5. current: the rated current, 1.7 A. steps: full steps per turn, 200. max_steps: the fastest full-step rate the rotor follows, 1000 a second (300 rpm). angle: where the shaft starts.

What the model gets right

Each coil is a resistor, so the motor loads its driver as the real one does. The current in each coil is read off the volts across it, the two currents point a magnetic field, and the rotor's 50 teeth line up with it: one turn of the field is four full steps, 7.2 degrees of shaft. So full step, wave drive, half step and any microstep a driver produces all come out of one rule, and a full step is 1.8 degrees.

The rotor goes the short way around to the field. A field that jumps exactly half a turn pulls it both ways at once and it stays put. Under 5 percent of the rated current the field holds nothing and the shaft stays wherever it was left, which is what disabling the driver is for.

Lost steps. The rotor turns at most max_steps full steps a second. A field that runs ahead faster than that leaves it behind, and once it is more than half a turn of the field behind, the short way is backwards: it slips four whole steps and ends up somewhere the sketch does not think it is. That is what a printer that moves too fast without acceleration does to its layers.

What it does not model

Inductance and back EMF, which together are what really make a stepper's torque fall off with speed: here the ceiling is flat and does not depend on the supply. Torque and load: nothing is hung on the shaft, so a motor at 10 percent of its current holds as well as one at 100. Resonance, and the small error a real rotor has between full steps. The rotor moves at its top rate or not at all, with no acceleration of its own. The 1000 steps a second is a typical unloaded start-stop rate on a 12 V driver, not a datasheet figure, because every datasheet draws that curve for a different supply.

Common mistakes

Wiring one wire from each coil to the same bridge, so each "coil" is half of two. Find the pairs with a meter: a coil reads about 1.5 ohms and two wires from different coils read open. Stepping at full speed from standstill. Running the motor off a driver whose current limit has not been set.

See it in action

Steppers on A4988 and DRV8825 turns two of these. Open it at /templates.