Stepper Motors and Motion Control: the short answer
A stepper motor moves in fixed steps. 8° each).
- Level
- Advanced
- Time
- About 6 min
- Topic
- Sensors and actuators
Set a stepper driver's current limit, choose microstepping and move smoothly with acceleration.
Before this: Motor Power and Drivers, Actuators, Motor Drivers & Protection
A stepper motor moves in fixed steps. The common NEMA 17 has 200 full steps per revolution (1.8° each). A driver such as the A4988, DRV8825 or TMC2209 takes STEP and DIR signals from the microcontroller: each pulse on STEP moves one step (or one microstep) in the direction set by DIR. Microstepping divides each step, for example 16 microsteps, for smoother, quieter motion; it improves smoothness more than real accuracy.
The driver controls the motor's current, not its voltage, so you can use a supply well above the motor's rated voltage (12 to 24 V is typical) for better speed. You must set the current limit with the driver's small potentiometer, by measuring the reference voltage Vref. For an A4988 the limit is I = Vref ÷ (8 × Rs), where Rs is the sense resistor on your board (often 0.1 Ω on clone boards, 0.068 Ω on some others; read it). For a DRV8825 with 0.1 Ω sense resistors it is I = 2 × Vref. Start at about 70 % of the motor's rated current.
Steppers lose steps if asked to start, stop or change speed instantly, so accelerate and decelerate with a ramp; the AccelStepper library does this for you. Put a 100 µF capacitor across the driver's motor supply pins, never connect or disconnect the motor while the driver is powered (the voltage spike can destroy it), and add a heatsink to the driver chip. For silent printers and robots, the TMC2209 adds very quiet modes and can be configured over UART.
Steps, microsteps and speed
A common stepper has 200 full steps per turn, which is 1.8 degrees each. A driver can divide each into microsteps, such as 16, for smoother and quieter movement, though the extra positions are not all exact, and torque per microstep is lower. Speed is set by how fast you send step pulses.
Torque falls as speed rises. A motor that runs at a low speed can stall if you try to start it at the high speed at once, so accelerate gradually with a ramp, and ramp down before stopping.
Current, voltage and heat
Set the driver's current limit to the motor's rated current, using the reference voltage on the driver module, and check the motor temperature. A higher supply voltage, within the driver's limit, lets the current rise quickly and gives more speed. Use a bulk capacitor on the supply, and never disconnect a motor while the driver is powered, since it can damage the driver.
Many drivers can reduce the current when the motor is idle, which cuts heat.
Losing steps
An open-loop stepper has no feedback, so if it stalls, the program does not know. Add limit switches and a homing routine at start-up, and size the motor with margin for the load. For an application where lost steps are a problem, use an encoder or a closed-loop driver.
- Starting a motor at high speed with no acceleration ramp.
- Setting the driver current above the motor's rating.
- Assuming the position is correct without homing or feedback.
Practise this lesson with Pro
The explanation above is free for everyone. The practice for Advanced lessons in every domain are part of the Pro plan at ₹999 a month.
With Pro you also get: a worked example, a hands-on task, a 3-question check.
