A cnc lathe program example is a line-by-line ISO 6983-1:2009 turning code listing. CNC programming converts part drawings into sequential instructions for spindle speed, feed rates, and tool paths. Each example program targets FANUC and ISO-compatible CNC lathe machine platforms in metric FANUC Type A format. The sequence pairs
G18 G21 G40 G80 G99
,
G54
,
G50
, en
G96
with
G70–G76
cycles. For the FANUC Type A examples, when diameter mode is active,
X-as
words set diameters and
U/W
set incremental shifts.
Onze 5-Block Lathe Program Anatomy Map keeps modal states easy to verify across multi-tool setups. Worked numbers span an assumed 2,500 rpm clamp at diameter 22.92 mm and an ISO 68-1:2023 M24 x 2.0 depth of 1.227 mm. Review every G code example in this tutorial with an offline backplotter before single-block dry runs on FANUC, Haas, and GSK lathes.
Reviewed by the SHANGHAI ANTS Machine Equipment technical team: verified against ISO 6983-1:2009, ISO 68-1:2023, ISO 965-1:2026, university machining lab guides, and controller manuals.
1. CNC Programming Structure, Word-Address Syntax, and Safe Start Header (G18 G21 G40 G80 G99)

Metric CNC program examples in this guide follow 5 structured blocks built on ISO 6983-1:2009 word-address syntax. Each tool header adapts the Haas Lathe Operator’s Manual safe startup line into five metric resets: G18 G21 G40 G80 G99. Clearing plane, units, compensation, cycles, and feed protects every subsequent tool call.
Onze 5-Block Lathe Program Anatomy Map separates persistent modal cutting states from one-shot startup lines. Think of this header like shifting a manual car into neutral and setting the parking brake before turning the key. Modal codes stay latched until overridden, while one-shot commands such as
G04
dwell or
G28
zero-return execute only in their single block.
Programmers moving from vertical mills notice how 2-axis CNC lathe programming fundamentals (covered conceptually with a single imperial walkthrough in our foundational tutorial) handle tool offsets differently from this metric multi-cycle code library. A vertical mill pairs
G54
part zero with a separate
G43 H01
tool length call. By contrast, a 2-axis FANUC-style lathe binds geometry and X/Z wear inside the 4-digit word T0101 (station 01, offset 01). For controller file formatting, the University of Florida CNC lathe guide specifies % file delimiters, an O program number, and comments no greater than 80 characters. Cutting Tool Engineering also recommends using clean parenthetical block notes.
| Program Block Layer | Typical G/M/Address Line | Modal vs. One-Shot | Controller & Setup Action |
|---|---|---|---|
| Block 1: File & Safe-Start Header |
% / O0240 / G18 G21 G40 G80 G99
|
Modal group resets | Sets XZ plane, metric units, cancels TNR comp, cancels active cycles, selects mm/rev |
| Block 2: Home & Tool Offset Call |
G28 U0 W0 ; T0101 ; G54
|
One-shot return / modal offset | Commands machine-zero return (verify turret-index clearance along retract path first), then applies station 01 wear |
| Block 3: Spindle & Clamp Control |
G50 S2500 ; G96 S180 M03 ; M08
|
Modal clamp & CSS | Limits max RPM to 2,500 rpm before starting constant surface speed at 180 m/min |
| Block 4: Canned-Cycle Engine & P-Q Contour |
G71 U2.0 R0.5 / G71 P110 Q180 ...
|
Canned multi-pass execution | Roughs bar stock leaving U0.5 diameter and W0.1 face allowance for G70 finishing |
| Block 5: Axis-Ordered Retract & End |
G00 X120.0 ; M09 ; G28 U0 W0 ; M30
|
One-shot retract / rewind | Retracts X clear of stock before Z move, shuts coolant/spindle off, rewinds file |
What Does G28 G91 Z0 Do vs. G28 U0 W0 on a CNC Lathe?
Beide
G28 G91 Z0
en
G28 U0 W0
skip workpiece zero before returning to the machine reference point, though retract clearance along the path still needs verification. On FANUC Type B/C controls,
G28 G91 Z0
returns only Z via a zero incremental step. On FANUC Type A lathes,
G28 U0 W0
returns both X and Z without activating
G91
.
A Practical Machinist G28 thread warns that absolute
G28 X0 Z0
passes through work datum
X0 Z0
first. Note Haas NGC lathes use
U
en
W
for incremental turning moves, and Haas lathe documentation recommends
G53 X0
en
G53 Z0
so absolute mode remains active.
2. CNC Turning Coordinate Modes, Diameter Programming, Offsets (T0101), and Spindle Control (G96/G50)

