Sub topic 8
Setting the driver's current limit
This chapter assumes you can wire a STEP/DIR driver to a separate motor supply (the previous chapter) and that you know Ohm's law. Here you will learn why the driver needs a current limit, how to calculate the setting, and how to set and check it with a multimeter.
Why the driver needs a limit
A stepper motor's rated voltage is small. A typical NEMA 17 motor rated 1.5 A per phase has a winding resistance of about 2.8 Ω, so its rated voltage is 1.5 A × 2.8 Ω = 4.2 V. You usually power the driver from 12 V to 24 V. Higher voltage helps the current rise quickly against the coil's inductance, which keeps torque up at speed.
If you connected 12 V straight across a 2.8 Ω winding, the current would settle at over 4 A and the motor would overheat. The driver prevents this by chopping. It switches the coil voltage on until the current reaches the limit, switches it off briefly, then switches it on again. The limit is set by a reference voltage, called Vref, which you adjust with a small trimmer potentiometer on the board.
Setting Vref is therefore the step that matches the driver to the motor. Too low and the motor loses torque and skips steps. Too high and the motor and driver overheat.
The relationship between Vref and current
The driver measures coil current as the voltage across a small sense resistor (Rs) in series with the coil. It chops when that voltage reaches a fraction of Vref. The formulas below are for two common Pololu-style boards.
| Driver | Sense resistor | Current limit formula | Simplified |
|---|---|---|---|
| A4988 (Rs = 0.068 Ω) | 0.068 Ω | I = Vref / (8 × Rs) | I ≈ Vref × 1.84 |
| A4988 (Rs = 0.05 Ω, older boards) | 0.05 Ω | I = Vref / (8 × Rs) | I = Vref × 2.5 |
| DRV8825 | 0.1 Ω | I = Vref / (5 × Rs) | I = Vref × 2 |
Boards from different makers use different sense resistors, even with the same chip. Clone boards often have 0.1 Ω or 0.2 Ω resistors. Read the markings on the resistors (for example R100 means 0.1 Ω, R050 means 0.05 Ω) or the seller's documentation before you apply a formula.
Drivers such as the TMC2209 set the current in a different way, often through a Vref with its own formula or through a serial interface. Check the datasheet for your chip.
Rearranged to give the voltage you need:
- A4988: Vref = I × 8 × Rs
- DRV8825: Vref = I × 5 × Rs
Choosing a target current
The motor's rated current is the maximum continuous current per phase at which it stays within its temperature rating. Use it as a ceiling, not a goal.
- Start at about 70% to 80% of the rated current. This usually gives enough torque, and the motor and driver run cooler.
- Raise the setting only if the motor skips steps under load. Increase in small steps and check temperature after each change.
- Reach 100% only with a heat sink and airflow on the driver and a motor that you have confirmed stays at a safe temperature.
- Never set the limit above what the driver can deliver. The A4988 manages about 1 A per coil without a heat sink and about 2 A with good cooling. The DRV8825 manages about 1.5 A without a heat sink and about 2.2 A with cooling.
Full-step mode has a catch. In full-step operation both coils are energised at once, so the Pololu A4988 and DRV8825 documentation says each coil carries only about 70% of the set limit. In microstepping modes, the limit applies to the peak current in a coil at the top of its sine wave. If you tune the current in full-step mode and then switch to 1/16 microstepping, torque at the same limit will appear different. Tune in the mode you will actually use.
Worked example
You have a motor rated 1.5 A per phase and an A4988 board with 0.068 Ω sense resistors.
- Target current: 80% of 1.5 A = 1.2 A.
- Vref = 1.2 A × 8 × 0.068 Ω = 0.653 V.
With a DRV8825 board and the same motor:
- Target current: 1.2 A.
- Vref = 1.2 A × 5 × 0.1 Ω = 0.6 V.
The helper below does this arithmetic. It also shows the check you should make: the result must stay below what the driver can supply.
// Computes the Vref needed for a target coil current.
// senseOhms is the sense resistor value on your board.
// gain is 8 for A4988 and 5 for DRV8825.
float vrefForCurrent(float amps, float senseOhms, float gain) {
return amps * gain * senseOhms;
}
void setup() {
Serial.begin(115200);
float ratedAmps = 1.5f;
float targetAmps = ratedAmps * 0.8f; // 80% of rating
float a4988 = vrefForCurrent(targetAmps, 0.068f, 8.0f);
float drv8825 = vrefForCurrent(targetAmps, 0.1f, 5.0f);
Serial.print("Target current (A): ");
Serial.println(targetAmps, 2);
Serial.print("A4988 Vref (V): ");
Serial.println(a4988, 3);
Serial.print("DRV8825 Vref (V): ");
Serial.println(drv8825, 3);
}
void loop() {
}The sketch needs no driver wiring. It only prints numbers to the Serial Monitor.
Setting Vref on the board
Follow these steps:
- Wire the motor and both supplies as in the previous chapter. Do not run STEP pulses yet.
- Set the multimeter to DC volts in the 2 V range. Connect the black probe to the driver's GND pin or to the ground of the motor supply.
- Touch the red probe to the metal body of the trimmer potentiometer, or to the Vref test pad if the board has one.
- Turn the trimmer with a small plastic or ceramic screwdriver. A metal screwdriver can short against nearby parts and shift the reading when it touches the trimmer. Turn in small steps and wait for the reading to settle.
- Stop when the reading matches your calculated Vref.
Some people measure with the motor disconnected. This works for Vref, which does not depend on the load, but you must not connect or disconnect the motor while the driver is powered.
Verifying the setting
A correct Vref does not guarantee a correct current, because the sense resistor value or chip variant may differ from your assumption. Check these points:
- Run the motor at a modest speed for 5 to 10 minutes. The motor case may reach 50 °C to 70 °C and still be fine. If you cannot hold a finger on it for a few seconds, reduce the current or add cooling.
- Touch the driver chip's heat sink with care. A driver that is too hot to touch needs more airflow or a lower limit.
- If you have a bench supply with a current display, watch the motor supply current. It will be well below the coil current because the driver converts high voltage and low current into the opposite at the coil. The reading is still useful to spot a large change after you adjust Vref.
- Listen to the motor. A loud, rough sound at low speed can mean the current is too high for the microstepping mode, or too low for the load.
If the driver has a thermal shutdown, it will stop the motor and restart after cooling. Repeated stops while the motor runs mean you should reduce current or improve cooling, not ignore the restarts.
Common mistakes
- Using the wrong formula. The A4988 and DRV8825 formulas differ, and clone boards differ again. Confirm the sense resistor.
- Measuring at the wrong point. Measure Vref against ground, not against the 5 V rail.
- Setting the limit in full-step mode and running 1/16 microstepping. Retune in the mode you use.
- Setting 100% of rated current with no cooling. The motor can overheat even when the driver is fine.
- Adjusting while the motor is running. Stop the pulses first so a slip of the screwdriver does not cause a current surge.
- Changing Vref to fix a stall that is really a speed problem. Above a certain step rate, more current does not restore torque. That is covered in the chapter on torque and missed steps.
Exercise
Your motor is rated 2.0 A per phase. You use a DRV8825 board with 0.1 Ω sense resistors and want a current limit of 75% of the rating. What Vref should you set, and what would the same Vref give on an A4988 board with 0.068 Ω resistors?
Show answer
Target current = 0.75 × 2.0 A = 1.5 A. For the DRV8825, Vref = I × 5 × Rs = 1.5 × 5 × 0.1 = 0.75 V. On the A4988 with Rs = 0.068 Ω, the same 0.75 V gives I = Vref / (8 × 0.068) = 0.75 / 0.544 ≈ 1.38 A, which is about 92% of the rating and 8% below the 1.5 A you wanted to avoid exceeding by mistake. This shows why you must recalculate when you change driver boards.
Exercise
You set Vref for 1.2 A in full-step mode, and the motor runs well. You then switch the driver to 1/16 microstepping and the motor feels weaker at the same speed. Give one likely reason and one fix.
Show answer
In full-step mode both coils are on at once, and the effective per-coil current is about 70% of the limit, so the setting that worked is not the same as the peak current in a microstepping mode. In microstepping, the average torque is lower because the current in each coil follows a sine wave. The fix is to retune Vref for the new mode, in small steps, while checking temperature, and to lower speed or add acceleration if the motor still skips steps.