Sub topic 3
Why torque drops with speed and steps get missed
This chapter assumes you can write basic Arduino code with setup, loop, and digitalWrite, you understand Ohm's law, and you power the motor from a separate supply.
Why torque drops with speed
A stepper motor's coils need time to build and collapse their magnetic fields. At low speed, the rotor has time to follow each pulse. As speed rises, the coil current cannot change direction fast enough, so the available torque falls.
| Speed range | Torque behavior |
|---|---|
| Low | Close to the rated torque |
| Medium | Torque falls as the coils switch more quickly |
| High | Torque is low, and the rotor may skip steps |
A missed step means the rotor lags behind the pulses and never reaches the commanded position. Your code still counts the steps, so the position drifts.
Acceleration ramps
Starting at full speed can cause a missed step. A ramp raises the speed gradually so the rotor keeps up with each pulse.
Using the Stepper and AccelStepper libraries
The built-in Stepper library is simple, but step() blocks until the move finishes. The AccelStepper library is non-blocking and applies ramps for you. Call run() as often as possible.
#include <AccelStepper.h>
AccelStepper stepper(AccelStepper::DRIVER, 3, 4); // STEP pin 3, DIR pin 4
void setup() {
stepper.setMaxSpeed(1000); // steps per second
stepper.setAcceleration(500); // steps per second per second
stepper.moveTo(800);
}
void loop() {
if (stepper.distanceToGo() == 0) {
stepper.moveTo(-stepper.currentPosition());
}
stepper.run();
}Managing heat and avoiding driver damage
- Set the driver's current limit to the motor's rated current, not higher.
- Keep the driver's heat sink attached and allow airflow.
- Never connect or disconnect the motor while the driver is powered.
- Check that the driver's supply voltage stays within its rated range.
Troubleshooting common faults
| Symptom | Likely cause | Fix |
|---|---|---|
| Motor hums but does not turn | Current too low, or speed too high | Raise current slightly or lower the speed |
| Motor vibrates at some speeds | Resonance | Use microstepping or change speed |
| Driver or motor overheats | Current limit too high | Lower the current limit |
| Position drifts | Missed steps | Add acceleration or reduce speed |
> Note: The Stepper library is not suitable for moves that must run while the program does other work.
Beyond open-loop control
Open-loop control assumes every pulse produces one step. An encoder on the shaft measures the real position, so the controller can detect and correct missed steps. Closed-loop stepper systems use this feedback, but they need extra hardware and more complex code.
Exercise
The AccelStepper is set to a maximum speed of 2000 steps per second with an acceleration of 500 steps per second squared. How many steps does the motor take to reach maximum speed?
Show answer
Use distance = v² / (2a). That is 2000² / (2 × 500) = 4,000,000 / 1000 = 4000 steps.