Learn

A4988 pinout: every pin, the microstep table and the current limit

Start building free

Or see every lesson.

  • 455parts on the bench
  • 43boards running now
  • 1.00xreal time, on every board
Arduino Uno: an A4988 with its mode pins on switcheslive0.000 s 0.00x
Press Run, then click a mode switch to change the step resolution
MS1, MS2 and MS3 are on 5 V, so the A4988 is at 1/16 step and 3200 pulses turn the NEMA 17 once.

The A4988 carrier is a small board with 16 pins in two rows of eight, a chip under a stick-on heat sink and a trimmer for the current. The left row is logic: EN, MS1, MS2, MS3, RST, SLP, STEP and DIR. The right row is power: VMOT, GND, 2B, 2A, 1A, 1B, VDD and GND. That is the order Pololu’s carrier has them in, and the order Mokxi’s part uses.

The circuit above is an Uno sending 3200 pulses to an A4988 and a NEMA 17, then 3200 back. The three switches are MS1, MS2 and MS3, all on 5 V to start, which is 1/16 step: the board shows "1/16" and the shaft turns once each way. Click a switch while it runs and the board shows the new resolution.

The 16 pins

The two GND pins are one ground plane on the board, so either will do, and Mokxi treats them the same way. Pololu asks for an electrolytic capacitor of at least 47 µF across VMOT and GND close to the board, because the motor’s wiring throws voltage spikes the chip is not rated for; Mokxi does not model those spikes, so the circuit runs without one, and a bench board should not. Pololu also warns that plugging or unplugging the motor while the driver is powered can destroy it.

A4988 carrier pins, top to bottom, and what each does when nothing is wired to it
PinRowWhat it doesLeft unconnected
ENLogicEnable, active low. HIGH lets the outputs go; the step count carries on.Pulled low by 100 k: outputs on
MS1LogicMicrostep selectPulled low by 100 k
MS2LogicMicrostep selectPulled low by 50 k
MS3LogicMicrostep selectPulled low by 50 k
RSTLogicReset, active low. Holds the outputs off and the position at home.Floats, which is a reset: link it to SLP
SLPLogicSleep, active low. STEP is ignored for 1 ms after it goes high.Pulled up by 10 k: awake
STEPLogicOne step on each rising edgeFloats: drive it
DIRLogicWhich way each step goesFloats: drive it
VMOTPowerMotor supply, 8 to 35 VOutputs off
GNDPowerMotor ground, one plane with the other GNDUse either GND
2BPowerCoil 2Coil 2 open
2APowerCoil 2Coil 2 open
1APowerCoil 1Coil 1 open
1BPowerCoil 1Coil 1 open
VDDPowerLogic supply, 3 to 5.5 V; sets the input thresholdsChip off
GNDPowerLogic groundUse either GND

MS1, MS2 and MS3: the microstep table

Each mode pin is pulled low inside the chip, so a board with nothing on them runs in full step. Every row of the table below was set on Mokxi’s A4988 and read back off the board. The combinations the datasheet leaves out (MS3 high without both of the others) are read as full step: in the circuit above, MS1 switched to ground with the other two still high shows "full".

In full step the chip holds each coil at 70.7 percent of the limit, the four points where both coils carry the same current, and a driver switched into full step from a microstep goes to the nearest of them.

A4988 step resolution, and pulses for one turn of a 200-step motor
MS1MS2MS3ResolutionSteps a turn
LOWLOWLOWFull step200
HIGHLOWLOWHalf step400
LOWHIGHLOWQuarter step800
HIGHHIGHLOWEighth step1600
HIGHHIGHHIGHSixteenth step3200

Vref and the current limit formula

The current limit is I = VREF / (8 × RS), where RS is the current sense resistor beside the chip and VREF is the voltage on the trimmer, measured to GND. Pololu’s carriers made since 2017 use 0.068 ohm resistors and earlier ones 0.05 ohm; Mokxi’s default is 0.1 ohm, which many clones use. Read the code on yours: R100 is 0.1 ohm, R068 is 0.068 and R050 is 0.05.

