Skip to content

CNC Programming for Deep Hole Drilling Cycles: G76 and G87

CNC programming for deep hole drilling is fundamentally different from conventional drilling programming. The program must manage not just tool motion but coolant pressure, chip evacuation timing, feed reduction at entry and exit, and multiple retracts to clear chips. A poorly programmed deep hole cycle produces broken drills and scrapped parts regardless of machine capability.

Deep Hole Drilling Cycle Overview

G-Code Cycles for Deep Holes

G-CodeCycle NameApplicationChip EvacuationCoolant
G73High-speed peck drillSmall deep holes (< 3×D increments)Partial (chip break)Through-tool
G83Deep hole peck drillGeneral deep hole, standard machinesFull retract per peckThrough-tool or flood
G76Fine boringPrecision finish boringManual (operator removes chips)Flood or mist
G87Back boringBoring from opposite side of partManualFlood or mist
Custom macroUser-defined deep hole cycleGun drilling, BTA drillingProgrammable retract patternThrough-tool (high pressure)

Tip: Standard G83 peck cycles are not suitable for gun drilling or BTA drilling. These processes require continuous feed with specific coolant pressure management. Use custom macros or machine builder cycles for production deep hole drilling.

G83 Deep Hole Peck Cycle

G83 Format (Fanuc)

ParameterDescriptionTypical Values
G83 X_ Y_Hole positionX/Y coordinates
Z_Final hole depthAbsolute Z dimension
R_Retract planeUsually 2–5 mm above part
Q_Peck depth per pass3–10 mm for deep holes
P_Dwell at hole bottom0–500 ms (optional)
F_Feed ratemm/min
K_Number of repeats1 (default)

G83 Programming Example

O1000 (G83 DEEP HOLE EXAMPLE)
N10 G90 G80 G40 G49
N20 G54 G00 X0 Y0
N30 M03 S2000
N40 M08 (FLOOD COOLANT)
N50 G83 X50.0 Y25.0 Z-200.0 R3.0 Q5.0 F150.0
N60 G80
N70 M09
N80 M05
N90 M30

G83 Limitations for Deep Hole Drilling

LimitationProblemWorkaround
Fixed peck depthDoes not vary by hole sectionUse custom macro
No coolant pressure controlCannot reduce pressure at break-throughM-code coolant pressure commands
Full retract onlyWastes time on shallow pecksUse G73 if chip breaking is sufficient
No chip monitoringCannot detect chip packingOperator attention or load monitoring

Custom Macro for Gun Drilling

Fanuc Custom Macro Example

O2000 (GUN DRILLING CYCLE)
(G65 P2000 X_ Y_ Z_ R_ Q_ F_ S_)
(X Y = HOLE POSITION)
(Z = FINAL DEPTH)
(R = RETRACT PLANE)
(Q = FIRST PECK DEPTH)
(F = FEED RATE)

