CNC Canned Cycles: G81–G89 Drilling, Tapping & Boring with Real G-Code Examples
Canned cycles are the foundation of efficient hole machining in CNC programming.
From simple drilling (G81) to rigid tapping (G84) and boring (G85–G89), these G-codes automate repetitive tool motions, reduce programming time, and minimize operator error.
This guide covers real-world G81–G89 examples for Fanuc, Haas, Siemens, Heidenhain, and Mazak controls, with professional optimization tips.
📌 1. What Are CNC Canned Cycles?
Canned cycles are pre-programmed machining routines built into the control.
They automate the feed, dwell, retract, and return moves for specific operations.
Common Hole-Making Operations:
| Operation | Typical G-Code |
|---|---|
| Drilling | G81 |
| Spot Drilling / Dwell | G82 |
| Peck Drilling | G83 |
| Tapping | G84 |
| Boring (Feed Out) | G85 |
| Boring (Spindle Stop) | G86 |
| Back Boring | G87 |
| Manual Bore | G88 |
| Boring (Custom Retract) | G89 |
📌 2. Basic Canned Cycle Structure
G98 or G99 G8X X__ Y__ Z__ R__ F__
| Code | Function |
|---|---|
| G98 | Return to initial plane |
| G99 | Return to R-plane |
| G8X | Operation code (G81–G89) |
| X/Y | Hole coordinates |
| Z | Final depth |
| R | Retract plane |
| F | Feedrate |
📌 3. G81 — Standard Drilling Cycle
Example (Fanuc/Haas):
%
O1001 (G81 DRILLING)
G90 G17 G21 G40 G80 G54
T01 M06
G00 X0 Y0 S1200 M03
G43 Z100. H01 M08
G81 Z-20. R2. F150
X20. Y0.
X40. Y0.
G80
G00 Z100.
M09
M30
%
Drills holes at X0, X20, and X40, retracting to R2 between holes.
G80 cancels the cycle.
📌 4. G82 — Drilling with Dwell
G82 Z-15. R2. P200 F100
| Parameter | Function |
|---|---|
| P200 | Dwell time in milliseconds |
Ideal for countersinks or soft materials where dwell helps chip clearing.
📌 5. G83 — Peck Drilling Cycle (Deep Hole)
%
O1002 (PECK DRILLING)
G83 Z-50. Q5. R2. F120
X0 Y0
X20 Y0
G80
M30
%
| Parameter | Function |
|---|---|
| Q5. | Peck depth (mm) |
Retracts after every 5 mm to clear chips — perfect for holes deeper than 3×D.
📌 6. G84 — Rigid Tapping Cycle
%
O1003 (RIGID TAPPING)
G84 Z-20. R2. F1.25
X0 Y0
X20 Y0
G80
M30
%
| Parameter | Function |
|---|---|
| F1.25 | Pitch (mm per revolution) |
Requires M29 Sxxxx on Fanuc/Haas for spindle–feed synchronization.
M29 S800
G84 Z-20. R2. F1.25
Synchronizes spindle rotation and feed precisely for thread integrity.
📌 7. G85 — Boring Cycle (Feed Out)
G85 Z-40. R2. F100
Feeds to depth, then feeds out without stopping the spindle — ideal for finishing bores.
📌 8. G86 — Boring Cycle (Spindle Stop)
G86 Z-40. R2. F100
Stops the spindle at bottom, then retracts rapidly.
Used for precision boring or measuring operations.
📌 9. G87 — Back Boring Cycle
G87 Z-40. R2. F100
Cuts from the backside of the hole — often used with special fixtures or inverted parts.
📌 10. G88 — Manual Bore Cycle
G88 Z-40. R2. F100
Operator manually controls retract motion — typically for special measuring setups.
📌 11. G89 — Custom Retract Boring
G89 Z-40. R2. P300 F100
Dwell at bottom before feeding out — useful for smooth bore finishes.
📌 12. Haas Example — Mixed Cycles in One Program
%
O2000 (HAAS MIXED CYCLES)
T01 M06
G90 G54 G17 G40 G80
S1000 M03
G00 X0 Y0 Z100.
G81 Z-20. R2. F150
X25 Y0
G82 Z-20. R2. P200 F100
X50 Y0
G83 Z-50. R2. Q5. F120
G80
M30
%
Combines G81, G82, and G83 in one machining cycle — efficient multi-feature drilling.
📌 13. Siemens Example — CYCLE83 (Peck Drilling)
CYCLE83(DEPTH=-50, PECK=5, RETR=2, FEED=120)
Siemens cycles are parameterized — easier for editing or post-processing.
📌 14. Heidenhain Example — Cycle 200–209 (Drilling Set)
CYCL DEF 200 DRILLING
Q200=+2 ; RETRACT PLANE
Q201=-20 ; DEPTH
Q206=+150 ; FEED
Q202=+2 ; PECK DEPTH
Q210=+0 ; DWELL
Heidenhain uses numbered parameterized cycles instead of G-codes.
📌 15. Mazak Example — Smooth G83
G83 Z-60. R2. Q5. F150
Identical logic to Fanuc — pitch-perfect peck control for deep holes.
📌 16. Advanced Example — Drill Pattern Macro
#100=0
#101=50. (X spacing)
WHILE [#100 LT 5] DO1
G81 X[#100*#101] Y0 Z-20. R2. F120
#100=#100+1
END1
G80
M30
Automatically drills 5 holes along the X-axis with equal spacing.
📌 17. Cycle Optimization Tips
| Goal | Adjustment |
|---|---|
| Chip evacuation | Increase Q in G83 |
| Hole accuracy | Add dwell with G82 |
| Surface finish | Use G85 instead of G81 |
| Time reduction | Use G99 (return to R-plane) |
| Safety | Always cancel with G80 |
📌 18. High-Pressure Coolant Integration
M88 (HPC ON)
G83 Z-80. Q5. R2. F200
M89 (HPC OFF)
High-pressure coolant clears deep chips and extends tool life.
📌 19. Tool Life Macro Example
#500 = [#500 + 1]
IF [#500 GT 100] THEN #3006 = 1 (REPLACE DRILL)
Stops the program after 100 holes to replace the tool automatically.
📌 20. Future Trends (2025–2030)
- AI-controlled adaptive peck depth (sensor-based chip detection)
- Smart coolant modulation by tool load
- Digital twin-based cycle optimization
- Automatic depth compensation for thermal drift
- Closed-loop hole inspection with on-machine probing
✅ Conclusion
Mastering G81–G89 canned cycles allows you to automate 90% of drilling, tapping, and boring operations efficiently.
By combining cycles with macros, sensors, and adaptive parameters, you transform traditional machining into data-driven precision drilling for the Industry 4.0 era.
Leave a comment