Stepper driver, A4988
STEP and DIR in, two coil currents out, and it does nothing until RST is tied to SLP.
- 16 pins
- 2 settings
- In 8 projects
- In 3 lessons
The Stepper driver, A4988 in brief
What it is, and every setting the properties panel gives it.
The A4988 is the 16-pin StepStick carrier for a bipolar stepper such as a NEMA 17: two H bridges, a current chopper and a translator, so a sketch only sets DIR and pulses STEP. VMOT takes 8 to 35 V for the motor, VDD 3 to 5.5 V for the logic, and 1A, 1B, 2A and 2B go to the coils. On an Uno any two digital pins do; on an ESP32 power VDD from 3.3 V, because the inputs switch at 0.7 of VDD and a 3.3 V high never steps a driver whose VDD is on 5 V, which Mokxi reproduces. MS1 to MS3 are pulled low, full step, and select 1/2, 1/4, 1/8 or 1/16; EN is active low and pulled low. The current limit is VREF / (8 x 0.1 ohm), 1 A at the default 0.8 V. Coming out of sleep it ignores STEP for 1 ms. The classic mistake is leaving RST unwired: it floats, a floating reset is a reset, and nothing moves, hence the link from RST to SLP. The chopper’s ripple, inductance, thermal shutdown and the 2 A rating are not modeled.
- Family
- Outputs
- Pins
- 16
- vref
- 0.8
- the voltage on the current-limit trimmer, 0.8 V on the A4988 and 0.5 V on the DRV8825 by default.
- rsense
- 0.1
- the sense resistors, 0.1 ohm. The current limit
is
VREF / (8 x RSENSE)on the A4988 andVREF / (5 x RSENSE)on the DRV8825, which is 1 A for both defaults. The board shows the limit it works out.
16 pins
Named as the editor names them, so a wire lands where you expect it.
How to use the A4988 stepper driver with an Arduino
STEP to pin 3 and DIR to pin 4, VMOT to 12 V, VDD to 5 V, both grounds to the Uno’s GND, and the motor’s coils on 1A and 1B and on 2A and 2B. Then link RST to SLP. RST floats on the carrier and a floating reset holds the driver off, so a board with nothing on RST does nothing at all.
Each rising edge on STEP is one step of the current resolution. In this project MS1, MS2 and MS3 are all on 5 V, which is 1/16 step, so the 3200 pulses the sketch sends turn the top motor once; the DRV8825 below gets the same pulses and, at 1/32 with the same three pins high, turns half as far. The current limit is VREF / (8 x 0.1 ohm): the default 0.8 V is 1 A, and the vref property changes it.
On an ESP32 power VDD from 3.3 V. The inputs switch at 0.7 of VDD, so a 3.3 V pin driving an A4988 whose VDD is on 5 V never steps it.
digitalWrite(DIR_A, HIGH);
for (unsigned int i = 0; i < 3200; i++) {
digitalWrite(STEP_A, HIGH);
delayMicroseconds(4);
digitalWrite(STEP_A, LOW);
delayMicroseconds(396);
}What is true about the Stepper driver, A4988, here
In its help article’s own words: what the simulation gets right, and where it stops.
Modeled
The translator: a position round one electrical cycle, moved one step of the
current resolution by each rising edge on STEP, and two coil currents set to its
cosine and sine times the current limit. At rest it sits at the datasheets' home
position, both coils at 70.7 percent. Full step visits only those 45 degree
points, so switching into full step from a microstep goes to the nearest one.
The current limit, including the case people meet: the chopper cannot push more
than the supply allows, so a winding whose resistance times the limit is more than
VMOT just gets VMOT. That is why these want 12 V or 24 V to run a motor rated
at 3.
The pins nobody wires. RST floats on the carrier and a floating reset is a
reset, so a driver with nothing on RST does nothing at all: every wiring diagram
has a link from RST to SLP for this reason. EN high lets go of the coils
while the translator keeps counting steps, as the datasheets say. Coming out of
sleep, STEP is ignored for 1 ms (1.7 ms on the DRV8825).
Logic levels. The A4988's inputs switch at 0.3 and 0.7 of VDD, so a 3.3 V board
driving an A4988 whose VDD is on 5 V is out of spec: 3.3 V never reaches the
3.5 V a high needs, and here it never steps. Power VDD from 3.3 V and it does.
The DRV8825 switches at fixed 0.7 V and 2.2 V, so any board drives it.
Not modeled
The chopper as a circuit: its off time, its decay modes, the ripple they leave on
the current, and the whine of a slow decay at low speed. The model gives each coil
exactly the table's current, worked out from the winding's resistance as the rest
of the circuit shows it. Coil inductance, so the current never lags. The 2 A and
2.2 A ratings, thermal shutdown and over-current protection, so FLT never pulls
low. The minimum STEP pulse widths (1 and 1.9 microseconds), which no sketch gets
near. The A4988 mode combinations its datasheet does not list are read as full
step. The pull resistors on the carrier are the Pololu layout; clones vary.
From A4988 and DRV8825 stepper drivers, in full.
See the Stepper driver, A4988 in a project
8 built-in projects use it. Each opens in the editor, already wired.
Where it turns up in a lesson
3 lessons place it in their own circuits.
The boards it is shown on
Each of these 2 boards has a built-in project with the Stepper driver, A4988 in it.
Arduino libraries for the Stepper driver, A4988
Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.
The rest of the bench
Every one of these is drawn and simulated the same way.
Wire up the Stepper driver, A4988
Open the editor and push it into the breadboard. It is free, and it runs on your own machine.