Digital Readout Kit for Mills, Lathes, & Grinding
Updated Published

Understanding G27, G28, G29 and G30

Take a closer look at these reference position commands.

Share

CNC Controller stock photo
Photo Credit: Getty Images

A few months ago I compared using the return to reference (zero return) position (G28) to the motion relative to the machine coordinate system command (G53). I received a few questions regarding other commands related to a machine’s reference position, and I’d like to explain them here.

In order to understand G27, G29 and G30, you must have a firm understanding of G28. This return to reference position is a two-step command. Indeed, if the single block switch is turned on, you must press the cycle start button twice to fully execute a G28 command.

For any axis letter addresses included in the G28 command, the machine first will move (at rapid) to an intermediate position in those axes. Then, it will rapid to the zero return position in the commanded axes. Consider this G28 command:

G91 G28 X1.0 Y2.0 Z1.5

First, the machine will simultaneously move 1.0 (plus) in X, 2.0 (plus) in Y and 1.5 (plus) in Z. This is the intermediate position. Next, all three axes will simultaneously move to the zero return position. A special light—the axis origin light—will be illuminated as each axis reaches the zero return position.

Since most programmers want the machine to go straight to the zero return position, they give this command:

G91 G28 X0 Y0 Z0

Now the intermediate position is nothing in each axis from the current position (incremental motion of zero in each axis), so the machine stays put during the first step of G28. In the second step, all three axes will simultaneously move to the zero return position for each axis.

G27 – Reference position (zero) return check

This command tests whether a positioning movement ends at the zero return position. Consider this command:

G27 G00 X9.5373

If the positioning movement ends with the X axis at its zero return position, the X axis origin light will be lit and the machine will continue. If not, an alarm will be sounded.

I don’t see much need for this command any more. Prior to fixture offsets on machining centers and geometry offsets on turning centers, G92 and G50 were used to assign program zero. With old machines made prior to about 1982, the machine had to be in its planned position in each axis before the cycle could be activated. Many programmers chose the zero return position as the planned starting point.

It was also often important to confirm that a positioning movement truly ended at the zero return position. Consider these commands:

G50 X8.3765 Z10.3776 (Assign program zero; machine is at zero return position)
T0101 (Index to station one, invoke offset one)
(Machine with this tool)
G00 G27 X8.3765 Z10.3776 T0100 (Move to turret index position)

In this example, G27 is being used to confirm that the machine truly ended up at the same position that it started (X and Z values match G50 command and tool offset was canceled).

G29 – Return from reference position

G29 is also a two-step command. First, it causes the machine to move (in the axes commanded) to the intermediate position used in the most recent G28 command. Second, it causes the machine to move to the position included in the G29 command. Consider this command:

G90 G29 X1.0 Y1.0

The machine will first simultaneously move in X and Y to the intermediate position of the most recent G28 command. Then it will simultaneously move to X1.0 and Y1.0 (relative to program zero).

While this could be helpful when you must avoid some kind of obstruction, you must be very careful when using G29. If the intermediate position changes from tool to tool, and if tools are run out of sequence (as is often necessary when rerunning tools), a tool may not move to its expected intermediate position. For this reason, I recommend programming any obstruction-clearing motions with basic positioning commands (G00, G01, etc.), and avoiding G29.

G30 – Return to second reference position

G30 is an optional feature and may not be included on your machines. It works much like G28, except the ending position is now definable through parameter settings. G30 is often used when a machine tool builder must define a special position in each axis, such as with pallet changers on machining centers. The zero return position may not make a good pallet-change position, so the builder may incorporate a second reference position for X and Y. Then, a G30 command is given when a pallet change is required:

G91 G30 X0 Y0

G30 is programmed just like G28. First, the machine moves to an intermediate position (zero from the current position in X and Y, in our case). Second, the machine rapids simultaneously in X and Y to the second reference position.

Again, the physical location for the second  reference position is set in parameters, so if you should ever need to incorporate a special reference position, you will be able to do so with G30.

High Accuracy Linear Encoders
World Machine Tool Survey
MMS Top Shops
Gardner Business Intelligence
To any Measurement Question there is an Answer
Kennametal
Norton Superabrasives Wheels  Paradigm Plus
Precision grinding & hard turning custom solutions
Koma Precision
Hurco
Paperless Parts
IMTS 2024

Related Content

6 Machine Shop Essentials to Stay Competitive

If you want to streamline production and be competitive in the industry, you will need far more than a standard three-axis CNC mill or two-axis CNC lathe and a few measuring tools.

Read More

Improving Workflows in Small Shops with Custom ERP

Small shops might not be ready for all of the functionality of an off-the-shelf ERP system, but modular, custom ERP programs can help improve workflow while providing the flexibility to change as shops grow.

Read More
CAD/CAM

Can ChatGPT Create Usable G-Code Programs?

Since its debut in late 2022, ChatGPT has been used in many situations, from writing stories to writing code, including G-code. But is it useful to shops? We asked a CAM expert for his thoughts.

Read More
Basics

5 G-Code Tips for Increasing CNC Efficiency

Optimizing G code is a low-cost way to improve CNC efficiency without sacrificing usability and safety.

Read More

Read Next

Large Part Machining

The Cut Scene: The Finer Details of Large-Format Machining

Small details and features can have an outsized impact on large parts, such as Barbco’s collapsible utility drill head.

Read More

3 Mistakes That Cause CNC Programs to Fail

Despite enhancements to manufacturing technology, there are still issues today that can cause programs to fail. These failures can cause lost time, scrapped parts, damaged machines and even injured operators.

Read More
CNC Turnkey Package for Knee Mills and Lathes