Back to GSM Code List

G98 and G99: how high the tool comes back between holes

In the canned cycles of a milling machine, G98 and G99 decide how high the tool comes out after each hole: with G99 it goes back only as far as the R plane and with G98 it climbs to the initial plane, which is the Z the axis was at when the cycle started. G99 saves cycle time and G98 is what saves clamps, vise jaws and steps. Careful on a lathe: on Fanuc A system lathes and on Haas lathes, G98 and G99 are not return planes but feed modes, per minute and per revolution.

For reference only: syntax changes with the control, the post-processor and the machine parameters. Check the official manual and run a simulation before cutting. Legal notice.

Family
Cycles
Machine
Milling, Turning, Mill-turn
Risk
High
Example
G81 X10 Y10 Z-12 R2 F120 G99

Syntax by control

Fanuc (milling)

G99 G81 X20. Y20. Z-18. R3. F200

Both are modal and belong to the same group, so you can slot them in between one hole and the next: it is enough to write G98 in the block of the hole after which you have to cross an obstacle. The power up state on most controls is G98.

Haas (milling)

G99 G81 X20. Y20. Z-18. R3. F200

Identical to Fanuc. Haas adds Setting 52 (G83 Retract Above R), which changes how far the peck cycle retracts above the R plane, and that stacks on top of whatever G98 and G99 decide.

Fanuc / Haas (turning)

G99 G01 X40. Z-30. F0.25

On a lathe they have nothing to do with planes: G99 is feed per revolution and G98 feed per minute. It is the same pair of codes with two completely different meanings depending on the machine, and mixing them up is a classic when you move from the mill to the lathe.

Siemens 840D / 828D

CYCLE81(100, 0, 3, -18)

Siemens uses neither G98 nor G99 in cycles: the two heights are parameters of the cycle itself, RTP (retract plane, the first one) and RFP (reference plane). With MCALL active, the return between positions is made to the retract plane.

Heidenhain TNC (Klartext)

CYCL DEF 200 TALADRADO Q200=+3 Q204=+100

It goes by parameters here too: Q200 is the set-up clearance, which acts as the R plane, and Q204 is the second set-up clearance, which acts as the initial plane for clearing obstacles. The control decides which to use depending on whether there is a collision risk between points.

Address letters used with it

LetterWhat it setsUnit
G98 / G99Modal selector of the return plane in milling. They take no arguments and stay active until the other replaces them or until a reset.modal, no units
Initial planeIt is not written: it is the Z coordinate the axis was at just before the first block of the cycle. Start the cycle from Z2 and the initial plane is Z2, so a G98 climbs no higher than that.mm / in
RReference plane of the cycle: the height where the tool switches from rapid to feed and the one it returns to under G99. The usual value is 2 or 3 mm above the face.mm / in
G80Cancels the cycle. Until it is written, any block with an X or a Y repeats the hole, and the return is still governed by the active G98 or G99.modal, no units

Worked example

Six holes in a long plate held down by two clamps in the middle. The holes on the left and on the right are in clear ground, but the move from one group to the other crosses over the clamps. That jump is the reason G98 exists, and the example shows exactly which block it has to be written in.

O0098 (SEIS AGUJEROS CON BRIDAS EN MEDIO)
( Program header. )
G21 G17 G40 G49 G80
( Millimeters, XY plane and a clean state. )
G91 G28 Z0.
( Z to the reference point in incremental before the change. )
T5 M06
( 8 mm drill. )
G90 G54 G00 X20. Y30.
( Absolute, work offset and positioning over the first hole. )
G43 H05 Z100. M03 S2400
( T5 length offset and spindle on. That Z100 is the key to the example: it will be the initial plane, and it is deliberately above the clamps. )
M08
( Coolant on. )
G99 G81 Z-22. R3. F200
( First hole. Rapids down from Z100 to Z3, drills to Z-22 and returns to Z3, because G99 is active. )
X60.
( Second hole. The move happens at Z3 and the path is clear. )
X100.
( Third hole, also at Z3. )
G98 X140.
( Fourth hole, the last one before the clamps. On finishing it climbs to the initial plane Z100 instead of staying at Z3. )
G99 X220.
( Fifth hole, now on the other side. The move happens at Z100, which is where the tool was left, so it passes over the clamps; once there it drops to R and goes back to behaving like G99. )
X260.
( Sixth hole, with the path clear again. )
G80 G00 Z100. M09
( Cancels the cycle before any rapid move and shuts the coolant off. Without the G80, this very block would drill. )
G91 G28 Z0. M05
( Z to the reference point and spindle stop. )
G90 M30
( Back to absolute and end. )
Open the simulator to check the example

