Inaccuracy Issues with Stepper Motors Using GRBL and CNC Shield

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.

Please get rid of all the extra white space lines and repost your code.

1 Like

Done, sorry for the inconvenience.

Is that 4 revs or 1 rev?

With 200 steps/rev, that looks like 0-150 RPM in 0.002sec.

What sort of accelerations are you asking for with GRBL?

Thanks for answering.

I think it's a 4 revs if it's on full step.
I was editing the code to see if the results are consistants , and they were so. The stepper motor always stop on the same start point.

I don't care about the speed as much as I care about the accuracy. When I move the stepper motor and return it to the same coordinates, I notice inaccuracies and likely missed steps
Example

G0 X0.0
G0 X10.0
G0 X0.0

One common cause of missed steps is accelerating faster than the motor can follow.

1 Like

They may be too weak for your purpose.

Motors behave differently under real load.

2 Likes

Hello DaveX,
Apologies for the delayed response; I was occupied with something at home.
I tried lowering the feed rate on the GRBL panel, and it no longer missed steps. The maximum feed rate I found is 25 in metric units.

Hello DrDiettrich,
thanks for answering.

I haven't put any load on them yet. But i think that they are too weak.
I guess the seller on aliexpress lied about their caracteristics lol.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.