When diameter mode is active in FANUC Type A turning,
X
commands diameters while
U
en
W
command incremental steps. Pairing an assumed
G50 S2500
clamp with
G96 S180
hits 2,500 rpm near diameter 22.92 mm via
n = (1,000 * Vc) / (π * d)
. Clamping RPM bounds speed; jaw grip and bar support govern safe setups.
Once startup modal resets and tool offsets in the program header are active, constant surface speed controls cutting velocity along changing diameters. As diameter decreases toward centerline
X0
, spindle RPM increases to maintain a steady surface speed until the spindle-speed limit is reached, after which actual surface speed decreases. According to MachiningDoctor’s G96/G97 guide, metric RPM is calculated using
(1,000 * Vc) / (π * d)
. For inches, MachiningDoctor gives RPM = (12 * Vc) / (π * d), while Sandvik Coromant turning formulas define the cutting-speed (vc) and diameter variables.
Long-overhang boring bars also require lighter cuts and reduced spindle speeds. Sandvik Coromant states tangential force Ft should be less than 90% of the bar’s rated load limit and suggests using turning cutting speeds and feeds with conservative depths. U.S. Patent US6470776B1 describes a V-block CNC clamping device that compensates workpiece axis eccentricity (d) in CNC setups. Similarly, the University of Florida CNC lathe manual warns that longer tools need spindle speeds decreased by as much as 75% to reduce vibration and premature tool failure.
Worked CSS Speed-Clamp Calculation (Assumed
G96 S180
with
G50 S2500
): Assume AISI 1045 bar at
Vc = 180 m/min
and a programmed
G50 S2500
cap (2,500 rpm). Evaluating
n = (1,000 * 180) / (3.14159 * d) = 57,296 / d
across assumed diameters shows spindle behavior. At diameter 60 mm, the spindle runs 955 rpm, and at diameter 30 mm speed doubles to 1,910 rpm. The curve hits 2,500 rpm at a diameter of 22.92 mm (
57,296 / 2,500
). Near diameter 10 mm and
X0
, theoretical RPM climbs past 5,730 rpm toward infinity while actual speed stays capped at 2,500 rpm. Lower the ceiling whenever jaw grip, imbalance, or rear bar overhang requires it.
Workpiece Diameter (X) |
Formula Calculation | Uncapped RPM | Actual RPM UnderG50 S2500
|
Effective Surface Speed |
|---|---|---|---|---|
Ø60.0 mm(OD stock) |
180,000 / (π * 60)
|
955 rpm | 955 rpm | 180.0 m/min |
Ø30.0 mm(Turned step) |
180,000 / (π * 30)
|
1,910 rpm | 1,910 rpm | 180.0 m/min |
Ø22.92 mm(Clamp crossover) |
180,000 / (π * 22.92)
|
2.500 tpm | 2,500 rpm (Clamp engages) | 180.0 m/min |
Ø10.0 mm(Facing approach) |
180,000 / (π * 10)
|
5,730 rpm | 2,500 rpm (Clamped) | 78.5 m/min |
X0.0 mm(Centerline face) |
d -> 0
|
Tends to infinity (undefined at d = 0) | 2,500 rpm (Clamped) | 0 m/min at dead center |
In a standard rear-turret coordinate system,
+Z
points away from the headstock toward the tailstock and
+X
points away from centerline. Setting front face datum Z0 lets tools remove material along negative Z- moves. With diameter mode enabled on FANUC Type A controls,
X
words set diameters while
U
en
W
set incremental steps.
3. Typical CNC Lathe G-Codes and M-Codes Quick Reference (Turning vs. CNC Milling Programming)

Lathe G-codes run inside the G18 XZ plane and swap critical FANUC Type A definitions compared to vertical mills. On Type A lathes,
G90
runs an OD box-turning cycle and
G99
sets
mm/rev
feed. On mills,
G90
sets absolute mode and
G99
selects R-plane return. Checking modal groups stops unintended tool plunges.
Modal groups explain why copying lines from a CNC mill to a CNC lathe creates silent bugs. The Industrial Monitor Direct modal guide and our complete CNC G and M code list assign Group 2 to
G17
on mills and
G18
on lathes. Feed and distance settings also swap between families of controllers. For centerline drills, taps, and threading, operators switch from G96 to operation-specific G97 fixed RPM (e.g., S500 of S800).
| Code | Modal Group / Category | FANUC Lathe Type A Behavior | FANUC Type B/C or CNC Milling Behavior |
|---|---|---|---|
G00
|
Group 01 (Motion) | Rapid non-cutting positioning between clear points | Identical rapid traverse positioning in X/Y/Z |
G01
|
Group 01 (Motion) | Linear cutting feed at activeFrate |
Identical straight-line feed interpolation |
G02 / G03
|
Group 01 (Motion) | Clockwise / CCW circular arc in XZ (Rof I/K) |
Clockwise / CCW arc in XY plane whenG17active |
G18
|
Group 02 (Plane) | XZ turning plane default for arcs and nose comp | Mills default toG17XY plane; face mills cut in XY |
G20/G21
|
Group 06 (Units) | Inch (G20) or millimeter ( G21) input units |
Identical imperial vs. metric unit switching |
G28 / G53
|
Group 00 (One-Shot) |
G28 U0 W0of G53 X0 Z0turret home retract |
G28 G91 Z0of G53 Z0spindle-head Z home |
G40/G41 /G42
|
Group 07 (Compensation) | Cancel / left / right tool-nose radius compensation | Cutter diameter comp in XY pocket milling |
G50 / G92
|
Spindle Clamp / Datum |
G50limits spindle RPM or sets coords; G92cuts threads |
Type B/C lathes useG92for speed limit or coord preset |
G70 / G71 / G72
|
Turning Cycles | Finish (G70), OD axial rough ( G71), face rough ( G72) |
Not used on 3-axis vertical mills |
G74 / G75 / G76
|
Turning Cycles | End-face peck drill, OD grooving, compound threading | Milling usesG81/G83drill and G84rigid tapping |
G90/G91
|
Cycle vs. Distance |
G90is an OD turning cycle; U/Wis incremental |
Type B/C & mills useG90absolute and G91incremental |
G96/G97
|
Group 02/13 (CSS) |
G96constant surface speed; G97fixed RPM |
Mills keepG97fixed spindle RPM for rotating tools |
G98/G99
|
Feed vs. Retract |
G98feed per minute (mm/min); G99feed per rev (mm/rev) |
Type B/C & mills useG94/G95feed and G98/G99retract plane |
M03 / M08 / M30
|
Miscellaneous PLC | Spindle CW on, flood coolant on, program end & rewind | Same standard PLC M-code meanings across controls |
Why Can Milling G90/G91 and G98/G99 Codes Cause Crashes on a Fanuc Type A Lathe?
Pasting milling codes into a FANUC Type A lathe risks a crash because
G90
invokes an OD cutting cycle instead of absolute mode. Likewise, G98 changes feed into millimeters per minute rather than selecting initial-plane drill return.
Under active G98, an F0.2 feed stalls almost motionless. Conversely, commanding F150 under active G99 drives the tool 150 mm per spindle revolution into the part or chuck.
4. Simple CNC Lathe Program Example: Facing, Step Turning, and Circular Arcs (G00, G01, G02/G03)

