A4988 pinout: every pin, the microstep table and the current limit
Or see every lesson.
- 455parts on the bench
- 43boards running now
- 1.00xreal time, on every board
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.
| Pin | Row | What it does | Left unconnected |
|---|---|---|---|
| EN | Logic | Enable, active low. HIGH lets the outputs go; the step count carries on. | Pulled low by 100 k: outputs on |
| MS1 | Logic | Microstep select | Pulled low by 100 k |
| MS2 | Logic | Microstep select | Pulled low by 50 k |
| MS3 | Logic | Microstep select | Pulled low by 50 k |
| RST | Logic | Reset, active low. Holds the outputs off and the position at home. | Floats, which is a reset: link it to SLP |
| SLP | Logic | Sleep, active low. STEP is ignored for 1 ms after it goes high. | Pulled up by 10 k: awake |
| STEP | Logic | One step on each rising edge | Floats: drive it |
| DIR | Logic | Which way each step goes | Floats: drive it |
| VMOT | Power | Motor supply, 8 to 35 V | Outputs off |
| GND | Power | Motor ground, one plane with the other GND | Use either GND |
| 2B | Power | Coil 2 | Coil 2 open |
| 2A | Power | Coil 2 | Coil 2 open |
| 1A | Power | Coil 1 | Coil 1 open |
| 1B | Power | Coil 1 | Coil 1 open |
| VDD | Power | Logic supply, 3 to 5.5 V; sets the input thresholds | Chip off |
| GND | Power | Logic ground | Use 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.
| MS1 | MS2 | MS3 | Resolution | Steps a turn |
|---|---|---|---|---|
| LOW | LOW | LOW | Full step | 200 |
| HIGH | LOW | LOW | Half step | 400 |
| LOW | HIGH | LOW | Quarter step | 800 |
| HIGH | HIGH | LOW | Eighth step | 1600 |
| HIGH | HIGH | HIGH | Sixteenth step | 3200 |
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.
| Sense resistor | VREF for a 1 A limit | Limit at VREF 0.8 V |
|---|---|---|
| 0.05 ohm | 0.40 V | 2.00 A |
| 0.068 ohm | 0.54 V | 1.47 A |
| 0.1 ohm | 0.80 V | 1.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).
| A4988 pin | To | Why |
|---|---|---|
| STEP | Pin 3 | One step per rising edge |
| DIR | Pin 4 | Which way |
| RST | SLP, on the board | Or the driver never wakes |
| MS1, MS2, MS3 | 5 V, GND or nothing | The resolution, from the table |
| VDD | 5 V | Logic supply |
| GND (logic) | GND | Shared with the Uno |
| VMOT | The motor supply’s +, 12 V here | 8 to 35 V |
| GND (motor) | The motor supply’s − | |
| 1A, 1B | One coil | A pair, found with a meter |
| 2A, 2B | The 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.
Keep going
Build this for real
Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.