🔨 G-CODE CYCLES · CUSTOM MACROS · GUNDRILL · BTA

CNC Programming for
Deep Hole Drilling

From G73 and G83 peck cycles to Fanuc Macro B, Siemens CYCLE83, and continuous-feed gundrilling and BTA programming. Peck-depth rules, dwell, chip breaking, complete working G-code examples, and the custom macros that take over beyond 8×D.

6+Canned & macro cyclesG73 · G83 · G74 · G85 · CYCLE83 · 241
~8×DCanned-cycle limitThen macro or gundrill
1–5×DPeck depth ruleShrink as the hole deepens
400:1Gundrill L/DContinuous feed, no peck

When Standard Cycles Stop Working

30-Second Summary: Standard peck cycles (G73 chip-break, G83 chip-clear) are reliable to roughly 8× drill diameter (L/D 8:1). Beyond that you need progressively decreasing peck depths, a custom macro, or a switch to continuous-feed deep hole drilling (gundrilling or BTA). Choosing the wrong cycle either wastes cycle time or risks breaking the tool. On dedicated gundrill and BTA machines the tool feeds continuously — pecking is primarily a machining-center technique for carbide deep hole drills.

Match the cycle to the L/D ratio before you write a single line of G-code:

🎯
≤ 3×D→ G81 plain drill
🔧
3–8×D→ G83 full-retract peck
⚙️
8–20×D→ Progressive macro
🔥
> 20×D→ Gundrill / BTA
💡 The core rule: Canned cycles evacuate chips; they do not solve chip generation. If chips cannot escape, they re-cut, pack, and break the drill. Every deep-hole program is really a chip-evacuation program — choose the cycle that matches how aggressively chips must be removed at that depth.

Five Cycles You Will Actually Use

CodeNameRetract BehaviorBest ForPractical Depth Limit
G81Standard / plain drillNo peck — continuous feed in, rapid outShallow holes, spot drills, through-holes ≤ 3×D< 3×D
G73High-speed peck (chip break)Short retract of the chip-break distance d inside the holeModerate depths, ductile materials that make stringy chips~4.5×D
G83Full-retract peck (deep hole)Full retract to the R-plane each peckDeep holes needing complete chip evacuation~8×D (to 12×D with careful peck sizing)
G74End-face peck drill (lathe)Short retract R per peck along ZDeep Z-axis drilling on turning centers< 8×D
G85Boring / feed-out cycleFeed to depth, feed back out — no rapid retractReaming and boring where a power-feed retract avoids drag marks—

G85 earns a mention in deep-hole work because its feed-out retract prevents the tool from scoring the bore wall on withdrawal — useful for a finishing pass after peck drilling. It is a modal cycle, canceled with G80, like the rest.

Cycle syntax at a glance

G81 X_ Y_ Z_ R_ F_                 (plain drill - no peck)
G73 X_ Y_ Z_ R_ Q_ F_               (high-speed peck - Q = peck depth, short retract)
G83 X_ Y_ Z_ R_ Q_ P_ F_ K_         (deep hole peck - Q = peck, P = dwell at bottom, K = repeats)
G74 R(e);  G74 Z_ Q_ F_             (lathe end-face peck - Q in microns, R = retract per peck)
G85 X_ Y_ Z_ R_ F_                  (boring - feed in, feed out)
⚠️ Modal caution: All five cycles are modal. Always cancel with G80 before the next tool call — a forgotten G80 is the single most common "machine does something weird" bug in drilling programs.

G73 vs. G83 in Depth

✅ G73 — Chip Break

  • Retracts only the chip-break distance d (≈0.010–0.015″ or ~1 mm), set in machine parameters (Fanuc 5114 metric / 5115 inch)
  • Stays in the hole — faster, less vibration, better hole finish
  • Ideal for shallow to moderate depths and stringy ductile chips
  • No dwell at the bottom
⚠️ Check the G73 retract default: the d value lives in a machine parameter, not the program — some controls ship with an excessive default (~0.4 in) that silently wastes most of the cycle moving through air. Verify it on a new machine and set d to ~3% of drill diameter (min 0.003 in).

⚠️ G73 — Limits

  • Chip evacuation degrades as the hole deepens — the short retract never clears the flutes
  • Not reliable past ~4.5×D
  • Wrong cycle where chips must fall completely free