Stopping a solid-bar facing pass at
X0.0
can leave a center pip depending on the touch-off datum, compensation, and insert nose geometry. When configured in diameter mode with a 0.8 mm nose radius, feeding to X-1.6 mm clears center by 0.8 mm radially. Stepped shoulders follow via G01 feeds and G02/G03 arcs.
The University of Florida CNC lathe facing guide shows a 1/32-inch (approx. 0.8 mm) insert feeding to X-0.062 at F0.005 ipr to clear the face nub.
Similarly, the Haas Lathe Operator’s Manual feeds to X-0.02 past zero before retracting along Z. Listing
O0101
provides a metric machine programming example for a
Ø50 mm
6061-T6 aluminum bar. It turns a
Ø38 mm
nose, a
2.0 mm × 45°
chamfer, and an
R3.0 mm
shoulder fillet. Confirm
G02
versus
G03
polarity in graphics before cutting.
%
O0101 (STEPPED PIN 6061-T6 50MM BAR.)
N10 G18 G21 G40 G80 G99 ; (SAFE START.)
N20 G28 U0 W0 ; (HOME TURRET.)
N30 T0101 ; (STATION 01 OFFSET 01.)
N40 G54 ; (WORK DATUM FRONT.)
N50 G50 S2500 ; (MAX 2500 RPM.)
N60 G96 S220 M03 ; (CSS 220 M/MIN CW.)
N70 G00 X52.0 Z2.0 M08 ; (CLEAR 50MM OD COOLANT ON.)
N80 G00 Z0.0 ; (MOVE TO FACE.)
N90 G01 X-1.6 F0.15 ; (FACE PAST CENTERLINE.)
N100 G00 X52.0 Z2.0 ; (CLEAR FACE.)
N110 G00 X34.0 ; (CHAMFER START X.)
N120 G01 Z0.0 F0.20 ; (TOUCH Z0 EDGE.)
N130 G01 X38.0 Z-2.0 F0.15 ; (2MM 45-DEG CHAMFER.)
N140 G01 Z-22.0 ; (TURN 38MM CYLINDER.)
N150 G02 X44.0 Z-25.0 R3.0 ; (R3.0 FILLET ARC.)
N160 G01 X50.0 ; (FACE SHOULDER TO OD.)
N170 G01 X52.0 Z-26.0 ; (45-DEG EXIT.)
N180 G00 X120.0 M09 ; (X CLEAR BEFORE Z.)
N190 G28 U0 W0 ; (MACHINE HOME.)
N200 M05 ; (SPINDLE OFF.)
N210 M30 ; (REWIND.)
%
For a cnc programming example in inch units, rescale dimensions and feeds explicitly instead of swapping only G21 for G20.
Pure conversion maps X-1.6 F0.15 to X-0.0630 F0.005906 and the 50 mm blank to Ø1.9685 in. Switching to a 2.000 in bar with
X-0.062 F0.005
builds a separate
example in inch
shop setup. Verify circular interpolation (G02/G03), rescaled radius conversions listed below, and core lathe turning and grooving operations when adapting this cnc lathe basic programming example.
| Block Range | Metric (G21) Command |
Imperial (G20) Equivalent |
Geometric Reason |
|---|---|---|---|
N10–N60
|
G21 ... G50 S2500 / G96 S220
|
G20 ... G50 S2500 / G96 S722
|
Approximates 220 m/min surface speed (722 SFM) under same 2,500 rpm ceiling |
N80–N90
|
G01 X-1.6 F0.15
|
G01 X-0.0630 F0.0059
|
Diameter X places tip 0.8 mm (1x radius) past center; UF guide uses an equivalent 1x-radius overtravel to X-0.062 |
N130–N150
|
G02 X44.0 Z-25.0 R3.0
|
G02 X1.732 Z-0.984 R0.118
|
Rescales the 3.0 mm shoulder fillet arc (3.0 / 25.4 = 0.118) into G20 inch coordinates |
How Do You Write a Simple CNC Lathe Program Step by Step From a Part Drawing?
Write a simple lathe program from a print in four steps. First, establish Z0 at the finished face and extract step diameters, shoulder lengths, and chamfers. Second, add modal resets and an active speed cap. Third, program any facing clearance past center, matching tool geometry, tool datum and diameter/radius mode. Fourth, write OD steps front to back and check G02/G03 polarity in a backplotter.
5. Multi-Pass Turning Cycle Examples: G71 OD Roughing, G72 Facing, G70 Finishing, and G74 Drilling

