G28.2 on CNC: Defining Temporary Reference Positions (Not Returning Home)
In CNC machining, you’re likely familiar with G28
(return to reference point – home position) and possibly G30
(return to a secondary reference point). The G28.2
G-code, however, serves a fundamentally different purpose: it allows you to define a temporary, programmable reference point within your part program. **It does not command any movement.**This is a crucial distinction.
This article clarifies the precise function of G28.2
, explains how it differs from G28
and G30
, and provides practical examples for its use on CNC lathes and machining centers. We’ll focus primarily on Fanuc and compatible controls, as the availability and implementation of G28.2
can be control-specific.
Crucial Note: Before using any G-code, always consult the programming manuals for your specific CNC control system and machine tool. Never assume a G-code’s function without verification.
1. Understanding Reference Points: Permanent vs. Temporary
Before diving into G28.2
, let’s clarify the different types of reference points in CNC:
- Machine Reference Point (Home Position): This is a fixed, permanent location determined by the machine tool builder (MTB). It’s the origin of the machine coordinate system. You typically home the machine (move it to this point) on startup.
G28
(usually withG91
) is used to return to this point. - Secondary Reference Points (2nd, 3rd, 4th): Some machines have additional, fixed reference points (often used for tool changes or pallet changes). These are also set by the MTB or a technician, and
G30
is used to return to them. - Work Offsets (G54-G59, etc.): These define the part zero (the origin of your part program) relative to the machine zero. You use these to tell the machine where your workpiece is located.
- Temporary Reference Points (G28.2): These are temporary points that you define within your part program, relative to the active work offset. They are not permanent and are not related to the machine’s home position.
2. G28.2: Defining a Temporary Reference Point
The G28.2
command defines a temporary reference point. It does not move the machine. You specify the location of this temporary point using axis words (X
, Y
, Z
, etc.), and these coordinates are interpreted relative to the currently active work offset (G54
-G59
, etc.).
Syntax (Fanuc and Similar Controls):
G28.2 X... Y... Z... A... B... C... ;
G28.2
: The command to define a temporary reference point.X...
,Y...
,Z...
,A...
,B...
,C...
: The coordinates of the temporary reference point, expressed in the active work coordinate system.
Example:
If G54
is active, and you execute:
G28.2 X10.0 Y20.0 Z5.0;
You are defining a temporary reference point at X=10.0, Y=20.0, Z=5.0 relative to the origin defined by G54. The machine does not move.
3. How to Use the Temporary Reference Point (G91 G28)
The primary purpose of defining a temporary reference point with G28.2
is to provide a convenient location to return to later in the program, without having to calculate absolute machine coordinates. You do this using G28
(the reference point return command) in incremental mode (G91
):
G91 G28 X0 Y0 Z0 ; Return to the *temporary* reference point defined by G28.2
Important:
- You must use
G91
(incremental mode) withG28
to return to theG28.2
-defined point. - The
X0 Y0 Z0
(orU0 W0
on a lathe) are incremental distances of zero. This is what tells the machine to go to the reference point (either the primary reference point if noG28.2
has been executed recently, or the temporary one ifG28.2
was used).
4. Applications and Examples (Lathes and Mills)
The main benefit of G28.2
is simplifying programming and potentially reducing rapid traverse distances in complex programs.
Example 1: Machining Multiple Sides of a Part (Mill with 4th Axis)
This example demonstrates using a 4th axis (A-axis) to rotate the part, and using G28.2 to set a temporary reference point.
; Assume G54 is the work offset for the first side.
G54 ; Select work offset for side 1
; ... (Machining operations on side 1) ...
G28.2 X50.0 Y0 Z0 ; Define a temporary reference point for side 1
; (50mm in X from the G54 origin)
G91 G28 X0 Y0 Z0 A0; Return to *temporary* reference point (side 1)
G00 A90.0 ; Rotate the part 90 degrees (to side 2)
; Now, WITHOUT changing the work offset, define a NEW temporary ref point
; relative to the SAME G54 origin, but for the rotated part:
G28.2 X50.0 Y0 Z0; ; Define temporary ref point for side 2 (still relative to G54!)
G91 G28 X0 Y0 Z0 A0; Return to *temporary* reference point (side 2)
; ... (Machining operations on side 2) ...
G00 A180.0; Rotate to Side 3
G28.2 X50.0 Y0 Z0; ; Define temporary ref point for side 3
G91 G28 X0 Y0 Z0 A0; Return to Temp Ref
;... (Machining operations on side 3)...
; (And so on for other sides)
G91 G28 X0 Y0 Z0 A0; Return to *machine* home (after canceling any G28.2 points)
M30;
Explanation:
G54
is the main work offset.G28.2
defines a temporary reference point relative to G54 for each side.G91 G28 X0 Y0 Z0
returns to the most recentG28.2
point.- We can define new temporary points for each rotated position, without changing the work offset.
Example 2: Minimizing Rapid Traverse (Mill or Lathe)
; ... (Setup, tool selection, etc.) ...
G00 X10.0 Y10.0 Z5.0 ; Move to a position near the first group of features
G28.2 X10.0 Y10.0 Z5.0 ; Define a temporary reference point
; --- Machining operations in this area ---
; ... (Use G91 G28 X0 Y0 Z0 to return to the temporary reference point
; between operations, instead of going all the way home) ...
G91 G28 X0 Y0 Z0;
; ... (More operations in this area) ...
G91 G28 X0 Y0 Z0;
; ...
; --- Move to a different area of the part ---
G00 X100.0 Y50.0 Z5.0 ; Rapid to a new area
G28.2 X100.0 Y50.0 Z5.0 ; Define a *new* temporary reference point
; --- Machining operations in the new area ---
; ... (Use G91 G28 X0 Y0 Z0 to return to the *new* temporary reference point) ...
; --- Finish ---
G91 G28 X0 Y0 Z0 ; Return to machine home (cancels any active G28.2)
M30;
Example 3: Using with a tool change:
G28.2 X50 Y0 Z100; Set Ref Point
; Do some work
T0101;
G91 G28 Z0; move home
M06; Tool change
G0 Z100;
; Do More Work
5. Control-Specific Variations
- Fanuc:
G28.2
for defining the temporary reference point, used withG91 G28
for returning to it, is the standard implementation on many Fanuc controls. - Siemens: Siemens controls may have similar functionality, but it’s unlikely to be called
G28.2
. Siemens uses a different system of reference points and coordinate transformations. Consult the Siemens documentation. - Haas: Haas controls might have similar functionality, but it’s likely named differently.
- Mazak: Refer to specific machine documentation.
- Mitsubishi: Refer to specific machine documentation.
- Other Controls: Always consult your documentation.
6. Troubleshooting
- Unexpected Movements:
- Confusing
G28.2
withG28
orG30
.G28.2
defines a point; it doesn’t move to it. - Using
G28
inG90
mode afterG28.2
without understanding the intermediate point behavior. UseG91 G28
to return to the temporary reference. - Incorrect work offset active when
G28.2
is executed. The temporary reference point is relative to the active work offset.
- Confusing
- Alarms: If
G28.2
is not supported, you’ll get a syntax error.
7. CAM Software
Most CAM systems do not directly use G28.2
in the generated G-code. CAM software manages reference positions through work offsets and fixture offsets, and generates direct G00
/G01
moves to achieve the desired positioning. A skilled CAM programmer might use G28.2
in very specific, controlled situations if they understand its behavior thoroughly and the post-processor is configured to support it, but this is uncommon.
8. Frequently Asked Questions (FAQ)
- Q: What’s the difference between G28.2, G28, and G30?
- A:
G28.2
defines a temporary reference point.G28
moves the machine to the primary reference point (home).G30
moves the machine to a secondary, pre-defined reference point.
- A:
- Q: Can I use G28.2 to redefine the machine’s home position?
- A: No.
G28.2
defines a temporary reference point relative to the current work offset. It does not change the machine’s permanent home position.
- A: No.
- Q: Is G28.2 a standard G-code?
- A: It’s relatively standard on Fanuc and compatible controls, but always check your manual.
- Q: When should I use G28.2?
- A: When you need to define a temporary, programmable reference point within your part program, relative to your work offset, for convenience or to optimize toolpaths.
9. Conclusion
The G28.2
G-code is a specialized command for defining a temporary reference point within a CNC program, primarily on Fanuc and compatible controls. It is not a return-to-home command; G28
and G30
perform that function. Understanding the critical difference between defining a point (G28.2
) and moving to a point (G28
, G30
), and knowing how to use G28.2
in conjunction with G91
and G28
, is essential for correct usage. While G28.2
can be useful in specific situations, for most common programming tasks, relying on standard work offsets (G54
-G59
) and G28
(with G91
) for homing is the recommended approach. Always consult your machine’s documentation for the definitive guide to its G-code implementation.