DryRun beta

Controller notes

GRBL 1.1 and grblHAL: supported G-codes and error codes

After this page you can tell which lines of your program GRBL 1.1 or grblHAL rejects, and with which error: number. You can also decide which settings of your sender and controller to check before you trust a clean result.

DryRun reads a program the way the firmware does and runs it on a model of your router. Lines GRBL would refuse get GRBL's own error number. Moves past the travel stop the run as a limit does. Collisions and the cut are computed against the sheet on the spoilboard.

The page is based on the GRBL and grblHAL source code, their documentation, the CAM posts' source and users' reports, not on a real controller. What depends on your sender, firmware build or settings is listed under "Not confirmed" at the end.

The GRBL demo, /app?demo=demo-grbl, is a Shapeoko 4 XXL with three programs: a two-tool Fusion 360 job, a one-tool Carbide Create / VCarve file, and a Fanuc post's output that GRBL would stop on.

Which machines

The catalogue has two GRBL routers. Each has the vendor's travel, a simple box frame, a spoilboard and a simplified Z head. Measure your own machine before you trust collisions with the frame or the head.

Machine Travel X × Y × Z (mm) Controller Homes at Soft limits
Genmitsu 3018-PROVer V2 290 × 180 × 40 GRBL 1.1 front-left (assumed) off (assumed)
Shapeoko 4 XXL 838 × 838 × 102 GRBL 1.1 (Carbide Motion) back-right on

For any other router (X-Carve, LEAD, LongMill), add your machine in the Library and set its Controller to GRBL 1.1 or grblHAL; Describe your machine shows how. For FluidNC and Grbl-Mega-5X choose GRBL 1.1. They read CAM output as GRBL 1.1 does, except that FluidNC accepts G59.1–G59.3 and M62–M68, which DryRun's GRBL 1.1 rejects.

What GRBL rejects, and why it matters

GRBL checks a whole line before it runs it. If one word is wrong, it discards the line, answers error: and a number, and goes on with the next line. Carbide Motion, gSender, UGS and CNCjs stop the job on an error: reply. The job ends part-way, with the spindle running and the tool possibly in the material.

DryRun rejects the same lines with the same number. It was compared line by line with GRBL 1.1h; the three differences are below.

The simulation goes on after a rejected line, so one pass shows every problem.

The usual causes, from users' reports:

  1. G43 H1 → error:20. A Fanuc or generic post writes a tool length offset; GRBL has no tool table. The hint is GRBL has no tool table — a Fanuc/generic post; use a GRBL post. After a motion code on the same line (G0 G43 Z15 H1) it is error:24.
  2. G81 or G83 → error:20. Canned cycles from a non-GRBL post. The Fusion 360 "Grbl" post writes drilling as G0 and G1 moves.
  3. M6 → error:20 when it reaches GRBL itself. Usually the sender handles it (see Tool changes).
  4. error:33 on arcs. The end point is off the arc beyond GRBL's tolerance, typically inch output with too few decimals.
  5. G64 → error:20, and an A word → error:20 on a 3-axis GRBL.
  6. error:22. The first feed move has no F; GRBL starts with no feed rate.
  7. error:11. GRBL keeps 79 characters of a line, not counting spaces, / and comments. Posts that write many decimals can reach it.

wrongpost.nc in the GRBL demo is a Fanuc post's output. DryRun rejects O1001 (line 2), G64 (line 6), G43 H1 (line 10) and G81 (line 11), each with error:20. No move collides, but the verdict is DO NOT RUN: the job would stop on line 2.

Known differences from GRBL 1.1h:

Supported codes (GRBL 1.1)

Code On GRBL 1.1 In DryRun Refused with
G0, G1 Rapid in one straight line; feed Runs error:22 for a feed move before any F
G2, G3 Arc in G17, G18 or G19, by I J K (always incremental) or R; helical arcs and R below 0 are allowed Runs. A zero-radius arc (G2 X0 Y0 I0 J0) is a straight feed error:33, error:34 (below)
G4 Dwell, P in seconds: G4 P0.5 is half a second Runs. Axis words on the line move after the dwell error:28 without P
G10 L2 and L20 store a work offset Runs: the offset changes for the rest of the job, with a warning that the controller keeps it. L20 sets it from the current position, and DryRun starts at the machine's Home, not where your machine stands error:29 for P above 6
G17, G18, G19, G20, G21, G90, G91, G94 Plane; inch, mm; absolute, incremental; feed per minute Runs —
G28, G30 Go to a stored position; with axis words, through that point and only those axes Runs, to the machine's G28 position or G30 position (machine 0, GRBL's default) —
G28.1, G30.1 Store the current position Runs: used for the rest of the job, with a warning —
G38.2, G38.3, G38.4, G38.5 Probing Line skipped: probing is not simulated —
G40, G61, G91.1, M1 Accepted, no effect Runs, no effect —
G43.1, G49 Dynamic tool length offset in Z; cancel Runs: added to the tool's length error:37 for an axis other than Z
G53 Machine coordinates for this line Runs error:30 unless G0 or G1 is active
G54, G55, G56, G57, G58, G59 Work offsets Runs, from the setup's work zeros —
G80 Cancels the motion mode Runs error:31 for axis words after it
G92, G92.1 Shift the work coordinates; clear the shift Runs error:26 for G92 without axis words
G93 Inverse time: F is 1/minutes, for its own line Runs: G93 G1 X10 F2 takes half a minute error:22 without F on the line
M0, M2, M30 Pause; program end Runs: no pause; the program ends —
M3, M4, M5, M8, M9 Spindle and coolant Runs, no effect on the path —
M6 Rejected by GRBL itself; the sender does the change Runs as a manual change (Tool changes, below) error:20 only when Tool change is set to Tool table
Everything else Rejected Rejected with the same number error:20 for G41, G42, G43, G64, G73, G81–G89, G98, G99, M7, M98 and the letters O, H, Q, D; error:23 for G59.1, G59.2, G59.3 and Mxx.x