Practical keys to using G98/G99 in the workshop

What the initial plane is and who sets it

The initial plane is not programmed in the cycle: it is simply the Z coordinate the axis was at when the first block of the cycle ran. That is why the G43 block with the safe Z is the one that decides, without looking like it, how high a G98 will climb later on. If the program drops to Z5 before starting the cycle, the initial plane is Z5 and writing G98 buys you nothing. The healthy habit is to start cycles from a Z clearly above everything on the table.

When it is worth losing time with G98

G99 is faster because every hole ends two or three millimeters off the face, and on a plate with forty holes the difference is minutes. G98 is used when there is something between two holes taller than the R plane: clamps, nuts, vise jaws, a step in the part itself or a bar stop. Also when the holes are on faces at different heights, or when the move passes over an area already machined with walls in it. The efficient way is not to pick one for the whole cycle, but to slot G98 in only on the blocks where the path is not clear.

The double meaning on lathes and on other controls

On Fanuc lathes with the A code system and on Haas lathes, G98 and G99 are the feed mode: G98 in millimeters per minute and G99 in millimeters per revolution. There are no return planes because lathe cycles handle their own heights with other parameters. On Siemens and Heidenhain the concept exists but does not carry these codes: they are parameters inside the cycle, RTP and RFP on Siemens, Q200 and Q204 on Heidenhain. Before copying a block from one machine to another, look at which control it came from.

Mistakes that cost you a part (or a tool)

  • Staying in G99 with clamps, vise jaws or a step between one hole and the next: the move happens three millimeters off the face and the drill hits them sideways, in rapid.
  • Believing G98 goes to the R plane and G99 to the initial plane: it is exactly the other way around. G99 is the short, fast one; G98 is the one that climbs all the way.
  • Starting the cycle with the tool already down at Z2: the initial plane is left at Z2 and the G98 you write later lifts the tool above nothing at all.
  • Writing the G98 one block too late: the return from the previous hole has already happened at the old height. The G98 goes in the block of the last hole before the obstacle, not in the first one after it.
  • Inheriting a G99 from an earlier operation without noticing: both are modal and they survive the tool change on most controls.
  • Forgetting the G80 at the end: any later block with an X or a Y runs the whole cycle again, and the return plane is still whichever was active.
  • On a lathe, reading G99 as a return plane and programming a milling feedrate: F200 in feed per revolution is 200 millimeters for every turn of the spindle.

Frequently Asked Questions (FAQ)

What is the difference between G98 and G99?

The height the tool comes out to after each hole of a canned cycle. With G99 it returns to the R plane, which is usually two or three millimeters off the face. With G98 it climbs to the initial plane, which is the Z the axis had when the cycle started. Both are modal and you can alternate between them from hole to hole.

Which one is active if I write neither?

On most Fanuc and Haas controls the power up state is G98, but that is also a machine parameter and, above all, whichever the previous program left can still be active. Always writing it in the first block of the cycle takes the doubt away and costs nothing.

How do I switch between them in the middle of a hole pattern?

By writing the new code in the block of the hole concerned, next to the coordinate: G98 X140. drills that hole and comes out to the initial plane. The next block can go back to G99 with no problem, because the move will already have happened at the high level.

Do G98 and G99 mean the same thing on a lathe?

No. On Fanuc A system lathes and on Haas lathes they are the feed modes: G98 per minute and G99 per revolution. It is the same pair of codes with a different meaning, so a block copied from a mill to a lathe changes the feedrate instead of the return height.

Do they exist on Siemens or Heidenhain?

As codes, no. Siemens defines the two heights inside the cycle with the RTP and RFP parameters, and Heidenhain with Q200 (set-up clearance) and Q204 (second set-up clearance). The concept is identical: a short height to move fast and a high one to clear obstacles.

Related codes

Other codes in Cycles

See the full list of G and M codes

Related tools