Overview & Types
Stepper motors are brushless DC motors that divide a full rotation into a large number of discrete steps. Unlike conventional DC motors that spin freely, steppers move in precise angular increments – typically 1.8° (200 steps/revolution) – making them ideal for open-loop position control.
Main Types
- Bipolar Stepper: 4 wires, 2 coils. Current flows in both directions through each coil. Higher torque per size but requires an H-bridge driver. Most common type (NEMA 17, NEMA 23).
- Unipolar Stepper: 5 or 6 wires, center-tapped coils. Simpler driving (only needs switching transistors) but lower torque since only half the coil is energized at a time.
- Hybrid Stepper: Combines permanent magnet and variable reluctance designs. The most common type in practice; NEMA 17 and NEMA 23 are hybrid designs.
NEMA Standards
NEMA numbers refer to the faceplate size, not performance:
- NEMA 14: 35 mm faceplate. Small, light-duty applications.
- NEMA 17: 42 mm faceplate. The “standard” for 3D printers, CNC routers, and robotics.
- NEMA 23: 57 mm faceplate. Higher torque for CNC mills, laser cutters, and industrial automation.
- NEMA 34: 86 mm faceplate. Heavy-duty industrial applications.
Working Principle
A stepper motor works by sequentially energizing coils to create rotating magnetic fields that pull the rotor into alignment:
- Electromagnetic Alignment: When a coil is energized, the rotor teeth align with the stator teeth for that coil (minimum reluctance position).
- Sequential Switching: Energizing coils in sequence causes the rotor to “step” from one alignment position to the next.
- Step Angle: Determined by the number of rotor and stator teeth. For a 200-step motor: 360° / 200 = 1.8° per step.
Stepping Modes
| Mode | Steps/Rev | Torque | Smoothness | How It Works |
|---|---|---|---|---|
| Full Step | 200 | 100% | Roughest | One coil energized at a time |
| Half Step | 400 | ~70% | Better | Alternates between 1 and 2 coils |
| 1/4 Microstep | 800 | ~70% | Good | Current proportioned between coils |
| 1/8 Microstep | 1,600 | ~50% | Very Good | Finer current proportion |
| 1/16 Microstep | 3,200 | ~30% | Excellent | Near-sinusoidal current waveform |
| 1/32 Microstep | 6,400 | ~20% | Smoothest | Practical limit for most drivers |
Torque-Speed Relationship
Stepper motor torque decreases with speed due to inductance limiting current rise time. The pull-out torque curve shows maximum torque at each speed. Exceeding this causes missed steps.
Key formula: Linear speed = (Steps per second × Lead) / Steps per revolution
Example: 1000 steps/s × 8 mm lead / 200 steps/rev = 40 mm/s linear motion.
Electrical & Mechanical Specifications
| Parameter | NEMA 17 (typical) | NEMA 23 (typical) |
|---|---|---|
| Step Angle | 1.8° (200 steps/rev) | 1.8° (200 steps/rev) |
| Rated Current | 1.0–2.0 A per phase | 2.0–4.0 A per phase |
| Holding Torque | 0.2–0.6 N·m | 0.9–3.0 N·m |
| Phase Resistance | 1.0–3.0 Ω | 0.5–2.0 Ω |
| Phase Inductance | 2–8 mH | 2–10 mH |
| Rated Voltage | 2.5–4.0 V (driven at 12–24 V) | 2–6 V (driven at 24–48 V) |
| Rotor Inertia | 35–82 g·cm² | 200–500 g·cm² |
| Weight | 200–400 g | 500–1,200 g |
| Shaft Diameter | 5 mm | 6.35 mm (1/4″) |
Driver Circuits
Chopper Drivers (Step/Direction Interface)
Modern stepper drivers use a step/direction interface: one pulse on STEP pin = one motor step; DIR pin sets direction.
- A4988: Up to 2 A, 1/16 microstepping. The “workhorse” of 3D printing. Simple but can be noisy.
- DRV8825: Up to 2.5 A, 1/32 microstepping. Pin-compatible A4988 upgrade with lower minimum step size.
- TMC2209: Up to 2.8 A, 1/256 microstepping, UART configuration. Near-silent operation via StealthChop. The modern gold standard.
- TMC5160: Up to 4.4 A, SPI interface, integrated motion controller. For high-performance applications.
- TB6600: Up to 4 A, external driver box for NEMA 23/34 motors. Common in CNC machines.
Wiring for A4988 / DRV8825
- STEP → Any GPIO (pulse for each step)
- DIR → Any GPIO (HIGH/LOW for direction)
- EN → Any GPIO or tied LOW (enable driver)
- MS1, MS2, MS3 → Microstepping selection (pull HIGH/LOW)
- VMOT → 8–35 V motor supply + 100 μF capacitor
- 1A, 1B, 2A, 2B → Motor coil connections
Control Methods
Open-Loop Position Control
The simplest and most common approach: send a known number of step pulses, and the motor moves by that many steps. No feedback needed as long as the motor doesn’t miss steps.
Acceleration Profiling
Steppers cannot instantly reach high speeds. The rotor has inertia and the coils have inductance. A trapezoidal velocity profile is essential:
- Acceleration phase: Gradually increase step rate from start speed to cruise speed.
- Cruise phase: Constant step rate at desired speed.
- Deceleration phase: Gradually decrease step rate to stop precisely at target position.
Closed-Loop with Encoder
For applications that cannot tolerate missed steps (CNC machining), add a rotary encoder to the motor shaft. The controller detects and corrects step errors in real-time. The TMC2209 supports this via StallGuard sensorless homing.
Code Example — Arduino & ESP32
Arduino + A4988: Basic Stepping
// Stepper motor control with A4988 driver
// Wiring: STEP→D3, DIR→D4, EN→D5, VMOT→12V+100uF cap
const int STEP_PIN = 3;
const int DIR_PIN = 4;
const int EN_PIN = 5;
const int STEPS_PER_REV = 200; // 1.8 degree step angle
void setup() {
pinMode(STEP_PIN, OUTPUT);
pinMode(DIR_PIN, OUTPUT);
pinMode(EN_PIN, OUTPUT);
digitalWrite(EN_PIN, LOW); // Enable driver
Serial.begin(9600);
}
void moveSteps(int steps, bool clockwise, int delayUs) {
digitalWrite(DIR_PIN, clockwise ? HIGH : LOW);
for (int i = 0; i < steps; i++) {
digitalWrite(STEP_PIN, HIGH);
delayMicroseconds(delayUs);
digitalWrite(STEP_PIN, LOW);
delayMicroseconds(delayUs);
}
}
void loop() {
Serial.println("Rotating 1 full revolution CW");
moveSteps(STEPS_PER_REV, true, 1000); // 500 Hz step rate
delay(1000);
Serial.println("Rotating 1 full revolution CCW");
moveSteps(STEPS_PER_REV, false, 1000);
delay(1000);
Serial.println("Half revolution at higher speed");
moveSteps(STEPS_PER_REV / 2, true, 500); // 1000 Hz
delay(2000);
}
ESP32: AccelStepper with Acceleration Profiling
// Stepper motor with acceleration profiling on ESP32
// Requires: AccelStepper library (install via PlatformIO/Arduino IDE)
// Wiring: STEP→GPIO18, DIR→GPIO19, EN→GPIO21
#include <AccelStepper.h>
#define STEP_PIN 18
#define DIR_PIN 19
#define EN_PIN 21
AccelStepper stepper(AccelStepper::DRIVER, STEP_PIN, DIR_PIN);
void setup() {
Serial.begin(115200);
pinMode(EN_PIN, OUTPUT);
digitalWrite(EN_PIN, LOW); // Enable driver
stepper.setMaxSpeed(2000); // steps/second
stepper.setAcceleration(500); // steps/second^2
stepper.setCurrentPosition(0);
Serial.println("Stepper initialized with acceleration profiling");
}
void loop() {
// Move to absolute position (2 full revolutions)
Serial.println("Moving to position 400 (2 revolutions)");
stepper.moveTo(400);
while (stepper.distanceToGo() != 0) {
stepper.run();
}
Serial.printf("At position: %ld\n", stepper.currentPosition());
delay(1000);
// Return to home
Serial.println("Returning to position 0");
stepper.moveTo(0);
while (stepper.distanceToGo() != 0) {
stepper.run();
}
Serial.printf("At position: %ld\n", stepper.currentPosition());
delay(2000);
}
Real-World Applications
CNC & 3D Printing
- 3D printer axes (X, Y, Z) and extruder
- CNC router/mill axis control
- Laser cutter/engraver positioning
- PCB drilling machines
Automation & Instrumentation
- Telescope and satellite tracking mounts
- Camera slider and focus pull
- Laboratory sample positioning
- Textile and packaging machinery
Advantages vs. Alternatives
| vs. Actuator | Stepper Advantage | Stepper Disadvantage |
|---|---|---|
| DC Motor | Precise positioning without encoder, holding torque at standstill | Lower top speed, higher power consumption when idle |
| Servo Motor | Full 360°+ rotation, higher resolution with microstepping | No built-in feedback, can miss steps under overload |
| BLDC Motor | Simpler control (step/dir), inherent position control | Lower efficiency, resonance issues at certain speeds |
| Linear Actuator | Easily converted to linear (with lead screw), fine resolution | Needs mechanical conversion for linear motion (adds complexity) |
Limitations & Considerations
- Missed Steps: If the load exceeds the pull-out torque at the current speed, the motor misses steps with no indication (open-loop). Oversize the motor or add encoder feedback.
- Resonance: Steppers have resonant frequencies (typically 80–150 RPM) where vibration peaks and torque drops. Microstepping and dampers mitigate this.
- Heat Generation: Steppers draw rated current even when stationary to maintain holding torque. Use current reduction features (TMC2209’s CoolStep) or disable when not needed.
- Torque Falls with Speed: Unlike DC motors, stepper torque decreases significantly at higher speeds due to coil inductance limiting current rise time.
- Audible Noise: Full-step and half-step modes create audible whining. TMC2209 with StealthChop mode provides near-silent operation.
- Power Consumption: A NEMA 17 drawing 1.5 A at 12 V consumes 18 W per phase continuously. Two-phase operation doubles this. Heat sinks may be required.