G-codeCanned CyclesModal group 9Mill
G81 & G82: Drilling Cycles
G81 is the standard drilling canned cycle: from one block the tool rapids to the R plane, feeds down to Z at the programmed feed and rapids back out. G82 is the same cycle with a dwell at the bottom, the time in P, and that pause is the whole difference between them. Use G81 for through holes and plain drilled holes; use G82 for spot drilling, chamfering with a spot drill and counterbores, where the dwell lets the edges clean up the bottom so it comes out round and to depth. Both cycles stay live, so each later block carrying an X or a Y drills another hole at that position until G80 switches the cycle off.
Syntax
G81 X__ Y__ Z__ R__ F__ Rapid to R, feed to Z, rapid out
G82 X__ Y__ Z__ R__ P__ F__ Same, with a dwell at the bottom
G80 Cancel the cycle
G99 Retract to the R plane between holes
G98 Retract to the initial level between holesParameters
| Address | Meaning | Notes |
|---|---|---|
X Y | Hole position | Optional on the cycle block itself. Each later block with an X or a Y drills another hole |
Z | Final depth | Absolute in G90. In G91 it is the distance down from the R plane |
R | Retract plane | The height the rapid stops at and the feed starts from. 2 to 3mm (0.08 to 0.12in) above the face |
P | Dwell at the bottom, G82 only | Fanuc reads whole milliseconds, so P300 is 0.3 seconds. A Haas reads seconds, so the same dwell is P0.3 |
F | Drilling feed | Applies to the plunge only. The moves between holes stay rapid |
K | Repeat count | L on a Haas. In G91 it drills K holes at the incremental X and Y step |
On a mill, G98 and G99 are a separate modal group and decide where the tool goes between holes: back to the Z it was standing at when the cycle started, or only as far as the R plane. G99 is quicker, G98 is what clears the clamps.
Example
O0004 (SPOT AND DRILL 4 HOLES, 12MM ALUMINIUM PLATE)
G21 G17 G40 G49 G80 G90 (safe start block)
T07 M06 (6mm 90 degree spot drill)
G54
S3200 M03
G00 X20. Y20. (first hole, clear of the clamps)
G43 H07 Z25. M08 (tool length comp on, coolant)
G99 G82 Z-1.5 R2. P300 F120 (spot 3mm wide, 0.3s dwell, back to R)
X60. (second hole)
Y50. (third)
X20. (fourth)
G80 G00 Z25. M09 (cancel the cycle before anything else moves)
M05
T08 M06 (6.6mm drill, 118 degree point, M6 clearance)
S3000 M03
G00 X20. Y20.
G43 H08 Z25. M08
G99 G81 Z-14.5 R2. F360 (12mm plate, 2mm of point, 0.5mm through)
X60.
Y50.
G98 X20. (last hole retracts to Z25 to clear the clamp)
G80 G00 Z25. M09
G49
G91 G28 Z0. (home Z)
M30Controller differences
| Control | Behaviour |
|---|---|
| Fanuc | The cycle is modal in group 09 and is cancelled by G80 or by any group 01 motion code, so a G00 or G01 block ends it as well. K is the repeat count and works only in the block it is written in. P takes whole milliseconds and no decimal point: P500 is half a second, and P0.5 stops the program with PS0007, illegal use of decimal point. In G91 the R and Z words become distances rather than heights: R from the initial level, Z down from the R plane. |
| Fanuc lathe | The lathe's own drilling cycles are G83 for face drilling and G87 for side drilling, cancelled by G80. In G code system A the list gives G81 and G82 only as the FS10/11-T format spot drilling and counterboring cycles, and G98 and G99 are feed per minute and feed per revolution, not return levels. |
| Haas mill | Same addresses, but the loop count is L, not K. P is the dwell in seconds and takes a decimal: the Haas workbook's own spot drill line is G82 G99 Z-0.27 P0.5 R0.1 F12. for half a second, which a Fanuc rejects with PS0007. G98, back to the starting Z, is the default return. Setting 57, Exact Stop Canned X-Y, decides whether the control comes to a full stop at each hole before the Z move starts. |
| Haas lathe | G81 and G82 drill along Z with X, Z, W, R and F, and G82 adds P. G98 and G99 are the feed modes here, per minute and per revolution, with G99 the default, so the F on a drilling cycle is read per turn unless the program says G98. |
| Siemens 840D | The native language has no G81 or G82. Drilling is CYCLE81(RTP, RFP, SDIS, DP, DPR) and drilling with a dwell is CYCLE82(RTP, RFP, SDIS, DP, DPR, DTB): retraction plane, reference plane, safety clearance, final depth absolute or relative to the reference plane, and DTB, the dwell in seconds. MCALL CYCLE82(...) makes the cycle modal so each position that follows drills, and a bare MCALL cancels it, the job G80 does on a Fanuc. G81 and G82 exist only in ISO dialect mode, switched on with G291. |
| Mazak | Mazatrol conversational never writes G81. The DRILLING unit carries the hole diameter, depth and chamfer, the control builds the tool sequence from them (centre drill, drill, chamfer cutter), and the hole positions come from the shape lines underneath, PT for a single point. |
| Grbl | No canned cycles at all. G81 and G82 stop the stream with error:20. G80 is accepted because it is the state Grbl is always in, so the CAM system has to post every plunge and retract as plain G00 and G01 moves. |
| Marlin | No canned cycles either. G81 and G82 get an unknown command warning and the machine carries on to the next line, so the holes never get drilled and the program finishes looking like it worked. |
What goes wrong
Programming Z-12. in a 12mm plate leaves four holes that are not holes. A 118 degree drill carries about 2mm of point on a 6.6mm diameter, so the full diameter only breaks the back face at Z-14.5 with half a millimetre to spare. Work the point length out once, half the diameter divided by the tangent of 59 degrees, and build it into every depth.
Then there is the cycle nobody cancelled. G81 and G82 stay modal, and the next block carrying an X or a Y drills, whatever it was meant to do. The line that walks the table out to X150. puts a hole through the fixture instead. It hides well, because a G00 or G01 block ends the cycle on a Fanuc, so a program runs clean for months and then scraps a fixture the day somebody edits a positioning line.
G99 with clamps on the table is the third one. Between holes the tool lifts only to the R plane, 2mm above the face, and the next rapid drags it straight through a toe clamp. G98 sends it back to the height the cycle started from, so put G98 on the hole before any move that crosses something.
Three more that cost an afternoon each. In G91 the R and Z words stop being heights and become distances from where the tool is standing, so a cycle line copied out of a G90 program drills at the wrong depth without an alarm. P is milliseconds on a Fanuc: P300 is three tenths of a second, while a Haas program's P0.5 is written in seconds. And on a Haas or Fanuc lathe G99 is feed per revolution, so a drilling F360 meant as millimetres per minute asks for 360mm a turn.
Updated 26 Oct 2026