CNC lathe programming requires a different mindset from milling: linear movement along the Z axis, the X axis as the diameter direction, and the C axis for rotation. In this guide you will learn Fanuc-compatible CNC lathe G-Code commands, canned cycles, and how to generate them automatically with CAM232.
Coordinates on a CNC lathe are defined as follows:
Note: On some controllers the X value is entered as a radius. Check your machine parameters — selecting the wrong mode will result in dimensional errors.
| G-Code | Description | Example |
|---|---|---|
| G0 | Rapid positioning | G0 X100 Z5 |
| G1 | Linear cutting | G1 X50 Z-30 F0.2 |
| G2 | Clockwise circular | G2 X60 Z-20 R10 |
| G3 | Counter-clockwise circular | G3 X40 Z-15 R8 |
| G4 | Dwell | G4 P1000 (1 sec) |
| G20/G21 | Inch / Metric unit | G21 |
| G28 | Return to reference point | G28 U0 W0 |
| G40/G41/G42 | Tool nose radius compensation | G42 (right side) |
| G50 | Maximum spindle speed limit | G50 S3000 |
| G70 | Finish cycle (after G71/G72) | G70 P10 Q20 |
| G71 | OD roughing cycle | G71 U1.5 R0.5 |
| G72 | Face roughing cycle | G72 W1 R0.5 |
| G76 | Threading cycle | G76 P010060 Q100 R0.05 |
| G96 | Constant surface speed (CSS) | G96 S180 (180 m/min) |
| G97 | Constant RPM | G97 S1200 |
| G98/G99 | Feed: mm/min / mm/rev | G99 F0.15 |
One of the most critical decisions in lathe programming is the speed mode:
The controller automatically adjusts RPM as the diameter changes, keeping cutting speed constant. Ideal for a bright, consistent surface finish.
RPM stays fixed regardless of diameter changes. Preferred for threading, chamfering, and parting operations.
G71 automatically rough-machines complex OD profiles in multiple passes. Two blocks are required for Fanuc control:
Note: The G70 finish cycle is run after G71. G70 makes a single finishing pass over the P–Q profile using the finish parameters (F, S).
G76 automatically performs external or internal metric/inch threading. Two blocks are used in Fanuc format:
| Parameter | Description | Example |
|---|---|---|
| P (block 1) | Entry passes + exit type + angle | P010060 → 1 entry, 0 exit, 60° |
| Q (block 1) | Minimum pass depth (×0.001mm) | Q100 → 0.1mm |
| R (block 1) | Finish allowance | R0.05 |
| X (block 2) | Thread minor diameter | M30×2 → X27.835 |
| P (block 2) | Thread height (×0.001mm) | P1082 → 1.082mm |
| Q (block 2) | First pass depth (×0.001mm) | Q350 → 0.35mm |
| F | Pitch | F2.0 → 2mm pitch |
At each tool change the tool number (T) and offset number (two digits) are used together:
| M-Code | Description |
|---|---|
| M3 | Spindle forward (CW) |
| M4 | Spindle reverse (CCW) |
| M5 | Spindle stop |
| M8 | Coolant on |
| M9 | Coolant off |
| M30 | Program end and rewind |
| M0 | Program stop (operator confirmation) |
CAM232 online CAM software automatically generates G-Code from parameters for 12 lathe operations, eliminating manual G-Code writing:
Controller options include Fanuc, Siemens, Mazak, and others. G96/G97 mode, G98/G99 feed unit, and tool number are all set directly in the form.
Enter parameters, download G-Code. No installation.
Try CAM232 FreeCNC lathe programming demands a solid foundation in the coordinate system, speed modes (G96/G97), and canned cycles (G71, G76). You can adapt the G-Code examples in this guide to your own machine, or use CAM232 to generate all these cycles automatically. When parameters like speed mode, pitch, and finish allowance are set correctly, both surface quality and tool life improve significantly.