What Is G28 in CNC? Reference Return Explained
G28 is a reference-return command used across CNC controls. How it actually moves the tool depends on the controller, the coordinate mode, and the axes you program — so the safe way to use it is to understand the path before you run it.
Haas-style reference return (illustrative)
; switch to incremental, zero-distance intermediate G91 G28 Z0. G90 ; restore absolute mode
At a glance
G28 is a CNC reference-return command that moves the specified axes to a machine reference position. Depending on the controller and the programmed coordinates, the motion may include an intermediate position before the reference return. G28 does not automatically guarantee a collision-free path — its behavior must be verified against the machine's programming manual and the actual setup.
What Does G28 Do in CNC Programming?
G28 is used to send one or more axes to a machine reference position — the position defined by the machine configuration, not a fixed point you assume from the part. To read a G28 move correctly, keep four ideas separate:
- Machine reference position — set by the machine builder and the axis configuration. It is not a fixed corner you can infer from the part model; the location is machine-defined.
- Machine coordinate system — the coordinate frame the control uses to describe machine axis positions.
- Work coordinate system — for example G54, the frame your program uses to describe the part. A reference return is a motion, not a command that clears or resets stored work offsets to zero.
- Intermediate point — on some controllers and with some programming, the axis passes through an intermediate position before reaching the reference position.
Calling G28 is a positioning action. It is not a precision result by itself, and it does not by itself prove a part will hold a specific tolerance.
How G28 Moves the Machine
The actual path depends on two things: which axes you address, and whether an intermediate move applies. When no axis is addressed, the control may return the relevant axes directly. When axes are addressed, those axes move toward the reference position, and on some controls the addressed coordinates act as an intermediate point before the return. The diagram below shows the relationships; the real motion must be confirmed in the machine manual.
G28 Examples With G90 and G91
The examples below are written in a Haas-style milling convention and are shown to explain the idea. They are not a program you can copy to every controller, machine axis layout, or fixture. Always check the machine manual and verify the motion by simulation or single-block run.
Recommended pattern — incremental zero-distance intermediate, then restore absolute mode:
In this Haas-style reading, G91 makes the intermediate point zero-distance, so the Z axis returns to the reference position without first translating to a non-zero location in the current work coordinate system. Restoring G90 matters: if the program stays in incremental mode, the next blocks can be interpreted incorrectly.
Risk pattern — absolute coordinates as the intermediate:
With a work origin placed at or near the part or fixture, that first move toward X0 Y0 Z0 can travel through the part, clamps, or other obstacles before the return begins. This is exactly why the path — not just the endpoint — has to be checked.
Does G28 Work the Same on Every CNC Controller?
No single sentence covers every control. The table below states what the referenced documentation describes, and where it stops short of a universal claim.
| Control / system | Documented behavior | How this page treats it |
|---|---|---|
| Haas mill | With no axis address it can return the applicable axes to machine zero; addressing axes can involve an intermediate move, and G90/G91 change the motion meaning. | Used for the G90/G91 examples above. |
| Haas lathe | Supports X/Z and the U/W incremental addresses; G28 U0 W0 returns to machine zero in that lathe semantics. | Lathe syntax is treated separately from mill syntax. |
| LinuxCNC | G28 uses predefined reference-position parameters; an addressed move can also travel between a specified location and the stored position. | Shown as different from some Haas forms — not equated. |
| FANUC | G28 returns to the reference position; compensation and parameter details vary by version and machine builder. | No single compensation rule is applied across all FANUC machines. |
G28 vs. G29, G30, and G53
These codes are related but not interchangeable. The most common confusion is reading G28 as automatic collision avoidance and G53 as a one-command return to machine zero.
| Code | Primary purpose | Should not be read as |
|---|---|---|
| G28 | Return the addressed axes to the machine-defined reference position. | An automatic obstacle-avoiding path. |
| G29 | On supported controls, return from the reference position using the related intermediate logic. | An identical return path on every system. |
| G30 | Return to a second reference position where the control supports it. | The automatic tool-change position by definition. |
| G53 | For that block, position using the machine coordinate system; you still specify the target coordinates. | A zero-address command that returns to machine origin on its own. |
For more on the wider G-code set, see other CNC G-code commands and, when you first meet CNC, what CNC machining means.
Common G28 Programming Mistakes
| Mistake | Why it goes wrong | What to do instead |
|---|---|---|
| Wrong intermediate in absolute mode | The machine may first move to the addressed work-coordinate location. | State the coordinate meaning clearly and confirm the actual intermediate path. |
| Assuming G28 avoids collisions | The axis path can still cross the fixture, part, or structure. | Check the whole path and the motion envelope, not only the destination. |
| Forgetting to restore G90 | Following blocks may keep being read in incremental mode. | Restore the position mode in the example and verify the next block. |
| Treating all-axis return as default-safe | Simultaneous motion can interfere with the part, clamps, or machine structure. | Set the axis order from the machine structure and the operation's purpose. |
| Assuming G28 clears or keeps all compensation | Compensation is decided by the controller, parameters, and builder configuration. | Check the specific controller's tool length and radius compensation notes. |
| Calling G28 after an alarm or stop | The tool, workpiece, or axis state may not match the program's assumption. | Follow the manufacturer's recovery procedure; do not use G28 as emergency recovery. |
On tool length and radius offsets specifically, see the CNC H-code and tool length offsets guide.
G28 Safety Checklist Before Running a Program
- Check the manual. Read the G28 section for your exact controller and machine builder; do not assume another machine's behavior.
- Confirm the position mode. Know whether the move is interpreted in G90 (absolute) or G91 (incremental) and what the addressed coordinates mean.
- Simulate first. Run the program in simulation or single-block mode and watch the intermediate path, not only the endpoint.
- Confirm the machine travel. Verify the tool, holder, spindle nose, fixture, and rotary axes have clearance through the whole move.
- Verify compensation state. Check what happens to tool length and radius compensation on your control around the return.
- Do not use G28 as recovery. After an alarm, interruption, or collision, assess the actual state and follow the defined recovery procedure before any programmed return.
Frequently Asked Questions
What does G28 mean in CNC?
Is G28 modal or non-modal?
Why is G91 commonly used with G28?
Does G28 cancel G43 tool length compensation?
What is the difference between G28 and G53?
Does G28 reset G54?
Can G28 be used after an emergency stop or alarm?
Does G28 behave the same on CNC mills and lathes?
How do I verify a G28 move is safe before running the program?
What is the difference between G28 and G30?
Need a CNC partner who gets the details right?
G28 is one example of why process understanding matters on the shop floor. If you are sourcing machined parts, send us your drawing and we will review manufacturability, tolerances, and lead time against our in-house CNC, molding, and finishing capability.
Request a CNC Manufacturing ReviewXiamen Goldcattle Plastic & Metal Products Co., Ltd. — Founded in 1998. All six core processes performed in-house under one ISO 9001:2015 quality system.
Reviewed by Engineer Zhang, Senior Manufacturing Engineer at Xiamen Goldcattle Plastic & Metal Products Co., Ltd. This guide explains controller-specific behavior and does not predict the outcome for any specific machine setup; always verify against the machine programming manual. Founded in 1998.
