Back to Sensors & Actuators Series

Stepper Motors: Bipolar & Unipolar

April 10, 2026 Wasil Zafar 20 min read

The precision positioning motor behind every 3D printer and CNC machine. Master stepper motor types, driver ICs, microstepping modes, acceleration profiling, and embedded control code.

Contents

  1. Overview & Types
  2. Working Principle
  3. Electrical & Mechanical Specs
  4. Driver Circuits
  5. Control Methods
  6. Code Example — Arduino & ESP32
  7. Real-World Applications
  8. Advantages vs. Alternatives
  9. Limitations & Considerations

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.

Key Insight: Stepper motors provide precise positioning without feedback sensors. Each electrical pulse moves the shaft exactly one step, making them the backbone of CNC machines, 3D printers, and precision positioning systems.

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:

  1. Electromagnetic Alignment: When a coil is energized, the rotor teeth align with the stator teeth for that coil (minimum reluctance position).
  2. Sequential Switching: Energizing coils in sequence causes the rotor to “step” from one alignment position to the next.
  3. Step Angle: Determined by the number of rotor and stator teeth. For a 200-step motor: 360° / 200 = 1.8° per step.

Stepping Modes

ModeSteps/RevTorqueSmoothnessHow It Works
Full Step200100%RoughestOne coil energized at a time
Half Step400~70%BetterAlternates between 1 and 2 coils
1/4 Microstep800~70%GoodCurrent proportioned between coils
1/8 Microstep1,600~50%Very GoodFiner current proportion
1/16 Microstep3,200~30%ExcellentNear-sinusoidal current waveform
1/32 Microstep6,400~20%SmoothestPractical 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

ParameterNEMA 17 (typical)NEMA 23 (typical)
Step Angle1.8° (200 steps/rev)1.8° (200 steps/rev)
Rated Current1.0–2.0 A per phase2.0–4.0 A per phase
Holding Torque0.2–0.6 N·m0.9–3.0 N·m
Phase Resistance1.0–3.0 Ω0.5–2.0 Ω
Phase Inductance2–8 mH2–10 mH
Rated Voltage2.5–4.0 V (driven at 12–24 V)2–6 V (driven at 24–48 V)
Rotor Inertia35–82 g·cm²200–500 g·cm²
Weight200–400 g500–1,200 g
Shaft Diameter5 mm6.35 mm (1/4″)
Voltage Misconception: Stepper motors are rated at low voltages (e.g., 3.2 V) but should be driven at much higher voltages (12–48 V). Modern chopper drivers (A4988, TMC2209) regulate current, not voltage. Higher voltage means faster current rise time, which means higher torque at higher speeds.

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
Critical: Never disconnect stepper motor wires while the driver is powered! The back-EMF from the motor’s inductance can destroy the driver chip instantly. Always power off before connecting/disconnecting motors.

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:

  1. Acceleration phase: Gradually increase step rate from start speed to cruise speed.
  2. Cruise phase: Constant step rate at desired speed.
  3. 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. ActuatorStepper AdvantageStepper Disadvantage
DC MotorPrecise positioning without encoder, holding torque at standstillLower top speed, higher power consumption when idle
Servo MotorFull 360°+ rotation, higher resolution with microsteppingNo built-in feedback, can miss steps under overload
BLDC MotorSimpler control (step/dir), inherent position controlLower efficiency, resonance issues at certain speeds
Linear ActuatorEasily converted to linear (with lead screw), fine resolutionNeeds 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.
Current Setting: A4988/DRV8825 drivers have a VREF potentiometer to set maximum current. Formula: Imax = VREF / (8 × Rsense). For A4988 with 0.1Ω sense resistors: Imax = VREF × 1.25. Measure VREF with a multimeter and adjust with a small screwdriver.