✅ G83 — Chip Clear

  • Retracts fully to the R-plane each peck — chips fall clear, coolant reaches the edge
  • Supports a P dwell at the bottom for accurate hole depth
  • The correct cycle for deep holes and long-chip materials

⚠️ G83 — Cost

  • Slower per hole than G73 — every peck is a full trip out of the hole
  • Re-entry shock can chip a brittle carbide edge
  • Exposes more of the drill to vibration on the long retract stroke

How G83 actually retracts

G83 rapids to the position, rapids to the R-plane, feeds to depth Q, then rapid-retracts all the way to the R-plane. On the next stroke it rapids back down to a point Q − d (one chip-break clearance above the previous bottom), then feeds the remaining d plus the next full peck:

G98 G83 Z-200. R3. Q20. P0.5 F120.
1. Rapid to X,Y        2. Rapid to R3.0         3. Feed to -20.0
4. Rapid to R3.0       5. Rapid to -19.9 (Q-d)  6. Feed to -40.0
... repeat to Z-200., dwell P0.5, then G98 rapid to the initial plane
⚠️ The hidden cycle-time killer: The clearance d — how far above the previous peck bottom G83 stops on its rapid re-entry — is a machine parameter (Fanuc: parameter No. 5115, "clearance of canned cycle G83"). Many controls ship with d = 0.100″. Cutting it to 0.010″ can dramatically shorten deep-hole cycle times without hurting chip evacuation. Too small, however, and the drill slams into chip buildup at full rapid — some shops raise the rapid-stop distance (e.g., parameter 6211 on some controls) to protect the tool.

How Deep Should Each Peck Go?

L/D RatioRecommended Initial Peck DepthRecommended CycleNotes
3:1–5:11.5–2.0 × DG83Standard peck cycle is sufficient
5:1–8:11.0–1.5 × DG83Reduce feed by 20%
8:1–12:10.5–1.0 × DG83 or custom macroProgressive decrease recommended
12:1–20:10.3–0.5 × D, decreasing with depthCustom macroUse a pilot hole; feed reduction factor 0.6×
> 20:10.2–0.3 × D, decreasing progressivelyCustom macro onlyPilot hole required; reduction factor 0.5×
💡 Web-recommended peck sizing: A widely used rule of thumb is 1–5× drill diameter per peck — 1–2×D for shallow holes, smaller pecks for deep or stringy-chip materials. A common progression is 3×D on the first peck, 2×D on the second, then 1×D for the rest. Some controls (e.g., G&L) support decreasing peck depth automatically: start near 3×D and cut each successive peck ~20% until it bottoms out near 20% of the initial Q. Many shops simply run 1×D and never look back.
✅ Hybrid approach: For very deep holes in stainless or alloy steel, run G73 (high-speed chip break) through the upper portion, then switch to G83 (full retract) for the deeper portion where chips must be cleared completely. Short 0.05–0.1″ chip-breaking pecks beat long pecks on stringy chips — even at the cost of cycle time.

Machining Center Example

20 mm carbide drill, 200 mm deep (10:1)

O1000 (G83 PECK DRILL - 20MM DRILL, 200MM DEEP, L/D 10:1)
N10  G21 G40 G80 G90          (metric, cancel canned cycles)
N20  G54 G0 X50. Y50.         (hole position)
N30  S900 M03
N40  G43 H01 Z20. M08         (tool length comp, coolant on)
N50  G98 G83 Z-200. R3. Q20. P0.5 F120.
N60  G80                      (cancel the cycle)
N70  G0 Z100. M09
N80  M05
N90  M30
Q20 = 20 mm peck (1×D). P0.5 = 0.5 s dwell at the bottom to stabilize the hole and clear residual chips. G98 retracts to the initial plane; G99 would retract only to the R-plane.
⚠️ When to abandon G83: At 10:1 this program is at the practical edge of a plain G83. Push toward 12:1–20:1 and you should switch to the progressive macro in the next section — or cut the first peck to 0.5–1.0×D and drop the feed 20–30%.

Progressive Deep Hole Cycle

For holes exceeding 8×D on Fanuc-controlled machining centers, this custom macro progressively reduces peck depth as the hole deepens. Note the correct Macro B convention: square brackets for arithmetic, parentheses for comments.

O9001 (DEEP HOLE MACRO - FANUC MACRO B)
(CALL: G65 P9001 Z_ Q_ R_ T_ I_ F_)
#26 = Z final depth (absolute)
#17 = Initial peck depth Q (mm)
#18 = Minimum peck depth R (mm)
#20 = Dwell at bottom T (seconds)
#4  = Decrease rate I (0.1 = 10% per peck)
#9  = Feed rate F (mm/min)