Two-line
G71
removes bulk stock in 2.0 mm radial passes (
U2.0 R0.5
) and leaves
U0.5 W0.1
for
G70
finishing. Under Haas G71 rules, Type I forbids X or Z reversals, while Type II permits X-axis (still no Z-axis) reversals whenever block P commands both X and Z; by comparison, older FANUC controls can require the Type II CNC option unlocked.
Some FANUC cycles ignore
G41/G42
until
G70
finishing.
Separating roughing and finishing via
G71/G70
lets programmers edit one contour between
N100
en
N160
. Haas G71 OD/ID Stock Removal Cycle documentation also notes that Haas controls support single-line
D
cut depth or two-line notation. Users on a Practical Machinist G71 thread stress entering
G40
inside the
Q
block (
N160
) so uncancelled nose compensation won’t alter post-cycle retracts.
In this worked listing,
U0.5
diameter leaves 0.25 mm radial finish stock; choose allowances suited to your insert nose radius and chipbreaker minimums. Use
G72 W2.0 R0.5
when facing heavy face stock. For centerline drilling, switch from CSS to
G97
fixed RPM. Then call the
G74
axial peck drilling cycle (
G74 R0.5
/
G74 Z-35.0 Q4000 F0.12
at
X0.0
).
(FANUC SYSTEM A TWO-LINE G71 + G70.)
N50 T0101 ; (CNMG 120408 R0.8.)
N60 G50 S2500 ; G96 S180 M03 ; M08 ; (CLAMP AND CSS.)
N70 G00 X56.0 Z2.0 ; (APPROACH 1MM CLEAR.)
N80 G71 U2.0 R0.5 ; (2MM DOC, R0.5 RETRACT.)
N90 G71 P100 Q160 U0.5 W0.1 F0.25 ; (LEAVE ALLOWANCE.)
N100 G00 G42 X20.0 ; (P-BLOCK: G42 ON FOR G70.)
N110 G01 Z0.0 F0.15 ; (FACE PLANE.)
N120 G01 X24.0 Z-2.0 ; (2MM CHAMFER.)
N130 G01 Z-35.0 ; (TURN 24MM OD.)
N140 G01 X36.0 Z-35.0 ; (STEP TO 36MM.)
N150 G01 Z-58.0 ; (TURN 36MM OD.)
N160 G01 G40 X56.0 ; (Q-BLOCK: EXIT + G40 CANCEL.)
N170 G00 X120.0 M09 ; G28 U0 W0 ; M01 ; (SAFE RETURN.)
N200 T0202 ; (DNMG 150604 R0.4.)
N210 G50 S2500 ; G96 S240 M03 ; M08 ; (FINISH SPEED.)
N220 G00 X56.0 Z2.0 ; (START CLEARANCE.)
N230 G70 P100 Q160 ; (FINISH CONTOUR.)
N240 G00 X120.0 M09 ; G28 U0 W0 ; (HOME.)
| Cycle & Parameter | FANUC 0i-TF Two-Line Format | Haas NGC Single-Line Format | Contour & Allowance Constraint |
|---|---|---|---|
G71OD Roughing |
G71 U2.0 R0.5+ G71 P100 Q160 U0.5 W0.1 F0.25
|
G71 P100 Q160 D2.0 U0.5 W0.1 F0.25
|
Type I needs monotonic X/Z; Type II pocket dips require X and Z inPblock |
G72Face Roughing |
G72 W2.0 R0.5+ G72 P.. Q.. U0.5 W0.1 F0.22
|
G72 P.. Q.. D2.0 U0.5 W0.1 F0.22
|
Cuts perpendicular to Z axis; best when raw face overhang exceeds X stroke width |
G70Finish Pass |
G70 P100 Q160
|
G70 P100 Q160
|
Executes finish path along P-Q geometry per controller nose-compensation rules |
G74Axial Peck Drill |
G74 R0.5+ G74 Z-35.0 Q4000 F0.12
|
G74 Z-35.0 K4.0 F0.12
|
Run underG97fixed RPM at X0.0; FANUC Quses microns while Haas Kuses active units |
6. Grooving (G75) and Metric Threading (G76) CNC Lathe Programming Examples

Worked
M24 x 2.0
threading uses ISO 68-1:2023 external design depth (1.227 mm) to set
P1227
after a
G75
relief groove. Finished compliance under ISO 965-1:2026 Class 6g depends on pre-thread OD, tip radius, and gauging. Keep
G97
fixed spindle RPM active during threading.
In ISO screw-thread geometry, the fundamental triangle height is
H = 0.866025 * P
, while
0.6495 * P
appears as a traditional flat-crest handbook approximation. Standard ISO 68-1:2023 external design profiles define a rounded-root profile with radial depth h3 = 0.61343 * P, reviewed alongside basic profiles in BoltScience’s ISO 68-1:2023 analysis. For the rounded-root external metric thread design profile, BoltScience reports a minimum root radius of R1 = 0.125 * P (0.144 * P for a fully rounded root) to reduce stress concentration. BoltScience cites improved fatigue strength and tool life.
Worked
M24 x 2.0 6g
Metric Thread Calculation: For pitch
P = 2.0 mm
, fundamental triangle height is
H = 1.732 mm
(
0.866025 * 2.0
). External design depth equals
h3 = 1.227 mm
(
0.61343 * 2.0
), giving
P1227
. Tolerance grades follow ISO 965-1:2026. On MachiningDoctor’s M24 x 2.0 6g table, Class 6g lists allowance
es = 0.038 mm
and major diameter 23.682–23.962 mm. It also shows external pitch diameter 22.663 mm, minimum root radius 0.25 mm, and truncation C = 0.25–0.308 mm, while the top Basic Thread Dimensions table shows theoretical minor diameter 21.835 mm. Subtracting
2 * 1.227
from nominal 24.000 mm yields 21.546 mm minor diameter. Referencing the 23.962 mm 6g limit sets our
G76
target at
X21.508 mm
. Inspect finished threads with calibrated GO/NO-GO ring gauges.
Before threading, cut a
G75
peck groove ahead of the
Ø36 mm
wall. Cutting Tool Engineering recommends starting Z three to four pitches clear of the face (
Z6.0–Z8.0
). It also lists infeed options
A0, A29, A30, A55, A60, A80
. Set the 60-degree tool included angle in P020060 per GCodeTutor.
On Practical Machinist, machinists advise against mixing compound G76 and radial G92 passes when Z sync differs. Browse our single-point lathe threading guide for insert choices.
(TOOL 03: G75 3.0MM WIDE UNDERCUT GROOVE AT Z-35.0 TO DIA 21.0MM)
N300 T0303 ; (3.0 mm wide grooving insert, Z0 set at left cutting edge)
N310 G50 S2000 ; G96 S110 M03 ; M08 ;
N320 G00 X26.0 Z-35.0 ; (Position 2.0 mm over 24 mm OD at groove rear wall)
N330 G75 R0.5 ; (Peck retract R0.5 radially per stroke)
N340 G75 X21.0 Z-35.0 P1500 Q0 F0.08 ; (Plunge to 21.0 mm dia in 1.5 mm radial pecks)
N350 G00 X120.0 M09 ; G28 U0 W0 ; M01 ;
(TOOL 04: G76 TWO-LINE M24 X 2.0 CLASS 6G EXTERNAL METRIC THREAD)
N400 T0404 ; (60-deg ISO metric full-profile insert, R >= 0.25 mm)
N410 G97 S800 M03 ; M08 ; (LOCK fixed RPM with G97 - NEVER G96 during threading!)
N420 G00 X26.0 Z6.0 ; (Approach 3x pitch = 6.0 mm clear of face for Z servo sync)
N430 G76 P020060 Q100 R0.05 ; (2 spring, 0 chamfer, 60-deg tip, Q100 min cut, R0.05 fin)
N440 G76 X21.508 Z-33.5 P1227 Q350 F2.0 ; (Target 6g minor X21.508, h3=1.227 mm, 1st pass Q350, pitch F2.0 mm)
N450 G00 X120.0 M09 ; G28 U0 W0 ;
| Word & Value | Line Block | Engineering Unit | Machining Action |
|---|---|---|---|
P020060
|
Block 1 | 02 passes / 00 chamfer / 60 deg | Runs 2 zero-infeed spring passes, 0-lead pullout (into groove), and 60-degree tool-tip included angle setting (GCodeTutor G76) |
Q100 / R0.05
|
Block 1 | Microns (Q) / mm ( R) |
Per GCodeTutor,Qblocks tiny 0.001 mm rubbing passes and Rreserves finish stock (worked values Q100en R0.05for O0240) |
X21.508 Z-33.5
|
Block 2 | mm (X dia, Z endpoint) | Stops root diameter at 21.508 mm (23.962 - 2*1.227) and terminates inside groove |
P1227 Q350 F2.0
|
Block 2 | Microns (P/Q) / mm/rev ( F) |
Commands 1.227 mm radial depth,Q350micron first pass (350 μm worked input), and 2.0 mm/rev thread pitch |
7. Complete CNC Lathe Programming Example: Stepped, Grooved, and M24x2.0 Threaded Shaft

