CNC Milling Drilling Cycles: G81, G82, G83, G84 and G80

10 July 2026

Mentor CNC Editorial Team

On a CNC mill it is possible to program several holes of the same type one by one with long motion lines; but this lengthens the program and increases the chance of error. FANUC controls use canned drilling cycles to simplify drilling. In this lesson we learn the basic cycles beginners will use most: G80 cancels the canned cycle, G81 standard drilling, G82 dwell drilling at the hole bottom, G83 peck deep drilling, G84 tapping; G98 returns to the initial plane, G99 to the R plane.

1. Objectives of the lesson

After this lesson the student will be able to understand what a canned drilling cycle is; drill a standard hole with G81; explain the role of the dwell in G82; peck-drill deep holes with G83; grasp the basic logic of the G84 tapping cycle; distinguish the Z, R, Q, P and F addresses; explain the difference between G98 and G99; and understand the importance of using G80 at the end of the cycle.

2. What is a canned drilling cycle?

Without a cycle we would have to repeat the same Z moves for every hole. With a canned cycle the drilling moves are defined once; the following lines only give the new hole positions. For example after G81 Z-15. R5. F120.; is defined, the lines X50. Y20.; and X80. Y20.; open new holes under the same conditions. This structure shortens the program and ensures the holes are machined under identical conditions.

3. Basic addresses

A simple drilling cycle is written as G81 X20. Y20. Z-15. R5. F120.;. Addresses: X Y the hole center position, Z the final hole depth, R the approach plane where the cutting feed begins, F the drilling feed rate. Some cycles also use Q (depth taken per peck) and P (dwell time at the hole bottom).

4. What is the R plane?

R is the level where the tool switches from rapid to cutting feed. For example in G81 Z-15. R3. F120.; the tool rapids to the hole center, rapids to the R3 plane, feeds from the R plane to Z−15 at F120, and retracts when the hole is complete. The R plane must be a safe distance above the part; if the part top face is Z0, R3 means the tool starts drilling 3 mm above the surface. If R is too low the tool rapids close to the surface/clamp; if too high the cycle time is needlessly extended.

5. G81 – Standard drilling cycle

G81 is used for simple drilling operations. General format: G81 X... Y... Z... R... F...;.

G90 G54 G00 X20. Y20.;
G43 H03 Z50.;
G98 G81 Z-12. R3. F120.;
X50. Y20.;
X80. Y20.;
G80;

In this program three holes (X20 Y20, X50 Y20, X80 Y20), hole depth 12 mm, R plane 3 mm above the part, feed 120 mm/min. G81 is mostly used for standard drilling, center-drilling, short easy-to-clear holes and some simple countersinks. In deep holes, since chip evacuation is difficult, G83 is more suitable.

6. G82 – Dwell cycle at the hole bottom

G82 dwells briefly when the tool reaches Z depth and then retracts. General format: G82 X... Y... Z... R... P... F...;. Example: G82 X20. Y20. Z-5. R2. P500 F100.; — Z−5 final depth, R2 approach plane, P500 dwell, F100 feed. How the dwell is interpreted varies by FANUC model; on some systems P is millisecond-based, so the real machine manual must be checked. G82 is used for flat-bottom countersinks, operations needing a short dwell at the bottom, holes where surface quality is desired, and center/spot drilling. If the dwell is too long the tool can rub and heat at the hole bottom.

7. G83 – Peck deep drilling

If a deep hole is drilled in one pass, chips can jam in the drill flutes; the drill can break, the hole surface can spoil, the tool can overheat. G83 drills the hole in small steps rather than one pass; this is called peck drilling. General format: G83 X... Y... Z... R... Q... F...;. Example: G83 X30. Y30. Z-30. R3. Q5. F100.; — final depth Z−30, R3 plane, each plunge Q5, feed F100. The tool advances in ~5 mm steps, retracts to clear chips, and repeats until the hole is complete. Q is the approximate depth taken per peck; it is chosen by hole diameter, depth, drill type, material and coolant. Too large a Q reduces the chip-clearing benefit; too small a Q lengthens the operation.

