G98 G-Code: Return to Initial Plane in Canned Cycles

G98 tells your CNC machine to return the cutting tool to its starting Z height after each canned cycle operation. That starting height is called the initial point — it’s wherever the Z-axis was before the canned cycle began.

This matters because it keeps your tool safely above clamps, fixtures, and any other obstacles as it moves between holes.

Key Takeaways

  • G98 returns the tool to the initial Z position (where Z was before the canned cycle started)
  • It’s the safer choice when clamps, fixtures, or other obstacles are present
  • G99 is the alternative — it only returns to the R plane, which is closer to the part
  • G98 is modal: it stays active until you switch to G99 or cancel with G80
  • On lathes, G98 means something different — it sets feedrate to per-minute mode
G98 – At A Glance
FunctionReturn to initial point after canned cycle
TypeModal (Group 10)
Cancelled byG99, G80
Default on most controlsYes
Used withG73, G74, G76, G80–G89
Machine typeMachining center (mill)

G98 vs G99

Both G98 and G99 control where the tool goes after finishing each hole in a canned cycle. The difference is how high the tool travels.

visualization of how a cnc machine moves using g98 and g99 codes shows motion of travel for the machine

G98 lifts the tool all the way back to the initial point — the Z position the machine was at when the canned cycle started. If you started your cycle at Z5.0, that’s where the tool returns after each hole.

G99 only retracts to the R plane — a clearance height you define with the R word in your code. The R plane is closer to the part. That makes G99 faster, but it also means the tool might clip a clamp or fixture if you’re not careful.

Use G98 when you have obstacles in the way. Use G99 when the area between holes is clear and you want to shave cycle time.

COMMON MISTAKE – Switching to G99 without checking for obstacles

G99 retracts to the R plane, which is often only 0.1″ above the part. If a clamp or workstop is taller than that, you’ll get a collision.

Always visualize the tool path between holes before using G99 on a crowded fixture.

Parameters Used with G98

G98 is paired with a canned cycle code and a set of words that define the operation. Here’s what each one does:

  • Initial plane – The Z height before the canned cycle starts. G98 returns here after each hole. Set this above all obstacles.
  • R – The R plane (retract plane). The tool moves from here down into the hole. Set just above the part surface.
  • Z – The bottom of the hole. How deep you’re drilling, boring, or tapping.
  • X / Y – The position of each hole on the part.
  • F – Feedrate. How fast the tool moves into the material. This depends on tool diameter and material.

The R value should clear everything on the part — the workpiece, clamps, and fixture plates. A common starting point is R0.1 (about 2.5mm above the surface).

G98 Code Format

The basic format for a drilling canned cycle with G98 looks like this:

G81 G98 X0 Y0 R0.1 Z-1.0 F5.0
  • G81 – The canned cycle (simple drill). Swap in any canned cycle code you need (G82, G83, G84, etc.)
  • G98 – Return to initial point after each hole
  • X0 Y0 – Hole location
  • R0.1 – Retract plane, 0.1″ above the part
  • Z-1.0 – Drill depth
  • F5.0 – Feedrate in inches per minute

X and Y can go on a separate line before the canned cycle call if you prefer. The feedrate should always be included — don’t rely on whatever value was last active.

G98 Code Example

This example drills four holes with a mix of G98 and G99 to show how they work together.

N1 G90 G54 G00 X0 Y0          (Absolute mode, work offset, rapid to first position)
N2 G43 H01 Z5.0 M08           (Tool length comp, initial point Z5.0, coolant on)
N3 G82 G99 Z-3.0 R1.0 P500 F50.0   (Counterbore cycle, return to R plane)
N4 X10.0                       (Drill hole at X10 — returns to R1.0)
N5 G98 X20.0                   (Drill hole at X20 — returns to initial point Z5.0)
N6 G99 X30.0                   (Back to R plane return for final hole)
N7 G80                         (Cancel canned cycle)

Line by line:

N2 establishes Z5.0 as the initial point. That’s the height G98 will return to.
N3–N4 use G99 — the tool retracts to R1.0 (just above the part) between these two holes. Fine here because there are no obstacles in the way.
N5 switches to G98. After drilling this hole, the tool returns to Z5.0. Maybe there’s a clamp near X20 that the tool needs to clear on the way to X30.
N6 switches back to G99 for the final hole — faster retract, no obstacles.
N7 cancels the canned cycle with G80.

What Does G98 Do on a Lathe?

G98 works completely differently on a CNC lathe.

On a lathe, G98 sets the feedrate mode to feed per minute. So if you program F100 with G98 active, the tool moves at 100 inches per minute (or 100 mm/min in metric mode).

G99 on a lathe sets feedrate to feed per revolution — the tool advances a fixed amount for each rotation of the spindle. Feed per revolution is more common for turning operations.

So if you’re reading lathe programs, don’t confuse these — G98/G99 on a lathe have nothing to do with canned cycle retract planes.

FAQS

Is G98 a modal command?

Yes, G98 is a modal command. 

Modal codes will stay on until changed to another code in the same code group or until they are canceled. 

It will only be in effect for running canned cycles though. G98 has no effect on straight line movement with either G00/G01 or circular movement with G02/G03.

What is the initial point in G98?

The initial point is the Z position the machine was at when the canned cycle started. If your tool was at Z5.0 when you called the canned cycle, G98 will return to Z5.0 after every hole. Set your initial point above all clamps and fixtures so the tool clears them safely.

Is G98 on by default?

On most Fanuc-based controls, yes — G98 is the default at power-on and after a reset. You don’t need to program it explicitly unless you want to switch back from G99. It’s always a good habit to program it anyway to make your intent clear.

Can I use G98 and G99 in the same program?

Yes. Because both are modal, you can switch between them mid-program to optimize cycle time. Use G99 between holes where there are no obstacles, and switch to G98 before holes near clamps or fixture edges. Just make sure you know the tool path before you run it.

Does G98 affect feedrate?

Not on a machining center. On a mill, G98 only controls where the Z-axis returns after each canned cycle hole — it has no effect on feedrate. (On a lathe, G98 does control feedrate mode — see the lathe section above.)