G76 threading cycle explained: Fanuc two-line and Haas formats, with a worked 1/2-13 example
Every word of the Fanuc two-line and Haas G76 decoded: thread height 0.6134 × pitch, the D×√n pass rule, RPM guidance, and a complete ready-to-run 1/2-13 UNC program.
G76 is the canned threading cycle on Fanuc and Haas lathes: you give it the minor diameter, the thread end point, the thread height, a first-pass depth, and the lead, and the control generates the whole stack of progressively shallower passes for you — no writing fifteen G32 lines by hand. On Fanuc it's two G76 lines back to back (the first sets the rules, the second describes the thread); on Haas it's traditionally one line with K and D instead of the packed P/Q words. This post decodes every word in both formats, shows the square-root rule the cycle uses to size each pass, and works a complete 1/2-13 UNC external thread you can lift straight into a program.
The Fanuc two-line format, word by word
Fanuc splits G76 across two consecutive blocks. Line 1 is the "how to cut" line, line 2 is the "what to cut" line. The confusing part is that P appears on both lines and means something completely different each time.
Line 1: G76 P(mm)(rr)(aa) Q(min depth) R(finish allowance)
P is a packed 6-digit word -- three 2-digit fields:
mm = number of finishing (spring) passes, 01-99
rr = chamfer / pullout at the end of the thread,
in units of 0.1 x lead (10 = 1.0 x lead, 00 = none --
use 00 only when you have a relief groove to run into)
aa = infeed / tool angle: 60, 55, 30, 29, or 00
Q = MINIMUM depth per pass. Units are microns (metric) or
ten-thousandths "tenths" (inch) -- Q0050 = 0.0005" on a
typical inch-mode Fanuc. No decimal point allowed.
R = finish allowance left for the spring passes (decimal OK,
R0.0010 = 0.001").
Line 2: G76 X(minor dia) Z(thread end) P(height) Q(1st pass) F(lead)
X = final minor diameter of the thread
Z = Z coordinate where the thread ends
P = thread height, RADIAL, single depth -- microns/tenths,
no decimal (P0472 = 0.0472")
Q = depth of the FIRST pass -- microns/tenths, no decimal
(Q0120 = 0.0120")
F = thread lead (= pitch for a single-start thread)The Haas format
Haas kept the same cycle but unpacked the words into plain decimal-point values, which is why most people find it easier to read:
G76 X(minor dia) Z(thread end) K(height) D(1st pass) F(lead)
X = final minor diameter
Z = Z coordinate of the thread end
K = thread height, radial (decimal: K0.0472)
D = first pass depth (decimal: D0.0120)
F = lead
Optional words:
A = tool angle (A60, A30, A0 -- like Fanuc's aa field)
P = cutting method (P1-P4: single-flank / alternating-flank
variants -- check your Haas manual for the exact table)
Note: Haas controls will ALSO accept the Fanuc two-line G76
format via a control setting, so Fanuc-style programs usually
run unmodified. If a two-line G76 program alarms out on a Haas,
that setting is the first thing to check.How deep, how many passes (the square-root rule)
Two numbers drive everything: the thread height and the first-pass depth. For an external 60° UN thread, the radial height the controls use is the sharp-root approximation:
Thread height (radial): h = 0.6134 x pitch
G76 infeed is DEGRESSIVE. From the first-pass depth D, the total
infeed after pass n is:
total infeed after n passes = D x sqrt(n)
pass 1: D x sqrt(1) = D (full D)
pass 2: D x sqrt(2) = 1.414 x D (only 0.414 x D more)
pass 3: D x sqrt(3) = 1.732 x D (only 0.318 x D more)
...
Each pass removes a roughly constant AREA of material, so the
cutting force stays about the same as the tool goes deeper and
the engaged flank gets wider. The minimum-depth Q on Fanuc line 1
stops the late passes from getting uselessly thin.
Number of roughing passes: n = (h / D)^2
Worked for 1/2-13 UNC external:
pitch = 1/13 = 0.0769"
h = 0.6134 x 0.0769 = 0.0472"
minor = 0.500 - 2 x 0.0472 = 0.4056"
first pass D = 0.012"
passes = (0.0472 / 0.012)^2 = 15.5 -> ~16 roughing passes
+ finish passesSixteen passes sounds like a lot if you learned threading on a manual lathe, but this matches shop practice: forum consensus on depth-per-pass is 0.010–0.015" on the first pass for a coarse thread, tapering down to a thou or less at final depth — which is exactly the D×√n curve. Want fewer passes? Raise D (a rigid setup with a full-profile insert takes 0.015"). Chattering or pushing off on small parts? Drop D to 0.008" and let the cycle add passes.
Complete worked example: 1/2-13 UNC external
Threading 0.75" of 1/2-13 on the end of a bar, relief groove at the shoulder, carbide laydown insert in T0101. Fanuc:
(1/2-13 UNC EXTERNAL, 0.75 LONG, RELIEF AT SHOULDER) T0101 G97 S800 M03 (CONSTANT RPM - NEVER G96 FOR THREADING) G00 X0.55 Z0.2 (START ABOVE OD, ~2.6 X PITCH RUN-IN) G76 P020060 Q0050 R0.0010 G76 X0.4056 Z-0.75 P0472 Q0120 F0.0769 G00 X1.0 Z0.5 (RETRACT) M05
G97 S800 M03— constant 800 RPM, spindle forward. Locked RPM is what keeps every pass in the same helix.G00 X0.55 Z0.2— start position: 0.05" above the 0.500" OD, and 0.2" ahead of the thread (about 2.6× pitch) so the Z axis can accelerate to full feed and sync before the tool touches metal.P020060— packed: 02 finishing passes, 00 chamfer/pullout (none — we have a relief groove to run into), 60° infeed angle.Q0050— minimum pass depth 0.0005" (tenths, no decimal). Keeps the last few passes from becoming zero-depth rubbing passes.R0.0010— 0.001" finish allowance shaved off by the two spring passes.X0.4056— final minor diameter: 0.500 − 2 × 0.0472.Z-0.75— thread ends 0.75" from the face.P0472— thread height 0.0472" radial (tenths, no decimal — different meaning than line 1's P).Q0120— first pass 0.0120" deep; the control runs the √n schedule from here (≈16 roughing passes).F0.0769— lead = 1/13. Feed is in inches per rev here, which is why threading only works under G97 with encoder sync.
The Haas single-line equivalent of the two G76 blocks:
G97 S800 M03 G00 X0.55 Z0.2 G76 X0.4056 Z-0.75 K0.0472 D0.0120 F0.0769 G00 X1.0 Z0.5 M05
Same thread, same passes — K carries the height, D carries the first-pass depth, both with normal decimal points.
What RPM for single-point threading
Slower than you'd turn the same diameter. The trade consensus: carbide threading inserts run happily at 200–400 SFM; HSS much slower (30–60 SFM territory). The 800 RPM in the example is about 105 SFM at 1/2" — deliberately conservative for a first part. The real ceiling usually isn't the insert, it's the machine: at 13 TPI the Z axis must travel 0.0769" per revolution, and near the end of the thread it has to decelerate, stop, and retract in sync. Run too fast toward a shoulder and the servos physically can't keep up — the control either distorts the last threads or alarms out. Give yourself a relief groove, or leave 2–3× pitch of runout (that's what the rr chamfer field is for), and whatever RPM you pick, keep it constant: the cycle re-enters the same helix each pass only because the encoder says the spindle is where it was last time.
Infeed angle: P60 vs P29 vs alternating
- 60 (straight radial) — tool plunges straight in; both flanks cut at once. Fine for small, fine-pitch threads; on bigger threads both flanks cutting means a V-shaped chip with nowhere to go — chatter and torn finish.
- 29–30 (flank infeed) — the CNC equivalent of setting a manual compound to 29.5°: the tool feeds down the flank so mostly the leading edge cuts and the chip curls off one side. Best chip flow, best finish, the most common choice.
- 00 (alternating flank) — the control alternates infeed between flanks, sharing wear across both edges. Worth it on large-pitch threads (8 TPI and coarser) where one flank would take all the abuse.
Common G76 mistakes
- Threading in G96. Constant surface speed changes RPM mid-cycle and the passes stop landing in the same groove. G97 or scrap — no exceptions.
- Wrong Q/P units. The no-decimal words are microns on metric controls and tenths on inch controls — but it's parameter-dependent. Q120 meaning 0.012" vs 0.0120mm is a 25× error. Check your control's manual, then prove it in graphics before cutting.
- No pullout room. Threading dead into a shoulder with rr = 00 and no relief groove leaves the Z axis nowhere to decelerate. Cut a relief groove or program the chamfer pullout.
- Too little run-in. Starting 0.05" off the face doesn't give Z room to reach full feed before contact — the first threads come out shallow-pitched. Use 2–3× pitch minimum (the 0.2" in the example).
- Confusing P with the wire measurement. P/K is the radial height the tool travels from the OD you actually turned. Pitch-diameter checks with thread wires or a thread mic tell you how much more to go — adjust wear offset or X, not the P word.
- Assuming every control has it. GRBL and most hobby controllers have no G76 at all. LinuxCNC does — but its G76 uses its own words (P for pitch, I/J/K for position and depths), so a Fanuc block pasted into LinuxCNC is wrong, not just different.
Generate it instead
If you'd rather not memorize which P means angle and which P means height, ShopCAM does this whole page in one screen: dial in the thread spec and length, and it generates the complete threading program — heights, minor diameter, pass schedule, and the correctly formatted words for Haas, Fanuc, or LinuxCNC output profiles. Same 0.6134 × pitch and D√n math as above, no word-format memorizing, nothing to mistype at the control.
Related
- G-code to face a 2.5" part — complete program, line by line
- Tap drill chart — UNC/UNF sizes with % thread math
- Speeds and feeds — the full reference
- Free browser calculators for the shop
- ShopCAM — conversational G-code programming
Note: Run the first part in single-block with your hand on the feed-rate override, and graph the cycle in verify mode before any metal moves. Numbers reviewed 2026-07.