8. Difference between G81 and G83

FeatureG81G83
Machining modeDrills in one passDrills in small steps
UseStandard and short holesDeep holes
Chip evacuationLimitedBetter
Q valueNot usedUsed
Cycle timeShorterLonger

Simple selection logic: short and easy hole → G81; deep hole with chip-jam risk → G83.

9. G84 – Tapping cycle

G84 is the basic tapping cycle for cutting right-hand threads. General format: G84 X... Y... Z... R... F...;. In tapping the spindle rotation and Z-axis feed must be synchronized, so F is not chosen at random. For a metric tap the basic relation is F = n × P (F: mm/min feed, n: spindle rpm, P: thread pitch). For example an M8×1.25 tap at S400 rpm gives F = 400 × 1.25 = 500 mm/min:

S400 M03;
G84 X20. Y20. Z-15. R3. F500.;

On FANUC systems rigid tapping may require additional commands such as M29, depending on the machine builder; the FANUC manual states that no axis or new S command should be written between M29 and G84. The real tapping program must be prepared according to the machine builder’s procedure.

10. Difference between G98 and G99

After a drilling cycle is complete, G98 or G99 selects the height the tool returns to. G98 – Return to the initial plane: after finishing the hole the tool returns to the first Z plane where the cycle began; safer when there are vise jaws, clamps or surfaces at different heights. G99 – Return to the R plane: the tool returns only to the R plane; faster because it gives a shorter move between holes, but if there is an obstacle between holes the tool can collide while moving at the R plane. On the first part or near clamping elements, G98 may be preferred.

11. G80 – Canceling the canned cycle

A drilling cycle is a modal command; after G81 is written, the following X and Y coordinates are treated as new holes. So when the holes are complete the cycle must be canceled with G80;. If G80 is not written, a later X or Y move can unintentionally start a new drilling operation. G80 is also used at a safe program start to cancel a previous cycle: G17 G21 G40 G49 G80 G90 G94;.

12. Simple drilling program with G81

Four holes at X20 Y20, X60 Y20, X60 Y50, X20 Y50. G81 is defined once; the other holes are given only with X and Y.

%
O1800 (G81 DRILLING);
G17 G21 G40 G49 G80 G90 G94;
T03 M06;
G54 S1200 M03;
G00 X20. Y20.;
G43 H03 Z50.;
M08;
G98 G81 Z-12. R3. F120.;
X60. Y20.;
X60. Y50.;
X20. Y50.;
G80;
G00 Z50.;
M09;
M05;
G49;
G91 G28 Z0.;
G90;
M30;
%

13. Deep hole example with G83

Four holes 30 mm deep; each hole is machined with ~5 mm pecks.

%
O1810 (G83 DEEP HOLE);
G17 G21 G40 G49 G80 G90 G94;
T04 M06;
G54 S900 M03;
G00 X20. Y20.;
G43 H04 Z50.;
M08;
G98 G83 Z-30. R3. Q5. F90.;
X60. Y20.;
X60. Y50.;
X20. Y50.;
G80;
G00 Z50.;
M09;
M05;
G49;
G91 G28 Z0.;
G90;
M30;
%

14. Which values are not rewritten in the same cycle?

After the cycle starts, the Z depth, R plane, Q value, F feed and G98/G99 selection remain modal; the following holes can be written only as X40. Y20.;. But if the depth or another value will change, the new value must be written explicitly: X40. Y20. Z-15.;.

15. Working sequence in a drilling cycle

A drilling program is generally prepared as: (1) call the tool, (2) select the workpiece zero, (3) start the spindle, (4) go to the X–Y center of the first hole, (5) call the tool length with G43 H, (6) turn on coolant, (7) start the G81/G82/G83/G84 cycle, (8) write the other hole coordinates, (9) cancel the cycle with G80, (10) retract the tool to a safe Z, (11) stop the coolant and spindle.

