Hi! I'm a beginner and I'm trying to see if my stepper motor works properly.
I'm trying to make my stepper motor 17HE08-1004s from stepperonline rotate clockwise 360 degrees every second, but instead it twitches and rotates randomly in both directions. I use the A4988 driver from AZ-delivery and an Arduino Uno. Below I will list all the values I currently have:
Motor power supply: 20V
Logic power supply: 5V (from Arduino)
Vref: 1.17V (can't seem to increase it more than this on the driver)
Which of these values do you think is the problem and why?
here is my very simple code:
const int stepPin = 3;
const int dirPin = 4;
void setup() {
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
}
void loop() {
// Set direction to HIGH (e.g., clockwise)
digitalWrite(dirPin, HIGH);
// Rotate 360 degrees (200 steps)
for(int x = 0; x < 200; x++) {
digitalWrite(stepPin, HIGH); // Step motor
delayMicroseconds(500); // Wait for 500 microseconds
digitalWrite(stepPin, LOW); // Turn off step
delayMicroseconds(500); // Wait for 500 microseconds
}
// Wait for 10 seconds after completing 360-degree rotation
delay(1000); // 10000 milliseconds = 10 seconds
}
Hello,
I’m also new to stepper motors and had a similar problem. Could the twitching be because of the microstepping settings or maybe some noise in the wires?
Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.
Can you please post a link to data/specs of your stepper motor?
What are you using for a power supply for the motor?
Hmmmm. Identical code problems from two different posters, all in the same week. I suspect they neglected to tell the AI code generator how many steps per second the motor was to take.