Sub topic 6
Choosing a stepper driver
This chapter assumes you know how a stepper motor steps through its coils, can read the motor ratings (rated current, coil resistance, holding torque), and know the difference between full-step and microstepping. Here you will learn how to pick the driver that sits between the Arduino and the motor.
Why the Arduino cannot drive the motor directly
An Arduino pin supplies about 20 mA. A small stepper coil needs hundreds of milliamps to a few amps, often at a higher voltage than the board runs on. The motor coils are also inductors, so switching them off produces voltage spikes that damage unprotected electronics. A driver handles all of this. It switches the coil current in both directions and limits the current. It also absorbs the spikes and turns simple logic signals into the coil sequence.
Two families of driver
Drivers fall into two families, and the difference decides most purchases.
Plain H-bridge boards
Boards built on the L298N or L293D contain H-bridges. These are switches that let current flow through a coil in either direction. You supply the four coil-control signals yourself, and the Arduino generates the full-step or half-step sequence. The Stepper library works with these boards.
Their limits:
- They do not regulate current. Current is set by the supply voltage divided by the coil resistance, so the supply must be close to the motor's rated voltage. This usually limits you to low-voltage, high-resistance motors.
- Bipolar transistor outputs drop around 2 V or more, which wastes power as heat.
- They cannot microstep without extra work from the Arduino.
- They offer little protection against overcurrent or overheating.
Chopper drivers with STEP/DIR
Modules such as the A4988, DRV8825, TMC2209 and TB6600 take two logic signals. A pulse on STEP moves the motor one step (or one microstep), and the level on DIR selects the direction. The driver generates the coil sequence internally.
These drivers are called chopper drivers because they regulate current. A sense resistor measures coil current, and the driver switches the supply on and off rapidly to hold the current at a set limit. This has three consequences:
- You can supply a voltage far above the motor's rated voltage. The extra voltage lets current rise quickly against the coil's inductance, which gives better torque at speed.
- The current limit is a setting, not a side effect of the supply voltage. The next chapters cover wiring and setting it.
- Microstepping is built in, selected with pins or configuration registers.
For nearly every new project, choose a STEP/DIR chopper driver. The rest of this tutorial assumes one.
Comparing common modules
The figures below are typical values for popular breakout boards. Always confirm them against the datasheet for the exact board you buy, because manufacturers differ and cooling changes what is safe.
| Driver | Supply range | Practical current per coil | Finest microstep | Notes |
|---|---|---|---|---|
| A4988 | 8 to 35 V | About 1 A without a heatsink, up to 2 A with cooling | 1/16 | Cheap and widely documented |
| DRV8825 | 8.2 to 45 V | About 1.5 A without cooling, up to 2.5 A with cooling | 1/32 | Wider voltage range, fault output pin |
| TMC2209 | 4.75 to 29 V | About 1.4 A RMS typical on modules | 1/256 interpolated | Very quiet, optional UART configuration |
| TB6600 | 9 to 42 V | Up to about 4 A | 1/32 | Larger board, opto-isolated inputs, DIP switches |
Selection criteria
Work through these criteria in order.
- Current. Read the motor's rated current per phase. The driver must supply at least that much continuously, and the figure must be achievable with the cooling you plan to use. Do not rely on a driver's peak current rating. A driver marketed as "2 A" often overheats at 2 A without a heatsink and a fan.
- Supply voltage. The supply must fall inside the driver's range with headroom. Inductive spikes and a supply that rises when the motor decelerates can push the voltage above its nominal value. Running an A4988 from a 35 V supply is asking for a dead driver.
- Resolution. More microstepping gives smoother motion, but the Arduino must generate pulses faster. At 1/32 steps, a 200-step motor needs 6400 pulses per revolution. Chapter "Microstepping" covers the limits. A higher setting does not give proportionally better positioning accuracy.
- Noise. Chopper drivers switch at an audible frequency in many cases, and the motor whines. The TMC2208 and TMC2209 use a quiet mode (StealthChop) that nearly eliminates this. It is worth the extra cost for desk or household projects.
- Protection and diagnostics. Thermal shutdown, overcurrent protection and a fault pin help you survive mistakes. Cheap boards may offer little. The DRV8825 has a fault output, and the TMC2209 can report faults over its UART.
- Interface and logic level. Most modules accept 3.3 V or 5 V logic on
STEPandDIR. Check this if you use a 3.3 V board. Larger external drivers like the TB6600 usually have opto-isolated inputs that need enough drive current, often 5 to 15 mA. Check the manual because an Arduino pin may need a series resistor value chosen for it.
What the pins look like in code
A typical breakout has STEP, DIR, ENABLE (active low, so LOW turns the outputs on), and microstep select pins MS1 to MS3. This sketch for an A4988 selects 1/16 microstepping and turns the motor one revolution. At 1/16 a 200-step motor needs 3200 pulses per revolution.
const int STEP_PIN = 3;
const int DIR_PIN = 4;
const int ENABLE_PIN = 5;
const int MS1_PIN = 6;
const int MS2_PIN = 7;
const int MS3_PIN = 8;
const int STEPS_PER_REV = 200 * 16; // 200-step motor at 1/16 microstepping
void setup() {
pinMode(STEP_PIN, OUTPUT);
pinMode(DIR_PIN, OUTPUT);
pinMode(ENABLE_PIN, OUTPUT);
pinMode(MS1_PIN, OUTPUT);
pinMode(MS2_PIN, OUTPUT);
pinMode(MS3_PIN, OUTPUT);
// A4988: MS1, MS2 and MS3 all HIGH selects 1/16 step.
digitalWrite(MS1_PIN, HIGH);
digitalWrite(MS2_PIN, HIGH);
digitalWrite(MS3_PIN, HIGH);
digitalWrite(DIR_PIN, HIGH);
digitalWrite(ENABLE_PIN, LOW); // active low: outputs on
}
void loop() {
for (int i = 0; i < STEPS_PER_REV; i++) {
digitalWrite(STEP_PIN, HIGH);
delayMicroseconds(150);
digitalWrite(STEP_PIN, LOW);
delayMicroseconds(150); // 300 us period, about 62 RPM
}
delay(1000);
}Other drivers use different microstep tables. On a DRV8825, for example, 1/16 needs MS1 low, MS2 low and MS3 high... the pattern differs from the A4988, so check the table for your board before you copy pin states.
Common mistakes when choosing
- Buying on the current headline. A 2 A rating is a ceiling that needs cooling. If the motor is rated 1.8 A, use a driver rated for 2 A or more, and plan to set the current limit lower than the maximum.
- Using the motor's rated voltage as the supply. With a chopper driver, a rated 3 V motor is normally run from 12 to 24 V. The driver limits the current, so the higher voltage does not overdrive the motor.
- Choosing too fine a microstep for the controller. An 8-bit Arduino toggling pins with
digitalWritetops out at a few tens of thousands of pulses per second. A fast motor at 1/32 may ask for more than that. - Forgetting the enable pin. If the motor holds torque but never moves, or the driver gets hot while idle, check how
ENABLEis wired. Holding current produces heat even when nothing moves.
Exercise
Your motor is rated 1.5 A per phase and 2.8 V. You have a 24 V supply. The candidates are an L298N board, an A4988 module, and a DRV8825 module. Which can you use and why? What would you check about the supply?
Show answer
The L298N is a poor choice. It does not regulate current, so 24 V across a coil of about 1.9 ohms would push far more than 1.5 A and burn the motor. The A4988 and DRV8825 both regulate current with a chopper, so you can run the motor from 24 V by setting the current limit to the motor's rating. The A4988 supply range ends at 35 V and the DRV8825 at 45 V, so 24 V fits both with headroom. At 1.5 A both need a heatsink and airflow. The DRV8825 has the wider voltage margin and finer microstepping, so it is a reasonable first pick. Check that the supply can deliver the needed current and that voltage spikes will not exceed the driver's maximum.
Exercise
A project uses a 200-step motor at 1/32 microstepping, and you want 120 RPM. How many step pulses per second must the Arduino produce? Is this a concern for a loop that uses digitalWrite and delayMicroseconds?
Show answer
Steps per revolution is 200 × 32 = 6400. At 120 RPM that is 2 revolutions per second, so 12,800 pulses per second, which is a period of about 78 microseconds. A digitalWrite call takes several microseconds on an 8-bit AVR board, so the loop is close to its limit, and any other work in the loop will slow the pulses. Use a lower microstep setting, a faster board, or a library that generates pulses efficiently.