If you had to write the G-code for pecking a hole line-by-line, a simple 10-hole bolt pattern would take hundreds of lines of code. Enter the Canned Cycle: a pre-packaged sequence of machine movements triggered by a single G-code.

1. The Anatomy of a Canned Cycle

Most canned cycles follow the exact same structure. Once you learn the format, switching between drilling, tapping, or boring is just a matter of changing the initial G-code.

(Standard Canned Cycle Format)
G8X X__ Y__ Z__ R__ Q__ P__ F__
  • G8X: The cycle type (G81, G83, etc.).
  • X, Y: The location of the hole.
  • Z: The final depth of the hole.
  • R: The Reference Plane (where the tool rapids down to before feeding).
  • Q: The Peck Depth (used in G83/G73).
  • P: Dwell Time at the bottom of the hole (used in G82).
  • F: Feed Rate.
Advanced Variables: I, J, & K

While XYZ, R, Q, and F cover 90% of standard drilling, you might see I, J, and K in advanced canned cycles:
• Boring Shifts (G76/G87): I and J dictate the shift amount and direction the boring bar moves before retracting, preventing it from scratching the finished bore on the way out.
• Variable Pecking (G83 on some controls): I (First Peck Depth), J (Amount to reduce each subsequent peck), and K (Minimum Peck Depth).

2. Retract Planes: G98 vs. G99 (CRITICAL)

Before calling a canned cycle, you must tell the machine how high to retract between holes. Getting this wrong is the easiest way to crash a drill into a vise jaw.

G98: Initial Plane Return

The tool will retract all the way back up to the Z-height it was at before the canned cycle started. Use this when you have to jump over clamps or tall features between holes.

G99: R-Plane Return

The tool will only retract to the R-plane (usually 0.1" above the part). Use this for high-speed drilling on flat surfaces to save time.

3. The Heavy Hitters: Common Canned Cycles

G81: Standard Drill

The simplest cycle. Feed down to Z, rapid back out. Used for center drilling, spot drilling, or shallow holes where chip clearing isn't an issue.

G98 G81 Z-0.5 R0.1 F15.0 Z-12.5 R2.5 F380.0

G82: Drill with Dwell

Exactly like G81, but it pauses at the bottom of the hole for a specified time (P). Perfect for counterboring or spot drilling to ensure a perfectly flat, clean finish.

(P500 = 0.5 seconds dwell)
G99 G82 Z-0.25 R0.1 Z-6.5 R2.5 P500 F10.0 F250.0

G83: Deep Hole Peck Drill

Feeds down a specific distance (Q), then rapids completely out of the hole to clear chips, then rapids back down to continue. Used for deep holes (depth > 3x diameter).

(Pecks 0.1" at a time) (Pecks 2.5mm at a time)
G98 G83 Z-2.0 R0.1 Z-50.0 R2.5 Q0.1 Q2.5 F12.0 F300.0

G73: High-Speed Peck Drill

Similar to G83, but it does not retract completely out of the hole. It just backs up slightly to break the chip. Much faster than G83, but chips must be flushed out by coolant.

G99 G73 Z-1.5 R0.1 Z-38.0 R2.5 Q0.05 Q1.25 F20.0 F500.0

G84: Rigid Tapping

Used to cut internal threads. The spindle RPM and Z-axis feed rate are perfectly synchronized. At the bottom of the hole, the spindle instantly reverses direction and feeds back out to the R-plane.

Note: Formula for tapping feed rate: RPM / Threads Per Inch (TPI) = Feed (IPM).

Note: Formula for metric tapping feed rate: RPM × Pitch = Feed (mm/min).

(Tapping 1/4-20 at 500 RPM. 500/20 = 25 IPM) (Tapping M6x1.0 at 500 RPM. 500 * 1.0 = 500 mm/min)
M29 S500 (Enable rigid tap mode on some machines)
G98 G84 Z-0.5 R0.2 F25.0 Z-12.5 R5.0 F500.0

4. The Most Important Code: G80

G80: Cancel Canned Cycle

Canned cycles are Modal. If you turn on G81, the machine will drill a hole at *every single X/Y coordinate* you give it until you tell it to stop. Always put a G80 at the end of your drilling operation. If you forget, the machine will plunge a drill into your part when it tries to rapid to its home position!

(Example of a complete operation)
G00 Z1.0 Z25.0 (Move to safe initial plane)
G98 G81 X1.0 Y1.0 Z-0.5 R0.1 F10.0 X25.0 Y25.0 Z-12.5 R2.5 F250.0 (Drill hole 1)
X2.0 Y1.0 X50.0 Y25.0 (Drill hole 2)
X3.0 Y1.0 X75.0 Y25.0 (Drill hole 3)
G80 (CANCEL CYCLE - Extremely Important)
G00 Z5.0 Z125.0 (Safe to rapid away)

Visualize Your G-Code

Want to see these drill cycles in action? Copy the complete operation code above and paste it into our interactive G-Code Viewer to instantly see the toolpath drawn on your screen.

Open G-Code Viewer
Pro Tip: Clearance Planes

Always set your R-plane at least 0.100"2.5mm above the surface of your part. If the part surface isn't perfectly flat, or if there is a burr from a previous operation, a tighter clearance could cause the tool to crash before it slows down to its feed rate.

Conclusion

Canned cycles save thousands of lines of programming and make hand-coding at the machine feasible. Remember to match your retract plane (G98/G99) to your fixturing situation, match your cycle to your depth (G81 vs G83), and never forget your G80!