FIFTY LINETurn G-code
Online generatorOnline calculatorsReference

Machining cycle

Thread cutting on a CNC lathe

External and internal threads: right/left-hand, multi-start, with lead-in and lead-out

A clickable cycle form: tap any field to see what it does.

Threading cycle form (internal) with parameters and the live 2D toolpath simulator

 

Форма цикла «Резьба» (внутренняя)

Cycle form: internal threading shown — geometry and thread mode on the left, live 2D toolpath simulator on the right.

Thread calculator →Thread depth, minor or bore diameter and the diameter of every pass — metric and UNC/UNF. Free, in your browser.

The threading cycle supports external and internal threads, right- and left-hand direction, multi-start threads, and configurable lead-in/lead-out sections for the tool.

The threading motion syntax switches between G32 and G33 with a selectable pitch address letter (I/K/F) — matching your specific controller and post-processor.

Who needs this cycle

Needed for cutting standard cylindrical threads — from fasteners to multi-start threads — without manually calculating passes.

Key form parameters

  • •External/internal thread diameter
  • •Thread pitch
  • •Number of starts
  • •Length of the threaded section
  • •Lead-in and lead-out
  • •Right/left-hand direction

G-code example

Real output of the threading cycle for an external right-hand M12×1.5 thread: 20 mm long, 10 roughing passes and 1 finishing pass, depth 0.92 mm per side, 2 mm lead-in and 2 mm run-out, 50 rpm. Thread motion is G32 with K as the pitch address. The code lines were not edited by hand.

The program uses diameter mode G7, so X in the code is a diameter: passes go from X12.0000 to X10.1600, which matches the reference minor diameter of an M12×1.5 bolt (d₃ = 10.16 mm). The numbers in the header comments (Touch X 6.0000, Final X 5.0800) are printed as radius — the same sizes, just half the diameter.

threading.ngc · 125 lines — Show the full program
%
(Turn G-code)
(External thread)
(Thread motion: G32 K)
(Direction: right-hand)
(Starts: 1)
(Touch X: 6.0000)
(Clearance: 0.0000)
(First X: 6.0000)
(Final X: 5.0800)
(Remaining depth: 0.9200)
(Cut start Z: 3.0000)
(Cut end Z: -20.0000)

G21 G18 G90 G7 G40 G80
G54

G97 S50 M3
G0 Z3.0000
G0 X18.0000

G0 Z3.0000
(Pass 1 of 10, X12.0000)
G0 X12.0000
G0 Z2.0000
G32 Z0.0000 K1.5000
G32 Z-18.0000 K1.5000
G32 X14.0000 Z-20.0000 K1.5000
G0 X18.0000

G0 Z3.0000
(Pass 2 of 10, X11.7956)
G0 X11.7956
G0 Z2.0000
G32 Z0.0000 K1.5000
G32 Z-18.0000 K1.5000
G32 X14.0000 Z-20.0000 K1.5000
G0 X18.0000

G0 Z3.0000
(Pass 3 of 10, X11.5911)
G0 X11.5911
G0 Z2.0000
G32 Z0.0000 K1.5000
G32 Z-18.0000 K1.5000
G32 X14.0000 Z-20.0000 K1.5000
G0 X18.0000

G0 Z3.0000
(Pass 4 of 10, X11.3867)
G0 X11.3867
G0 Z2.0000
G32 Z0.0000 K1.5000
G32 Z-18.0000 K1.5000
G32 X14.0000 Z-20.0000 K1.5000
G0 X18.0000

G0 Z3.0000
(Pass 5 of 10, X11.1822)
G0 X11.1822
G0 Z2.0000
G32 Z0.0000 K1.5000
G32 Z-18.0000 K1.5000
G32 X14.0000 Z-20.0000 K1.5000
G0 X18.0000

G0 Z3.0000
(Pass 6 of 10, X10.9778)
G0 X10.9778
G0 Z2.0000
G32 Z0.0000 K1.5000
G32 Z-18.0000 K1.5000
G32 X14.0000 Z-20.0000 K1.5000
G0 X18.0000

