Canned Cycles & Hole Patterns
Canned cycles package a multi-step drilling or boring sequence into one line of code. This page explains how they work internally, their modal behavior, G80 cancellation, retract modes, and how to program efficient hole patterns.
Concept
A canned cycle is a pre-programmed motion sequence stored in the CNC controller. When you write a single line like G83 R2. Z-15. Q3. F120., the controller remembers a whole recipe: rapid to the hole X/Y, rapid down to R2, feed in 3 mm pecks to Z-15, retract to clear chips, and return to the R plane. You only need to give new X/Y positions for each subsequent hole.
Canned cycles are modal. Once activated, the stored R/Z/F/Q/P recipe stays active until canceled. On a Haas mill, a bare X/Y block (no motion G-code) repeats the cycle at the new position; an explicit G00/G01 block also exits cycle mode, but G80 is still written explicitly so the intent is unambiguous. If you forget to end the pattern, an unexpected X/Y move can become an unwanted hole.
Why It Matters
Before canned cycles existed, a drilling program looked like this for each hole:
G00 X10. Y10. (rapid to hole)
G00 Z2. (rapid to R)
G01 Z-15. F120. (feed down)
G00 Z2. (rapid back up)
G00 X50. Y30. (rapid to next hole)
G01 Z-15. F120. (feed down again)
G00 Z2. (back up)
The hand-written snippet above is a two-hole fragment. The independent four-hole cycle example below shows the pattern:
G99 G81 R2. Z-10. F100. X-25. Y-25.
X25. Y-25.
X25. Y25.
X-25. Y25.
G80
The first hole coordinates are on the G81 call line, so the call itself drills hole 1; the next three lines drill holes 2–4. The controller handles the rapid-feed-retract sequence for every hole, and every hole uses the same R plane, depth, and feed.
How It Works
Inside Every Canned Cycle
When the controller executes a canned cycle, it performs these five steps in order:
- Rapid to X/Y position — moves the tool to the hole coordinate at rapid traverse.
- Rapid to R plane — moves Z down to the R plane at rapid speed. R is typically 2–3 mm above the workpiece.
- Feed to Z depth — switches to feed rate F and cuts to the programmed Z depth. Peck cycles (G83) do this in Q increments with retracts between.
- Dwell or special motion — G82 dwells at the bottom; G84 reverses spindle for tapping; G85 feeds back out.
- Retract — G98 retracts to the initial Z plane (the height before the cycle was called); G99 retracts only to the R plane.
- Repeat or cancel — XY moves to the next hole and the recipe repeats; G80 ends it.
Common Canned Cycles Reference
| Code | Name | Motion | Use For |
|---|---|---|---|
| G81 | Simple drill | Feed in, rapid out | Through holes, centering |
| G82 | Drill with dwell | Feed in, dwell P, rapid out | Spot faces, counterbores |
| G83 | Peck drill | Feed Q, retract, repeat | Deep holes, chip clearing |
| G84 | Tapping | Synchronous feed in, spindle reverses at bottom, feed out | Tapped holes (see page 34) |
| G85 | Bore | Feed in, feed out | Reaming, boring |
| G80 | Cancel cycle | — | End of hole pattern |
Modal Behavior and Re-Commanding
When a cycle is active, the R, Z, F, Q, P values are stored and reused. You only need to re-specify a value when it changes. For example, if all holes are the same depth, you write Z once in the G81 line. If hole 3 needs a different depth, you write a new Z on that line — the controller updates the stored Z for subsequent holes too.
This means you can mix depths in one pattern: drill three holes at Z-15, then change to Z-25 for the next two, all within the same active cycle. Just remember to G80 when done.
G80: Canceling the Cycle
G80 cancels the active canned cycle without moving the axes. On Haas mills, a bare X/Y block repeats an active cycle, while an explicit G00 or G01 also cancels it. We still use G80 to make the end of the pattern clear. After the completed G99 example, the tool is at R2. The following G00 Z50 retracts to this example's verified clearance height; Z50 is not a universal safe position.
Example
Worked example: Four Ø6 mm holes on a 50 mm square, centered at (0,0). Holes at (−25,−25), (25,−25), (25,25), (−25,25). Through-holes in 8 mm plate: Z depth = 8 + 0.3×6 = 9.8 mm, use Z-10. R plane Z2. No obstructions, so G99. Feed 100 mm/min at S2000.
O0018 (4-HOLE PATTERN)
G21 G17 G90 G40 G80
G54
T01 M06 (Ø6 DRILL)
S2000 M03
G00 G43 H01 Z50. M08 (tool length move, at verified Z50 clearance)
G94
G00 X-25. Y-25. (rapid above hole 1 at Z50)
G99 G81 R2. Z-10. F100. (drill hole 1, retract to R2)
X25. Y-25. (hole 2)
X25. Y25. (hole 3)
X-25. Y25. (hole 4)
G80 (cancel cycle)
G00 Z50. (retract to verified clearance)
M09
M05
M30
Block trace (4 holes, exactly):
| Block | Drills? | Cumulative holes | End Z |
|---|---|---|---|
| G43 Z50 / G00 XY to hole 1 | no | 0 | 50 |
| G99 G81 R2 Z-10 F100 (already at X-25 Y-25) | hole 1 | 1 | R2 |
| X25 Y-25 | hole 2 | 2 | R2 |
| X25 Y25 | hole 3 | 3 | R2 |
| X-25 Y25 | hole 4 | 4 | R2 |
| G80 | no | 4 | R2 (mode off) |
| G00 Z50 | no | 4 | 50 |
G98 vs G99 Retract, Side by Side
G98 and G99 only differ in how high the tool lifts after each hole. G99 retracts to R; G98 retracts to the initial plane established before the cycle. If a clamp sits between hole 1 and hole 2, call G98 on the hole 1 line so that after hole 1 the tool is already above the obstacle before XY moves to hole 2. If the tool is already sitting low on R and an obstacle appears, do not rely on G98 retroactively: G80, move Z to a verified height, then re-establish the cycle. G98 is not itself a safety guarantee; the initial plane must be above the obstacle and the XY envelope must be clear.
Hole Patterns: Rectangular Array and Bolt Circle
For a rectangular array, list X/Y rows. For a bolt circle, compute each point: (Cx + R×cosθ, Cy + R×sinθ). Example: 6 holes on a pitch circle radius 30 mm, starting at 0°, every 60°: (30,0), (15,25.98), (−15,25.98), (−30,0), (−15,−25.98), (15,−25.98). Each is one X/Y line under the active cycle. Coordinates are rounded to two decimals consistently. The Engineering Tools bolt-circle calculator automates this table.
Modality Traps: What Stays Active
Beyond the cycle itself, the G98/G99 choice, the R and Z values, and the feed F are all modal. If you switch from G81 to G83 halfway, the new Q applies, but R and Z are inherited unless restated. If you switch tools and forget G80, the new tool's first positioning move can drill. The startup block G21 G17 G90 G40 G49 G80 exists partly to clear these modes so each program begins from a known state.
Common Mistakes
- Forgetting G80 — on a Haas, a bare X/Y block repeats the cycle. A positioning X/Y written without an explicit motion code can become an unwanted hole. Always write G80 after the pattern.
- Thinking G80 retracts to Z50 — G80 only cancels the cycle mode. The tool stays at its current Z. Write G00 Z50 explicitly.
- Changing R or Z without re-commanding — R and Z are stored from the cycle line. If you forget to re-specify Z for a deeper hole, it drills to the old depth.
- G99 around a boss or clamp — retracting only to R2 between holes can hit a raised feature. Use G98 when there is any obstacle.
- Leaving cycle state implicit between tools — explicitly cancel the drilling cycle with G80 before changing tools. On the Haas mill used here, bare X/Y blocks can repeat an active drilling cycle, while an explicit G00 or G01 cancels it. Do not assume that every first move after a tool change must drill; establish the intended state and verify the next tool's approach.
Practice
1. After writing G99 G81 R2. Z-15. F120., you write X10. Y20.. What happens?
Ans
The machine rapidly positions to (10,20), rapid to R2, feeds to Z-15 at 120 mm/min, and retracts to R2 (G99). The R, Z, and F are inherited from the G81 line.
2. Why write G00 Z50 after G80?
Ans
In this example G80 leaves the tool at R2, where the last hole completed. G80 does not move Z. The program then writes G00 Z50, a height verified for this setup; that is not a universal safe position.
3. Eight holes on a bolt circle at the same depth. How many G81 lines and how many X/Y lines?
Ans
One G81 call line that includes the first hole coordinates, then 7 more X/Y lines for holes 2–8, then G80. The call itself drills hole 1; do not list hole 1 twice.
4. You need hole 1 at Z-10 and holes 2–4 at Z-20 in the same pattern. How do you do it?
Ans
Write G81 with Z-10 for hole 1. On the hole 2 line, write X... Y... Z-20. The new Z overrides the stored depth. Holes 3 and 4 inherit Z-20. Then G80.
Repeating Holes with L and Subprograms
Many controls support a repeat address after a hole line, and all support calling a subprogram for a repeating pattern. On a rectangular array, write one row as a subprogram of X offsets, then call it once per Y row. This keeps the cycle active while XY steps repeat. For a bolt circle, compute the coordinates once and list them; a subprogram is overkill for six holes but saves typing for 24.
Cycle Parameters Across Tools
Each tool has its own spindle speed and feed, but R plane and Z depth are usually similar across tools on the same part. After the drill, the tap uses the same X/Y pattern but a different Z, R, and F. Call the pattern again with the new tool, restating R, Z, and F; do not assume the old values are safe for the new tool. G80 between tools prevents the new tool's first move from inheriting the drill cycle.
What Changes Between G81, G82, G83, G84, G85
The XY/R/Z/F framework is identical; only the bottom-of-hole motion changes. G81 feeds in and rapids out. G82 adds a dwell P. G83 feeds in Q pecks and retracts fully between. G84 reverses the spindle and feeds out. G85 feeds in and feeds out. This means once you have drilled G81, switching to G83 only adds Q and changes the code letter; the hole positions stay the same.
Programming a Tapped Hole with the Same Cycle
Assume G21/G94, a prepared tap drill, and S500. For M8×1.25, F = S×pitch = 625 mm/min. G84 R2. Z-15. F625. The control reverses spindle at the bottom. G98 is usually chosen for tapping so the tool retracts above the fixture between holes.
Cycle Parameter Dialect Table
| Parameter | Haas mill example | Note |
|---|---|---|
| R | R2. | distance above Z0, mm under G21/G94 |
| Z | Z-10. | tip position, negative into part |
| Q | Q3. | peck increment, mm (G73/G83 family) |
| P | P0.5 | dwell seconds, decimal on Haas |
| F | F100. | mm/min under G94 |
| G98/G99 | modal | initial plane vs R retract |
When a New Tool Reuses the Same Holes
Drill, then tap, then countersink on the same X/Y positions. Each tool calls G80 at the end and re-establishes its own cycle with its own R, Z, F, and S. The coordinates can be kept in a subprogram and called three times, once per tool. Never carry a drill cycle's R2 into a tap cycle without restating it; the tap needs a different R clearance and feed.
Common Setup Checks Before Running a Cycle
Confirm: H offset and G54 are calibrated; R plane clears the hole opening; the retract plane (R for G99, initial Z for G98) clears fixtures between holes; Z depth includes the 118° drill tip and breakthrough; F matches G94 mm/min; spindle direction and RPM suit the tool. Dry-run the first hole at low feed override.
Normal Completion vs Interrupted Cycle
When the pattern finishes normally, every hole has completed its feed and retract, and the tool ends at R2 under G99. If the feed hold or an alarm stops the machine mid-hole, the tool may be at the bottom or mid-peck; do not assume the cycle is "done". Resume from a known state: confirm Z position, reset mode, and only then continue. The trace table above describes a clean run, not an interrupted one.
Why G98 Is Set on the Hole Before the Obstacle
If a clamp sits between hole 1 and hole 2, writing G98 on the hole 1 line means hole 1 finishes by retracting to the initial plane before any XY move toward hole 2. Setting G98 on hole 2 itself would be too late: the tool would already have to cross the obstacle at R2 height. The mode change applies from that block onward.