Hello, I just purchased 3 NEMA 17 stepper motors, 3 DRV8825 drivers, a CNC shield, and an Arduino Uno. I wanted to familiarize myself before starting a CNC project.
First, I put the CNC shield on the Arduino Uno and installed the drivers. I powered the CNC shield with a 24V power supply and powered the Arduino from my laptop. I adjusted the driver voltage to 0.7V (the stepper motors have a phase current of 1.5A). After calibration, I connected the motors (disconnecting the power supply beforehand).
When testing the stepper motors using the Arduino IDE, they worked perfectly—precise and consistently returning to the same point each time.
After confirming everything was working correctly, I uploaded GRBL and used UGS and GRBL Panel as G-code senders. However, I noticed inaccuracies with the stepper motors. For instance, when sending a command like "G0 X1.0" followed by "G0 X0.0," the motor didn't return precisely to its original position (it was slightly off), and the error increased with larger movements.
Ps: the code that i tested the stepper motors on the Arduino IDE is
// defines pins numbers
const int stepX = 2;
const int dirX = 5;
const int stepY = 3;
const int dirY = 6;
const int stepZ = 4;
const int dirZ = 7;
const int enPin = 8;
void setup() {
// Sets the two pins as Outputs
pinMode(stepX,OUTPUT);
pinMode(dirX,OUTPUT);
pinMode(stepY,OUTPUT);
pinMode(dirY,OUTPUT);
pinMode(stepZ,OUTPUT);
pinMode(dirZ,OUTPUT);
pinMode(enPin,OUTPUT);
digitalWrite(enPin,LOW);
digitalWrite(dirX,HIGH);
digitalWrite(dirY,LOW);
digitalWrite(dirZ,HIGH);
}
void loop() {
// Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x < 800; x++) {
digitalWrite(stepX,HIGH);
delayMicroseconds(1000);
digitalWrite(stepX,LOW);
delayMicroseconds(1000);
}
delay(1000); // One second delay
for(int x = 0; x < 800; x++) {
digitalWrite(stepY,HIGH);
delayMicroseconds(1000);
digitalWrite(stepY,LOW);
delayMicroseconds(1000);
}
delay(1000); // One second delay
for(int x = 0; x < 800; x++) {
digitalWrite(stepZ,HIGH);
delayMicroseconds(1000);
digitalWrite(stepZ,LOW);
delayMicroseconds(1000);
}
delay(1000); // One second delay
}
Thanks in advance.