Programma
O0240
links four tool stations (
T0101–T0404
) to machine
Ø55 mm
AISI 1045 bar into a stepped, relief-grooved,
M24 x 2.0 threaded shaft. Each tool header repeats modal resets, speed clamps, and safe retracts independently. Run offset touch-offs, backplot dry runs, and ring gauging prior to batch cuts.
Standalone code blocks often fail during mid-program tool restarts. As Modern Machine Shop Key CNC Concept #5 notes, omitting redundant speed commands works from tool #1 to tool #5 sequentially. However, restarting at tool #5 after tool #10 keeps tool #10’s 1500 rpm active instead of 500 rpm. Repeating
G18 G21 G40 G80 G99
,
G50
/
G97
, coolant codes, and home retracts keeps each tool section independent.
| Feature Segment | Target Diameter / Geometry | Z-Axis Extent fromZ0Face |
Assigned Tool & Cycle |
|---|---|---|---|
| Front Face & Thread Lead Chamfer |
Z0.0face / 2.0 mm × 45°chamfer |
Z+0.5stock face down to Z-2.0
|
T0101rough face + T0202finish |
Threaded Diameter (M24 x 2.0 6g) |
Pre-thread ODØ23.90 mm(within 23.682–23.962 mm 6g window; G76root X21.508references 23.962 mm max) |
Z-2.0to Z-32.0(30 mm length) |
T0101 G71/ T0202 G70/ T0404 G76
|
| Thread Relief Undercut Groove |
Ø21.0 mmroot diameter, 3.0 mm wide |
Z-32.0to Z-35.0
|
T0303(3 mm groover) G75
|
| Center Bearing Journal |
Ø36.0 mm cylinder following leading R2.0 mm convex edge radius |
Z-35.0 to Z-58.0 (leading edge blend followed by cylindrical land) |
T0101 G71/ T0202 G70 G42
|
| Rear Flange Shoulder |
Ø48.0 mmOD (from Ø55 mmstock) |
Z-58.0to Z-85.0
|
T0101 G71/ T0202 G70 G42
|
%
O0240 (STEPPED GROOVED M24X2.0 SHAFT - AISI 1045 - 55MM BAR.)
(CONTROL: FANUC 0I-TF SYSTEM A - METRIC G21 - Z0 AT FRONT FACE.)
(TOOL 01: FACE AND G71 ROUGH - CNMG120408 R0.8.)
N010 G18 G21 G40 G80 G99 ; (MODAL RESET.)
N020 G28 U0 W0 ; (HOME TURRET.)
N030 T0101 ; G54 ; (T01 WORK DATUM G54.)
N040 G50 S2500 ; (MAX 2500 RPM.)
N050 G96 S180 M03 ; M08 ; (CSS 180 M/MIN CW.)
N060 G00 X57.0 Z0.2 ; (APPROACH Z0.2.)
N070 G01 X-1.6 F0.20 ; (FACE PAST CENTER.)
N080 G00 X56.0 Z2.0 ; (CYCLE START POINT.)
N090 G71 U2.0 R0.5 ; (2MM DOC, R0.5 RETRACT.)
N100 G71 P110 Q180 U0.5 W0.1 F0.25 ; (LEAVE ALLOWANCE.)
N110 G00 G42 X19.9 ; (P110: G42 ON FOR G70.)
N120 G01 Z0.0 F0.14 ; (FACE PLANE.)
N130 G01 X23.9 Z-2.0 ; (2MM CHAMFER.)
N140 G01 Z-35.0 ; (TURN 23.9MM OD.)
N150 G01 X32.0 ; (STEP WALL.)
N160 G03 X36.0 Z-37.0 R2.0 ; (R2.0 EDGE RADIUS.)
N170 G01 Z-58.0 ; (TURN 36MM STEP.)
G01 X48.0 ; (STEP WALL TO OD.)
G01 Z-85.0 ; (TURN REAR FLANGE.)
N180 G01 G40 X56.0 ; (Q180: G40 CANCEL.)
N190 G00 X120.0 M09 ; M05 ; G28 U0 W0 ; M01 ; (HOME STOP.)
(TOOL 02: G70 FINISH - DNMG150604 R0.4.)
N200 G18 G21 G40 G80 G99 ; (SAFE START.)
N210 T0202 ; G54 ; (T02 OFFSET.)
N220 G50 S2500 ; G96 S230 M03 ; M08 ; (CSS 230 M/MIN.)
N230 G00 X56.0 Z2.0 ; (MATCH START POINT.)
N240 G70 P110 Q180 ; (FINISH CONTOUR.)
N250 G00 X120.0 M09 ; M05 ; G28 U0 W0 ; M01 ; (HOME STOP.)
(TOOL 03: G75 3MM GROOVE AT Z-35.0.)
N300 G18 G21 G40 G80 G99 ; (SAFE START.)
N310 T0303 ; G54 ; (T03 GROOVER.)
N320 G50 S2000 ; G96 S110 M03 ; M08 ; (CLAMP 2000 RPM.)
N330 G00 X26.0 Z-35.0 ; (CLEAR 23.9MM OD.)
N340 G75 R0.5 ; (PECK RETRACT.)
N350 G75 X21.0 Z-35.0 P1500 Q0 F0.08 ; (GROOVE TO 21MM.)
N360 G00 X120.0 M09 ; M05 ; G28 U0 W0 ; M01 ; (HOME STOP.)
(TOOL 04: G76 M24 X 2.0 6G THREAD.)
N400 G18 G21 G40 G80 G99 ; (SAFE START.)
N410 T0404 ; G54 ; (T04 THREADER.)
N420 G97 S800 M03 ; M08 ; (FIXED 800 RPM G97.)
N430 G00 X26.0 Z6.0 ; (3X PITCH LEAD CLEAR.)
N440 G76 P020060 Q100 R0.05 ; (2 SPRING PASSES.)
N450 G76 X21.508 Z-33.5 P1227 Q350 F2.0 ; (ISO 68-1 H3=1.227.)
N460 G00 X120.0 M09 ; M05 ; G28 U0 W0 ; (HOME.)
N470 M30 ; (REWIND.)
%
Prior to pressing Cycle Start on O0240, audit the listing with our 4-pass Canned-Cycle Coordinate Audit:
| Audit Pass | Blocks Inspected | Coordinate Check Rule |
|---|---|---|
| Pass 1: Profile & Compensation |
N110–N180( P-Qblock) |
Verify monotonic increase in X (19.9 -> 56.0), decreasing Z, G42on Pblock, and G40inside Qblock |
| Pass 2: Spindle & Clamp Curves |
N040, N220, N320, N420
|
ConfirmG50establishes an RPM cap ahead of G96en G97 S800activates fixed RPM before G76
|
| Pass 3: Retract Vector Order |
N190, N250, N360, N460
|
EnsureG00 X120.0clears stock and groove walls radially before G28 U0 W0(or G53 Z0) |
| Pass 4: Mid-Program Restart Safety |
N010, N200, N300, N400
|
Verify safe-start modal reset,G54, tool offset, and speed mode repeat at every tool header |
8. First-Part Prove-Out Checklist: Debugging Offsets and Preventing CNC Lathe Crashes

