Every CNC programmer eventually faces a deceptively simple question: should I send the machine home with G28 or park it at a secondary reference position with G30? On the surface, both commands accomplish the same basic task , they move axes to a predefined location. But beneath that simplicity lies a meaningful difference in how your machine behaves between cycles, how your automation interfaces with the control, and how much time you waste on non-cutting moves.
If you have ever watched a machine rapiding all the way to the home position after every part, only to travel back to the workpiece for the next cycle, you have already felt the cost of defaulting to G28 without considering G30. This post unpacks the mechanics of both commands, explains the hierarchy of reference positions on modern Fanuc and compatible controls, and gives you a practical framework for choosing the right one in production environments.
Understanding the Reference Position Hierarchy
Before comparing G28 and G30 directly, it helps to understand how a CNC control organizes its reference positions. Fanuc-based controls, which dominate the global installed base of machining centers and lathes, maintain a layered system of coordinate landmarks.
The Machine Reference Point (Machine Zero)
Every machine has an absolute, fixed reference point determined by its physical design. On a vertical machining center, this is typically at the positive limit of all axes. On a lathe, it usually sits at the turret’s maximum positive X and the spindle face in Z. The machine establishes this point during the homing cycle (G28 or manual reference return) by decelerating off the dogs on each axis.
This point never changes. It is the root of the machine coordinate system, and every position the control knows about ultimately traces back to it.
The First Reference Position G28
G28 sends the machine to the first reference position, which is almost always the machine reference point itself. When you execute:
G28 G91 Z0; The Z axis moves to its intermediate point (in this case, since the incremental distance is zero, it effectively goes directly), then continues to the machine home position. The same applies to any axis or combination of axes.
G28 is the most common reference return command in CNC programming. It is well understood, universally supported, and serves as the default “go home” command in the vast majority of posted programs.
The Second Reference Position G30
G30 sends the machine to the second reference position. This is a user-definable location that you set during machine setup, typically stored in a parameter or a work offset register. On most controls, you establish the second reference position by manually jogging the machine to the desired location and then writing those machine coordinates to the designated parameter.
The command syntax looks like this:
G30 G91 Z0; This behaves identically to G28 in structure, it passes through an intermediate point and then rapids to the second reference position. The difference is purely in the destination.
G30 P2, P3, and P4 Additional Reference Positions
Modern Fanuc controls extend the concept further. G30 can accept a P address to specify which secondary reference position you want:
- G30 P2 Second reference position (the standard G30 destination)
- G30 P3 Third reference position
- G30 P4 Fourth reference position
Each of these is independently configurable. This gives you up to three additional parking positions beyond the machine home, and each one can serve a different purpose in your process.
Not all machines support P3 and P4. Whether they are available depends on the control model and the options the machine tool builder enabled. Always verify with your parameter manual before relying on them in a production program.
G28 in Practice: Reliable but Inefficient
G28 is the command most programmers learn first, and for good reason. It is predictable, safe, and leaves no ambiguity about where the machine will end up. After a G28, you know that every axis is at its home position, clear of the work envelope, and ready for part loading or tool changes.
When G28 Makes Sense
There are legitimate scenarios where G28 is the right choice:
- Tool changes on machines without a dedicated tool-change position. Some machines perform tool changes at the machine reference point. If your spindle needs to be at home to engage the tool changer arm, G28 before M06 is not just convenient it is mandatory.
- Shutdown and setup procedures. When an operator needs to load a fixture, inspect a part, or perform any manual intervention, sending the machine home with G28 ensures maximum clearance and a known starting state.
- Initial program proving. During the first runs of a new program, G28 between operations provides a comfortable safety margin. You can watch the machine return to a known position, verify that nothing collides, and confirm your coordinate systems before letting the cycle run at full speed.
The Hidden Cost of G28 in Production
The problem with G28 is distance. On most machines, the home position is far from the work envelope. A vertical machining center with 1000 mm of X travel and 500 mm of Y travel might sit with its home position at X+1000, Y+500. If your part is centered on the table, every G28 call sends the table 500 mm in X and 250 mm in Y away from the part and then the next operation has to travel all the way back.
Over a full shift, this wasted motion adds up. Consider a simple scenario:
- Part cycle time: 3 minutes
- G28 travel time per cycle: 8 seconds (4 seconds out, 4 seconds back)
- Parts per shift (8 hours): 160
- Wasted time per shift: 160 × 8 = 1,280 seconds, or over 21 minutes
That is more than half a shift lost per week, and this is a conservative estimate. Complex parts with multiple operations, each returning home between them, can easily double or triple that figure.
G30 in Practice: Strategic Positioning
G30 solves the distance problem by letting you choose a parking position that is close to the work envelope but still safe for part loading, tool changes, or automation interaction.
Setting Up the Second Reference Position
The process for defining the second reference position varies by machine builder, but the general procedure is:
- Jog the machine to the desired parking location. This should be a position where the spindle is clear of the fixture, the table can be accessed for loading, and any automation (robot, pallet changer, bar feeder) can operate without interference.
- Record the machine coordinates displayed in the position display page.
- Enter those coordinates into the designated parameters. On Fanuc controls, these are typically parameters 1241–1246 (for G30 P2), though the exact numbers depend on your control model and axis count.
- Test the command in MDI mode. Execute
G30 G91 Z0;and verify that the machine moves to the expected position.
Some controls allow you to set the second reference position through a soft key on the position page, which writes the current position directly to the parameter. Check your operator manual for the specific procedure on your machine.
Practical Example: Pallet Changer Integration
A pallet changer is one of the clearest use cases for G30. Consider a horizontal machining center with a two-pallet changer. The pallet change position is fixed the machine must be at a specific location for the changer mechanism to engage.
If that position is not at the machine home (and it usually is not), G30 is the natural solution. Your program ends each cycle with:
G30 G91 Z0;
G30 G91 X0 Y0;
M00; (or pallet change M-code) The machine rapids to the second reference position which you have aligned with the pallet change location and the changer can operate. No wasted motion to the far corner of the travel, no unnecessary distance.
Practical Example: Robot Load/Unload
In automated cells with robotic part handling, the robot needs a consistent, repeatable location to access the spindle or the fixture. G30 gives you that location without forcing the machine to its home position.
A typical sequence might look like:
G30 G91 Z0; (raise spindle to safe Z)
G30 G91 X0 Y0; (move to robot access position)
M05; (spindle stop)
M09; (coolant off)
M00; (or robot interface signal) The robot grips the finished part, removes it, loads a new blank, and signals the control to continue. The machine never travels to home, saving several seconds per cycle seconds that directly translate to higher throughput.
G30 P3 and G30 P4: Multi-Station Strategies
If your control supports G30 P3 and G30 P4, you can define additional parking positions for specific purposes. A few strategies:
P3 for tool measurement. Some shops use a tool probe positioned in a fixed location on the table. G30 P3 can send the machine to the probe access position between tool measurement cycles, without conflicting with the pallet change position (G30 P2) or the home position (G28).
P4 for chip conveyor clearance. On machines where the chip conveyor is at one end of the table, G30 P4 can position the table to dump chips efficiently during a programmed pause, without relying on the operator to manually jog the axes.
Different positions for different fixtures. If you run multiple fixtures on the same table, each with a different optimal clearance position, G30 P2 and G30 P3 can serve each fixture independently.
G28 vs G30: Decision Framework
With the mechanics understood, how do you choose? Here is a practical framework:
Use G28 When:
- The machine requires home position for tool change
- You are proving a new program and want maximum clearance
- The operation involves manual intervention (setup, inspection, measurement)
- You are ending a shift and want the machine at a known rest position
- The second reference position has not been configured or verified
Use G30 When:
- The machine has a dedicated tool change position that is not at home
- You are integrating with a pallet changer, robot, or automation system
- Cycle time optimization matters (high-volume production)
- The work envelope is large and home is far from the part
- You have multiple operations per part and want to minimize non-cutting time between them
Use G30 P3/P4 When:
- You have more than one designated parking position
- Different operations require different clearance locations
- You are managing multiple automated processes on the same machine (probing, chip management, part handling)
Common Mistakes and How to Avoid Them
Forgetting the Intermediate Point
Both G28 and G30 use an intermediate point before the final destination. If you write:
G28 Z0; without specifying G90 or G91, the behavior depends on the current modal state. If G90 (absolute) is active, Z0 means the intermediate point is at Z0 in the work coordinate system which could be inside the part. Always be explicit:
G28 G91 Z0; (incremental, intermediate is current position + 0 = current position, then rapid home) The same principle applies to G30. Be deliberate about incremental vs. absolute mode when specifying the intermediate point.
Not Verifying the Second Reference Position
Unlike G28, which is a fixed mechanical position, G30 depends on parameters that someone entered manually. Parameters can be changed, overwritten during maintenance, or set incorrectly during initial configuration. Before relying on G30 in a production program, verify the position by running the command in MDI and confirming that the machine stops where you expect.
Assuming G30 Is Always Safe
G30 is only as safe as the position you define. If the second reference position is too close to the fixture, a slightly oversized part or a misplaced clamp could cause a collision. Always leave adequate clearance the time you save by positioning G30 close to the part is not worth the risk of a crash.
Using G30 on Unsupported Controls
Some older or budget controls do not implement G30, or they implement it differently. Fanuc, Mitsubishi, and Siemens all support G30, but the parameter numbers, P-address behavior, and default values vary. Check your specific control documentation before assuming compatibility.
Real-World Impact: A Case Study
A job shop running aluminum housings on a vertical machining center was struggling to meet a customer’s volume requirement. The cycle time was 4 minutes and 20 seconds, and the target was 120 parts per shift. They were hitting 105.
After analyzing the program, the programmer noticed that G28 was called four times per cycle once before each tool change on a machine where the tool change position was only 200 mm from the spindle’s working position, but the home position was 800 mm away. Each G28 call wasted about 5 seconds.
By configuring G30 P2 to match the actual tool change position and replacing the four G28 calls with G30 calls, the cycle time dropped by 18 seconds. The new cycle time was 4 minutes and 2 seconds. Over an 8-hour shift, that 18-second savings produced approximately 15 additional parts enough to meet the target with margin.
No new tooling was purchased. No feeds or speeds were changed. No fixtures were modified. The only change was strategic use of a secondary reference position that was already available on the control.
Programming Best Practices
To wrap up, here are some coding habits that will serve you well:
Document your reference positions. Add a comment at the top of every program that uses G30, stating what the second reference position is and how it was set. Future programmers (or future you) will thank you.
(G30 P2 = Pallet change position, set 2024-03-15, see setup sheet #47) Be consistent across programs. If your shop uses G30 P2 for the pallet changer on a given machine, use it that way in every program for that machine. Consistency prevents confusion and reduces the chance of someone changing a parameter without understanding its purpose.
Use incremental mode for intermediate points. G91 with a zero distance is the safest way to specify “stay where you are, then rapid to the reference position.” It avoids any ambiguity about coordinate systems.
Test in MDI before production. Always dry-run G30 commands in MDI mode after setting or changing the reference position. A 10-second test can prevent hours of downtime from a collision or mispositioning.
Consider your automation. If you are designing a new cell or retrofitting automation, define your G30 positions as part of the cell design not as an afterthought. The parking position should be a deliberate engineering choice, not a convenient spot that happened to be available.
Conclusion
G28 and G30 are not interchangeable commands with different names. They represent two different philosophies of machine positioning. G28 is the safe default it sends the machine to a fixed, known, mechanically defined home. G30 is the optimized choice it sends the machine to a purpose-built position that reflects the actual needs of your process.
In low-volume, manual-load environments, the difference may be negligible. But in high-volume production, automated cells, or any application where seconds per cycle translate to parts per shift, G30 is one of the simplest and most effective tools available for reducing non-cutting time.
Configure it carefully. Verify it regularly. And stop sending your machine home when it does not need to go there.




