My experience with arduino cnc shield was bit frustrating at start. This article is about version v3.0 CNC shield. I didn’t know anything about this shield, GRBL software and how gcode is sent to CNC machine. So I was pretty unsure about everything I was doing. Original manual is pretty massive to start with and there seemed to be no 5 minute setup guide. But for first time test, I am not in mood to read all that. I want to plugin and see things moving, and then make my progress through settings afterwards. Be sure to read original Arduino CNC shield article also. Here I share my experience and problems occured.
- I am using Ubuntu linux with KDE desktop, but I suppose this works universally.
- You even don’t need to have CNC shield to go trough this article- minimum requirement is to have Arduino UNO development board (or possibily some other Arduino board).
If you get your machine up and running- first thing you need is probably some clamps to hold your stock in place. You might find this online g-code generating tool I created useful.
Getting GRBL code on Arduino
I downloaded latest ( on time of writing this article it was v0.9i version ) source from “https://github.com/grbl/grbl” by downloading by “Download ZIP” button on the right. It downloads current master branch as zip file. So in future it might download some newer version which maybe not be the same version I was using when writing this article. If you want to use the exact same code version that I used in this article, you can download it here. But I suggest using latest, since it probably will work also. Then you have to add It as library and after that you can import grbl library to your source. You can read more about compiling here.
First problem- after importing I was not able to upload/flash it on Arduino on first try. A error raised: “./sketchbook/libraries/grbl/nuts_bolts.h:73:15: error: ‘uint32_t’ was not declared in this scope“. By adding #include <stdint.h> before other includes removed this problem. Note that, there is no need for additional code. Only importing and you are done. Just upload it to your Arduino UNO board. Before GRBL v0.9 there was no direct upload option (If I remeber correctly). Anyway – my code looked like this:
Connecting to GRBL via Arduino serial monitor
Now everything should be ready to go. I opened serial monitor via Tools menu in Android IDE. Note that since GRBL version 0.9 you have to set baud rate to 115200. Otherwise you only see some garbled characters echoed to serial monitor window.
Everything seemed OK to this point. In terminal following welcome message popped up: Grbl 0.9i [‘$’ for help]. That means everything is OK and I was connected. But it can’t go so smooth isn’t? I stepped into next issue. I tried to send some commands, but nothing happened. Except – “?” command yielded results similar to this: <Idle,MPos:0.0000,0.0000,0.0000,WPos:0.0000,0.0000,0.0000,Buf:0,RX:0>
After wrestling with this problem some time I finally learned why this was happening. One must set “No line ending” to “Carriage return” in Arduino Serial monitor (bottom – right). Actually it’s said in GRBL Readme too, but somehow I had missed it. I was exited. Finally I got something back. It was “$$” command which returns current settings used by GRBL software.
GRBL v0.9i serial monitor welcome message
First steps and sending gcode to GRBL?
I would test real movements without hooking motors up into your CNC machine at first. To get hang of this before ripping your nice machine apart. Now for testing you could insert g-code command such as “G0 X2.0 Y2.0 Z2.0” into Serial monitor terminal – it should move all motors a bit. (Look video at end) Even if you have no shield, drives or motors hooked up- terminal should report back with “ok”. You are done!
I had some unanswered questions also. Do I have to add limit switches before motors will move? What about homing cycle? Turned out that I can just configure that there is no limit switches. Also homing cycle is not needed. Nothing at all. Everything runs smoothly without configuring beforehand. See config lines $20, $21 and $22. Zeroes mean that these features are turned off by default config.
I somehow had problems with default settings at first. Motors did not move. At first only one step was done and no “ok” was echoed back. Settings were different than in article. I think I messed up something earlier somehow. Anyway – probably acceleration or maximum rate of movement was with wrong settings- so command executed too slow and echo back no “ok”.
Default GRBL v0.9 settings with Arduino CNC shield version 3.0
Default settings Arduino had were following. I don’t know – are they same for all installations or not. Anyway, here is my printout of settings for reference.
$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.020 (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)
$132=200.000 (z max travel, mm)
Video with default settings
Here is a quick video with all 3 axes moving with default settings and no micro stepping applied. Just running different axes forward and backwards separately and in the end also back to zero simultaneously. Wantai 42BYGHW609 stepper motors were in use.