What G28 means
A 3D printer normally starts without a trusted physical position. Marlin uses G28 to move the requested axes toward their endstops and establish machine coordinates. With no axis letters, it generally homes every axis; listing X, Y or Z limits the request to those axes.
The same code is not semantically universal. LinuxCNC and Fanuc-style workflows can treat G28 as a rapid return to a predefined position, optionally through an intermediate point. Sending a printer-style assumption to a CNC machine can therefore create unexpected rapid motion. Always read the documentation for the controller that will execute the file.
Syntax and parameters
G28G28 X YG28 ZX / Y / ZAxis flags. In Marlin they request homing for the named axes and do not need numeric values.
OMarlin option to skip axes whose positions are already trusted, when supported.
RMarlin option to raise the nozzle before homing, when supported.
Practical examples
Home every printer axis
G28Common start-G-code form for a Marlin-based printer.
Home X and Y only
G28 X YLeaves Z unchanged on Marlin; axis-letter behavior must be checked on other controllers.
Firmware context
| System | Status | What changes |
|---|---|---|
| Marlin | Common | Homes all axes or the named axes using configured endstops and homing behavior. |
| Klipper | Common | Homes axes through the configured homing system; macros may redefine behavior. |
| RepRapFirmware | Check dialect | Homing behavior is driven by system macros and machine configuration. |
| CNC controllers | Check dialect | Often returns to a stored reference position and may use an intermediate move rather than probing endstops. |
What this viewer can show
For 3D-printing analysis the viewer resets the named axes to zero so later path measurements have a frame. It cannot simulate endstops, safe-Z moves, macros or CNC stored-reference behavior.
Common mistakes
- Homing causes real machine motion; confirm the path is clear before sending it manually.
- Bed-leveling state and safe-Z behavior after G28 depend on firmware configuration.
- Never assume a Marlin G28 explanation applies unchanged to a CNC controller.
Primary sources
This page is an original explanation, reviewed against the firmware documentation below. Always confirm commands against the firmware and configuration on the machine that will execute them.