problem with A4988 Driver

Hello, I just started playing with Arduino. I’m working on a simple project with a stepper motor. My setup is basically identical to this one: https://lastminuteengineers.com/a4988-stepper-motor-driver-arduino-tutorial/ The wiring is the same. The difference is that in the article they use an Uno, while I’m using a Nano and I am powering it by 12V and my code is simpler. As you can see in the video, when I power up my project the motor vibrates strangely for about a second and then starts working normally. I have no idea what’s causing this. Does anyone have any ideas? my code:
const int dirPin = 2;
const int stepPin = 3;

void setup() {

pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);

}

void loop() {
digitalWrite(stepPin, HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin, LOW);
delayMicroseconds(1000);
}
const int dirPin = 2;
const int stepPin = 3;

void setup() {

pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);

}

void loop() {
digitalWrite(stepPin, HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin, LOW);
delayMicroseconds(1000);
}
Last Minute Engineers
In-Depth: Control Stepper Motor with A4988 Driver Module & Arduino
Learn about A4988 Stepper Motor Driver along with Pinout, Wiring, Arduino Code for Microstepping, Controlling Speed & Direction of NEMA 17 Stepper Motor
No description
No description
9 Replies
Stoneware
StonewareOP5d ago
No description
AnonEngineering
code seems ok https://wokwi.com/projects/441100356695539713, perhaps your 12v source can't supply enough current or the current limiter on the A4988 isn't set correctly?
Stoneware
StonewareOP5d ago
to be exact I have it connected like this https://wokwi.com/projects/441101111253045249 maybe I connected power incorrectly? I am going to check the current limiter my 12v source have 5A so it should be enough
Stoneware_stepper Copy - Wokwi ESP32, STM32, Arduino Simulator
Run IoT and embedded projects in your browser: ESP32, STM32, Arduino, Pi Pico, and more. No installation required!
AnonEngineering
it should be fine, Vin is rated to 12v 5A should be fine, check the limiter or perhaps the phasing of your stepper is different
Stoneware
StonewareOP4d ago
I checked the limiter and the phases, they are fine. However I noticed that when I remove the connection between SLP and RST the problem disappears, but introduces the new one. Now the motor doesn't operate smoothly when it should. What is expected I guess but maybe its a clue for what's actually going on ?
const int dirPin = 7;
const int stepPin = 8;



void setup() {
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
delay(10000); //DELAY <---------------
}

void loop() {
digitalWrite(stepPin, HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin, LOW);
delayMicroseconds(1000);
}
const int dirPin = 7;
const int stepPin = 8;



void setup() {
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
delay(10000); //DELAY <---------------
}

void loop() {
digitalWrite(stepPin, HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin, LOW);
delayMicroseconds(1000);
}
another thing. I think it happens when everything is powering up because this code make it so it vibrates like in the video for 1-2 seconds and then stops for 10seconds. I also powered it up once with step pin disconnected and it was also vibrating for 1-2 seconds I connected EN pin to 5V and the problem disappeared, however now it's disabled so that's no use, but maybe its another clue
AnonEngineering
if EN is HIGH the driver is not enabled, so that makes sense idk what is causing the vibration you see
Stoneware
StonewareOP4d ago
thank you for trying to help 😉 tomorrow I am going to try different arduino board. maybe this one outputs some noisy signals ¯\_(ツ)_/¯ I have no other ideas to try
AnonEngineering
i'd try a different A4988 too if you can 🙂
Stoneware
StonewareOP3d ago
Unfortunately I do not have another one. But if changing boards won't help I will probably buy one

Did you find this page helpful?