Learn

Stepper motor vibrating but not turning: find the cause

Start building free

Or see every lesson.

  • 455parts on the bench
  • 43boards running now
  • 1.00xreal time, on every board
Arduino Uno: a 28BYJ-48 that humslive0.000 s 0.00x
Press the button
The stepper turntable with IN2 and IN3 crossed. Press the button: the photos are counted and the shaft stays where it is.

A stepper that buzzes and stays put is being asked for something it cannot do: pull toward two places at once, start faster than it can follow, or turn with no current in its coils. Each of those has a short list of causes, and most of them are wiring.

The circuit above is the stepper turntable with one mistake in it: the wires to IN2 and IN3 on the 28BYJ-48’s board are crossed, IN2 on pin 10 and IN3 on pin 9. Press the button. The serial monitor counts "photo 1", "photo 2" and "photo 3" as if the plate were turning, and the shaft does not leave 0 degrees. Swap the two wires back and the same sketch turns the plate 45 degrees for every stop.

Mokxi shows a motor that cannot turn as a shaft that stands still; it does not make the noise. Everything below was made on Mokxi’s engine, on its 28BYJ-48 and on a NEMA 17 behind an A4988, and the causes Mokxi does not model have their own section at the end, so you know which ones to check with a meter.

First: a 28BYJ-48 or a NEMA 17?

The two fail in different ways. A 28BYJ-48 has five wires, one of them a red common, and a ULN2003 board that only switches its coils on and off, so its faults are the order the coils are switched in and how fast. A NEMA 17 has four wires and needs a driver such as an A4988 that sets the current in each coil, so its faults are mostly the driver’s pins and supplies, and which two wires make a pair.

28BYJ-48: the coil order in the sketch

The motor’s plug fits its board one way, so the motor end is rarely wrong. The four wires from IN1 to IN4 to the Arduino are, and so is the order the sketch names the pins in. With the Arduino Stepper library and the board on pins 8 to 11, Stepper motor(2048, 8, 10, 9, 11) turned 512 steps into 90.1 degrees and printed "done after 1502 ms". Stepper motor(2048, 8, 9, 10, 11), the order most people type, left the shaft at 0.3 degrees: it hummed in place for the same 1502 ms. AccelStepper is the same, and wants IN1, IN3, IN2, IN4 too.

Both libraries number their pins for a motor on two H bridges, one coil on the first two pins and one on the last two, while a ULN2003 numbers its coils in order around the motor. Swapping the middle two pins converts one to the other, and crossing the middle two wires on the breadboard undoes it again, which is the circuit at the top of this page.

The Stepper library on a 28BYJ-48, in the order that turns
#include <Stepper.h>

// IN1, IN2, IN3, IN4 on pins 8, 9, 10, 11, given as IN1, IN3, IN2, IN4.
Stepper motor(2048, 8, 10, 9, 11);

void setup() {
  Serial.begin(115200);
  motor.setSpeed(10);   // rpm
  motor.step(512);      // a quarter turn
  Serial.print("done after ");
  Serial.print(millis());
  Serial.println(" ms");
}

void loop() {}

28BYJ-48: too fast to start

The Stepper library’s setSpeed() is in rpm, and a 28BYJ-48 will not start much faster than 17 of them. With setSpeed(17) the quarter turn above took 883 ms and arrived at 90.1 degrees. With setSpeed(20) it took 751 ms and the shaft moved 0.3 degrees. At 2048 steps a turn, 20 rpm is 683 steps a second, over the 600 a second the datasheet gives for starting from rest, and Mokxi’s model misses every step after the first, as a real one does. AccelStepper gets further because it ramps up; the AccelStepper guide shows this motor at 900 full steps a second with an acceleration, and losing nearly every step without one.

NEMA 17: the coil pairs

A NEMA 17 has two coils and four wires, and each coil’s two wires have to go to one of the driver’s output pairs: 1A and 1B for one coil and 2A and 2B for the other on an A4988. We wired one wire from each coil to each pair instead, so each pair drove half of two coils, and 50 steps that should have turned the shaft 90 degrees left it exactly where it powered up. Unplugging one wire of one coil did the same: with only one coil the field flips straight back and forth, and the rotor is pulled both ways at once.

Swapping the two wires of one coil is not a fault. It reverses the motor: the same 50 steps turned it 90 degrees the other way. Find the pairs with a meter, never by the colors alone; the stepper motor wiring guide shows how.

