Lesson 9: Lathe Programming Basics

Updated

In short

On a lathe the Z axis lies along the spindle centre line and X is usually programmed as a diameter; the work zero sits on the part face at the centre line. In a Fanuc lathe program (system A), G96 with a G50 S limit holds constant surface speed, G99 sets feed in mm/rev, T0101 calls the tool with its offset, and the contour is roughed with G71 and finished with G70.

In this lesson you will learn:

  • how the X and Z axes work on a lathe and why X is programmed as a diameter;
  • how to use constant surface speed G96 with the G50 speed limit, and constant rpm G97;
  • the difference between feed per revolution G99 and feed per minute G98;
  • how to call a tool with T0101 and what tool nose radius compensation does;
  • how to write a facing and OD turning program with G71 and G70.

On a lathe the workpiece rotates and the tool moves in two axes. The program structure is similar to milling, but several rules differ. This lesson uses a Fanuc 0i-TF lathe control with G-code system A, the most common system on lathes. Other controls and G-code systems B and C differ, so the machine manual is always the authority.

Axes and work zero

The Z axis lies along the spindle centre line, positive away from the chuck. The X axis gives the position relative to the centre line and is usually programmed as a diameter: X30.0 means Ø30 mm, not a 30 mm radius. Incremental moves use addresses U and W: U-2.0 reduces the diameter by 2 mm, i.e. the tool moves 1 mm. The work zero is normally at the intersection of the centre line and the part face, so all Z coordinates on the part are negative. The G18 (ZX) plane is active by default on lathes (see machine axes and coordinates).

CodeMeaning (Fanuc lathe, system A)
X / ZAbsolute coordinates, X as diameter
U / WIncremental coordinates (instead of G91)
G18ZX plane (default)
G96 S…Constant surface speed, m/min
G97 S…Constant spindle speed, rpm
G50 S…Maximum spindle speed limit
G99 / G98Feed in mm/rev / mm/min
G41 / G42 / G40Nose radius compensation left / right / off
T0101Tool station 01, offset number 01

Note: in system A, G90 is not the absolute-coordinates command – it is a turning cycle. The milling safe block G21 G17 G40 G49 G80 G90 must therefore not be copied into a lathe program.

Cutting speed and feed: G96, G50, G97, G99

G96 S200 makes the control hold a constant cutting speed of 200 m/min, calculating rpm from the current X: n = 1000 × Vc / (π × D). At Ø42 mm that is about 1516 rpm, at Ø30 mm about 2122 rpm, and towards the centre the speed would theoretically rise without limit. G96 is therefore always preceded by G50 S…, a speed limit (2500 rpm here) chosen to suit the chuck, the clamping and the balance of the workpiece. In system A, G50 with X and Z sets the coordinate system, so only G50 S… is written for the limit. G97 selects constant rpm, used for threading, drilling on centre and often for parting off. G99 is feed in millimetres per revolution (F0.25 = 0.25 mm/rev), the normal mode for turning; G98 is mm/min, used e.g. with live tools.

Tool call and nose radius compensation

T0101: the first two digits are the turret station, the last two the offset (geometry and wear) number. M06 is normally not needed: the turret indexes as soon as it receives the T command, so the tool must be in a safe position beforehand. The insert nose is rounded (e.g. rε = 0.8 mm on a CNMG 120408 insert, see turning insert ISO designation), while the program describes an imaginary tool tip. Diameters and faces come out correct, but chamfers, tapers and radii show an error. It is removed by G41/G42 – usually G42 for OD turning towards the chuck – once the nose radius R and tip direction T are entered in the offset table. Compensation is switched on and off (G40) in a positioning move, not while cutting.

Example: facing and a Ø40/Ø30 shaft

From Ø42 mm bar (e.g. C45 steel) a 50 mm long shaft is turned: a Ø30 mm step 25 mm long and Ø40 mm up to Z-50. The bar sticks out of the chuck about 60 mm (part, parting blade width and clearance), with up to 1 mm of stock on the face.

O0901 (SHAFT D40 D30 L50)
N10 G21 G18 G40 G97 G99
N20 T0101 (OD TOOL R0.8)
N30 G50 S2500
N40 G96 S200 M03
N50 G00 X44.0 Z2.0 M08
N60 G01 Z0 F0.15
N70 X-1.6 (FACING)
N80 G00 Z2.0
N90 X44.0
N100 G71 U2.0 R0.5
N105 G71 P110 Q150 U0.4 W0.1 F0.25
N110 G00 X30.0
N120 G01 Z-25.0 F0.1
N130 X40.0
N140 Z-50.0
N150 X44.0
N160 G70 P110 Q150
N170 G00 X100.0 Z100.0 M09
N180 M05
N190 M30

BlocksWhat happens
N30–N40Speed limit 2500 rpm, constant 200 m/min surface speed
N50–N90Facing to X-1.6 – past centre by twice the nose radius so no pip is left
N100–N105G71 roughing: 2 mm depth on radius, 0.5 mm retract, 0.4 mm stock on diameter and 0.1 mm in Z, F0.25
N110–N150Finished contour; first block moves in X only (type I)
N160G70 finishing pass with F0.1 from the contour blocks
N170Retract to a safe position (machine-dependent; often G28 U0 W0)

The contour consists only of cylinders and faces, so nose radius compensation is not needed here. Cutting data are example values; real values depend on the insert and material, and the insert maker's data takes priority. G71 and G70 parameters are explained in detail in Fanuc lathe cycles G70–G76, and the process in CNC turning.

Parting off

The finished part is separated from the bar with a parting tool (e.g. T0202, 3 mm wide). Part off at constant rpm G97, or with G96 and a low G50 limit, at reduced feed (e.g. 0.05–0.1 mm/rev), reducing it further near the centre. The Z position depends on which corner of the blade is the reference point: with the chuck-side corner as reference, a 3 mm blade and a 50 mm part need Z-53.0. The part must be caught in a catcher or supported (see grooving and parting tools).

Exercise

Add a 1 × 45° chamfer on the front edge of the Ø30 mm step (at Z0). Which contour blocks change, and is G71 type I still valid? What effect does the 0.8 mm nose radius have without G42? The answer is in the FAQ.

Next lesson: Lesson 10: Program verification and safe start-up.

Frequently asked questions

Why is X programmed as a diameter on a lathe?

Turned parts are dimensioned by diameter on drawings and diameters are what you measure with a caliper, so it is convenient and reduces errors. Whether X is diameter or radius is set by a control parameter.

Why is G50 S needed with G96?

In G96 the spindle speed rises as the diameter falls and would theoretically go to infinity at the centre. G50 S caps the maximum rpm so the chuck and workpiece are not overloaded.

What does T0101 mean?

The first two digits are the turret station, the last two the offset number. T0100 usually cancels the offset, and the same tool can be used with another offset number, e.g. T0111.

Exercise answer

Contour start: N110 G00 X28.0, N112 G01 Z0 F0.1, N114 X30.0 Z-1.0, then N120 Z-25.0. The first block still moves in X only and the contour is monotonic, so type I is valid. Without G42 and with rε 0.8 mm material would be left on the chamfer – it would come out about 0.47 mm smaller in each direction (about 0.5 × 45°), so an accurate chamfer needs G42.

Looking for someone to do this job? Find a manufacturer on the marketplace or post a request.

Services offered I need a service