#100 = #5043          (current Z position)
#101 = #100 - #17     (first peck target)
#102 = #17            (current peck depth)

WHILE [#101 GT #26] DO1
  G01 Z#101 F#9
  G00 Z#100           (retract to previous safe Z)
  #100 = #101         (update safe Z)
  #102 = #102 * [1 - #4]    (reduce peck depth)
  IF [#102 LT #18] THEN #102 = #18    (clamp to minimum)
  #101 = #101 - #102  (next peck target)
  IF [#101 LT #26] THEN #101 = #26    (don't overshoot final depth)
END1

G01 Z#26 F#9          (final depth)
G04 P#20              (dwell at the bottom)
G00 Z[#5043]          (retract to initial plane)
M99

Call it for a 20 mm drill, 400 mm deep (20:1) — 15 mm initial peck, 10% reduction per peck, 3 mm minimum, 0.5 s dwell:

G65 P9001 Z-400. Q15. R3. T0.5 I0.1 F120.
💡 Make it a canned cycle: Bind the macro to a custom G-code and call it modally like a built-in cycle. Store a negative G-code number in the user-defined G-code parameters starting at 6050 (tied to programs O9010 and up). Example: parameter 6051 = -123 makes G123 call O9011 modally; parameter 6050 = -89 makes G89 call O9010. Enable G66.1 modal calls (parameter 6007, bit 3 = 0), and cancel with a redefined G80 (parameter 6052 = 80, running program O9012 that issues G80, G67, and resets the first-hole flag #500).

End-Face Peck Drilling on Turning Centers

On Fanuc lathes, G74 is the end-face peck drilling cycle (it doubles as face grooving when X and P are added). It is programmed in two blocks, and the Q value is entered in microns without a decimal point:

G74 R(e);              (e = retract distance per peck, mm - modal)
G74 Z(W) Q(delta-k) F(f);   (Z = final depth, Q = peck in microns, F = mm/rev)

Worked example — 15 mm drill, 50 mm deep, 10 mm pecks

O2000 (G74 END-FACE PECK DRILL ON LATHE)
N10  G21 G97 S750 M03
N20  G0 X0. Z3.
N30  G74 R1.0             (retract 1 mm per peck)
N40  G74 Z-50. Q10000 F0.05   (Q10000 = 10 mm peck, F = 0.05 mm/rev)
N50  G0 Z50. M05
N60  M30
The cycle rapids back to the start of the last peck before feeding again — a short-retract (chip-break style) behavior along Z.
⚠️ Micron trap: Fanuc reads Q as an integer micron value — no decimal point. Q5000 is 5 mm, not 0.005 mm. If a CAM post-processor emits Q in millimeters or with a decimal, the control silently drills a fraction of the intended peck. The retract amount R is modal and can be preset via parameter No. 5139 on many controls.

CYCLE83 Deep Hole Drilling

Siemens controls use CYCLE83 for deep hole drilling with a comprehensive parameter set — progressive peck reduction, dwell at depth and at retract, and a feed-rate factor:

CYCLE83(RTP, RFP, SDIS, DP, DPR, FDEP, FDPR, DAM, DTB, DTS, FRF, VARI)
ParameterMeaningExample Value
RTPRetract plane (absolute)Z = 2.0
RFPReference plane (absolute)Z = 0.0
SDISSafety clearance1.0
DPFinal depth (absolute)Z = -100.0
DPRFinal depth (relative to RFP)100.0
FDEPFirst peck depth15.0
FDPRFirst peck depth (relative)—
DAMSubsequent peck depth (reduction amount)2.0
DTBDwell at depth (seconds)0.5
DTSDwell at start of retract (seconds)0.0
FRFFeed-rate factor for first peck0.8
VARIOperation mode (0 = chip break, 1 = full retract)1
⚠️ Cross-control trap: On Siemens controls, G74 is not a drilling cycle — it returns the machine to the reference point. Always use CYCLE83 for deep hole drilling on Sinumerik. What works on a Fanuc is not portable without checking.

Cycle 241 & Cycle 205

Heidenhain controls offer Cycle 241 specifically for single-lip deep hole drilling (gundrilling), with programmable spindle-speed reduction and coolant control:

CYCL DEF 241 SINGLE-LIP DEEP HOLE DRILLING
Q200 = +2    ;SET-UP CLEARANCE
Q201 = -400  ;DEPTH
Q206 = +120  ;FEED RATE FOR PLUNGING
Q211 = +0.5  ;DWELL TIME AT DEPTH
Q203 = +0    ;SURFACE COORDINATE
Q204 = +50   ;2ND SET-UP CLEARANCE
Q208 = +300  ;RETRACTION FEED RATE
Q256 = +20   ;STARTING ANGLE
Q257 = +0    ;ANGLE INCREMENT

Cycle 205 (Universal Pecking) provides variable peck depth with chip breaking, suitable for deep hole drilling on machining centers. Q parameters control the initial and subsequent peck depths, dwell time, and feed-rate reduction — the Heidenhain answer to the Fanuc progressive-macro problem, built in.

Continuous-Feed Programming

Gundrilling uses a single-lip tool that evacuates chips through a V-shaped groove, driven by high-pressure coolant delivered through a hole inside the tool. On a dedicated gundrill machine the tool feeds continuously with no pecking, and it retracts immediately at the bottom — no dwell, to avoid leaving dwell marks. On a machining center, gundrilling works only if the machine has through-spindle high-pressure coolant; external flood coolant cannot reach the cutting zone in a deep hole.

Pilot hole replaces the starter bushing

💡 Pilot hole rule: Drill a pilot 1–2×D deep and 0.0005″ (about 0.012 mm) larger in diameter than the gundrill. A flat-bottom pilot is best — it eliminates entry deflection. Approach the pilot at ~25 RPM to line up, stop ~0.100″ before the pilot bottom, then engage coolant and spindle speed and feed.
✅ Capability: Gundrilling covers roughly 1–50 mm diameter (micro-drilling down to 1–3 mm) and reaches L/D of 400:1 or better on dedicated machines; 20:1 and beyond generally requires dedicated equipment for reliable straightness.

Worked program — 10 mm gundrill, 400 mm deep (40:1), machining center

O3000 (GUNDRILL - CONTINUOUS FEED, THROUGH-SPINDLE COOLANT)
N10  G21 G40 G80 G90
N20  G54 G0 X0. Y0.
N30  S1500 M03
N40  M08              (high-pressure through-spindle coolant ON)
N50  G43 H01 Z3.
N60  G1 Z-400. F180.  (single continuous feed - no peck, no dwell)
N70  G0 Z150. M09     (retract immediately at the bottom)
N80  M05
N90  M30

For through-holes, feed 20–30% of the diameter past the far wall so the tip fully breaks through.

⚠️ Exception: Some small-diameter gundrill makers (e.g., Moldino) specify that their small gundrills should always be run with a G83 peck cycle — always follow the tool supplier’s recommendation rather than the general continuous-feed practice.

Single Tube System Programming

BTA drilling is a continuous-feed process — the hole is cut in one pass and chips are evacuated through the tool (Single Tube System, STS) back to the chip box. There is no pecking. Program it as a single feed move with high-pressure coolant; the real work is sizing the machine settings for the hole diameter.

O4000 (BTA STS - CONTINUOUS FEED ON CNC LATHE)
N10  G21 G97 S250 M03
N20  G0 X0. Z2.
N30  M08              (high-pressure coolant ON, typically 50-100 bar)
N40  G1 Z-800. F0.1   (single continuous feed - F in mm/rev)
N50  G0 Z150. M09     (retract at the bottom, no dwell)
N60  M05
N70  M30
Reference setting (ISCAR STS guide)ValueNotes
Cutting speed Vc~250 SFM (~76 m/min)Lower for the Double Tube System ejector (~230 SFM)
Feed rate~0.006–0.010 IPR (0.15–0.25 mm/rev)Continuous, scaled to tool diameter
Coolant pressureup to ~1450 PSI (~100 bar)Drives chip evacuation through the tube
Net power / feed forcecharted vs. diameter (0.6–1.1″: 1.3–10.7 HP; feed force to ~1800 lbf)Use the toolmaker’s charts, not guesses
⚠️ Toolmaker’s caveat: Published STS settings are starting points and “should not be used as exact recommendations.” Modify them for material, machine rigidity, and coolant quality before production — and monitor coolant pressure continuously: a sudden drop signals chip blockage.

Making Macros Behave Like Canned Cycles

Built-in cycles have limits — for example, drilling deep holes in malleable materials needs a combination of chip breaking and chip clearing that no single canned cycle provides. Custom macros solve this. This lathe macro (O9011) binds to a user-defined G-code (G174 via parameter 6051) and includes error trapping so a bad call alarms instead of cutting air:

O9011 (LATHE DEEP-HOLE MACRO - BIND TO G174 VIA PARAM 6051)
(CALL: G65 P9011 Z_ Q_ F_   OR   G174 Z_ Q_ F_)
#26 = Z final depth (abs)     #17 = Q peck (microns)     #9 = feedrate
IF [#17 EQ #0] THEN #3000 = 100 (PECK LENGTH NOT SPECIFIED)
IF [#26 EQ #0] THEN #3000 = 101 (DEPTH NOT SPECIFIED)
#17 = #17 / 1000.             (microns to mm)
#100 = #5002                  (current Z position)
#101 = #100 - #17             (first peck target)
WHILE [#101 GT #26] DO1
  G1 Z#101 F#9
  G0 Z#100                    (retract to the start of the last peck)
  #100 = #101
  #101 = #101 - #17
  IF [#101 LT #26] THEN #101 = #26   (clamp final peck)
END1
G1 Z#26 F#9
G0 Z#5002                     (retract to start)
M99
Usage: replace G74 with G174 in an existing program — e.g., G174 Z-20. Q5000 F20. The macro rapids to 1 mm before the previous depth before feeding, exactly like a canned cycle.

Combined chip-break + chip-clear macro (machining center)

A combined macro uses an outer WHILE loop for chip clearing (full retract to the R-plane) and an inner WHILE loop for chip breaking (small retracts) inside each clearing peck. It reuses the standard G83 words plus a V address for the chip-break distance, called modally with G66.1:

G66.1 P9010 X1.0 Y1.0 Z-3.25 R0.1 Q1.0 V0.1 F5.0
X2.0          (second hole position - macro still active)
X3.0
G67           (cancel the modal macro call)
💡 Keep state between holes: A well-written macro stores modal arguments in common variables only when they are specified (e.g., IF [#24 NE #0] THEN #101 = #24), so previously specified values persist across multiple hole positions — just like a built-in canned cycle.

Deep hole cycles by controller

ControllerPrimary Deep Hole CycleKey Features
Fanuc / HaasG83 (standard), G73 (chip break)
Macro B custom cycles for L/D > 12:1
Modifiable with custom macros; Q parameter for peck depth; variable retract amounts
HeidenhainCycle 241 (single-lip)
Cycle 205 (universal pecking)
Single-lip specific with speed control; programmable spindle reduction; coolant on/off per step
Siemens SinumerikCYCLE83Comprehensive parameter set; progressive peck reduction; dwell at depth and retract; feed-rate factor
Mazak (Mazatrol)M+ / M- codes integrated in the drilling unitConversational programming; deep hole parameters in the drilling unit setup
Okuma (OSP)M-codes with custom macro variablesCustom macro with deep hole drilling canned-cycle options

Mistakes That Break Deep Hole Programs

💡 Progressive peck formula: Peck depth at stroke n = Initial Peck × (1 − Decrease Rate)n−1. Example: initial peck 20 mm, decrease 10% → stroke 2 = 18 mm, stroke 3 = 16.2 mm, stroke 4 = 14.6 mm. Use G73-style chip breaking (short retract) on each stroke, with a full G83-style retract every 3–4 strokes for thorough chip clearing.
⚠️ Carbide drill caution: Pecking a solid carbide deep hole drill risks chipping the cutting edge at each re-entry — the repeated shock of re-entering the cut can fracture the edge. Prefer continuous feed (gundrill/BTA style) with high-pressure through-spindle coolant. If pecking is unavoidable, use very small retracts (0.5–1.0 mm, G73 style) and cut the feed 50% for the first 0.5 mm of each peck.
❌ The five classic mistakes: (1) Using G73 past ~4.5×D — chips never leave the flutes. (2) Entering G74 Q with a decimal point — Fanuc reads integer microns, so a CAM post that emits Q in mm silently drills a tenth of the intended peck. (3) Retracting G83 with coolant OFF — the next peck re-cuts settled chips. (4) Pecking a solid carbide drill like HSS — chipped edges. (5) Gundrilling without a pilot hole — a tiny entry wander grows into a large axis error at 25×D.

Programming tips that save tools

Keep Reading