A cross-control G-code and M-code reference, organized by operation — what you actually want the machine to do — rather than by code number. Each row is one operation (a feed move, an arc, a probe, a drilling cycle, a work-offset select…) and each control's column shows the exact code that control uses for it.
Covers LinuxCNC, GRBL (1.1), Centroid (CNC12 — Acorn / Allin1DC / Oak; mill unless called out), FANUC (0i / 30i, mill-focused with lathe specifics flagged), Mach 3 (Mill Rev 1.84-A2), and Mach 4 (Mill v1.0).
How to read the tables:
- A cell shows the code(s) that control uses for the operation — e.g.
the "probe toward work" row reads
G38.2for LinuxCNC,G31for FANUC, andM115/M116for Centroid. —means the control has no equivalent code for that operation.- A code with a dotted underline has a control-specific caveat; the full note is in that row's Notes column (and on hover).
- Use the control filter at the top of the tables to hide every column but your own.
Sources used for fact-checking are listed at the bottom of this doc.
#Codes by operation
Motion & interpolation
The moves that actually cut. These are the most portable codes — G0–G3 mean the same thing on every control here.
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Rapid positioning | G0 |
G0 |
G0 |
G0 |
G0 |
G0 |
Non-cutting traverse at the machine's max rate. |
| Linear feed move | G1 |
G1 |
G1 |
G1 |
G1 |
G1 |
Feed-controlled straight cut; requires an F word. |
| Clockwise arc / helix | G2 |
G2 |
G2 |
G2 |
G2 |
G2 |
I/J/K center offsets or R radius, in the active plane. Add a Z move for a helix. |
| Counter-clockwise arc / helix | G3 |
G3 |
G3 |
G3 |
G3 |
G3 |
Same conventions as the CW arc, opposite direction. |
| Dwell (pause) | G4 |
G4 |
G4 |
G4 |
G4 |
G4 |
Mach3/4: decimal P = seconds, integer P = milliseconds. |
| Full-circle CW (current pos as center) | — | — | — | — | G12 |
G12 |
Mach3: partial |
| Full-circle CCW | — | — | — | — | G13 |
G13 |
Mach3: partial |
| Cubic-spline interpolation | G5 |
— | — | — | — | — | LinuxCNC only. NOT the same as FANUC G5 (look-ahead) — see the false-friends note. LinuxCNC: G5 = cubic spline through control points |
| Imaginary-axis designation | — | — | — | G7.1 |
— | — | FANUC cylindrical / polar interpolation prep. |
Plane selection
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Select XY plane | G17 |
G17 |
G17 |
G17 |
G17 |
G17 |
Default. Arcs use I/J. |
| Select ZX plane | G18 |
G18 |
G18 |
G18 |
G18 |
G18 |
Arcs use I/K. |
| Select YZ plane | G19 |
G19 |
G19 |
G19 |
G19 |
G19 |
Arcs use J/K. |
Work coordinates & offsets
Where the part zero lives. Extended fixtures past the first six are where the controls diverge the most.
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Select work coord system 1–6 | G54 / G55 / G56 / G57 / G58 / G59 |
G54 / G55 / G56 / G57 / G58 / G59 |
G54 / G55 / G56 / G57 / G58 / G59 |
G54 / G55 / G56 / G57 / G58 / G59 |
G54 / G55 / G56 / G57 / G58 / G59 |
G54 / G55 / G56 / G57 / G58 / G59 |
G54 is the default WCS after power-on on most controls. |
| Work coord systems 7–9 | G59.1 / G59.2 / G59.3 |
— | — | — | G59.1 / G59.2 / G59.3 |
G59.1 / G59.2 / G59.3 |
The LinuxCNC / Mach way to get three more fixtures. |
| Extended fixture bank (P-addressed) | — | — | — | G54.1 |
— | G54.1 |
FANUC: P1–P48 (0i) or P1–P300 (30i). Mach4: P1–P248. Centroid uses a different, NO-decimal form below. FANUC: G54.1 P1–P48 (0i) / P1–P300 (30i) Mach4: G54.1 P1–P248 |
| Extended work offsets (Centroid) | — | — | G54 P1–P12 |
— | — | — | Centroid's 12 optional extended fixtures (WCS #7–#18). Note the space and NO decimal — distinct from FANUC's G54.1 Pn. Centroid: also addressable as E7–E18 |
| Set work offset value (absolute) | G10 L2 |
G10 L2 |
G10 L2 |
G10 L2 |
G10 L2 |
G10 L2 |
P1 = G54 … P6 = G59. The active WCS need not match P. |
| Set work offset to current position | G10 L20 |
G10 L20 |
G10 L20 |
G10 L20 |
G10 L20 |
G10 L20 |
"Set to here" form. |
| Local coordinate offset | G52 |
— | G52 |
G52 |
G52 |
G52 |
Temporary frame shift on top of the active WCS. |
| Move in machine coordinates (non-modal) | G53 |
G53 |
G53 |
G53 |
G53 |
G53 |
One-shot move in the machine frame. |
| Set position / coordinate offset | G92 |
G92 |
G92 |
G92 |
G92 |
G92 |
FANUC has G92.1 / G92.2 to clear or restore; Mach has G92.1. |
Units & distance modes
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Program in inches | G20 |
G20 |
G20 |
G20 |
G20 |
G20 |
|
| Program in millimeters | G21 |
G21 |
G21 |
G21 |
G21 |
G21 |
|
| Absolute distance mode | G90 |
G90 |
G90 |
G90 |
G90 |
G90 |
|
| Incremental distance mode | G91 |
G91 |
G91 |
G91 |
G91 |
G91 |
|
| Absolute arc-center mode | G90.1 |
— | G90.1 |
— | G90.1 |
G90.1 |
I/J/K become absolute coordinates, not offsets. Centroid: varies by CNC12 version |
| Incremental arc-center mode (default) | G91.1 |
G91.1 |
G91.1 |
G91.1 |
G91.1 |
G91.1 |
Feed & speed modes
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Feed per minute | G94 |
— | G94 |
G94 |
G94 |
G94 |
Default on mills. On a FANUC LATHE this role is played by G98 — see the false-friends note. |
| Feed per revolution | G95 |
— | G95 |
G95 |
G95 |
G95 |
On a FANUC LATHE this role is played by G99. |
| Inverse-time feed mode | G93 |
G93 |
G93 |
G93 |
G93 |
G93 |
F = 1/minutes; required for some rotary moves. Centroid: G93 on, G94 off. |
Tool length & cutter compensation
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Cutter compensation OFF | G40 |
G40 |
G40 |
G40 |
G40 |
G40 |
Default state. |
| Cutter comp LEFT of path | G41 |
— | G41 |
G41 |
G41 |
G41 |
D word selects the offset register. |
| Cutter comp RIGHT of path | G42 |
— | G42 |
G42 |
G42 |
G42 |
|
| Dynamic cutter comp (offset in source) | G41.1 / G42.1 |
— | — | — | — | — | LinuxCNC puts the D value in the source line instead of a register. |
| Cutter-comp corner style | — | — | — | — | — | G40.1 / G40.2 |
Mach4 only: G40.1 arc-rounded, G40.2 square. |
| Tool length offset (positive) | G43 |
— | G43 |
G43 |
G43 |
G43 |
H word selects the TLO register. |
| Tool length offset (negative) | — | — | G44 |
G44 |
— | — | Rarely used; FANUC-style. Centroid documents G44 in CNC12. |
| Dynamic tool length offset (in source) | G43.1 |
G43.1 |
— | — | — | — | |
| Cancel tool length offset | G49 |
G49 |
G49 |
G49 |
G49 |
G49 |
|
| Set tool-table entry directly | G10 L1 |
— | G10 L1 |
G10 L1 |
G10 L1 |
G10 L1 |
P = tool number, R = value. Centroid documents this in CNC12. LinuxCNC: partial |
| Set tool length so current pos = value | G10 L10 |
— | G10 L10 |
G10 L10 |
G10 L10 |
G10 L10 |
LinuxCNC: partial |
| Set tool length / radius wear & radius | — | — | G10 L11 / G10 L12 / G10 L13 |
G10 L11 / G10 L12 / G10 L13 |
G10 L11 / G10 L12 / G10 L13 |
G10 L11 / G10 L12 / G10 L13 |
Centroid CNC12 documents the L11/L12/L13 family explicitly; support varies on others. FANUC: varies Mach3: varies Mach4: varies |
Drilling, boring & tapping cycles
Canned hole cycles. GRBL has none — CAM posts expand these into raw G1 moves.
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Cancel canned cycle | G80 |
— | G80 |
G80 |
G80 |
G80 |
Required to exit drill/bore/tap modes. |
| Standard drilling | G81 |
— | G81 |
G81 |
G81 |
G81 |
Z down at feed, rapid out. |
| Drilling with dwell at bottom | G82 |
— | G82 |
G82 |
G82 |
G82 |
Spot / counterbore use. |
| Peck drilling (full retract) | G83 |
— | G83 |
G83 |
G83 |
G83 |
Q = peck depth; full retract clears chips. |
| High-speed peck drilling (short retract) | G73 |
— | G73 |
G73 |
G73 |
G73 |
|
| Right-hand tapping | G84 |
— | G84 |
G84 |
G84 |
G84 |
Mach3: needs OEM plugin for rigid tap |
| Left-hand / counter tapping | G74 |
— | G74 |
G74 |
G74 |
G74 |
FANUC LATHE reassigns G74 to a face-grooving cycle — see false friends. |
| Rigid tapping | G33.1 |
— | — | — | — | G84.2 / G84.3 |
Dedicated rigid-tap codes; otherwise rigid mode is a flag on G84. LinuxCNC: LinuxCNC rigid-tap code |
| Boring (feed in, feed out) | G85 |
— | G85 |
G85 |
G85 |
G85 |
|
| Boring (feed in, stop, rapid out) | — | — | — | G86 |
G86 |
G86 |
Centroid's CNC12 canned set is G81–G85 + G89; G86/G87/G88 are not in the manual. |
| Back boring | — | — | — | G87 |
G87 |
G87 |
|
| Boring with manual retract | — | — | — | G88 |
G88 |
G88 |
|
| Boring with dwell (feed out) | G89 |
— | G89 |
G89 |
G89 |
G89 |
|
| Fine boring (oriented stop, shift, retract) | — | — | G76 |
G76 |
G76 |
G76 |
FANUC LATHE reassigns G76 to a threading cycle — see false friends. Centroid: partial; verify per version |
Probing & tool setting
The biggest divergence on the page. LinuxCNC/GRBL use G38.x, FANUC/Mach use G31, and Centroid uses M-codes entirely.
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Probe toward work, error if no contact | G38.2 |
G38.2 |
M115 / M116 |
G31 |
G31 |
G31 |
FANUC syntax: G31 P1–P4 for multi-step skip. Centroid has NO G31/G38 — it probes with protected-move M-codes. Centroid: protected-move probing; M115 minus, M116 plus |
| Probe toward work, no error if no contact | G38.3 |
G38.3 |
M115/M116 L1 |
— | — | — | Centroid: L1 suppresses the no-contact error |
| Probe away from surface | G38.4 / G38.5 |
G38.4 / G38.5 |
M125 / M126 |
— | — | — | G38.4 errors if still in contact; G38.5 does not. Centroid: probe-away variants |
| Multiple probe inputs | — | — | — | — | — | G31.1 / G31.2 / G31.3 |
Select among several probe inputs. |
| Move an axis until a switch trips | — | — | M105 / M106 |
— | — | — | Feeds the named axis until a PLC switch/input opens (P > 0) or closes (P < 0). Centroid: M105 minus, M106 plus |
Coordinate transforms — rotation, scaling, mirror, polar
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Coordinate rotation ON | G68 |
— | G68 |
G68 |
G68 |
G68 |
Rotates the active plane around a center. XY plane only on Mach3/4. |
| Coordinate rotation OFF | G69 |
— | G69 |
G69 |
G69 |
G69 |
|
| Scaling ON | — | — | G51 |
G51 |
G51 |
G51 |
P or I/J/K = scale factors. Mach4 warns arc scaling can be unpredictable. Centroid: Centroid folds scaling AND mirroring into G51 |
| Scaling OFF | — | — | G50 |
G50 |
G50 |
G50 |
FANUC LATHE reassigns G50 entirely — see false friends. Centroid: also mirroring-off; partial/version-dependent |
| Mirror image ON / OFF | — | — | — | G51.1 / G50.1 |
— | — | Centroid has no separate mirror codes — mirroring rides on G50/G51. |
| Polar coordinates ON / OFF | — | — | — | G16 / G15 |
— | G16 / G15 |
Encodes X as radius, Y as angle. |
Look-ahead, smoothing & exact stop
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Exact stop (non-modal, one block) | G9 |
— | G9 |
G9 |
G9 |
G9 |
One-shot version of G61. |
| Exact stop (modal) | G61 |
G61 |
G61 |
G61 |
G61 |
G61 |
Decelerates fully at every endpoint. |
| Exact stop (variant) | G61.1 |
— | — | — | G61.1 |
G61.1 |
|
| Path blending / continuous mode | G64 |
G64 |
G64 |
G64 |
G64 |
G64 |
LinuxCNC: G64 P<tol>. FANUC tunes this via G5.1 HPCC instead. FANUC: partial; HPCC tuning differs |
| AI contour control / HPCC (look-ahead) | — | — | — | G5.1 |
— | — | FANUC look-ahead: Q1 on, Q0 off. NOT the same as LinuxCNC G5 spline — see false friends. |
| Nano smoothing / HPCC variant | — | — | — | G5.4 |
— | — | FANUC: some 30i-B only |
| Look-ahead acc/dec enable (older FANUC) | — | — | — | G8 |
— | — | G8 P1 on, G8 P0 off. |
Homing & reference returns
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Return to reference position (home) | G28 |
G28 |
G28 |
G28 |
G28 |
G28 |
GRBL/Mach: pre-defined stored position. |
| Store the G28 reference point | G28.1 |
G28.1 |
— | — | G28.1 |
G28.1 |
|
| Return from reference (via intermediate point) | G29 |
— | G29 |
G29 |
G29 |
G29 |
|
| Return to secondary reference | G30 |
G30 |
G30 |
G30 |
G30 |
G30 |
|
| Store the G30 reference point | G30.1 |
G30.1 |
— | — | G30.1 |
G30.1 |
|
| Reference-position check | — | — | — | G27 |
— | — | Verifies the machine is at home. |
Program flow & subprograms
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Compulsory program stop | M0 |
M0 |
M0 |
M0 |
M0 |
M0 |
Cycle-start to resume. |
| Optional stop | M1 |
M1 |
M1 |
M1 |
M1 |
M1 |
Skipped unless the OSTOP switch is on. |
| Program end (no rewind) | M2 |
M2 |
M2 |
M2 |
M2 |
M2 |
|
| Program end + rewind | M30 |
M30 |
M30 |
M30 |
M30 |
M30 |
What most CAM emits at file end. |
| Call subprogram | — | — | M98 |
M98 |
M98 |
M98 |
FANUC/Centroid/Mach: P<file> L<reps>. LinuxCNC uses O-codes instead. |
| Return from subprogram / end of macro | — | — | M99 |
M99 |
M99 |
M99 |
|
| Named / numbered subroutines | O-codes |
— | — | — | — | — | LinuxCNC's model: o100 sub / o100 endsub / o100 call. LinuxCNC: o<n> sub / endsub / call |
| Macro call (one-shot) | G65 |
— | G65 |
G65 |
— | G65 |
Centroid: L = repeat count, not feed. Mach4: macro file must be .nc; A–Z args map to #1–#26. LinuxCNC: via O-code subs |
| Modal macro call / cancel | — | — | — | G66 / G67 |
— | G66 / G67 |
Centroid's CNC12 list documents only one-shot G65 — no G66/G67. |
| Re-run program from start | — | — | — | — | M47 |
M47 |
Mach4: partial |
Macros, variables & flow control
How each control does branching and loops. These are language constructs, not G-codes — shown for porting macros. Centroid is the notable one: no WHILE/DO.
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Parametric variables | #<named> |
— | #vars |
#vars |
VBScript |
Lua |
LinuxCNC: named & numbered params Centroid: Macro-B style FANUC: Macro-B Mach3: Param1/2/3() Mach4: scripted |
| Conditional (IF / THEN) | O… if/elseif/else/endif |
— | IF/THEN/ELSE |
IF[…] THEN / GOTO |
VBScript |
Lua |
Centroid: supported |
| Loop (WHILE / DO) | O… while/endwhile |
— | — | WHILE[…] DO / END |
VBScript |
Lua |
Centroid CNC12 has NO WHILE/DO loop — use IF + GOTO instead. |
| Branch (GOTO) | — | — | GOTO Nnnn |
GOTOn |
— | — | Centroid: jump to a block number |
| Set internal control parameter | — | — | G10 P_ R_ |
— | — | — | Centroid-specific. E.g. G10 P73 R0.02 configures the G73 peck-retract before the cycle call. Centroid: no L word |
Spindle & coolant
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Spindle on, clockwise | M3 |
M3 |
M3 |
M3 |
M3 |
M3 |
S word sets speed. |
| Spindle on, counter-clockwise | M4 |
M4 |
M4 |
M4 |
M4 |
M4 |
GRBL laser mode: dynamic power. |
| Spindle stop | M5 |
M5 |
M5 |
M5 |
M5 |
M5 |
|
| Spindle orient (oriented stop) | — | — | M19 |
M19 |
M19 |
M19 |
Centroid: needs a custom M19 macro. Mach3: depends on builder VBScript. Mach3: builder-dependent |
| Mist coolant on | M7 |
M7 |
M7 |
M7 |
M7 |
M7 |
|
| Flood coolant on | M8 |
M8 |
M8 |
M8 |
M8 |
M8 |
|
| All coolant off | M9 |
M9 |
M9 |
M9 |
M9 |
M9 |
Tool change
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Tool change | M6 |
— | M6 |
M6 |
M6 |
M6 |
Pairs with a prior Tn. GRBL pauses and prompts. |
| Set current tool number (no change) | M61 |
— | — | — | — | — | Declares the loaded tool without a swap. |
Feed & spindle overrides
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Enable feed & speed overrides | M48 |
— | M108 |
M48 |
M48 |
M48 |
Centroid uses M108 for this instead of M48. |
| Disable feed & speed overrides | M49 |
— | M109 |
M49 |
M49 |
M49 |
Often used inside tapping cycles. Centroid uses M109. |
| Granular override control (LinuxCNC) | M50 / M51 / M52 / M53 |
— | — | — | — | — | Feed (M50), spindle (M51), adaptive feed (M52), feed-stop (M53). |
Digital & analog I/O
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Set digital output | M62 / M64 |
— | M94 |
— | M62 / M64 |
M62 / M64 |
Centroid uses M94 (e.g. M94/1 sets output 1). Mach3: usually via OEM scripts. Centroid: M94/n Mach3: partial |
| Clear digital output | M63 / M65 |
— | M95 |
— | M63 / M65 |
M63 / M65 |
Centroid uses M95 (e.g. M95/1 clears output 1). Centroid: M95/n Mach3: partial |
| Wait for input | M66 |
— | M100 / M101 |
— | M66 |
M66 |
Centroid uses M100/M101 (PLC-bit wait). Mach4: P<input> L<timeout-sec>. Mach3: partial |
| Analog output | M67 / M68 |
— | — | — | — | M67 / M68 |
M67 synchronized, M68 immediate. Mach4: partial |
| PLC-bit wait (Centroid) | — | — | M100 / M101 |
— | — | — | M100 waits until a PLC bit is open/off; M101 until closed/on. SAME numbers run user scripts on LinuxCNC/Mach — see false friends. Centroid: M100 open, M101 closed |
| Direct output / IO macro family (Mach4) | — | — | — | — | — | M200–M219 / M220–M224 / M228 |
Modal state (LinuxCNC)
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Save / restore modal state | M70 / M71 / M72 / M73 |
— | — | — | — | — | M70 save, M71 invalidate, M72 restore, M73 save autoreturn state. |
Turning / lathe cycles
Lathe (T-series) territory. The columns above describe MILL behavior; several codes mean something different on a lathe.
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Diameter / radius mode (LinuxCNC lathe) | G7 / G8 |
— | — | — | — | — | |
| Spindle max RPM clamp (CSS) | G50 |
— | G50 |
G50 |
G50 |
G50 |
FANUC lathe: G50 S____ clamps RPM under G96. Mill G50 means scaling-off — a true false friend. LinuxCNC: partial Centroid: partial FANUC: G50 S____ Mach3: partial |
| Set work-coord origin (FANUC lathe) | — | — | — | G50 |
— | — | G50 X_ Z_ on a FANUC lathe sets the work origin (the other G50 sub-use). FANUC: G50 X_ Z_ |
| Constant surface speed (CSS) on | G96 |
— | G96 |
G96 |
G96 |
G96 |
S in m/min (G21) or sfm (G20). Centroid: partial Mach3: partial |
| Constant spindle RPM (cancel CSS) | G97 |
— | G97 |
G97 |
G97 |
G97 |
Centroid: partial Mach3: partial |
| Synchronous threading (constant pitch) | G33 |
— | G33 |
G33 |
— | — | Centroid: optional |
| Finishing turning cycle | — | — | G70 |
G70 |
— | G70 |
Uses a profile defined by G71/G72. Centroid: T-series only Mach4: partial |
| Stock-removal turning (roughing) | — | — | G71 / G72 |
G71 / G72 |
— | G71 / G72 |
G71 longitudinal, G72 facing. FANUC: Type I or Type II syntax. Centroid: T-series only Mach4: partial |
| Face grooving (FANUC lathe G74) | — | — | G74 |
G74 |
— | — | Same G74 that means left-hand tapping on a mill. Centroid: T-series |
| Threading cycle (FANUC lathe G76) | G76 |
— | G76 |
G76 |
— | — | Same G76 that means fine boring on a mill. Type I (single-block) or Type II (P/Q/R). LinuxCNC: lathe Centroid: T-series |
| Feed per minute (FANUC lathe) | — | — | — | G98 |
— | — | On a FANUC LATHE, G98 means feed/min — the role G94 plays on the mill. FANUC: lathe only |
| Feed per revolution (FANUC lathe) | — | — | — | G99 |
— | — | On a FANUC LATHE, G99 means feed/rev — the role G95 plays on the mill. FANUC: lathe only |
Canned-cycle return mode (mill)
| Operation | LinuxCNC | GRBL | Centroid | FANUC | Mach3 | Mach4 | Notes |
|---|---|---|---|---|---|---|---|
| Return to initial Z after a cycle | G98 |
— | G98 |
G98 |
G98 |
G98 |
FANUC LATHE reassigns G98 to feed-per-minute — see the Turning group and false friends. |
| Return to R-plane after a cycle | G99 |
— | G99 |
G99 |
G99 |
G99 |
FANUC LATHE reassigns G99 to feed-per-revolution. |
#False friends — same number, different meaning
The operation tables above already handle the "different code, same job" case — each row lists every control's spelling, so you can't miss it. This section is about the opposite and more dangerous case: the same number does fundamentally different things on different controls or modes. A program that runs cleanly on one will produce wrong output — or crash — on another.
If you're porting G-code between platforms, this is the section to read twice.
#M100 / M101 — PLC-bit wait vs user-script slot
A FANUC-trained operator and a Centroid-trained operator will write
M100 for two completely incompatible reasons.
| Control | M100 | M101 |
|---|---|---|
| Centroid CNC12 | Pause program until referenced PLC bit / input is open (off / 0). Pair with M101. Custom prompt via cncxmsg.txt |
Pause until PLC bit is closed (on / 1) |
| LinuxCNC | Runs external user-script file named M100 from config dir (the whole M100–M199 range is reserved this way) |
Runs user-script M101 |
| FANUC | Not assigned in the standard. Typically machine-builder-defined via PMC ladder | Same |
| Mach 3 | Free slot — runs M100.M1S VBScript macro if present, otherwise undefined |
Same for M101.M1S |
| Mach 4 | Free slot — runs M100.mcs Lua macro if present, otherwise undefined |
Same for M101.mcs |
| GRBL | Not supported | Not supported |
Portability impact: A Centroid program using M100 /5000 to wait on
a vacuum-ready PLC signal will, on LinuxCNC, try to execute an external
script literally named M100 — completely different runtime. On a stock
Mach3 install with no M100.M1S written, the same line silently does
nothing. Always rewrite explicit PLC waits when moving between controls.
#G98 / G99 — canned-cycle return (mill) vs feed mode (FANUC lathe)
The single biggest mill-vs-lathe trap on FANUC.
| Control / mode | G98 | G99 |
|---|---|---|
| FANUC mill | Canned-cycle return to initial Z | Canned-cycle return to R-plane |
| FANUC lathe (T-series) | Feed per minute (the role G94 plays on the mill) | Feed per revolution (the role G95 plays on the mill) |
| LinuxCNC (mill or lathe) | Canned-cycle return to initial Z | Canned-cycle return to R-plane |
| Centroid CNC12 (mill) | Canned-cycle return to initial Z | Canned-cycle return to R-plane |
| Mach 3 / Mach 4 | Canned-cycle return to initial Z | Canned-cycle return to R-plane |
Portability impact: A FANUC T-series lathe program that sets G98
expecting feed-per-minute will, on every other platform here, be parsed
as a canned-cycle return-mode change. The lathe-feed-mode interpretation
is FANUC-T-series-exclusive.
#G50 — three completely different meanings depending on platform/mode
| Control / mode | G50 |
|---|---|
| FANUC mill | Scaling OFF (cancels G51) |
| FANUC lathe | Two distinct sub-uses on the same control: G50 X_ Z_ sets work-coord origin; G50 S_____ clamps maximum spindle RPM under G96 CSS mode |
| Mach 3 / Mach 4 | Scaling OFF (mill) |
| LinuxCNC | Not implemented (LinuxCNC does not support FANUC-style G50/G51 scaling) |
| Centroid CNC12 mill | Partial scaling-off support; varies across CNC12 versions |
| Centroid CNC12 lathe (T-series) | Follows FANUC lathe convention |
| GRBL | Not supported |
Portability impact: A FANUC lathe program that issues G50 S3000 to
cap a CSS-driven spindle will be a no-op or error on mill controls,
because the mill-side G50 takes no S word.
#G74 — counter-tapping (mill) vs face grooving (FANUC lathe)
| Control / mode | G74 |
|---|---|
| FANUC mill | Left-hand (counter) tapping canned cycle |
| FANUC lathe | Face grooving / peck face turning cycle |
| LinuxCNC | Left-hand tapping (mill) |
| Centroid CNC12 mill | Left-hand tapping |
| Centroid CNC12 lathe (T-series) | Face grooving |
| Mach 3 / Mach 4 | Left-hand tapping (mill) |
| GRBL | Not supported |
Portability impact: Same code, same control vendor (FANUC), totally different machining operation depending on whether the control is a mill or a lathe. Posts targeting a lathe always assume the FANUC lathe meaning.
#G76 — fine boring (mill) vs threading (FANUC lathe)
| Control / mode | G76 |
|---|---|
| FANUC mill | Fine boring cycle (oriented spindle stop at bottom, retract by shift amount to avoid scoring the wall) |
| FANUC lathe | Multi-pass threading cycle — Type I (older single-block syntax) or Type II (modern multi-block P_ Q_ R_ syntax). The block layout is completely different from the mill version |
| LinuxCNC mill | Not supported |
| LinuxCNC lathe | Threading cycle |
| Centroid CNC12 mill | Partial — verify against the specific control version |
| Centroid CNC12 lathe (T-series) | Threading cycle |
| Mach 3 / Mach 4 mill | Fine boring |
| GRBL | Not supported |
Portability impact: A lathe-threading G76 block has a completely different argument list than a mill-boring G76 block. They are not interchangeable.
#G5 / G5.1 / G5.4 — different high-speed look-ahead implementations
| Control | G5 family |
|---|---|
| FANUC | G05.1 Q1 = AI contour control on; G05.1 Q0 = off. Some 30i-B variants use G05.4. Older controls use G05 (no decimal) or G08 P1 for the same look-ahead/acceleration smoothing |
| LinuxCNC | G5 (no decimal) = cubic spline interpolation — a totally different operation, not a HSM look-ahead toggle |
| Centroid / Mach 3 / Mach 4 / GRBL | Not supported |
Portability impact: Same number, completely different math. A
LinuxCNC G5 block defines a spline curve through control points; a
FANUC G05 toggles a look-ahead acceleration mode. Output is unrelated.
#Quick differences cheat sheet
GRBL intentionally omits canned cycles, cutter comp, polar coords, scaling, rotation, macros, and subprograms. CAM posts targeting GRBL expand cycles into raw G01 moves and skip G41/G42 entirely.
FANUC is the lineage everyone else copies, but it's where most divergence happens at the high end. The single biggest cross-control trap: G98/G99 are canned-cycle return modes on the mill, but feed-mode modes on the lathe. G50, G70–G76 also reassign on lathe. High-speed machining options (G05.1, G05.4, G08, G64 tuning) vary by controller generation and machine builder.
LinuxCNC is closest to a clean superset of standard RS-274/NGC. It adds first-class probing variants (G38.2–G38.5), digital/analog HAL I/O M-codes (M62–M68), user-defined M100–M199 scripts, and uses O-codes for subroutines rather than FANUC-style M98/M99.
Centroid (CNC12) is mostly FANUC-compatible for the canonical drill,
bore, and macro codes. Macro programming uses #-variables with
IF/THEN/ELSE and block-number GOTO branching — it does not
have WHILE/DO loops. Probing is done with M-codes (M105/M106,
M115/M116/M125/M126), not G31/G38. Extended work offsets use
G54 Pn (no decimal), not G59.1+ or G54.1. G70–G76 lathe cycles only
apply on T-series. The canonical mill canned-cycle set is G81–G85 + G89;
G86/G87/G88 back-bore and modal-macro G66/G67 are not in the CNC12 manual.
Mach 3 is the lowest-feature commercial control here — no G65 macros
(custom M-codes are VBScript .M1S files instead), no polar coordinates,
no extended fixture offsets beyond G59.3, no G31 multi-probe. M62–M66
typically need OEM scripts rather than working natively. Subroutines via
M98/M99 work.
Mach 4 is a substantial superset of Mach 3: adds G65 macros (with
.nc macro-file extension required), G54.1 P1–P248 extended fixtures,
G31.0–G31.3 multi-probe, G12/G13 full-circle, polar coords, G84.2/G84.3
rigid tap, G40.1/G40.2 cutter-comp corner styles, native M62–M68 I/O,
and an M200–M228 family. Lua replaces VBScript for custom M-codes —
Mach3 macros do not port directly.
#How this app handles non-supported codes
G54.APP's parser is permissive — unrecognized G or M codes are kept
verbatim in the source and just don't affect the visualization. So a
file written for FANUC with G68 rotation or M98 subprogram calls
will render the linear/arc moves it does understand and silently skip
the rest. Always sanity-check the simulation against the target control's
expected behavior before cutting.
#Sources
These are the public references consulted while building this chart. Vendor manuals (FANUC, Centroid) ship with the controller and may not be publicly archived; where a vendor PDF was used, the URL is the one that served at the time of writing.
LinuxCNC (free, online):
- G-code quick reference — https://linuxcnc.org/docs/html/gcode/g-code.html
- M-code quick reference — https://linuxcnc.org/docs/html/gcode/m-code.html
- Main user manual — https://linuxcnc.org/docs/
GRBL 1.1 (open source):
- Supported commands wiki — https://github.com/gnea/grbl/wiki/Grbl-v1.1-Commands
commands.mdsource-of-truth — https://github.com/gnea/grbl/blob/master/doc/markdown/commands.md
Centroid CNC12 (vendor PDFs):
- Macro Programming guide — https://www.centroidcnc.com/centroid_diy/downloads/acorn_documentation/centroid_cnc_macro_programming.pdf
- M-Series (Oak / Allin1DC) Operator's Manual v4.14 — https://www.centroidcnc.com/centroid_diy/downloads/CNC12-v414_operator_manuals/centroid-cnc12-oak-allin1dc-mill-operator-manual-v4.14.pdf
- v3.16 Mill Operator Manual — https://www.centroidcnc.com/downloads/centroid_v3.16_mill_operator_manual.pdf
- G and M codes extract — https://www.centroidcnc.com/centroid_diy/downloads/centroid_G_and_M_codes.pdf
- PLC + CNC Functions Programming Manual (CNC12 v5.x+) — https://www.centroidcnc.com/centroid_diy/downloads/centroid_plc_programming_manual.pdf
- Helman CNC mirror of Centroid Mill M-code list — https://www.helmancnc.com/centroid-m-code-cnc-mill/
- Centroid forum post on G10 P/R parameter-setting form — https://centroidcncforum.com/viewtopic.php?t=3429
FANUC (third-party aggregators of vendor manuals; vendor PDFs are generally not freely hosted):
- FanucWorld "Ultimate M-Code & G-Code List for Fanuc Controls" — https://content.fanucworld.com/m-code-g-code-list/
- REACO CNC FANUC Machining Center G/M codes — https://reacocnc.com/blogs/fanuc-g-code-m-code-list/g-code-m-code-machining-center
- REACO CNC FANUC CNC Lathe G/M codes — https://reacocnc.com/blogs/fanuc-g-code-m-code-list/g-code-m-code-lathe
- Helman CNC "Fanuc 31i G Codes Machining Center" — https://www.helmancnc.com/fanuc-31i-g-codes-machining-center-fanuc-30i-31i-32i/
- Cross-checked against: FANUC Series 0i-MD Operator's Manual, FANUC Series 30i/31i/32i-MODEL B Operator's Manual, FANUC Macro Compiler / Macro Executor Programming Manual (titles only — these are not openly hosted)
Mach 3 (ArtSoft / MachMotion):
- MachMotion "G and M-code Reference Using Mach3Mill Rev 1.84-A2" — https://machmotion.com/documentation/Software/Mach3/Mach3%20GCode%20Language%20Reference.pdf
- Mach3 G-Code Manual (MachMotion) — https://machmotion.com/documentation/Software/Mach3/Mach3%20G-Code%20Manual.pdf
- Mach3 V3.x Macro Programmer's Reference (ArtSoft) — https://www.machsupport.com/wp-content/uploads/2013/02/Mach3_V3.x_Macro_Prog_Ref.pdf
- Helman CNC "Mach3 Mill G Code List" — https://www.helmancnc.com/mach3-mill-g-code-list/
- CNCCookbook on Mach3 + G65 — https://www.cnccookbook.com/m98-m99-g-code-cnc-subprograms/
Mach 4 (ArtSoft / MachMotion):
- Mach4 Mill GCode Manual v1.0 (ArtSoft) — https://www.machsupport.com/wp-content/uploads/2014/05/Mach4%20Mill%20GCode%20Manual.pdf
- MachMotion Mach4 G & M Code Reference Manual — https://machmotion.com/documentation/Software/Mach4/Mach4-G-and-M-Code-Reference-Manual.pdf
- MachMotion BookStack Mach4 G/M Code Reference — https://support.machmotion.com/books/software/page/mach4-g-code-and-m-code-reference
- Mach4 Lathe Programming Guide — https://www.machsupport.com/wp-content/uploads/2014/05/Mach4%20Lathe%20GCode%20Manual.pdf
- Warp9 Mach3 vs Mach4 FAQ — https://www.warp9td.com/index.php/faq/faq-g-code-m-code
#Known unverifiable / uncertain entries
- FANUC G05.4 nano smoothing — present on some 30i-B variants, not universal across the 30i family.