G28 sends the machine to its stored reference position — for most
machines, home. G30 does exactly the same thing to a second stored
position (commonly the tool-change spot). Both look trivial and both hide
the same trap: the block's axis words are not a destination. They're an
intermediate point the machine visits on the way.
G28 ; all axes straight to the reference position
G28 Z0 ; first move to work Z0 (!), THEN home Z
G91 G28 Z0 ; the safe idiom: zero-length incremental move, then home Z
G90 ; ...and restore absolute mode immediately
That middle line is one of the most copied — and most misunderstood —
lines in CNC. In absolute mode, Z0 is work Z0. With a typical work
offset touched off at the part top, "go home via work Z0" means dropping
to the stock surface (or into a fixture) before retracting. The
G91 G28 Z0 idiom survives because it makes the intermediate hop a
zero-length move — but it leaves the control in incremental mode, which is
why the G90 chaser matters just as much.
#Why the intermediate point exists
The two-step move let 1980s programs route around fixtures with no machine-coordinate motion command: pull to a safe spot, then home. Modern practice has a cleaner tool for "go to a machine position":
G53 G0 Z0 ; machine Z0 (top of travel), no intermediate point
G53 G0 X-10 Y-500 ; park — explicit, absolute, no modal side effects
Where the post supports it, G53 moves are the recommended replacement
for G28 gymnastics — nothing modal changes and nothing is implied.
| 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. |
— means the control has no equivalent code. Full cross-control tables: the complete G-code & M-code reference.
#Setting and checking the positions
G28.1/G30.1(LinuxCNC, GRBL, Mach) store the current position as the G28/G30 point — jog where you want it and run the code once.- FANUC / Centroid fix the reference by homing or machine parameter; programs can't move it.
G27(FANUC) checks that the program has the machine at the reference and alarms if not — a pre-shift sanity test in high-volume work.G29returns from the reference through the same intermediate point; it exists for symmetry and almost never appears in real files.
#Common mistakes
G28 Z0in absolute mode. The classic. It reads as "home Z" and executes as "plunge to work Z0, then home Z." UseG91 G28 Z0 G90, or better,G53 G0 Z0.- Forgetting the G90 after the idiom. The next program (or MDI command) inherits G91 and every move becomes a delta. Pair them mechanically.
- Assuming G28 is where you left it (GRBL/Mach). G28.1 stores wherever the machine sat when someone last ran it. If another operator moved it, your "safe" retract isn't. Machine-coordinate moves don't have this failure mode.
- Homing through the part. Bare
G28moves all axes simultaneously — from below a fixture plate, X/Y motion at cutting height can hit it. Retract Z first, then home the rest.