G-codeCoordinate SystemMill · Lathe · 3D printer

G27, G28, G29 & G30: Reference Point Return

G28 sends an axis to machine home, the fixed position the machine finds when it references, and it gets there in two moves: first to an intermediate point you give it, then home. G30 does the same thing to a second reference point, which on most machines is the tool change height. G29 is the way back out, from home through the point the last G28 used to a position you name. G27 moves to a position and alarms if that position turns out not to be the reference point, so it checks rather than retracts. On Marlin printer firmware the same numbers mean homing, bed levelling, probing and parking, which the table below sets out.

Syntax

G28 X__ Y__ Z__      Home, via the intermediate point X, Y, Z
G91 G28 Z0.          Home Z with no intermediate move, the usual safe retract
G30 X__ Y__ Z__      2nd reference point, via the intermediate point
G29 X__ Y__ Z__      Out from the reference point, through the stored intermediate point
G27 X__ Y__ Z__      Position, then alarm if the axis is not at the reference point

Parameters

AddressMeaningNotes
X Y Z on G28 and G30Intermediate pointMeasured from part zero under G90, from where the tool stands under G91. Only the axes you name move
X Y Z on G29Final positionThe path runs from the reference point, through the point the last G28 used, then here
X Y Z on G27Position to checkReached first, then compared against the reference point

Nothing in the block says where home is. The reference points are machine data, set when the machine is commissioned and read from parameters at run time, so the same lines put the spindle in a different place on a different machine.

Example

O0006 (SLOTTED COVER, 20MM 6082 PLATE)
G21 G17 G40 G49 G80 G90          (safe start block)
T04 M06                          (16mm three flute cutter)
G54                              (part zero at the left end of the plate)
S4500 M03                        (226m/min in aluminium)
G00 X-20. Y12.                   (clear of the plate, left of the slot)
G43 H04 Z30. M08                 (tool length comp on, flood coolant)
G01 Z-5.8 F600                   (roughing depth, 0.2mm on the floor)
X160. F1400                      (through the slot in one pass)
G00 Z30. M09                     (clear of the strap clamp)
G49                              (comp off before any reference move)
G91 G28 Z0.                      (Z alone to machine home, X and Y stay put)
G90 G28 X-20. Y200.              (out past the fixture, then X and Y home)
M05
M00                              (first off, operator checks the slot depth)
S4500 M03
G29 X-20. Y12.                   (back in through X-20. Y200. to the slot start)
G43 H04 Z30. M08
G01 Z-6. F600                    (finish pass on the floor)
X160. F1400
G00 Z30. M09
G49
G91 G30 Z0.                      (Z to the 2nd reference point, the tool change height)
M30

Controller differences

ControlBehaviour
FanucThe intermediate point is read in whichever of G90 or G91 is live, which is the whole reason G91 G28 Z0. is written the way it is: zero distance to the intermediate point, then straight home. The 2nd reference point is parameter 1241 and the 3rd is 1242, and with 1241 left at zero G30 goes to the same place as G28. A failed G27 check raises alarm 092, axes not on the reference point.
HaasA G28 block with no axis word sends every axis to machine zero, so the word you leave off changes the move. The Home G28 key on the Zero Return line of the panel is a separate thing: on a mill it takes Z home first and then X and Y, and with an axis letter typed in first it homes that axis alone.
SiemensThe native language approaches the reference point with G74 X1=0 Y1=0 Z1=0 and a fixed point, the job G30 does, with G75 FP=2 X1=0 Y1=0. Each needs a block of its own and the machine axis names; the values after them are ignored but have to be written. FP picks fixed point 1 to 4 from machine data MD30600, and fixed point 1 when FP is left off. In Fanuc dialect G74 is counter tapping, so the same three characters do different jobs.
GrblG28 and G30 do not home anything. They rapid to a position stored beforehand with G28.1 or G30.1 and held in EEPROM, while homing is the $H cycle and nothing else. G27 and G29 are not in the supported list and stop the stream with error:20.
MarlinAll four numbers mean something else. G28 homes to the endstops with no intermediate point, all axes when no letter is given and G28 X Z for X and Z alone. G29 is bed levelling and needs a G28 first, G30 probes a single Z point and G27 parks the nozzle at a set position.

What goes wrong

G28 Z0. with the G91 left off drives Z down before it ever goes up. Under G90 that Z0. is the intermediate point, so Z rapids down to the top of the job in the live work offset before it turns round for home. Write G91 G28 Z0.: zero distance to the intermediate point, then straight up.

G28 X0. Y0. in G90 does the same thing sideways. Those two words set the intermediate point at part zero, so the cutter rapids to the corner of the job at whatever height it stands, through a strap clamp if one is in the way, and only then heads home. Retract Z on its own line first, then send X and Y.

Third is G30 landing somewhere else on the machine next door. The second reference point is machine data, parameter 1241 on a Fanuc, set by whoever commissioned that spindle, and with 1241 at zero G30 goes to the same place as G28. A program that changes tools clear of a tall vice on one machine swings the spindle into it on another.

On a Haas the panel key teaches the wrong lesson. Home G28 on the pendant takes Z up before X and Y move, but that order is documented for the key, not for a G28 block, so in a program give Z a block of its own before any other axis heads home.

Grbl runs no homing cycle on G28. It rapids to whatever was last stored with G28.1, and homing against the switches is $H and only $H.

Last, printer firmware. On Marlin G29 is bed levelling and G30 a single probe, so a mill program's G29 sent to a converted printer starts probing instead of moving out.

Updated 28 Oct 2026