After any program edit, run a dry check at 5% rapid override per the University of Florida protocol using
Single Block
en
Distance-to-Go
. Rapid override leaves cutting feedrates active, and Single Block response is limited inside threading passes. Verify tailstock clearance and restrain the rear bar stock.
Serious turning incidents trace to both code errors and unsupported rear stock. On
G90/G91
controls, CNC Training Centre warns that leaving
G91
active after
G28 G91 Z0
shifts later moves unless
G90
returns. Using
G53
avoids setting
G91
from absolute mode, though path clearance still requires checking. On setup hazards, Washington State L&I / NIOSH FACE Report 10WA01001 reports a fatality involving a
6-foot
stainless bar in a Haas TL-3W lathe. Roughly 3 feet (36 in) projected unsupported behind the spindle and bent nearly 80 degrees. Separately, a U.S. DOL OSHA investigation issued 16 serious violations after an unguarded
1-inch
bar protruding 34 inches killed a machinist. Spindle liners, rear bar supports, and conservative speed caps pair with rigid lathe chuck workholding.
| Failure Mode / Hazard | Programming or Setup Trigger | Consequence on Machine | Prove-Out Check & Quantitative Fix |
|---|---|---|---|
| Diameter-vs.-Radius 2x Plunge | Programming radiusX25.0on diameter-mode control |
Tool plunges to half intended diameter, snapping insert | Verify diameter parameter and compareDistance-to-GoX target against stock OD |
| Simultaneous X-Z Rapid Vector | CommandingG00 X24.0 Z-35.0across OD step or chuck |
Turret clips shoulder corner or tailstock center diagonally | Always rapidXclear first on retract, or approach Zclear outside bar first |
| Decimal Point Integer Scaling | WritingX24instead of X24.0when Parameter 3401 DPI=0 |
Control reads 24 microns (0.024 mm), 1,000x smaller | Enforce explicit decimal points on every dimensional coordinate |
| Unbalanced Rear Bar Whip | ~3 ft / 36 in unsupported bar (FACE); ~34 in protrusion (OSHA) | Unsupported bar bends (nearly 80° in FACE case) and whips fatally | Keep overhang inside spindle tube, fit rear bar support, and set setup RPM limits |
G91Retained After G28
|
ForgettingG90after G28 G91 Z0on Type B/C |
Next Z coordinate becomes incremental travel error | UseG28 U0 W0(Type A) or G53 X0 Z0to preserve absolute mode |
| Active Nose Comp Into Retract | LeavingG41/G42modal across non-cutting rapid exits |
Subsequent move carries full tool-nose offset vector | Verify modal cancel on the status display without clearing stored geometry or wear offsets |
G54 Z0Raw vs. Finish Face |
Touching tool on rough saw cut instead of clean face datum | Shoulder depths and groove walls shift by face stock | Check tailstock/travel limits first, verify axial air-cut clearance at UF 5% rapid, then skim-faceZ0
|
Mid-Program S-Word Omission |
Rerunning Tool 2 without re-callingG97/G50klem |
Tool inherits previous tool’s higher speed (e.g., 1500 rpm vs 500) | Repeat full header, offset, andSlimit at every tool index |
9. Manual G-Code vs. Conversational Programming vs. CAM Software and Offline G-Code Simulators

