When Learning CNC Lathe Programming, These 12 Codes Decide the Part
Every lathe program is built from a small set of G and M codes. This page explains what each one actually does to the tool, the spindle and the part, with the values we use on the floor. When learning CNC lathe programming, the goal is simple: read a block of code and name the line that will scrap the part.

In this article
- 1
- 2
- 3
- 4
- 5
- 6
- 7
When learning CNC lathe programming: why 12 codes cover most turning work
A lathe program looks long, but the motion is controlled by very few words. Positioning, two kinds of feed, two arcs, four canned cycles, spindle rotation and coolant. Add tool changes and the program length is mostly repetition with different coordinates. When learning CNC lathe programming, you are really learning how these few words interact, not memorizing a manual.
The number 12 is not a standard. It is the count that covers the vast majority of simple shaft, bushing and fitting work we quote every week. Once you know these, reading someone else's program stops being guesswork.
Each code has a boundary. G00 is fast and blind. G71 removes material in a pattern that assumes a certain stock shape. Knowing where a code stops being safe matters more than knowing its definition. That is the skill a programmer is paid for.
G00, G01, G02 and G03: moving the tool
G00 moves at machine rapid rate, usually 20–30 m/min on a turning center. It ignores the workpiece. Use it only above the part or in clear air. A G00 move at Z-2.0 mm with the tool still at X0 will drive straight into the face and break the insert.
G01 is straight feed at the programmed rate. On aluminum 6061 we run roughing at 0.25–0.35 mm/rev and finishing at 0.05–0.12 mm/rev. On 316 stainless, drop roughing to 0.15–0.25 mm/rev. Too light a finish feed rubs the material instead of cutting it, and the surface tears.
G02 and G03 cut arcs, clockwise and counterclockwise. On a lathe the arc is defined in the ZX plane, so I and K are the offsets from the start point to the arc center, not J. Writing J by habit is one of the most common mistakes for people coming from milling.
Use G02 or G03 only when the radius is real. A 0.4 mm corner break is faster as a chamfer with G01. Arc moves on a lathe tie up the control and, on small radii, produce a faceted surface that a chamfer avoids.
G71, G70, G74 and G76: removing metal by pattern
G71 is the roughing cycle. You give it a depth of cut per pass, a finish allowance and the profile. On 4140 steel we take 1.5–2.5 mm per side; on aluminum, 3–4 mm. The cycle assumes the stock is larger than the profile in one direction. If the blank is a casting with an irregular shape, G71 will take a heavy first cut and you should use G73 instead.
G70 is the finishing pass that follows the G71 profile. Leave 0.2–0.5 mm radial for it on steel and 0.3–0.5 mm on aluminum. Skip the allowance and the finish pass has nothing to remove, which produces a polished-looking but dimensionally wrong part.
G74 drills and pecks on the axis. For a Ø20 mm hole in 1045 steel, a 4–6 mm peck with full retract clears chips. On deep holes the peck depth should drop as depth increases, or the drill wanders and the hole runs off center.
G76 cuts threads with a controlled infeed. For an M20 × 2.5 thread on 303 stainless we use 1,200 rpm, a 0.3 mm first pass and a 0.08 mm minimum cut. Too few passes overload the insert; too many passes work-harden the surface and the thread tears.
M03, M08 and the codes that touch the machine
M03 starts the spindle forward. On an OD turning tool, forward means the top of the insert faces the cut. Run the wrong direction and the insert lifts off its seat. For a left-hand tool on a sub-spindle, that direction flips, which is why the same M03 is not always correct.
M08 turns on flood coolant. On 316 stainless and titanium it is not optional. Titanium chips ignite at the tool tip if the heat cannot leave, and dry turning a long stringy chip wraps the tool.
M30 ends the program and rewinds. M05 stops the spindle, M09 stops coolant. Put M05 and M09 before the tool retracts, not after. A tool that pulls out of a bore with the spindle still turning will drag a mark down the finished wall.
These are the codes people forget because they do not move anything. They still decide whether the part comes out clean or has a spiral scratch inside the bore.
Reading a program before you run it
The fastest way to catch a mistake is to follow the tool, not the code. Start at the tool change position and trace X and Z through the first ten blocks. If the tool passes through the part envelope before the spindle turns, you found the error without a crash.
Check the sequence of operations. Face, then center drill, then drill, then rough, then finish. A program that drills before facing will cut into a surface that is not flat yet, and the drill walks.
Look at the feeds against the material. The same program on 6061 and on 17-4PH stainless will not run the same way. If the programmer did not change feed and speed between materials, the stainless part will work-harden on the first pass.
Finally, check the M codes at the end of each tool block. A missing M09 leaves coolant running into the next tool change, and a missing M05 leaves the spindle turning while the turret indexes. Small things, real damage.
What these 12 codes will not do
They will not compensate for a worn insert. If a dimension drifts by 0.03 mm over 50 parts, the problem is the tool, not the program. Change the insert and re-check.
They will not handle a part that needs two setups. Codes cover one operation on one spindle. Once the part is flipped, you are building a new program with a new zero, and the tolerance stack between the two setups becomes the real limit.
They will not fix a bad workholding decision. A shaft held in a three-jaw chuck with 4× diameter overhang will deflect no matter how good the feeds are. Support it with a tailstock or steady rest before you tune the program.
Where the part needs ±0.005 mm over a long feature, the code is only half of it. Machine condition, thermal drift during the run and inspection between passes carry the rest. Treat the program as the plan, not the result.
The 12 codes and where each one stops being safe
Values are typical starting points for steel and aluminum on a turning center
| Code | What it does | Typical value | When it is the wrong choice |
|---|---|---|---|
| G00 | Rapid positioning | 20–30 m/min | Any move below the part surface |
| G01 | Straight feed | 0.25–0.35 mm/rev rough | Very light finish feed on stainless |
| G02 | Clockwise arc | I and K offsets in ZX | Corners under 0.5 mm radius |
| G03 | Counterclockwise arc | I and K offsets in ZX | Straight or chamfered edges |
| G71 | OD/ID roughing cycle | 1.5–2.5 mm per side, steel | Castings with irregular stock |
| G70 | Finishing pass | 0.2–0.5 mm allowance | When no stock was left |
| G74 | Peck drilling cycle | 4–6 mm peck, Ø20 mm hole | Holes under Ø5 mm |
| G76 | Threading cycle | 0.08 mm minimum cut | Threads finer than 0.5 mm pitch |
| G90 | Turning cycle, simple | Single pass, straight profile | Profiles with shoulders or radii |
| G94 | Face turning cycle | Face passes to a step | Long slender shafts |
| M03 | Spindle forward | Match tool hand | Left-hand tool on sub-spindle |
| M08 | Coolant on | Flood, always on steel | Rarely wrong on metal |
The takeaway
Learn these 12 codes and you can read any turning program. Trust the code alone and you will still scrap parts. If the job is a simple shaft or bushing, the codes plus correct feeds will do it. If the part needs tight tolerance over a long feature or two setups, send it to a shop that controls the machine and the inspection, not just the code.
Questions we hear from engineers
Do the same 12 codes work on every lathe control?
The G codes in this list are close to universal on FANUC-style controls, which is what most turning centers use. The M codes vary more. Some controls use M03 for spindle forward and some assign it differently on a sub-spindle.
Always check the machine manual for M code assignments before running an unfamiliar program. The G codes transfer between machines far more reliably than the M codes.
Why does G71 take a heavy first cut on a casting?
G71 assumes the stock is a cylinder larger than the finished profile. On a casting, the outer surface is irregular, so the first pass follows the programmed depth from a surface that is not where the control thinks it is.
For castings and forgings, use G73, which repeats the finished profile at increasing offsets and follows the actual stock shape more closely.
How do I choose between G01 chamfer and G02/G03 radius on a corner?
If the drawing says a radius, cut a radius. If it is a break edge under about 0.5 mm, a G01 chamfer is faster and produces a cleaner corner on most materials.
Small G02 and G03 arcs at high feed leave visible facets because the control interpolates in steps. A chamfer does not have that problem.
What feed and speed should I start with on stainless?
For 303 or 304 stainless on an OD turning tool, start around 0.15–0.25 mm/rev roughing and 0.05–0.10 mm/rev finishing, with surface speed in the 120–180 m/min range for carbide.
If the chip turns blue and the surface work-hardens, reduce surface speed before you reduce feed. Too light a feed on stainless rubs the surface and hardens it.
When should the program not be changed at all?
When the dimension is drifting slowly across a run, the tool is wearing and the program is fine. Change the insert, re-check the offset.
When the first part is out of tolerance and the tenth is good, the machine is warming up. Run a warm-up cycle or a few scrap parts before you touch the offsets.
Can these codes handle a part with a cross hole or milled flat?
Not on a two-axis lathe. A cross hole or flat needs a live tool and a C axis, or a second operation on a mill.
On a mill-turn center, the same G codes appear but the plane changes, and the arc offsets switch back to I and J. That is a different program, not an extension of this one.
Send us the drawing and we will read the program for you
Upload a STEP file and get a quotation with a free DFM analysis within 12 hours. We machine from one prototype to 10,000+ part runs, with 100% inspection before shipment.
12-hour quote100% inspectionNo minimum order quantity