We’ve dedicated this page to CNC lathe programming examples. Exercises covering the G-codes G70, G71, G90, G92, G94, G75, and G76 for CNC turning. Alongside example CNC programs built around a single canned cycle command, we’ve also included example programs covering more complex workpieces (multiple commands, multiple operations in sequence).
Non-Cycle Programming Examples
Non-cycle longitudinal turning
EXAMPLE: the hatched area of the part shown will be machined in 3 equal passes. Write the CNC program accordingly.

0888
N000 TO101
N010 M03 S1200
N020 G00 X40 Z2
N030 G01 Z-24 F0.1
N040 X41
N050 G00 Z2
N060 X35
N070 G01 Z-24
N080 X36
N090 G00 Z2
N100 X30
N110 G01 Z-24
N120 X45
N130 G28 U0 W0
N140 M30Non-cycle facing and longitudinal turning
The hatched regions of the part shown will be machined. Facing will be done in 2 equal passes, longitudinal turning in 3 equal passes. Write the CNC program accordingly.

N110 X31
N120 G00Z1
N130 X24
N140 G01 Z-15
N150 X25
N160 G00 Z1
N170 X18
N180 G01 Z-15
N190 X36
N200 G00 X100 Z100
N210 M05
N220 M30Example 2
Assume the surface of the part shown below has only a very small amount of stock remaining. Assume the cutting speed recommended by the toolmaker for the diamond insert being used is 180 m/min, and the feed rate is 0.2 mm.

O5000 Program number 5000
G50 S3000 Maximum spindle speed
M8 Coolant on
T0101 Call tool 1 with offset 1
G96 S180 Constant surface speed of 180 m/min
M3 Spindle clockwise
G0 X23. Z0.0 Rapid move to diameter 23, position 0
G1 X0. Z0.0 F0.2 Linear cut to diameter 0, position 0, at 0.2 mm feed
G0 X0. Z3. Rapid retract to diameter 0, position 3
G0 X16.Z3. Rapid move to diameter 16, position 3
G1 X16.Z0. Linear cut to diameter 16, position 0
G1 X20.3 Z-2.0 Cut to diameter 20.3, position -2.0
G1 X23.2 Z-20.0 Cut to diameter 23.2, position -20.0
G1 X21.3 Z-22. Cut to diameter 21.3, position -22.0
G1 X33.0 Z-22.0 Cut to diameter 33.0, position -22.0
G1 X33.0 Z-40.0 Cut to diameter 33.0, position -40.0
G1 X50.0 Z-40.0 Cut to diameter 50.0, position -40.0
G0 X150. Z200. Rapid move to diameter 150.0, position 200.0
M9 Coolant off
M5 Spindle stop
M30 End of program; return to start
Non-Cycle Bore Turning
The part shown has a diameter-8 hole that will be bored out to a diameter-14 hole with a boring bar. Write the turning program that removes 2mm per pass from diameter 8 to diameter 14.

04046
T00101
M103 S1000
G00 X10 Z5
G01 Z-16 F0.1
X9 G00 Z5 X12
G01 Z-16 F0.1 X10
G00 Z5
X14
G01 Z-16
G01 X8
G00 Z5 X200 Z200
M05
MG3 Convex Circular Machining
The part shown is to be machined with a cutting speed of 150 m/min and a feed rate of 0.2 mm. Assuming this is a finishing pass on the part surface, write the machining program.

O1000
G50 S3000
M8
G96 S150 M3
T0101
G0 X50.0 Z0.0G1 X0.0 Z0.0 F0.2
G0 X0. Z3.
G0 X46. Z3.
G1 X46. Z0.
G1 X50 Z-20.
G3 X60. Z-40 R40.
G1 X80. Z-40.
G1 X80. Z-50.
G0 X150. Z200
M9
M5
M30G2 Concave Circular Machining Example

O1500
G50 S3000
G96 S180 M3
T0101
G0 X59.Z0.
G1 X0.F0.2
G0 Z3.
X55.
G1 Z0
X59. Z-20.
G2 X76.Z45.R50.
G1 X80.
Z-55.
G0 X150.Z200
M5
M9
M30Canned Cycle Programming Examples
G90 Longitudinal Turning Cycle
The hatched area of the part shown will be machined using the G90 longitudinal turning cycle. Write the CNC program accordingly.