For concentric turning shafts, machinists write out G-code canned cycles by hand or use conversational wizards. For contoured splines and C/Y live-tool work, machinists use CAD/CAM. Every method still requires offline toolpath verification before cutting. As Productie Machining observes, dual-mode Mazatrol Smooth shops run EIA/ISO G-code directly when strict cycle-time control or revision lock matters.
Object-oriented conversational interfaces such as the graphics-assisted control architecture in U.S. Patent US5453933A (which includes a 39-frame microfiche appendix) allow for faster conversational CNC programming workflows on console jobs. Even so, NIST’s January 2026 digital twin study stresses pairing toolpaths with synchronized axis positions, spindle speeds, tool offsets, and machine alarm states to evaluate physical lathe behavior.
| Programming Path / Simulator Tier | Geometry & Feature Scope | Batch Size & Edit Latency | Verification Boundary |
|---|---|---|---|
Manual Canned Cycles (G70–G76) |
Stepped cylinders, chamfers, undercut grooves, and standard threads | Direct console parameter tweaks for wear or thread depth without CAM repost | Backplot path check via controller graphics or desktop toolpath plotter |
| Shop-Floor Conversational Systems | Simple shafts, pockets, and guided feature cycles at the control | Short-run prototype or repair setups programmed directly at the console | Built-in console graphics review; less granular cycle-time optimization |
| Full CAD/CAM Software Suite | Multi-tool contoured profiles, custom splines, and C/Y live-tool mill-turn work | Complex or repeat batches programmed offline while the spindle runs | Turning solid-stock simulation, multi-axis machine simulation, and post-processor audit |
| OEM Desktop Simulators & LLM Drafts | OEM controller training software (configured offsets) vs. text-generated code | Offline syntax rehearsal before shop-floor dry runs | OEM simulators model configured controller functions only (verify builder PLC alarms on machine); LLM text requires line-by-line review |
Can ChatGPT Make a Safe CNC Lathe Program Without Verification?
No, ChatGPT output needs backplotter verification, controller dialect checks, and first-part prove-out before cutting metal. CloudNC’s G-code risk analysis explains that standalone LLMs lack CAD geometry context and machine kinematics checks. As a result, generated listings often mix controller dialects or invent unsafe tool retracts.
In December 2025, a Michigan Technological University VLM study evaluated vision-language models on 16 G-code and PathPilot HMI pairs. Under the zero-shot full-image (ZS Full) configuration, it measured 0.875 G-code validity classification accuracy and 0.688 compliance accuracy, rising to 0.750 compliance accuracy under few-shot prompting. Because those metrics classify pre-written pairs rather than generative safety, automated checks never replace single-block dry runs.
10. Controller Dialects (FANUC Type A/B/C, Siemens, GSK), Turning Center Integration, and RFQ Checklist

