Free cookie consent management tool by TermsFeed G28 G-Code - the go home command for Gcode
Reference return

G28 G-Code

The above video lesson is part of a CNC Milling machine programming course available here

What is G28 G-Code?

The G-Code G28 is used to zero return the tool to its zero position via a reference point at rapid speed. A basic example of this line would look something like this:

G28 G91 X0 Y0 Z0;

Just stating G28; with no axis or axis set to zero as the above line would return all axis to the home position in a linear rapid move.

the G28 zero return g-code can be used to return one axis or multiple. The block G28 G91 Z0.0; would return the Z-axis to its reference position while G28 G91 X0.0 Y0.0 Z0.0; would return the 3 Axis X, Y and Z. If we add a value to one or more of the axis like this:

G28 G91 X0 Y0 Z20.0;

The machine would read this as go to the intermediate position of 20mm above the tool in Z before going to the reference position. We can use this to avoid obstacles inside the machine when moving the tool back to the home reference position as demonstrated by the image above.

Lets look at the line

G28 G91 X100.0 Y50.0 Z20.0;

In this example the tool would first travel to X100.0 Y50.0 and Z20.0 and then move to the home position.

G28 G-Code

Important note:

Machines will require a G91 command in the G28 line. The G91 switches the machine to incremental positioning If this code is omitted the machine will first move to the zero position defined by your datum. In other words, it will plough the cutter into the part before returning to the reference point.

Care must be taken to avoid a crash, as always, when running a new block of code, use single block with feed rate and rapid override on Zero, then control the speed of the cutter/tool with the override control to ensure everything is travelling in the expected direction.

Keeping an eye on the 'distance to go' readout will tell you how far you have left of travel during that block of code.

With that in mind, it is safer to move the Z axis first.

Depending on the version of your FANUC control, we can also program using U, V and W. This is another way to write incremental movements and is normally used on a CNC Lathe.

An example of this would be G28 W0.0; Executing this line would return the tool to Z0.0 reference position.

Alternative method.

There is also another way we can return to the reference point, by using G53. A G53 reference return line would look like this:

G53 Z0.0;

The G53 g-code calls the machine datum which is usually thie tool change position or machine home. The above line of code tells the machine to use the machine datum, the one that we can not change without going into the parameters (Not advisable). For more on using the G53 check out the article Here

The G-Code G28.1

Using the g-code command of G28.1 will reference all axis to the home position.

It behaves like the 'Reference all' button on some CNC controls.

As with all CNC machine advice, It is good practice to check the machine manual to see how your exact machine handles the G28 command. For example, the above G28.1 g-code is often used on MACH 3 controllers and Using U, V and W as incremental moves is more often found on CNC lathes.

Share this article

For a complete tutorial on CNC mill Programming check out my course.

The quickest way to learn CNC Programming