G84 Tapping Cycle — How to Program Rigid Tapping on a CNC Mill

The G84 tapping cycle cuts internal threads on a CNC machining center by synchronizing spindle rotation with Z-axis feed. When programmed correctly, the tap advances exactly one thread pitch per spindle revolution — creating clean, accurate threads without a floating tap holder.

This synchronization between spindle and axis is called rigid tapping. It requires the machine controller to control both simultaneously, which is why it behaves differently from other canned cycles.

G84 Syntax

G84 X_ Y_ Z_ R_ F_ P_
  • X, Y — hole position in the current plane
  • Z — depth of the tapped hole (final Z position)
  • R — R-plane (retract height above the part, where the cycle begins feeding)
  • F — feed rate (calculated from spindle speed and thread pitch)
  • P — dwell at the bottom of the hole in milliseconds (optional, not always needed)

Calculating the Feed Rate

This is where most G84 errors happen. The feed rate for tapping is not chosen freely — it is determined by spindle speed and thread pitch:

F = S × pitch

For a metric M8 × 1.25 tap at 600 RPM:

F = 600 × 1.25 = 750 mm/min

For an imperial 1/4-20 tap (pitch = 1/20 = 0.05 inch) at 500 RPM:

F = 500 × 0.05 = 25 inch/min

If F does not match the actual pitch of the tap, the threads will be damaged and the tap will likely break. Always calculate F from the spindle speed and the tap specification — never guess.

Complete G84 Example — M6 × 1.0 Through Hole

%
O2000 (M6 TAPPING EXAMPLE)
G17 G21 G40 G49 G80 G90
G28 G91 Z0.
G90

T5 M6                         (load M6 tap)
G0 G90 G54 X25. Y25. S800 M3  (position over first hole, 800 RPM)
G43 H5 Z50.                   (activate tool length offset)
M8

G99 G84 Z-18. R3. F800        (tap to 18mm depth, R-plane at 3mm, F=800×1.0)
X75. Y25.                     (second hole — cycle repeats automatically)
X75. Y75.                     (third hole)
X25. Y75.                     (fourth hole)
G80                           (cancel canned cycle)

G0 Z50.
M9
M5
G28 G91 Z0.
G28 X0. Y0.
M30
%

Note that after the first G84 block, you only need to specify the new X/Y position — the cycle parameters (Z, R, F) carry over as modal values until G80 cancels the cycle.

G98 vs G99 — Where the Tool Retracts Between Holes

G99 (R-plane return) — after each hole, the tap retracts only to the R-plane before moving to the next hole. Use when all holes are at the same level and there are no obstructions between them.

G98 (initial plane return) — the tap retracts to the Z height active when the cycle was called. Use when moving over clamps, fixtures, or steps between holes.

G98 G84 Z-18. R3. F800    (retract to initial plane between holes)
G99 G84 Z-18. R3. F800    (retract only to R-plane between holes — faster)

Spindle Reversal at the Bottom

At the bottom of the hole, the controller automatically reverses the spindle (M4) and retracts the tap at the same synchronized feed rate. You do not need to program this — it happens inside the cycle.

On some controllers, a P dwell (in milliseconds) at the bottom of the hole gives the spindle time to decelerate and reverse cleanly before retracting:

G84 Z-15. R3. F600 P200    (200ms dwell at bottom before reversal)

Whether P is needed depends on the machine — older or less rigid machines benefit from it; modern machining centers with fast servo response usually don't need it.

Common Mistakes

Wrong feed rate — the most frequent cause of broken taps. Always verify F = S × pitch before running.

R-plane too low — if R is set inside the hole instead of above the part surface, the cycle starts feeding before the spindle reaches speed. Keep R at least 2–3mm above the part.

Forgetting G80 — leaving the canned cycle active means the next positioning move will trigger another tap cycle. Always cancel with G80 after the last hole.

Using M4 manually — G84 manages spindle direction internally. Programming M4 before the cycle can cause the tap to cut in reverse on the way in.

Verify Your Tapping Program Before Running It

Tap breakage is expensive — and unlike a collision that stops the machine immediately, a broken tap inside a workpiece can mean hours of EDM work to extract it. Running the program in Eureka3X before cutting lets you verify the R-plane height, Z depth, and cycle behavior on a full 3D machine model.

Try Eureka3X free for 30 days →

Related Articles

Start verifying your real G-code today.

Ensure your programs are safe and accurate with Eureka 3X Pro.

Start 30-Day Free Trial