Arcs. GRBL compares the arc's radius at its start and at its end. It answers error:33 when they differ by more than 0.005 mm and also by more than 0.5 mm or 0.1 % of the radius. DryRun computes this in single precision, as GRBL does: G2 X100.05 I50 is 0.0500031 off.

Feed. After G93, a feed move in G94 needs a new F, or it is error:22.

Syntax. ; and ( ) comments, lower case, packed words (G0X0Y0), / and N numbers are GRBL syntax and get no note. GRBL ignores a / anywhere in the line. An unclosed ( comments out the rest of the line; a ) without ( is error:1. GRBL has no # variables or expressions: #1=5 is error:1, and G0 X#1 or G0 X[1+2] is error:2. A negative M (M-3) is error:23. A % line gets one note. A $ line ($H, $J=…) gets a note and no motion. A program needs no M30.

grblHAL

grblHAL keeps GRBL 1.1's error numbers and machine space and adds codes. With Controller set to grblHAL, the table above applies, plus:

A LongMill MK2 on its SuperLongBoard is a grblHAL machine with a tool table: Controller grblHAL, Tool table on.

GRBL error codes

GRBL 1.1's error numbers and texts, from gnea/grbl's error_codes_en_US.csv; grblHAL uses the same numbers. DryRun's messages give a short form, for example (error:20, unsupported command).

Code Text
1 G-code words consist of a letter and a value. Letter was not found.
2 Missing the expected G-code word value or numeric value format is not valid.
3 Grbl '$' system command was not recognized or supported.
4 Negative value received for an expected positive value.
5 Homing cycle failure. Homing is not enabled via settings.
6 Minimum step pulse time must be greater than 3usec.
7 An EEPROM read failed. Auto-restoring affected EEPROM to default values.
8 Grbl '$' command cannot be used unless Grbl is IDLE. Ensures smooth operation during a job.
9 G-code commands are locked out during alarm or jog state.
10 Soft limits cannot be enabled without homing also enabled.
11 Max characters per line exceeded. Received command line was not executed.
12 Grbl '$' setting value cause the step rate to exceed the maximum supported.
13 Safety door detected as opened and door state initiated.
14 Build info or startup line exceeded EEPROM line length limit. Line not stored.
15 Jog target exceeds machine travel. Jog command has been ignored.
16 Jog command has no '=' or contains prohibited g-code.
17 Laser mode requires PWM output.
20 Unsupported or invalid g-code command found in block.
21 More than one g-code command from same modal group found in block.
22 Feed rate has not yet been set or is undefined.
23 G-code command in block requires an integer value.
24 More than one g-code command that requires axis words found in block.
25 Repeated g-code word found in block.
26 No axis words found in block for g-code command or current modal state which requires them.
27 Line number value is invalid.
28 G-code command is missing a required value word.
29 G59.x work coordinate systems are not supported.
30 G53 only allowed with G0 and G1 motion modes.
31 Axis words found in block when no command or current modal state uses them.
32 G2 and G3 arcs require at least one in-plane axis word.
33 Motion command target is invalid.
34 Arc radius value is invalid.
35 G2 and G3 arcs require at least one in-plane offset word.
36 Unused value words found in block.
37 G43.1 dynamic tool length offset is not assigned to configured tool length axis.
38 Tool number greater than max supported value.

Codes 18 and 19 are unused in GRBL 1.1. On GRBL 1.1 DryRun never gives 3, 5–10 and 12–17: they come from $ commands, settings, homing, jogging and hardware.

When DryRun gives each number (the rules of GRBL's gcode.c):

Error When Example a CAM file can contain
20 any G or M code GRBL 1.1 does not support; any letter other than F I J K L N P R S T X Y Z G81, G43 H1, G64, M7, G90.1, O1001, A90 on a 3-axis machine, D1
21 two codes of one modal group G0 G80, M8 M9, M3 M5
22 G1/G2/G3 before any F G1 Z-1 as the first feed
23 a decimal where an integer is required G59.1, M3.1
24 two codes that use axis words (checked before the modal groups, and before G43, G38.x or Gxx.x is refused after G0–G3, G10, G28, G30, G92 or G43.1/G49) G0 G1 X1, G28 G1 X0, G0 G43 Z15 H1, G1 G1.5 X1
25 the same letter twice X1 X2
26 G10, G92 or G2/G3 without axis words G2 I5 J0
27 N above 10 000 000
28 G4 without P; G10 with neither P nor L G4
29 G10 with P above 6 G10 L2 P7 X0
30 G53 while G2/G3 or G80 is active G2 … then G53 X0
31 axis words while G80 is active G80 then G92 X0
32 an arc with no axis word in its plane G17 G2 Z5 I1
33 an arc whose end is not on it, an R arc to its start point
34 R smaller than half the chord
35 an IJK arc with no offset in its plane G17 G2 X1 Y1 K1
36 value words no command uses G0 X1 R2, G1 X1 P1
37 G43.1 with an axis other than Z G43.1 X1
38 T above 255 T300
4 a negative F, N, P, S or T G4 P-1
2 a letter without a number, or with a # or [ as its value G1 X, G0 X#1
1 a character that is not part of a word G0 X1 ,, #1=5
11 more than 79 characters, not counting spaces, / and comments a 5-axis post with 8 decimals

Machine space, homing and soft limits

After homing, GRBL counts machine coordinates from the homed end. Every axis runs from minus its travel ($130–$132) to 0. DryRun uses the same limits, so the readout shows negative machine coordinates, as your controller does.

Every program starts at the machine's Home position, where homing leaves the machine. That is about (−5, −5, −5), back-right, on a Shapeoko and (−285, −175, −1), front-left, on the 3018. The first rapid is drawn and checked from there. The real machine starts wherever you jogged it after homing.

A move past the travel stops the run there, as the machine stops. The Axis limit entry names what the controller does, by the machine's Soft limits setting (your $20):

The lines after it count as not executed, and the verdict is DO NOT RUN.

The spoilboard allowance. A through-cut goes a little into the spoilboard on purpose. The catalogue routers' spoilboard has a 1.5 mm allowance: the cutter may go 1.25 mm into it (1.5 minus the 0.25 mm collision margin). Deeper is a collision that gives the real depth, for example cutter T1 cuts 1.26 mm into spoilboard (allowance 1.25 mm) at …. The shank, holder and Z head get no allowance. The allowance belongs to the machine, not to the job, so keep it small.

Tool changes

GRBL itself only stores T and rejects M6. The sender does the change: it pauses, you change the tool, and Z is touched off again with the new one (touch plate, BitSetter, tool-length sensor). DryRun models that by default, with the machine's Tool change set to Touch off. Each tool's length from the setup applies from the start and after every M6, so every tip reaches the same work Z.

What the senders do with M6, from their documentation:

Sender What it does with M6
Carbide Motion intercepts M6: raises the spindle, prompts for the change, re-measures with the BitSetter, resumes
gSender Config → Tool Changing: "Ignore" is the default, then Pause, Code (macro), wizards, Passthrough
CNCjs ≥ 1.9.11 pauses on M6 with a confirmation pop-up
UGS intercepts M6 and pauses (setting name not verified)
grblHAL firmware $341 modes 1–3 touch off; mode 4 ignores M6

The first M6 of a program gets a note: M6: simulated as a manual change with Z touched off again, as Carbide Motion, CNCjs, UGS and grblHAL do; gSender's default (Tool Changing: Ignore) skips it and keeps the old tool; GRBL itself rejects M6 (error:20).

The Fusion 360 "Grbl" post writes a bare T2 and no M6 unless "Use M6" is on, and no sender stops there. DryRun warns T2 without M6: GRBL and the senders do not stop here — the machine keeps cutting with T1 … and keeps T1 in the spindle. A one-tool file with no M6 is normal on GRBL. It gets the note no tool change in program — GRBL ignores T; T1 from the setup is in the spindle.

Posts tried

DryRun is tested on output in the style of these posts. The samples come from each post's source or from files users published, not from every version of the post. On GRBL 1.1 all run without a rejected line except the Fanuc post:

A program opened without a project. When every program you open looks like GRBL output, DryRun runs it on the Shapeoko 4 XXL. It says that this is a guess: … so it runs on the default GRBL machine (Shapeoko 4 XXL) with no fixture and a 300 × 200 × 18 block — a guess: pick your machine in Create project. Three things make a program look like GRBL output: Carbide Create's or Kiri:Moto's header, a comment that names a GRBL machine, post or sender (Shapeoko, gSender, Carbide Motion), or the shape of Fusion's GRBL post.

Not confirmed

GRBL's source says exactly what the firmware does, so DryRun rejects instead of guessing. What is not verified lies outside the firmware: your sender, the vendor's build and your settings. Each item is what DryRun assumes, then the check on your machine.

On a DDCS V4.1 the manuals leave more open, so there DryRun warns — behaviour on DDCS not confirmed on the line itself.

Sources

Other controllers