What is G28 G-Code? Function, Syntax & Example
G28 is an important reference command in CNC machines. It returns the machine to its Home Reference Point. When a program finishes or a tool change is required, the G28 command moves all or selected axes (X, Y, Z) back to their original safe position. Operators also call this process a “zero return.”
What is G28?
The G28 command is used at the beginning and end of the program to safely move the tool away. When we simply write G28, the machine moves to the home position, but often the axes (X, Y, Z) are also given with it.
If you type G28 X10 Y10, the machine will first go to these specific coordinates and then return to the home position from there. The tool will return to the home position without any obstacles or collisions with the workpiece.
G28 command at the beginning and end of the program to safely move the tool away from the work area and make it easier for the operator to start a new job.
G28 G-Code Example
G01 Z-0.5 F10.
G00 Z1.0
G91 G28 Z0.
G91 G28 X0. Y0.
G90
M30
G91 G28 Z0
G91 tells the machine to move 0 distance from the current position and then move to the home position on the Z-axis. If you were to use G90 here, the tool would first drop to Z0 (surface) of the workpiece and then move to home, which would risk breaking the tool.
G91 G28 X0. Y0
This command sends the machine to the home position in the X and Y axes.
G90
This is a very important line! It puts the machine back in Absolute Mode so that the next program or next operation is not accidentally started in Incremental Mode.
M30
Terminates the program and moves the cursor back to Start.