O1453
N000 T0101
N010 M03 S1200
N020 G00 X43 Z2
N030 G90 X40 Z-52 F0.1
N040 X36
N050 X32
N060 X28
N070 X25
N080 X24
N090 G00 X150 Z150
N100 M30Grooving with G75
Write the CNC program that cuts only the groove on the given part, using the G75 code. Note: grooving tool T0202, groove tool width = 2.5mm

N000 T0202
N010 M03 S1200
N020 G00 X32 Z-30
N030 G75 R5
N040 G75 X10 Z-22,5 P300 Q2400
N050 R0 F0.1
N060 M05
N070 N30G70 and G71 Codes
Example 1: For the part shown, write the CNC program for only the hatched region, using the G70 and G71 codes.

NOTE = T0101 roughing tool / T0202 finishing tool
* Stock left for finishing: 0.8 mm on diameter and length
* Maximum depth of cut: 5 mm
* You may use whatever other suitable values you like for the rest of the program.
N000 T0101
N010 M03 S1500
N020 G00 X58 Z2
N030 G71 U1,5 R0.8
N040 G71 P16 Q17 U08 W08 F0
N050 G00 X22 Z2
N060 G01 Z0
N070 G03 X32 Z-5 R5
N080 G01 Z-40
N090 Z42 Z-45
N100 X56
N110 G00 Z100 Z100
N120 T0202
N130 G00 X58 Z2
N140 G70 P16 Q17 F0.02
N150 G00 X100 Z100
N160 M05
N170 M30Example 2
The hatched region of the part shown will be machined using the G71 and G70 codes. Write the CNC program for this operation. (Leave 1mm for the finishing pass.) T0101: left-hand roughing tool, finishing tool

N000 T0101
N010 M03 S2000
N020 G00 X62 Z8
N030 G71 U4 R0.8
N040 G71 P14 Q15 U1 W1 F0.2
N050 N14 G00 X0
N060 G01 Z0
N070 X20
N080 X30 Z-5
N090 Z-20
N100 X50
N110 N15 G03 X60 Z-25 R5
N120 G00 X100 Z100
N130 T0202
N140 G00 X62 Z8
N150 G70 P14 N15
N160 G00 X100 Z100
N170 M05
N180 M30Example 3
The part shown has a diameter-22 hole; after drilling with a diameter-20 drill, the bore will be finished with the G71 and G70 codes. Write the CNC program accordingly.

Operation order:
1: Drilling T0101 (diameter 20 U-drill)
2: Bore turning (rough removal) T0202 (boring bar)
3: Bore finish turning T0303 (finishing boring bar)
N000 T0101
N010 M03 S1200
N020 G0 X0 Z3 F0.2
N030 G1 Z-75
N040 G0 Z3
N050 X150 Z150
N060 G0 Z20 Z3
N080 G71 U1 RO.5
N090 G71 P18 Q19 U0.5 W0.5 F0.2
N100 N18 G0 Z40
N110 G1 Z-20
N120 X30 Z-25
N130 Z-43
N140 G3 X22 Z-47 R4N150 G1 Z-68
N160 N19 X20
N170 G0 X100 Z100
N180 T0303
N190 G0 X20 Z3
N200 G70 P18 Q10 F0.1
N210 G0 X100 Z100
N220 M30G94 Code
EXAMPLE: for the part shown, face the hatched 8mm section using the G94 code, taking a 2mm depth of cut per pass, over four passes.

N000 T0101
N010 M03 S1200
N020 G00 X62 Z10
N030 G94 X0 Z6 F0.1
N040 Z4
N050 Z2
N060 Z0
N070 G00 X100 Z100
N080 M30Threading with G92 and Grooving with G75

