Couldn't setup GRBL

Hello community,

I'm trying to build a laser engraver. I have done the mechanical part but had a problem with grbl firmware. I have tried a lot of scenarios.

I'm using A4988 motor drivers and I have already set vRef. Used 12V PSU with adjustable amp.

Scenario 1
UNO + A4988 with test code => Works perfectly.

Scenario 2
UNO + A988 + Arduino Cnc Shield with test code => Works perfectly (So, there is no problem with my shield)

Scenario 3
UNO + 4988 with grbl => Not working

Scenario 4
UNO + 4988 + Cnc Shield with grbl => Not working

According to scenario results I have problem with grbl setup.

How do I setup grbl:

Also tried same steps with old grbl 0.9 (GitHub - grbl/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 do I test grbl:

  • Universal G Code Sender
  • Laser GRBL
  • GCodes like G21G92X-1 (via arduino serial monitor)

I'm sure that my motor wirings are correct, because it works on scenario 1 and scenario 2.
I'm sure that my motor driver is working, because it works on scenario 1 and scenario 2.
I can share my wirings if it's necessary to see them.
I have used 2,3,4 for step and 6, 7, 6 for direction pins. (I get these pins from grbl's cpu_map file)

Here's the test code that I have mentioned.

// Define stepper motor connections and steps per revolution for the X axis motor:
#define dirPin 5
#define stepPin 2
#define enablePin 8  // ******** name the enable pin

#define stepsPerRevolution 200

void setup()
{
   // Declare pins as output:
   pinMode(stepPin, OUTPUT);
   pinMode(dirPin, OUTPUT);
   pinMode(enablePin, OUTPUT);  // ******** set the enable pinMode
   digitalWrite(enablePin, LOW); // ******** enable the motors
}

void loop()
{
   // Set the spinning direction clockwise:
   digitalWrite(dirPin, HIGH);

   // Spin the stepper motor 5 revolutions fast:
   for (int i = 0; i < 5 * stepsPerRevolution; i++)
   {
      // These four lines result in 1 step:
      digitalWrite(stepPin, HIGH);
      delayMicroseconds(500);
      digitalWrite(stepPin, LOW);
      delayMicroseconds(500);
   }

   delay(1000);

   // Set the spinning direction counterclockwise:
   digitalWrite(dirPin, LOW);

   //Spin the stepper motor 5 revolutions fast:
   for (int i = 0; i < 5 * stepsPerRevolution; i++)
   {
      // These four lines result in 1 step:
      digitalWrite(stepPin, HIGH);
      delayMicroseconds(500);
      digitalWrite(stepPin, LOW);
      delayMicroseconds(500);
   }
   delay(1000);
}

Exactly which one?
Among popular CNC shields some manage Grbl 0.9 and some Grble 1.1 as I remember.

The step pulse needs to be some 10 microseconds. The other delay affects the speed. Your test code spits out 1000 pulses per second. It's quite high. If the motor has a load it might be too much. But as You told, the steppers moved in Your first tests.

Hi, thanks for your reply.


I have this one.

About pulse, thanks for explanation but looks like it didn't cause any problem because it worked verry well.

When you load grbl by uploading the grblUpload sketch and once it is uploaded do you see something like:

Grbl 1.1f ['$' for help]

when you open the serial monitor (baud set to 115200)?

From serial monitor, what do you get in serial monitor if you send "$$" (no quotes) to grbl?
Please copy and paste the serial monitor output to a post.

$$ and other grbl commands works well and responses OK. I'm also aware unlocking using $X which also responses ok.

Edit: I'll share $$ output when I went to workshop.
Edit2: I'm using default configurations.
Edit3: I'm not using any switch for limit.

Hi, I went to my workshop.

When I reset arduino, motors draw 800mA and vibrates a little bit for 1-2 seconds then stops drawing. Noise probably.

After that it doesn't draws any current. Even I type G21G92X10 it responds ok but nothing happens.

I'am connecting A4988 enable pin to arduino's digital pin 8. When I remove this pin, it starts to draw 800mA again. And stops when I connect. ($X doesn't help)

Here's results of $$ (Current Test) (I have decreesed 101, 102, 103, 110, 111, 112)

$1=25
$2=0
$3=0
$4=0
$5=0
$6=0
$10=1
$11=0.010
$12=0.002
$13=0
$20=0
$21=0
$22=0
$23=0
$24=25.000
$25=500.000
$26=250
$27=1.000
$30=1000
$31=0
$32=0
$100=100.000
$101=100.000
$102=100.000
$110=100.000
$111=100.000
$112=100.000
$120=10.000
$121=10.000
$122=10.000
$130=200.000
$131=200.000
$132=200.000
ok
ok


Grbl 1.1h ['$' for help]```

Here's results of $$ When using 0.9 (OLD)
```Grbl 0.9j ['$' for help]
$0=10 (step pulse, usec)
$1=25 (step idle delay, msec)
$2=0 (step port invert mask:00000000)
$3=0 (dir port invert mask:00000000)
$4=0 (step enable invert, bool)
$5=0 (limit pins invert, bool)
$6=0 (probe pin invert, bool)
$10=3 (status report mask:00000011)
$11=0.010 (junction deviation, mm)
$12=0.002 (arc tolerance, mm)
$13=0 (report inches, bool)
$20=0 (soft limits, bool)
$21=0 (hard limits, bool)
$22=0 (homing cycle, bool)
$23=0 (homing dir invert mask:00000000)
$24=25.000 (homing feed, mm/min)
$25=500.000 (homing seek, mm/min)
$26=250 (homing debounce, msec)
$27=1.000 (homing pull-off, mm)
$100=250.000 (x, step/mm)
$101=250.000 (y, step/mm)
$102=250.000 (z, step/mm)
$110=500.000 (x max rate, mm/min)
$111=500.000 (y max rate, mm/min)
$112=500.000 (z max rate, mm/min)
$120=10.000 (x accel, mm/sec^2)
$121=10.000 (y accel, mm/sec^2)
$122=10.000 (z accel, mm/sec^2)
$130=200.000 (x max travel, mm)
$131=200.000 (y max travel, mm

I have tried gne/grbl, grbl/grbl and grblMega with different boards. Nothing Solved.

I have setup grblHAL on same conditions with stm32F411ceu6, it works perfectly right now.

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