G99 CNC Code Explained: An Easy Intro for Beginners [Return to R Plane]

What does the G99 code do?

The G99 code is a modal command that tells the cutting tool to move back to the R plane after finishing a canned cycle operation.

G99 is a very important code because it allows you to shorten the time needed to move your cutter around when machining.

The alternative to G99 is the G98 code

G98 also controls the movement of the machine after finishing a canned cycle.

Learn CNC Programming – It’s Easier Than You Think!

Learning G Code doesn’t have to be difficult…

If you know what to focus on.

Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.

Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!

Make Learning G Code Easy

G99 vs G98

Both codes are used to perform similar actions.

The difference is that they lift the tool to different heights when finishing a canned cycle process.

The G98 code lifts the tool back to the initial Z position which the machine was at when starting the canned cycle. This is safer option if you are unsure.

G99 travels back to the R plane instead. The R plane is closer to the part which can potentially cause problems if there are obstacles close to the part such as fixtures or clamps.

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

Other codes and parameters used with a G99 code

When using the G99 code you should consider all of the following items that can be included as part of the code:

The feed rate will depend on the material that is being cut and the diameter of the drilling tool that you are using.

The retract (R) plane or clearance level refers to the plane height where the tool can move safely from one hole to another. The R value should be set so the machine will clear any and all obstacles including clamps, fixtures and the part itself.

X and Y are the location of the hole. Z controls the depth of the hole.

G99 code format

Using the parameters above, the format for using a G99 code is:

G81 X0 Y0 R0 Z1 F5 G99

G81 is the canned cycle. This can be replaced with any other canned cycle as needed.

The rest of the codes are as listed in the parameters section above. The X, Y and F codes are not required. Often, the X and Y codes will be placed on the previous line.

It is good practice to include the feedrate (F) code.

What to think about when using G99

When using the G99 command, think about the obstacles that could be in the way of the movement of your cutter.

Using G99 will move your cutter to the R plane specified with the R code. 

The R plane will usually be set close to the top of the part to make the moves shorter which takes less time. 

This is great for reducing cycle time but not great for avoiding obstacles.

Common obstacles in the machine are:

  • The workpiece
  • Clamps
  • Fixtures
  • Other tooling

Reducing the cycle time is great for industrial CNC machines, but for hobbyists this isn’t as much of a concern. 

Unless you are trying to maximize the output of your machine, G98 is a safer option.

G99 code example

N1 Z5.0 M08;

N2 G82 G99 Z-3.0 R1.0 P500 F50.0;

N3 X10.0;

N4 G98 X20.0;

N5 G99 X10.0;

N6 G80;

The first line (N1) brings the drill down to 5mm above the material surface and turns on the coolant with M08.

Then, the second line (N2) sets the counterbore canned cycle with G82 and tells the machine to return to the R plane where Z = 1.0.

The Z-3.0 is the depth of the counterbore and P500 is the dwell time when the machine reaches the bottom of the hole in milliseconds.

F is feed rate in mm/min.

Line 3 (N3) tells the machine to move the X axis of the machine to the X=10.0 location. Because the canned cycle is a modal code, another counterbore will be drilled to the same parameters as in line 2.

The next line (N4) drills the third hole at X=20mm. G98 tells the control to return to the initial plane. This is Z=5.0, the last Z location before starting the canned cycle. The machine will rapid back to Z=5.0 above the part surface after drilling the previous hole.

The machine drills the final hole 10mm in X from the last one, the G99 code tells the machine to rapid back to the R position instead of the initial Z position.

Lastly, on line 6 (N6) G80 turns the counterboring canned cycle off.

Frequently asked questions about the G99 code

Is G99 modal?

Yes, G99 is a modal command. 

This means it will stay on until changed to another code in the same code group or canceled. 

It will only be in effect for running canned cycles though. 

G99 has no effect on straight line movement with either G00/G01 or circular movement with G02/G03.

What does the G99 code do on a lathe?

The G99 codes is completely different when running a CNC lathe.

G99 on a lathe sets the feed rate mode to feed rate per revolution.

This means if you use a F5 command and G99 is active, the feed rate will be set to 5 inches per revolution.

G98 on a lathe sets the feed rate mode to feed rate minute.

Want to learn more about CNC G Code?

Leave a Comment