Guide · Turning

Your First CNC Lathe Program: G71, G70, Grooving and G76 Step by Step

Write a complete turning program step by step: facing, G71 roughing, G70 finishing, a thread relief groove and an M20 x 2 thread with G76, ready to run in the free lathe simulator.

By cnccode · Updated
On this page
  1. 1. Start and face
  2. 2. Rough with G71
  3. 3. Thread relief
  4. 4. Thread with G76
  5. 5. Try changes
  6. More guides
  7. Frequently asked questions

We make a shaft from 40 mm bar: 30 mm and 36 mm steps with radii, and an M20 × 2 thread at the front. You can run the finished program in the CNC lathe simulator, where it is the first example.

1. Start and face

G50 S2500 limits the spindle, which is essential with constant surface speed because the RPM rises as X gets smaller. G96 S200 keeps 200 m/min. Facing goes to X-1 so that the nose radius leaves no pip.

G-code
G21 G40 G99
G50 S2500
G96 S200 M03
T0101
G00 X42. Z2.
G00 Z0.
G01 X-1. F0.15
G00 X42. Z2.

2. Rough with G71

You describe only the finished contour between two N-numbers. The control makes the passes. The first G71 line has the depth per side (U1.5) and the retract (R0.5). The second line names the contour and the finishing allowance: U0.4 on the diameter and W0.1 in Z.

G-code
G71 U1.5 R0.5
G71 P10 Q20 U0.4 W0.1 F0.25
N10 G00 X14.
G01 Z0. F0.1
G01 X20. Z-3.
Z-28.
X24.
G03 X30. Z-31. R3.
G01 Z-48.
G02 X36. Z-51. R3.
G01 Z-60.
N20 X42.
G70 P10 Q20

The first contour block must move X only for a type 1 cycle, and the tool must stand outside the stock diameter when G71 starts.

3. Thread relief

A 3 mm wide groove at the end of the thread gives the threading tool room to leave. Use G97 with a fixed RPM here and for the thread.

4. Thread with G76

G-code
T0404
G97 S700 M03
G00 X24. Z5.
G76 P020060 Q100 R0.05
G76 X17.55 Z-26. P1227 Q350 F2.0
  • P020060: 2 spring passes, no chamfer, 60° infeed.
  • Q100: smallest depth per pass 0.1 mm. R0.05: finishing allowance.
  • X17.55: root diameter. P1227: thread height 1.227 mm per side. Q350: first pass 0.35 mm.

P and Q have no decimal point in these lines. Start at least two pitches in front of the thread so the axis is up to speed. The thread calculator writes these two lines for any size.

5. Try changes

In the simulator change U1.5 to U3 and watch the number of passes. Delete the Q20 block and see the warning. Mistakes are free there.

Frequently asked questions

Why does G71 need a P and a Q?
They are the sequence numbers of the first and last block of the contour. G70 uses the same numbers for the finishing pass.
Why is the thread cut with G97 and not G96?
The spindle speed must stay constant between passes. If it changes, the tool does not meet the same groove again.
Was this page helpful?