16. Points to check before drilling

  • Are the drill diameter, tool H number, hole center and Z depth correct?
  • In a blind hole, is the tip allowance accounted for; is the R plane above the part and clamping?
  • Are the F feed and spindle rpm suitable; is G98/G99 safe; is G80 present at the end of the cycle?

17. Drill point angle and real hole depth

The Z value in the program mostly defines the point the drill tip reaches. Because the drill tip is conical, the programmed tip depth and the cylindrical full-diameter depth are not the same. For example if a blind hole must be full diameter over 15 mm, the drill tip must go deeper; this extra depth depends on the drill diameter and point angle. Basic rule: it must be checked whether the hole depth given on the drawing is the drill-tip depth or the full-diameter depth.

18. Points to check in G84 tapping

Before tapping: the correct pilot hole must be drilled, the tap pitch known, the hole deep enough, clearance left at the bottom of a blind hole, suitable lubrication used, the S and F values matched, and the tap’s rotation direction correct. A wrong feed value can cause the tap to jam or break. If the tap breaks, the broken tool piece and the hole must be checked before running the program again.

19. Other FANUC hole cycles: G73, G74, G76 and G85–G89

The four cycles above cover most everyday hole work. FANUC machining centers (M series) also offer cycles for chip breaking, left-hand tapping and boring. The formats in this section follow the FANUC 0i-F Operator’s Manual for machining centers (B-64604EN-2). In all of them X, Y, Z, R, F, G98/G99 and G80 cancel work as described above; K is the number of repeats.

CodeFormatAt hole bottomRetractTypical use
G73G73 X_ Y_ Z_ R_ Q_ F_ K_–Short retract after each peck, rapid at the endFast chip-breaking peck drilling
G74G74 X_ Y_ Z_ R_ P_ F_ K_Dwell, spindle reverses to CWCutting feedLeft-hand tapping
G76G76 X_ Y_ Z_ R_ Q_ P_ F_ K_Dwell, spindle orients and stops, tool shifts by QRapidFine boring
G85G85 X_ Y_ Z_ R_ F_ K_–Cutting feedReaming, boring
G86G86 X_ Y_ Z_ R_ F_ K_Spindle stopsRapidRough boring
G87G87 X_ Y_ Z_ R_ Q_ P_ F_ K_Orient and shift, cuts upwardOriented and shiftedBack boring
G88G88 X_ Y_ Z_ R_ P_ F_ K_Dwell, spindle stops, machine holdsManualSpecial jobs needing a manual retract
G89G89 X_ Y_ Z_ R_ P_ F_ K_DwellCutting feedBoring with a flat, clean bottom face

G73 – High-speed peck drilling

G83 retracts the tool to the R point after every peck. G73 retracts only a short distance, set in parameter 5114. The chip is broken but not cleared from the hole, so G73 is faster. When chip evacuation becomes difficult in a deeper hole, switch to G83.

M03 S1800 ;
G90 G54 G00 X20. Y20. ;
G43 Z50. H01 ;
G99 G73 Z-25. R2. Q4. F150 ;   (4 mm per peck)
X60. ;
G98 X100. ;                   (return to the initial level after the last hole)
G80 ;

G74 – Left-hand tapping

  • Start the spindle with M04 (counterclockwise) before the cycle. At the hole bottom the spindle reverses to clockwise and the tap backs out.
  • Choose F from spindle speed and thread pitch, as in G84.
  • Feedrate override is ignored during the cycle, and feed hold does not stop the machine until the return motion is complete.

G76 – Fine boring

At the hole bottom the control dwells for P, stops the spindle at a fixed angle (orientation) and shifts the tool away from the wall by Q, opposite to the tool nose. It then retracts in rapid traverse, so the boring bar does not leave a scratch on the bore.