For the part with the dimensions shown, cut only the M16 thread using the G92 code.
Note: the thread should have a chamfer, ready for tapping. M30 threading tool T0303
M16 thread minor diameter 13.54
Pitch: 2mm. The threading operation must be completed in at least 6 passes.
Q4046
N000 M03 S600
N0010 T0303
G00 X18 Z2
G92 X15 Z-70 F2
X14.5
X14.2
X14.1
X13.70
X13.54
G00 X100 Z100
M05Example 2
The hatched regions of the part shown will be machined. Write the CNC program according to the specified operation order and information.
Longitudinal roughing cycle with T0101 (LEFT-HAND TOOL) using the G71 cycle
Grooving with T0202 (GROOVING TOOL) using the G75 cycle
M20 threading with T0303 (THREADING TOOL) using G92 or G76, M20 minor diameter = 16.93, thread pitch = 2.5mm
Parting off with T0202 (GROOVING TOOL), tool width = 2.5 mm, tool zero point: bottom right corner

00092
T0101
M03 S2100
G00 X30 Z5
G71 U2 R1
G71 P14 Q15 U0 W0 F0.1
N14 G00 X0
G01 Z0
X16
X20 Z-2
Z-26
X24
N15 Z-35
G00 X22 Z-12 G75 R1
G75 X8 Z-18.5 P2000 Q2300 R0 F0.1G00 X100 Z100
T0303
G00 X22 Z5
G92 X19 Z-15 F2.5
X18
X17
X16.93
G00 X100 Z100
T0202
G00 X30 Z-33
G01 X0
G00 X100 Z100
M05
M30Center Drilling
The diameter-16 hole in the part shown will be drilled first with a center drill, then with a 16mm drill. Write the CNC program accordingly.

Q1453
G90 G54 G21 G99 G97
T0505 (CENTER DRILL) M03 S1200
G00 X0 Z2
G01 Z-8 F0.1 M08
G00 Z2
X200 Z200 T0707 (16MM DRILL)
M03 S1000
G00 X0 Z2
G01 Z-32 F0.1 M08
G00 Z2
X200 Z200
M05
M30G90 and G92 Program Example
The part shown will be turned down from diameter 26 to diameter 12, then an M12 thread will be cut. Use the G90 longitudinal turning cycle to reduce diameter 26 to 12, and the G92 threading cycle to cut the M12 thread. (M12 thread pitch is 1.75, minor diameter is 9.80mm)

O1071
G90 G21 G99 G97 G54
T0202
M03 S1600
G00 Z3
X28
G90 X22 Z-90 F0.1 M08 X18
X14
X12
G00 X100 Z100
T0303
M03 S400 G00 Z5
X13
G92 X11 Z-50 F1.75 M08G71 Code Program Examples
The hatched region of the workpiece shown
will be machined using the G71 multi-pass stock removal cycle. Write the CNC program accordingly.

O222 (SHAFT FRONT FACE)
G90 G54 G21 G99 G97
T0101
M03 S1100
G00 X42 Z3
G71 U2 R0.5
G71 P5 Q12 U0 W0 F0.2
N5 G00 X20
G01 Z0
X30 Z-5 Z-37
N12 G02 X40 Z-42 R5
G00 X200 Z200
M05
M30Example 2
Turn the part down from diameter 30 to diameter 16 using G71.

0252 (SHAFT M16)
T0101
M03 S1000
G00 X32 Z3
G71 U1.5 R1
G71 P10 Q20 U0.5 W0.2 F0.2 N10 G00 X16
G01 Z-88
N20 X30 G00 X200 Z200T0202 (FINISHING TOOL)
M03 S1600
G00 X32 Z3
G70 P10 Q20 F0.1
G00 X200 Z200
M05
M30Threading with G76

An M12x50 thread will be cut on the part shown. Write the CNC program to cut the thread using the G76 command (M12 thread pitch is 1.75, minor diameter is 9.80mm).

