G98 G-Code Command
G98 is a G-code command used in CNC machining to specify a canned cycle return to the initial point. This means that the Z-axis returns to its initial starting point between each X/Y position, which allows for programming up and around areas of the part, clamps, and fixtures. This command is one that is used most commonly with G81 and G83 canned drilling cycles.
How G98 G-Code Command Is Used
Here’s an example of a G-code program that uses G98 in a drilling canned cycle with comments in brackets and a spindle on command for 2000 rpm:
O0001 (Drilling Canned Cycle with G98 and Spindle On)
G90 G54 G00 X0 Y0 (Absolute positioning, rapid move to X0 Y0)
M03 S2000 (Spindle on clockwise at 2000 rpm)
G43 H01 Z50 (Tool Length on, move to Z50)
G98 G81 Z-10. R2. F50. (Drilling canned cycle with G98)
X10. Y10. (Move to 2nd drilling position at X10.0 Y10.0)
G80 (End drilling canned cycle)
M05 (Spindle off)
G91 G28 X0 Y0 Z0 (Return to home position)
G90 (reset absolute positioning)
M30 (End of program)
In this example, the program starts by setting up the work coordinate system and turning on the spindle at 2000 rpm. The program then runs a G81 drilling cycle using G98 to return to the initial Z position, in this case Z50, before moving to the 2nd drilling position at X10 Y10. The program then turns off the spindle and returns to the home position.
Specifying the G98 with the G81 drilling cycle lifts the drill up to Z50 enabling the tool to clear any clamps or protruding features in the workpiece. The other alternative is to use G99 which you can read about here.