M03 S600 ;
G90 G99 G76 X40. Y30. Z-30. R2. Q0.2 P500 F60 ;   (P500 = 0.5 s dwell)
G80 ;
  • Program Q as a positive value. The shift direction is set in parameter 5148.
  • Clamp the boring bar so that, at the oriented spindle position, its tip points opposite to the shift direction. Otherwise the tool moves into the wall instead of away from it.
  • Caution: Q is modal across drilling cycles and is also the depth of cut for G73 and G83. Write Q again when you program G73 or G83 after G76.

G85 and G89 – Retract at cutting feed

G85 feeds from R to Z and returns to R at the cutting feedrate. It is used for reaming and finish boring. G89 works the same way but dwells for P at the bottom, which helps produce a flat, clean face at the bottom of a counterbore.

G86 – Rapid retract with the spindle stopped

The spindle stops at the hole bottom and the tool retracts in rapid traverse. Because the tool tip can drag on the bore during retract, G86 is usually used for rough boring. If the R point and the initial level are very close, the spindle may not reach full speed before the next hole. In that case the manual recommends a G04 dwell before each hole instead of repeating with K.

G87 – Back boring

With the spindle oriented and the tool shifted by Q, the tool rapids through the hole down to the R point below it; in G87 the R point is on the underside. The tool is re-centered, the spindle starts and the tool cuts upward (Z+) to the Z point. The spindle then orients again, the tool shifts away and returns to the initial level. Return to the R level (G99) is not used in this cycle.

G88 – Dwell, stop and manual retract

After the dwell at the bottom the spindle stops and the machine enters a hold state. The operator can switch to manual mode and move the tool out of the hole. When the cycle is restarted, the tool returns to the initial or R level according to G98/G99, the spindle turns clockwise and the program continues with the next block.

Rules common to these cycles

  • Start the spindle with M03 before the cycle, or with M04 for G74.
  • A group 01 G code (G00–G03) in the same block as the cycle cancels the cycle.
  • Q and P are stored as modal data only when written in a block that actually drills.
  • If G43/G44 tool length compensation is commanded within the cycle, it is applied after positioning to the R point.
  • G76 and G87 require spindle orientation (stopping the spindle at a fixed angle). Check in the machine builder’s manual how this function and the shift direction are set on your machine.
  • Dimensions, speeds and feeds in the examples are for illustration only.

20. Common mistakes

  • Forgetting G80: a hole may be drilled unintentionally on the next X–Y move.
  • Writing the R plane too low: the tool rapids close to the surface/clamping.
  • Writing the Z sign wrong: the tool does not go deep enough or advances toward the table.
  • Not checking obstacles with G99: the tool can hit the vise moving low between holes.
  • Choosing Q wrong in G83: large Q causes chip jam, small Q wastes time.
  • Not calculating F by pitch in G84: the tap can break or the thread can spoil.
  • Using the wrong H offset: all hole depths come out wrong or a collision occurs.

21. Basic commands used in this lesson

CodeFunction
G80Cancels the canned cycle
G81Standard drilling
G82Dwell drilling at the bottom
G83Peck deep drilling
G84Tapping
G98Returns to the initial plane
G99Returns to the R plane
X, YHole center
ZFinal hole depth
RApproach plane
QPeck amount
PDwell time
FFeed rate

22. Lesson summary

In this lesson we learned that canned cycles shorten drilling programs; that G81 is used for standard drilling; that G82 dwells at the hole bottom; that G83 drills the hole in small steps to ease chip evacuation; that G84 is the tapping cycle; that Z sets the hole depth, R the approach plane, Q the peck amount and P the dwell time; that G98 returns to the initial plane and G99 to the R plane; and that the cycle must be canceled with G80 after drilling is finished.

Try it yourself: You can try the G81, G83 and G84 cycles covered in this lesson directly in your browser. Enter the part dimensions and hole positions, watch the toolpath in 3D and download the generated program: CNC Milling CAM Simulator and G Code Generator.