Turning center RFQs must specify dialect conversion or Siemens
G291
ISO mode, offline simulation tools, and spindle limits. For instance, ANTISHICNC’s 235 LANCEN slant-bed turning-milling center carries a FANUC 0i-TF control, 3,500 rpm limit, Φ460 mm bed swing, Φ66 mm bore, and Φ50 mm bar capacity. Blanket ISO wording can hide controller syntax differences during offline G-code validation and compliance checks.
Per controller modal documentation, native Siemens Sinumerik programs use cycles such as
CYCLE95
and require a post-processor unless ISO mode (
G291
) is configured. Switching between FANUC Type A and Type B/C also changes speed-clamp, incremental, and feed codes listed below. Published specifications on ANTISHICNC’s 235 LANCEN page list
Φ260 mm
cross-slide swing, 570 mm center distance, 550 mm maximum turning length, and an 11 kW spindle motor. The specification also includes an 8-inch hydraulic chuck and a repeat positioning accuracy of ±0.005 mm. Confirm bar liners, posts, and test cuts with the ANTISHICNC engineering support team.
| Programming Feature | FANUC Type A / GSK 980TDi | FANUC Type B / C | Haas NGC Lathe | Siemens 828D (ISO vs. Native) |
|---|---|---|---|---|
Spindle Clamp UnderG96
|
G50 S2500
|
G92 S2500
|
G50 S2500
|
LIMS=2500(native) |
| Incremental Axes |
U(X dia) and W(Z) |
G91 X Z(or U/Wif set) |
Uen Wfor incremental X/Z |
G91/ IC(...)
|
| Feed Mode Codes |
G99(mm/rev) / G98(mm/min) |
G95(mm/rev) / G94(mm/min) |
G99(mm/rev) / G98(mm/min) |
G95(mm/rev) / G94(mm/min) |
| OD Stock Removal | 2-lineG71 U.. R..+ P Q
|
Type B/C roughing cycle syntax per manual | 1-lineG71 P Q D..(2-line optional) |
NativeCYCLE95( G291selects ISO mode) |
| Single-Point Threading | 2-lineG76 P.. Q.. R..
|
2-lineG76(1-line on legacy) |
1-lineG76 X Z K D A F
|
CYCLE97/ G33
|
| RFQ Specification Item | Concrete Target Value / Requirement | Crash Prevention & Commissioning Purpose |
|---|---|---|
| Controller & G-Code System | Specify FANUC 0i-TF (Type A default), GSK 980TDi, or Siemens 828D | LocksG50vs. G92spindle clamping and G98/G99feed interpretation |
G71Cycle Variant Option |
Enable Type II non-monotonic pocket turning alongside Type I | Prevents contour alarms when turning grooved or relief-recessed shafts |
| Parameter 3401.0 (DPI) Setting | Record DPI = 1 (calculator decimal) or DPI = 0 (micron integer) on build sheet | Prevents 1,000x coordinate scaling bugs if an operator omits a trailing decimal |
| Spindle Bore, Bar Size & Chuck Limit | 235 LANCEN spec example:Φ66 mmbore, Φ50 mmbar capacity, 8-in hydraulic chuck, 3,500 rpm limit |
Guides spindle-liner sizing while jaw grip, overhang, and rear bar support govern safeG50speed |
| Rapid Override & Handwheel | Dedicated console rapid switch with selectable 5% setting plus pendant MPG | Supports single-block dry runs at UF 5% rapid during prove-out |
Tool Nose Radius Comp (G41/G42) |
Verify imaginary tool-nose direction codesT1–T9in geometry table |
Supports accurate chamfers andG02/G03fillets under G70finishing |
| CAM Post-Processor & Simulator | Include matching controller post-processor and compatible offline simulation option | Reduces manual dialect translation between CAM output and the machine control |
| Transfer & DNC Memory | Front USB port + Ethernet DNC interface matching part program sizes | Transfers long CAM-contoured programs cleanly without manual split files |
| FAT Sample Part & Metrology | Verify the 235 LANCEN acceptance sheet (±0.005 mm repeatability and surface-finish target) with GO/NO-GO gauges and request a test-cut engineering quote | Confirms turning and thread test-cut setup alongside reference G-code at commissioning |
Frequently Asked Questions on CNC Lathe Program Examples
What can you make with a CNC lathe using G71 and G76 cycles?
A 2-axis CNC lathe turns rotationally symmetric parts such as stepped drive shafts, bearing sleeves, and hydraulic adapters. Combining G71 roughing, G75 grooving, and G76 threading also produces stepped pulleys, sealing flanges, and precision threaded studs.
Slant-bed turning centers equipped with live tooling and C/Y axes can drill cross-bolt circles, mill keyways, and machine hex flats in one setup.
What is the difference between G96 constant surface speed and G97 constant RPM?
G96
scales spindle RPM inversely with tool diameter to keep commanded surface speed steady (
m/min
of
SFM
) until the programmed RPM limit takes hold. Below that crossover diameter, spindle RPM stays flat and actual surface speed drops toward zero toward the centerline, while
G97
locks constant RPM across all diameters.
Shops select
G96
for variable-diameter facing and profile turning, switching to fixed-RPM
G97
when drilling, tapping, parting, or cutting threads.
How do you choose between G41, G42, and G40 in a CNC lathe program?
G41 offsets the tool nose left of the programmed path and G42 offsets right along the cutting direction in G18, while G40 cancels offset. Selecting left or right depends on feed direction, turret mounting side, and imaginary nose tip code (
T1–T9
) rather than OD versus ID alone.
Your specific controller cycle rules will determine activation on straight linear lead-in moves and cancellation stages. Universal brand rules don’t apply.
What is the difference between G98 and G99 feed modes on a Fanuc CNC lathe?
On FANUC Type A turning controls,
G99
sets feed per spindle revolution (
mm/rev
of
in/rev
), whereas
G98
sets feed per minute (
mm/min
of
IPM
).
Programmers explicitly place
G99
in the safe-start block so chip load tracks spindle rotation under
G96
instead of assuming a machine power-on default.
What should you check before running a downloaded CNC lathe programming example PDF on your machine?
Before running any downloaded example PDF, verify controller dialect (FANUC Type A vs. Type B/C vs. Haas vs. Siemens), unit mode (
G20
/
G21
), spindle clamps, and
Z0
datum orientation.
Classroom PDFs often omit turret-index clearance moves or place
Z0
at finish face while setups touch off sawed stock. Borrowed two-line G71 parameters (U en R) differ from single-line Haas D syntax based on control settings. Some workbooks also leave nose offset active on exit. Always step any downloaded program through an offline backplotter and check tool-nose orientation codes (T1–T9).
Confirm tailstock and machine-coordinate retract clearance along air-cut paths, then prove out block one in Single Block at 5% rapid override while watching Distance-to-Go.
Why do some CNC lathe examples put G50 before G96 while others use G92?
Dialect parameter settings determine which G-code registers the maximum RPM ceiling versus coordinate presetting.
Under FANUC Type B/C parameters, G50 does not cap spindle RPM; the alternate code named in the heading sets both the RPM clamp and coordinate presetting (matching the controller dialect tables). Copying unverified headers across Type A and Type B/C controls can therefore bypass your intended speed limit.
Referenties en bronnen
- ISO 6983-1:2009, Automation systems and integration, Numerical control of machines, Program format and definitions of address words, Part 1, International Organization for Standardization
- CNC Lathe Programming and Safety Resources, University of Florida Department of Mechanical and Aerospace Engineering (Design and Manufacturing Laboratory)
- Become Familiar with CNC Code, Cutting Tool Engineering
- U.S. Patent US6470776B1, Clamping device and method of operation for a CNC machine, United States Patent and Trademark Office (via Google Patents)
- ISO 68-1:2023, ISO general purpose screw threads, Basic and design profiles, Part 1: Metric screw threads, International Organization for Standardization
- ISO 965-1:2026, ISO general purpose metric screw threads, Tolerances, Part 1: Principles and basic data, International Organization for Standardization
- Single-Point Thread Programming Can Be Fun and Easy, Cutting Tool Engineering
- Key CNC Concept #5, The Importance Of Program Formatting, Modern Machine Shop
- Machinist Dies After Being Struck by Rotating Steel Bar Stock in Lathe in Washington State (WA FACE Report 10WA01001), Washington State Department of Labor and Industries / NIOSH FACE Program
- OSHA Finds Multiple Violations After Metal Bar Strikes, Kills Lathe Operator (Release 16-0817-KAN), U.S. Department of Labor, Occupational Safety and Health Administration
- When CNC G-Code Programming Is a Must, Production Machining
- U.S. Patent US5453933A, CNC control system, United States Patent and Trademark Office (via Google Patents)
- Data Requirements for a Digital Twin of a CNC Machine Tool, National Institute of Standards and Technology (NIST)
- Few-Shot VLM-Based G-Code and HMI Verification in CNC Machining, Michigan Technological University (arXiv preprint, Dec 2025)













