G98 and G99: Canned Cycle Return Level
G98 and G99 decide how high the tool goes between holes in a canned cycle. G98 returns to the initial Z, G99 to the R plane.
G98 and G99 only matter inside a canned cycle such as G81, G82 or G83. Every canned cycle has two heights:
- The initial Z: where the tool was when the cycle started, usually a safe height above everything on the table.
- The R plane: the clearance height in the cycle's
Rword, usually a few millimetres above the part.
After each hole the tool rapids back up. G98 sends it to the initial Z. G99 sends it only to the R plane. The tool then moves to the next hole at that height.
When to use each
| G98 | G99 | |
|---|---|---|
| Retracts to | Initial Z | R plane |
| Speed | Slower: a longer move up and down for every hole | Faster: short moves between holes |
| Use it when | Clamps, vises or raised features sit between holes | The path between holes is clear |
Many programs mix the two: G99 for holes in a row where nothing is in the way, and G98 on the last hole before the tool has to cross a clamp or move to another part of the fixture.
Example: two rows of holes with a clamp between them
The tool starts at Z25 and drills six holes 6 mm deep with G81. In each row, G99 keeps the tool at R2 between holes. The last hole in each row uses G98, so the tool goes back up to Z25 before crossing to the next row.
(G98 and G99 example: two rows of holes, 6 mm deep)
(A clamp sits between the rows, so the last hole in each row uses G98)
G21 G17 G90 G54
T1 M6 (5 mm drill)
S2000 M3
G0 X10 Y10 Z25
(G99: return to the R plane, 2 mm above the part, between holes)
G99 G81 X10 Y10 Z-6 R2 F150
X30
(G98: return to the initial Z of 25 mm to clear the clamp)
G98 X50
G99 X50 Y40
X30
G98 X10
G80
G0 Z25
M5
M30
In CutViewer, the retracts to Z25 after X50 Y10 and X10 Y40 stand out from the short R-plane moves.
Line by line:
G99 G81 X10 Y10 Z-6 R2 F150starts the drilling cycle: rapid to R2, feed to Z-6, rapid back to R2.X30drills the next hole with the same cycle and the same G99 return. Canned cycles are modal, so only the new position is needed.G98 X50drills the last hole in the row and retracts to Z25 instead of R2.G80cancels the cycle. Without it, the next X or Y move would drill another hole.
G98 and G99 on lathes
On Fanuc-style lathes using the standard (A) G-code system, G98 and G99 have a different meaning: feed per minute and feed per revolution. Mills use G94 and G95 for that. Check your control's manual before you copy a program between a mill and a lathe.
How CutViewer shows G98 and G99
CutViewer draws each hole in a canned cycle as a rapid to the hole position, a rapid down to the R plane, a feed to the hole depth and the retract, using G98 or G99 to decide the retract height. Pecks and dwells inside a cycle are not drawn separately.
Frequently Asked Questions
What is the difference between G98 and G99?
In a milling canned cycle, G98 retracts the tool to the initial Z, the height it was at when the cycle started, after each hole. G99 retracts only to the R plane, the clearance height given by the R word. G99 is faster; G98 clears clamps and other obstacles between holes.
Which is the default, G98 or G99?
Most controls start in G98, which is the safer choice, but it varies by machine and some controllers keep the last setting. Programs should state G98 or G99 on the cycle line rather than rely on the default.
Do G98 and G99 mean something else on a lathe?
Yes. On Fanuc-style lathes using the standard (A) G-code system, G98 means feed per minute and G99 means feed per revolution. Milling machines use G94 and G95 for those, and G98 and G99 for the cycle return level.
Can I switch between G98 and G99 in the middle of a cycle?
Yes. Both are modal and can go on any hole line, so a common pattern is G99 for holes in a row and G98 on the last hole before the tool has to cross a clamp.
More G-Code Guides
Rapid positioning and straight cutting moves.
Clockwise and counter-clockwise arcs with I/J/K or R.
Pause for a set time, in seconds or milliseconds.
Choose the XY, XZ or YZ plane for arcs.
Inch or millimetre units for the program.
Return to home or a second reference position.
Cutter radius compensation, left, right and off.
Tool length offset on and off.
Work coordinate systems and machine coordinates.
Drilling canned cycles, from plain drilling to peck drilling.
Tapping cycle, and how to work out the feed rate.
Absolute positions or incremental distances.
Set the current position by shifting coordinates.
Feed per minute, per revolution, or inverse time.
Constant surface speed or a fixed spindle RPM.
Spindle, coolant, tool change, stop and subprogram codes.
Check your own program before you cut: open it in CutViewer to see the toolpath in 3D, the run time and any problems.
Open CutViewer