G99 G-Code Command

G99 G-Code Command

G99 is a G-code command used in CNC machining that instructs the machine to return to the initial level of the Z-axis after completing a drilling cycle. This command is often used in combination with G81, which is a drilling cycle command that instructs the machine to perform a series of holes at a specific depth. After completing each drilling cycle, the G99 command tells the machine to retract only to the ‘R’ value specified in the canned cycle, making it ready for the next operation.

How The G99 G-Code Command is Used

Here’s an example G-code program that uses G99 with a drilling canned cycle and spindle on command for 2000 RPM, with comments in brackets:

% O1234 (Program name)
G90 (Absolute programming)
G54 (Work offset)
M03 S2000 (Spindle on clockwise at 2000 RPM)
G00 X0 Y0 (Rapid move to first hole position)
G43 H01 Z50 (Tool length offset and rapid move to approach position)
G99 G81 R5 Z-10 F10 (Drilling canned cycle, R is the retract height, Z is the drill depth, F is the feed rate)
X10 Y10 (drill another hole)
G80 (cancel canned cycle)
G00 Z50 (Rapid move to safe height)
M05 (Spindle stop)
G91 G28 X0 Y0 Z0 (send the machine to home position)
G90 (re establish absolute positioning)
M30 (Program end)

In this example, the program starts by setting up some basic parameters, such as the program name, absolute programming, and work offset. Then, the spindle is turned on clockwise at 2000 RPM.

The program then moves the tool to the starting position, sets the tool length offset, and moves to the approach position using a rapid move. The drilling canned cycle with G99 is then initiated with a retract height of 5 units, a drill depth of -10 units, and a feed rate of 10 units per minute.

After completing the first hole, the G99 command returns the tool to the initial level of the Z-axis, in this example it is Z5 as specified by the ‘R’ value in the G81 canned cycle. The program then moves to the next hole position and drills the second hole. The drilling cycle is then cancelled with the G80 G-Code command. Then the tool retracts to a safe height, M05 stops the spindle, and the program ends with the M30 command.

This is typically used when the drill does not have to avoid any clamps or features on the workpiece. The G99 G-Code command is especially useful when lots of holes are being drilled as it eliminates a longer retract movement, thus speeding up the cycle time.

If the drill has to avoid clamps or features on the workpiece, G98 can be used instead to move the tool higher.

Share on pinterest
Share on email
Share on print

Table of Contents