N10 G90 G00 X#24 Y#25 (MOVE TO POSITION)
N20 Z#18 (RAPID TO RETRACT PLANE)
N30 G01 Z-#17 F#9 (FEED TO FIRST PECK)
N40 G04 P500 (DWELL AT BOTTOM)
N50 G00 Z#18 (RETRACT)
N60 #30 = #17 (CURRENT DEPTH)
N70 WHILE [#30 LT #26] DO1
N80 #30 = #30 + #17 (INCREMENT DEPTH)
N90 IF [#30 GT #26] THEN #30 = #26
N100 G01 Z-#30 F#9 (FEED TO NEXT DEPTH)
N110 G04 P500 (DWELL)
N120 G00 Z#18 (FULL RETRACT)
N130 END1
N140 M99

G76 Fine Boring Cycle

G76 Parameters (Fanuc)

ParameterDescriptionTypical Values
G76 X_ Y_Hole positionX/Y coordinates
Z_Final depthAbsolute Z
R_Retract plane2–5 mm above part
Q_Offset at retract0.2–1.0 mm (typical)
P_Dwell at bottom300–1000 ms
F_Feed ratemm/min
I_Offset direction XUsually 0
J_Offset direction YUsually 0

G76 Programming Example

O3000 (G76 FINE BORING EXAMPLE)
N10 G90 G80 G40 G49
N20 G54 G00 X75.0 Y40.0
N30 M03 S1800
N40 M08
N50 G76 X75.0 Y40.0 Z-150.0 R3.0 Q0.3 P500 F120.0
N60 G80
N70 M09
N80 M05
N90 M30

G76 Operation Sequence

StepActionDescription
1Rapid to R planeZ-axis rapid to retract plane
2Feed to Z depthBoring feed to final depth
3Dwell at bottomSpindle rotates at bottom (dwell P)
4Offset toolTool shifts by Q value (clears bore wall)
5Retract to R planeRapid retract with offset
6Return to centerTool shifts back to center
7Rapid to initial ZReturn to start position

G87 Back Boring Cycle

G87 Parameters (Fanuc)

ParameterDescriptionTypical Values
G87 X_ Y_Hole positionX/Y coordinates
Z_Final depth (Z- = starting point)Absolute Z
R_Retract plane (behind the bore)Absolute or incremental
Q_Tool offset0.3–1.0 mm
P_Dwell300–1000 ms
F_Feed ratemm/min

G87 Operation Sequence

StepActionDescription
1Position tool at holeWith offset (Q) to clear bore
2Rapid to Z depth (behind bore)Z-axis feed to start position
3Return tool to centerRemove offset
4Feed in Z+ directionBack boring feed
5Dwell at endP parameter
6Offset tool againQ offset to clear bore
7Rapid retractWithdraw tool

Peck Depth Calculation

Hole Diameter (mm)MaterialPeck Depth (mm)Retract Type
3–10Steel2–4Full retract
10–20Steel5–8Full retract
20–40Steel8–15Full retract
3–10Aluminum5–10Partial retract
10–20Aluminum10–20Partial retract
20–40Aluminum15–30Partial retract
Any (gun drill)AnyContinuous (no peck)N/A — continuous feed
Any (BTA)AnyContinuous (no peck)N/A — continuous feed

Depth-Dependent Feed Rate Programming

Depth Range (% of total)Feed Rate FactorReason
0–10% (entry)50–70%Reduce walking at entry
10–80% (steady)100%Full feed rate
80–95% (deep)80–90%Slight reduction for stability
95–100% (break-through)50–70%Reduce breakout burr

Siemens Control Programming

Siemens Cycle Calls

Siemens CycleEquivalent FanucDescription
CYCLE83G83Deep hole peck drilling
CYCLE86G76Fine boring
CYCLE87Boring with dwell and stop
CYCLE88Boring with dwell, stop, and retract

CYCLE83 Parameters (Siemens)

ParameterDescriptionExample Value
RTPRetract plane (absolute)3.0
RFPReference plane (absolute)0.0
SDISSafety distance2.0
DPFinal depth (absolute)-200.0
DTBDwell at bottom0.5
FRFeed rate150
_VARIMachining type (0=chip break, 1=full retract)1

Common Programming Mistakes

MistakeConsequenceCorrect Practice
Too large peck depthChip packing, drill breakageLimit peck to 1–2× drill diameter
No dwell at depthInconsistent hole bottom finishAdd P300–P500 dwell
Constant feed from entry to exitBell mouth, breakout burrReduce feed at entry and exit
No coolant pressure M-codeCoolant at wrong pressure when drilling startsAdd coolant M-codes at correct sequence points
Feed rate too high for peckOverload on entry per peckCalculate chip load per edge correctly
Ignoring spindle load monitoringCatastrophic failure undetectedProgram load monitor or operator check

FAQ

What is the difference between G73 and G83 for deep hole drilling?

G73 (high-speed peck) retracts only a small distance (d parameter) per peck — typically 0.5–2 mm — which breaks chips but does not fully clear them. G83 retracts fully to the R-plane per peck, fully clearing chips but taking more time. Use G73 for shallow holes where chip breaking is sufficient; use G83 for deeper holes where chip evacuation is critical.

Can I use standard G83 for gun drilling?

No — gun drilling requires continuous feed with no peck retracts. Each retract in gun drilling causes the drill to re-enter the hole, risking walking and guide pad damage. Gun drilling uses a custom macro with continuous feed and coolant pressure management. Some machine builders provide a dedicated gun drilling cycle that maintains spindle speed and coolant pressure during retracts.

How do I program feed rate reduction at hole entry and exit?

Program the entry and exit sections as separate G01 moves with reduced feed rate, then transition to a higher feed rate for the main drilling section. Alternatively, use a custom macro that applies feed rate scaling based on current depth as a percentage of total depth. The typical pattern is 50–70% feed at entry, 100% for the main section, and 50–70% at break-through.

What coolant M-codes are used in deep hole drilling cycles?

Common coolant M-codes for deep hole drilling include: M08 (flood coolant), M88 or M50 (high-pressure coolant on), M89 or M51 (high-pressure coolant off), and M07 (mist coolant). The specific M-codes vary by machine builder — always check the machine manual. High-pressure coolant should be activated before the spindle starts feeding and turned off after the tool clears the hole.

How do I program a back boring cycle with G87?

G87 requires special setup: the tool starts with an offset (Q) to clear the bore, rapids to Z depth (behind the bore), returns to center, feeds in the Z+ direction to back bore, dwells at the end, offsets again, and rapids out. The tool must have a clearance pass before entering the bore. G87 is used when the bore cannot be reached from the front side of the part.


CNC programming for deep hole drilling requires process-specific cycles and parameters. Standard peck cycles are adequate for shallow holes, but production deep hole drilling demands custom macros and proper feed rate management. This article reflects industry practice as of 2026.

Deep Hole Drilling Hub — Your Trusted Third-Party Industry Resource