NEMA 17 stepper motor help
Hello, when I turn the power on for my nema 17 stepper motor with a A4988 driver, it just does like one or 2 big steps, then stops and kind of squeals, getting quieter and quieter. I followed this tutorial so I have the same wiring(except for coils which I did myself so they’re correct) and code as the first example in the video : https://youtu.be/wcLeXXATCR4?si=PTPUoKzs47RR--uc.
here is the code: const int dirPin = 2; // direction pin
const int stepPin = 3; // step pin
void setup() {
pinMode(dirPin, OUTPUT);
pinMode(stepPin, OUTPUT);
// set direction of rotation to clockwise
digitalWrite(dirPin, HIGH);
}
void loop() {
// take one step
digitalWrite(stepPin, HIGH);
delayMicroseconds(2000);
// pause before taking next step
digitalWrite(stepPin, LOW);
delayMicroseconds(2000);
}
Thank you in advance for help
Rachel De Barros
YouTube
Control a NEMA 17 Stepper Motor with A4988 Driver and Arduino - Ful...
Want to master the NEMA 17 stepper motor with your Arduino? In this Arduino tutorial, I’ll walk you through all the wiring, code, and everything you need to know to get that stepper motor spinning with precision—no magic smoke included!
First, we’ll tackle the wiring: how to hook up your NEMA 17 to the A4988 motor driver without frying an...
2 Replies
Hello man! Just a quick question, why you are sure the wires on your motor are correct? You should be able to make it make some steps even manually, then you know the correct wire sequences.
Ok, to me, your problem looks like resolution problem, and may also be too fast steps for your motor to keep up. And may also be both.
Try lowering a lot your delay. On your code you are using 2ms for each coil, you are telling the motor to jump from a complete stop to a full speed. Its a machine, it has inertia, it may not be able to do it.
Use 50... Maybe 100 milliseconds and look to the motor shaft. It has to be running smoothly.
Then post the results here for more help!
The code seems OK, but your current limit may not be adjusted correctly, the power supply may not be delivering adequate current or as alexsb mentioned the coil phasing may not be correct for your particular stepper motor.
https://wokwi.com/projects/443119105616856065
(Also, she looks way too excited to be talking about A4988's 🙂 )