I built a setup where CNC shield is connected to the Arduino Uno. CNC shield is powered by a 12V, 5A source. During testing, I noticed that the motor spins in place a few times before starting to rotate properly, and its direction is random. I use A4988 and motor model is17HS4401S
I use laser grbl(v1.1) to control it. I download from here(GitHub - gnea/grbl: An open source, embedded, high performance g-code-parser and CNC milling controller written in optimized C that will run on a straight Arduino)
How can i solve it
How do You initialize the stepper positions at startup?
What your mean Sir
For example I click x direction left 10 step and the motor will rotate left and right randomly and start to run continuously in one direction, also like I press for left then the motor sometimes will in true direction and sometime will be wrong direction it is randomly.
grbl uses "homing" to figure out where the motors are in space. If you don't have homing limit switches and settings set up properly, it can fail in the homing process.
How have you set up homing?
Hi Sir
But now is if I restart it and I like press left for 5 step it will be noise inside but not run.
Is I also need a limit switch?
It even can work normal for 1 round.
What is the difference between spin and rotate?
Click what?
Using what code?
Press what?
Restart what?
1.rotate left right mean randomly left right rotate, after few time and rotate continue for 1 direction.
2.press my computer and give left like for 10 step.
3.The code that I use i already give link in my question.
5.Reconnect with my computer and turn off all motor and PCB
Since you are not using any limit switches, make sure homing is disabled: $22=0
And see if it behaves the same on Y
Did you set the pots on the drivers?
What is your motor speed? Post your code.
Is your motor cable inverted / upside-down? Pinned correctly? How does the motor work on the second A4988? Have you adjusted both A4988 for the motors?
I tried both side and I use wire is 4/6pin wire.
I alr change A4988 for 4 and I tried my all 3 motor but is same.
- Be sure to adjust "current limit" Pololu - A4988 Stepper Motor Driver Carrier
- Remove the shield.
- Connect: Arduino >> A4988 >> motor
- Run a minimal sketch.
#define dirPin 2
#define stepPin 3
#define stepsPerRevolution 200
void setup() {
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
}
void loop() {
digitalWrite(dirPin, HIGH); // clockwise
for (int i = 0; i < stepsPerRevolution; i++) { // 200 steps
digitalWrite(stepPin, HIGH);
delayMicroseconds(2000);
digitalWrite(stepPin, LOW);
delayMicroseconds(2000);
}
delay(1000);
}