Stepper driver Vref calculator
Which Vref to set with the trimmer so the motor stays cool and does not skip steps.
How to set Vref
Vref is the voltage on the driver's trimmer potentiometer, and the chip uses it to limit the winding current. The calculator takes the motor current from its datasheet, multiplies it by a margin (80 % by default) and calculates Vref with the formula from the driver's datasheet. For the A4988, the Allegro datasheet gives Imax = Vref / (8 × Rs). For the DRV8825, the TI datasheet gives Ichop = Vref / (5 × Rsense), and with a 0.1 Ω resistor Vref is half the current.
For the TMC2208 and TMC2209, the Trinamic datasheet gives Irms = 0.325 V / (Rsense + 0.02 Ω) × 1/√2 × Vref / 2.5 V. Here 0.325 V is the voltage across the sense resistor at full current, 0.02 Ω is the resistance inside the chip, and at Vref of 2.5 V the driver gives full current.
Examples
- NEMA 17 17HS4401 (1.7 A per phase) on a DRV8825 with R100: with an 80 % margin the peak current is 1.36 A, Vref = 1.36 × 5 × 0.1 = 0.68 V.
- The same motor on a TMC2209 with R110: 0.325 / (0.11 + 0.02) = 2.5 A, and Vref in volts equals the peak current in amps. For 1.36 A you set Vref to 1.36 V, and the RMS current comes out at 0.96 A.
Common mistakes
- People calculate Vref for a 0.1 Ω resistor without checking the marking on the module: on an A4988 with R050 the current comes out twice the calculated one, and 1.09 V gives 2.7 A.
- People turn the trimmer with a metal screwdriver while powered: it can short adjacent pins and burn out the driver.
FAQ
- What Vref should I set on an A4988 for a NEMA 17 17HS4401?
- The MotionKing datasheet gives the 17HS4401 a current of 1.7 A per phase, and some copies 1.5 A, so check the label. At 1.7 A and an 80 % margin the peak current is 1.36 A: with an R100 resistor Vref is 1.09 V, with R068 0.74 V, with R050 0.54 V.
- Where do I measure Vref and where do the multimeter probes go?
- Set the multimeter to DC voltage, 2 or 20 V range. Put the black probe on the driver's GND and the red one on the trimmer screw. The motor is disconnected while measuring. On a DRV8825 Vref appears when motor power VMOT is applied and RST and SLP are high: in sleep mode the reference voltage is off.
- Which Rsense does my module have: R100, R068, R050 or R110?
- Look at the marking on the small resistors next to the chip. R100 (0.1 Ω) is on cheap A4988 boards and on the DRV8825, R068 on Pololu A4988 since 2017, R050 on the older green Pololu A4988, R110 on TMC2208 and TMC2209 from Watterott, BIGTREETECH and FYSETC.
- Why is the formula different for the TMC2209?
- On the TMC2208 and TMC2209 Vref sets the RMS current, on the A4988 and DRV8825 the peak current. With microstepping the winding current follows a sine, and the peak is √2 times the RMS. If the driver is connected over UART, the current is set in firmware, for example run_current in Klipper. The trimmer then scales that current only if the firmware left the I_scale_analog bit on; Marlin clears it.
- Why does the motor or the driver get hot?
- According to Pololu, an A4988 without a heatsink or airflow holds about 1 A per phase and a DRV8825 about 1.5 A; above that you need a heatsink and a fan. A stepper motor draws current at hold too, when the shaft is standing still. If the motor gets hot, check Rsense and reduce the margin to 70 %.
- How do I set microstepping on an A4988 (MS1, MS2, MS3)?
- According to the datasheet, all three pins low give full step, MS1 high gives 1/2, MS2 high 1/4, MS1 and MS2 high 1/8, all three high 1/16. Inside the chip the MS pins are pulled to ground, so an unconnected pin reads as low.