NEMA 17: stepping too fast

Mokxi’s NEMA 17 follows up to 1000 full steps a second. We sent it 200 full steps, one turn, with gaps of 2000, 900, 500 and 300 microseconds after each pulse. With 2000 it turned once and came back to where it started. With 900, a little over 1000 steps a second, it fell behind, slipped, and ended 266.4 degrees from the start. With 500 it ended 72.0 degrees around, and with 300 it never moved at all. A real motor’s limit is lower once it carries a load, so start slowly, or ramp up with AccelStepper.

A4988 and DRV8825: the pins that switch the outputs off

A driver with its outputs off holds nothing and turns nothing. On these boards that is usually one of four pins, and each was tested on an A4988 with the same 50 pulses. RST left unconnected: it floats on the board, and a floating reset is a reset, so the board showed "off" and the shaft did not move. Link RST to SLP. EN high: the outputs let go and the shaft is free, though the driver keeps counting pulses. Leave EN unconnected, where it is pulled low, or drive it LOW.

VMOT too low. The A4988 runs its motor from 8 to 35 V: on 7.9 V it stayed off and on 8 V it turned. The Arduino’s 5 V pin is never enough. And no ground on the driver at all: with neither of its GND pins wired it stayed off.

Then the logic level. With VDD on 5 V an A4988 reads a high only from 3.5 V, so an ESP32’s 3.3 V STEP pulses never registered and the shaft never moved. Powering VDD from the board’s 3.3 V pin fixed it, and a DRV8825, which has no VDD pin, took the same pulses. STEP and DIR swapped is the quietest version: the sketch toggles DIR, which does nothing without an edge on STEP, and the shaft sat still.

The current limit, Vref

The trimmer on the driver sets the coil current. Turned nearly all the way down there is not enough current to hold the rotor, and Mokxi’s NEMA 17 needs at least 5 percent of its 1.7 A rating. With VREF at 0.05 V, a limit of 0.0625 A on a 0.1 ohm board, the shaft did not follow the steps; at 0.1 V it followed every one.

That second result is where Mokxi is kinder than a bench. It does not model torque or a load on the shaft, so any current above that floor turns it. A real motor with its current set too low turns unloaded and stalls, buzzing, as soon as it has to move something, so set VREF from the motor’s rated current; the A4988 pinout page has the formula.

What Mokxi does not model: check these on the bench

A missing common ground between the Arduino and the driver. With the driver on a battery or a bench supply of its own whose minus never meets the Uno’s GND, the motor stayed still in Mokxi, as on a desk, where the STEP pulses have nothing to be measured against, and the Circuit Doctor says the two grounds are apart. Mokxi’s ground symbols are all one ground with the board’s, though: with the Uno’s ground wire to the driver taken off and the driver grounded on a ground symbol of its own, the motor still turned. Run a wire from the Arduino’s GND to the driver’s GND whatever the simulator says.

The supply. Mokxi’s supplies are ideal, so a 9 V battery or an adapter that sags when the coils draw current, and a USB port feeding a 28BYJ-48’s 320 mA, work here and may not on a desk.

Torque and load: a belt too tight, a lead screw that binds, a gearbox that has jammed. Resonance at one speed, which makes a real stepper shudder and lose steps in a narrow band. Loose breadboard contacts and a wire broken inside its insulation, which a meter finds. Heat: an A4988 without a heat sink gives about 1 A a coil before it shuts itself down and starts again, which sounds like a stutter, and Mokxi does not model the driver’s temperature.

Questions

Why does my stepper motor vibrate but not turn?

On a 28BYJ-48, the pins are usually named in the wrong order (use IN1, IN3, IN2, IN4) or the speed is too high. On a NEMA 17, the coil pairs are mixed up, a coil wire is loose, the steps are too fast to start, or the current limit is too low for the load.

Why is my 28BYJ-48 not turning at all?

Check the pin order first, then the speed: in Mokxi 17 rpm starts with the Stepper library and 20 does not. Then check the board has 5 V and ground; with no ground on the board the shaft does not move in Mokxi either.

Why does my stepper only vibrate at high speed?

It cannot start at that speed. Start slower and speed up with an acceleration ramp, which is what AccelStepper’s setAcceleration() is for.

Does Mokxi make the buzzing sound?

No. A motor that cannot turn shows as a shaft that stays still, and the serial monitor and the step count carry on as if it were moving, which is the same thing a real sketch sees.

Build this for real

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