To set a limit, work backward: VREF = 8 × RS × I. For the 1.7 A rating of Mokxi’s NEMA 17 on a 0.1 ohm board that is 1.36 V, and most people set a little under the rating. Mokxi gives the coils the currents the formula says: with VREF at 0.8 V on a 0.1 ohm board each coil carried 0.707 A at rest, one half-step put the whole 1.000 A in one coil and none in the other, and at 0.4 V each coil carried 0.354 A. Click the A4988 in the circuit and change vref and rsense: the board prints the limit it works out.

The A4988 current limit for each common sense resistor
Sense resistorVREF for a 1 A limitLimit at VREF 0.8 V
0.05 ohm0.40 V2.00 A
0.068 ohm0.54 V1.47 A
0.1 ohm0.80 V1.00 A

Wiring an A4988 to an Arduino

Pins 3 and 4 are the ones the circuit above uses; any two digital pins do. The sketch for this wiring is on the A4988 and NEMA 17 tutorial, and AccelStepper takes the same pins as AccelStepper stepper(AccelStepper::DRIVER, 3, 4).

An A4988 on an Arduino Uno
A4988 pinToWhy
STEPPin 3One step per rising edge
DIRPin 4Which way
RSTSLP, on the boardOr the driver never wakes
MS1, MS2, MS35 V, GND or nothingThe resolution, from the table
VDD5 VLogic supply
GND (logic)GNDShared with the Uno
VMOTThe motor supply’s +, 12 V here8 to 35 V
GND (motor)The motor supply’s −
1A, 1BOne coilA pair, found with a meter
2A, 2BThe other coil

Logic levels, and wiring it to an ESP32

VDD is the logic supply, 3 to 5.5 V, and it also sets what counts as high: the inputs switch at 0.3 and 0.7 of VDD. That matters on a 3.3 V board. With VDD on 5 V a high has to reach 3.5 V, which an ESP32’s pins never do, and on an ESP32-C3 the shaft did not move. With VDD on the ESP32’s own 3.3 V pin it turned. In Mokxi a VDD of 2.9 V left the chip off and 3.0 V ran it.

The DRV8825 has the same footprint with no VDD pin, and reads 2.2 V as high whatever its supply, so it needs no change for a 3.3 V board; the DRV8825 guide has its own table and formula.

What Mokxi’s A4988 leaves out

The chopper as a circuit, with its decay modes and its whine at low speed; coil inductance; the 2 A rating, heat and thermal shutdown; and the 1 microsecond minimum STEP pulse, which no Arduino sketch gets near. The pull resistors are Pololu’s layout, and clones vary.

Questions

What do MS1, MS2 and MS3 do on an A4988?

They set the step resolution: all low is full step, MS1 alone is half, MS2 alone a quarter, MS1 and MS2 an eighth, and all three high a sixteenth. They are pulled low, so unconnected pins mean full step.

What is the A4988 Vref formula?

I = VREF / (8 × RS). On a 0.1 ohm board that is 1.25 A for every volt of VREF, so 0.8 V is a 1 A limit; on Pololu’s 0.068 ohm boards it is 1.47 A at 0.8 V.

Why does the A4988 need RST connected to SLP?

RST floats on the carrier and a floating reset holds the driver off. SLP is pulled up on the board, so linking the two keeps RST high and the driver running.

Can an A4988 run from 3.3 V logic?

Yes, if VDD is on 3.3 V too. The inputs switch at 0.7 of VDD, so with VDD on 5 V a 3.3 V pin never reads as high.

What voltage does the A4988’s VMOT need?

From 8 to 35 V. In Mokxi the outputs stay off at 7.9 V and come on at 8 V.

Build this for real

Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.