G28 is the code that sends the machine back to its reference position, the home point each axis finds when it homes. It sounds simple, but G28 does not go straight home: it travels through an intermediate point first, and that detail is what trips beginners up.

What G28 actually does

When the control reads G28, it moves in two stages:

  1. Rapid to an intermediate point that you specify in the same block.
  2. Continue from that point to the machine reference (home) position.

So G28 X0 Y0 does not mean go to X0 Y0. It means rapid to the intermediate point X0 Y0, then carry on to home. The intermediate point is read in whatever positioning mode is active, which is why the G90 vs G91 setting matters so much here. The behavior is documented in the LinuxCNC G-code reference and the standard reference-return guides.

The intermediate point is the catch

Because the intermediate point obeys the active mode, the same G28 line behaves differently depending on what came before it:

BlockActive modeWhat happens
G90 G28 Z0AbsoluteGoes to Z0 in work coordinates, then home (can plunge if Z0 is low)
G91 G28 Z0IncrementalNo move from current Z, then straight up to home (safe)
G28 X0 Y0AbsoluteThrough work X0 Y0, then home (can swing across the part)

The absolute version is risky: if your part zero sits low, G90 G28 Z0 drives the tool down to Z0 before going home. That is why the field-standard habit is the incremental form.

The safe pattern: G91 G28 Z0

The reliable way to clear the tool is to lift Z to home first, in incremental mode:

G91 G28 Z0   (lift straight to home in Z, no side move)
G28 X0 Y0    (then send X and Y home)
G90          (reset to absolute, always)

In G91, the Z0 means zero distance from where the tool is now, so there is no intermediate detour. The axis simply rises to the reference point. This is the move you almost always want before an M06 tool change so the tool is clear of the part and fixture. The one rule you cannot skip: reset to G90 afterward, because leaving G91 active will throw off every coordinate that follows.

Where you see G28

G28 shows up in two predictable places, which is why it belongs on any list of common G-codes for CNC beginners and is worth recognizing when you read a CNC program:

PlaceWhy
Before a tool changeGet the spindle clear and at home for the change
End of programPark the machine in a safe, known position for unloading

A related code, G30, returns to a secondary reference point instead of home, useful when a machine has a dedicated tool-change or load position. The G-code conventions treat both as reference returns that share the intermediate-point behavior.

Common mistakes with G28

Three errors cause most G28 surprises. First, leaving G91 active after the return, so the next absolute move lands in the wrong place; always follow with G90. Second, using the absolute form with a low part zero, which can plunge to the intermediate point before going home. Third, calling G28 with cutter compensation still on: cancel it with G40 first, because compensation through a reference return is undefined on many controls. None of these is hard to avoid once you know the move happens in two stages, not one.

For the full crash-postmortem version of what happens when the intermediate point is misread in G90 on a lathe, see why the Z axis dives toward the chuck on G28.

Bottom line

G28 returns an axis to the machine home, but it travels through an intermediate point first, read in the active mode. Use G91 G28 Z0 to lift straight to home in Z safely, then reset to G90. Avoid the absolute form unless you know exactly where the intermediate point lands.

Sources

Frequently asked questions

What does G28 do in CNC?

G28 returns the named axes to the machine reference (home) position. It rapids to an intermediate point you specify, then continues to home. It is used to park the machine safely, often before a tool change or at the end of a program.

Why is G28 usually written as G91 G28 Z0?

In incremental mode, Z0 means no movement from the current position, so the axis lifts straight up to home in Z with no sideways detour. Reset to G90 right after.

What is the difference between G28 and G30?

G28 returns to the primary machine reference (home). G30 returns to a secondary reference point stored in the control, selected with a P number on machines that support several.

What is the best way to memorize CNC codes like G28?

Drill them with active recall. A free app like G-Code Sprint quizzes G28 and the rest of the everyday codes as quick timed questions and repeats whichever ones you miss.

G-Code Sprint is a study and practice tool only. Always follow your instructor, employer, machine manual, and shop safety procedures.