G0 Z3.0000
(Pass 7 of 10, X10.7733)
G0 X10.7733
G0 Z2.0000
G32 Z0.0000 K1.5000
G32 Z-18.0000 K1.5000
G32 X14.0000 Z-20.0000 K1.5000
G0 X18.0000

G0 Z3.0000
(Pass 8 of 10, X10.5689)
G0 X10.5689
G0 Z2.0000
G32 Z0.0000 K1.5000
G32 Z-18.0000 K1.5000
G32 X14.0000 Z-20.0000 K1.5000
G0 X18.0000

G0 Z3.0000
(Pass 9 of 10, X10.3644)
G0 X10.3644
G0 Z2.0000
G32 Z0.0000 K1.5000
G32 Z-18.0000 K1.5000
G32 X14.0000 Z-20.0000 K1.5000
G0 X18.0000

G0 Z3.0000
(Pass 10 of 10, X10.1600)
G0 X10.1600
G0 Z2.0000
G32 Z0.0000 K1.5000
G32 Z-18.0000 K1.5000
G32 X14.0000 Z-20.0000 K1.5000
G0 X18.0000

(Finish passes at final X 5.0800)
G0 Z3.0000
(Finish pass 1 of 1)
G0 X10.1600
G0 Z2.0000
G32 Z0.0000 K1.5000
G32 Z-18.0000 K1.5000
G32 X14.0000 Z-20.0000 K1.5000
G0 X18.0000

G0 Z3.0000
M5
M30
%

Line-by-line breakdown

G21 G18 G90 G7 G40 G80
Start: millimetres, XZ plane, absolute coordinates, diameter mode for X (G7), cancel radius compensation and canned cycles.
G97 S50 M3
Constant speed — 50 rpm. When threading, Z motion is synchronised with the spindle (1.5 mm per revolution), so the speed must stay constant.
G0 Z3.0000 / G0 X18.0000
Retract to a safe point: 3 mm in front of the face, Ø18.
G0 X12.0000 / G0 Z2.0000
First pass: the tool moves to the major diameter Ø12 and comes to 2 mm from the face — the start of the lead-in.
G32 Z0.0000 K1.5000
Lead-in: synchronised motion from Z2 to Z0 at a 1.5 mm pitch. Over these 2 mm the Z axis gets up to speed, so the tool enters the metal already at the correct pitch.
G32 Z-18.0000 K1.5000
Cutting the full profile over 18 mm.
G32 X14.0000 Z-20.0000 K1.5000
Run-out: over the last 2 mm the tool rises smoothly in X to Ø14 without breaking synchronisation, so the thread ends without an abrupt step.
G0 X18.0000 / G0 Z3.0000
Rapid retract and return to the start for the next pass.
(Pass 2 of 10, X11.7956) … (Pass 10 of 10, X10.1600)
Each next pass goes about 0.204 mm deeper on diameter (≈0.102 mm per side); the tenth reaches the final Ø10.16.
(Finish pass 1 of 1)
A finishing (spring) pass at the same final Ø10.16 with no extra infeed — it cleans up the profile after the roughing passes.
M5 / M30
Spindle stop and program end.

Comments in this program were translated from Russian; the G-code itself is unchanged. For a controller that expects G33 or a different pitch letter (I or F), the thread motion syntax is switched in the program settings — the pass geometry stays the same.

What the codes in this program mean (G7, G32/G33, G97, M3, M5) — G- and M-code reference for lathes.

More on this topic: CNC lathe threading in LinuxCNC: G33 and G76 with examples.

Frequently asked questions

Which thread types are supported?

External and internal threads, right- and left-hand direction, and multi-start threads — all in one cycle.

Can I configure the lead-in and lead-out?

Yes, the lead-in (where the tool enters the material) and lead-out (where it exits) are configurable separately — needed for a clean start and end of the thread without tearing.

How is the threading move syntax set — G32 or G33?

You can switch between G32 and G33, and choose the pitch address letter (I/K/F) — matching your specific controller and post-processor.

Does it support multi-start threads?

Yes, the cycle supports any number of thread starts, spacing them evenly around the circumference automatically.

What is this cycle for?

Cutting standard cylindrical threads — from fasteners to multi-start threads — without manually calculating passes.