O1071G90 G21 G99 G97 G54
T0202 (THREADING TOOL)
M03 S1600G00 X 13 Z4
G76 P020060 Q200 R500
G76 X9,80 Z-50 R0 Q300 P1100 F1,75
GOO X200 Z00
MO5
M30
G76 P...(aabbcc)... Q... R...
G76 X... Z... P... Q... F...
P:(aabbcc)
aa: Number of finishing pass repeats
bb: Length of chamfer at thread end, as a multiple of pitch
cc: Thread profile angle (80°,60°,55°,30°,29°,0°)
Q: Minimum depth of cut, in microns
R: Finishing pass allowance
X: Thread minor diameter [major diameter - (0.65 x pitch x 2)]
Z: Z coordinate where the thread ends
P: Thread height in microns (0.65 x pitch)
Q: First pass depth, in microns and on radius
F: Thread pitch
CNC Lathe Example Questions
The part shown will be made from diameter-38 stock. Write the CNC program according to the following operation order.
Operation order:
1 – Facing (single pass)
2 – Outer profile turning (single pass)
3 – Grooving (tool width 4mm)
4 – Center drilling
5 – Diameter-16 drilling
6 – Parting off

O1453 (BUSHING)
G97 G21 G54 G90 G99
T0101 (LEFT-HAND OUTER DIAMETER TOOL)
M03 S1200
G00 X40 Z0
G01 X0 F0.1
G00 Z2
X30
G01 Z0
X36 Z-3
Z-37
X30 Z-40
Z43
X40
G00 X200 Z200
T0202 (4MM GROOVING TOOL) M03 S600
G00 X40 Z-22
G01 X30 F0.1
G00 X40
X200 Z200T0303(CENTER DRILL)
M03 S2400
G00 X0 Z5
G01 Z-8 F0.1
G00 Z5
G00 X200 Z200
T0404 (16MM DRILL)
M03 S600
G00 X0 Z5
G01 Z-48 F0.1
G00 Z5
X200 Z200
T0202 (4MM GROOVING TOOL)
M03 S1000
G00 X40 Z-44
G01 X15 F0.05
G00 X40
X200 Z200
M05
M30Question 2
Write the CNC program for the part shown according to the following operation order.
1 – Machine the hatched region using the G71 code, leaving 0.5 mm on diameter and length for finishing.
2 – Remove the finishing allowance from the hatched region using the G70 code
3 – Center drilling with T0303 (center drill)
4 – The hole in the part shown is diameter 8 mm. Drill the part with an 8mm drill.

O1234
T0101
M03 S1000
G00 X34 Z4
G71 U2 R1
G71 P10 Q20 UO.5 W0.5 F0.2
N10 G00 X14
G01 X20 Z-5
Z-13
G02 X28 Z-17 R4
N20 G01 X32
G00 X200 Z200
T0202
M03 S2500
G00 X34 Z3
G70 10 Q20 F0.1
G00 X200 Z200
T0303
M03 S1800 G00 X0 Z5
G01 Z-8 F0.1
G00 Z5
X200 Z200
T0404
M03 S900 G00
X0 Z5
G01 Z-35 F0.1
G00 Z5
X200 Z200 M05
M30Question 3
EXAMPLE QUESTION: write the CNC program needed to produce the part shown below.

O1234
T0101
M03 S1000
G00 X32 Z4
G71 U2 R1
G71 P10 Q20 U0 W0 F0.1
N10 G00 X0
G01 Z0
G03 X24 Z-12 R12
G01 Z-92 N20 X30
G00 X40 Z-42
G73 U10 W0 R4
G73 P30 Q40 U0 W0 F0.1
N30 G00 X25 Z-12G01 X24
G02 Z-72 R60
N40 G01 X25
G00 X200 Z200
T0202 (3MM PARTING TOOL) M03 S1000
G00 X26 Z-85
G75 R1
G75 X10 Z-92 P3000 Q2700 F0.2
G00 X32 Z-95
G01 X0 F0.1
G00 X25
X200 Z200
M05
M30Related Posts
CNC Lathe G84 Tapping Cycle Explained
CNC Lathe Setup Instructions
What the Keys on the CNC Milling Control Panel Mean
CNC Milling Programming Examples
CNC Milling Workshop Operating Instructions
CNC Lathe Workshop Work Instructions
The Structure of CNC Milling Machines
G00 Rapid Positioning Without Cutting CNC Code
