# Couldn't setup GRBL

**URL:** <https://forum.arduino.cc/t/couldnt-setup-grbl/1173489>\
**Category:** Motors, Mechanics, Power and CNC\
**Created:** [September 29, 2023, 2:34pm UTC](https://forum.arduino.cc/t/couldnt-setup-grbl/1173489 "2023-09-29T14:34:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kingof0](https://avatars.discourse-cdn.com/v4/letter/k/5f9b8f/32.png) [@kingof0](https://forum.arduino.cc/u/kingof0)\
**Post date:** [September 29, 2023, 2:34pm UTC](https://forum.arduino.cc/t/couldnt-setup-grbl/1173489/1 "2023-09-29T14:34:28Z")

</div>

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:

- Download src from [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](https://github.com/gnea/grbl/)
- Include library grbl-maser/grbl
- Examples /grbl/grblUpload
- Upload

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](https://github.com/grbl/grbl/))

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.

```arduino
// 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);
}

```

---

<div class="post-metadata">

**Author:** ![Railroader](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/railroader/32/274550_2.png) [@Railroader](https://forum.arduino.cc/u/Railroader)\
**Post date:** [September 29, 2023, 4:44pm UTC](https://forum.arduino.cc/t/couldnt-setup-grbl/1173489/2 "2023-09-29T16:44:37Z")

</div>

> [@kingof0](#):
>
> Arduino Cnc Shield

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

> [@kingof0](#):
>
> ```arduino
> digitalWrite(stepPin, HIGH);
> delayMicroseconds(500);
> digitalWrite(stepPin, LOW);
> delayMicroseconds(500);
> 
> ```

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.

---

<div class="post-metadata">

**Author:** ![kingof0](https://avatars.discourse-cdn.com/v4/letter/k/5f9b8f/32.png) [@kingof0](https://forum.arduino.cc/u/kingof0)\
**Post date:** [September 29, 2023, 11:09pm UTC](https://forum.arduino.cc/t/couldnt-setup-grbl/1173489/3 "2023-09-29T23:09:57Z")

</div>

Hi, thanks for your reply.

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/7/7/4/774454069857f559bb0d750d2ca2cfc0ee8195dc.jpeg)  
I have this one.

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

---

<div class="post-metadata">

**Author:** ![groundFungus](https://avatars.discourse-cdn.com/v4/letter/g/73ab20/32.png) [@groundFungus](https://forum.arduino.cc/u/groundFungus)\
**Post date:** [September 30, 2023, 1:38am UTC](https://forum.arduino.cc/t/couldnt-setup-grbl/1173489/4 "2023-09-30T01:38:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kingof0](https://avatars.discourse-cdn.com/v4/letter/k/5f9b8f/32.png) [@kingof0](https://forum.arduino.cc/u/kingof0)\
**Post date:** [September 30, 2023, 7:51am UTC](https://forum.arduino.cc/t/couldnt-setup-grbl/1173489/5 "2023-09-30T07:51:23Z")

</div>

$$ 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.

---

<div class="post-metadata">

**Author:** ![kingof0](https://avatars.discourse-cdn.com/v4/letter/k/5f9b8f/32.png) [@kingof0](https://forum.arduino.cc/u/kingof0)\
**Post date:** [September 30, 2023, 10:25am UTC](https://forum.arduino.cc/t/couldnt-setup-grbl/1173489/6 "2023-09-30T10:25:21Z")

</div>

Hi, I went to my workshop.

- Flashed [Release v1.1h (2019-08-25) Release · gnea/grbl (github.com)](https://github.com/gnea/grbl/releases/tag/v1.1h.20190825) (using xloader this time)
- Using A4988

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)

````arduino
$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

````

---

<div class="post-metadata">

**Author:** ![kingof0](https://avatars.discourse-cdn.com/v4/letter/k/5f9b8f/32.png) [@kingof0](https://forum.arduino.cc/u/kingof0)\
**Post date:** [October 1, 2023, 3:48pm UTC](https://forum.arduino.cc/t/couldnt-setup-grbl/1173489/7 "2023-10-01T15:48:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [March 29, 2024, 3:48pm UTC](https://forum.arduino.cc/t/couldnt-setup-grbl/1173489/8 "2024-03-29T15:48:49Z")

</div>

Closed on March 29, 2024, 3:48pm UTC

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