January 17, 2022

Programming a CNC lathe

A CNC lathe is the most advanced lathe that produces accurate results and is fast to use. It can slowly shear away material resulting in a beautiful intricate part. A CNC lathe has three capabilities: facing, boring, and turning. Facing involves the creation of a smooth surface by removing metal from a cylindrical workspace. Boring enlarges existing holes. Turning involves the creation of grooves, ridges, and indents from the workpiece.

A CNC lathe machine generally consists of tools such as the chuck that holds the workpiece, the spindle, and its motor for rotation and servo motor. It helps move the cutting tool to the machining points. The lathe machine has a coordinate system that designates the positions needed for machining the workpiece. The vertical direction of the CNC lathe machine is called the X-axis, while the horizontal direction is the Z-axis.

G-code and M-code are the programming languages used in programming a CNC lathe machine. G-code and M-code came from APT programming language. They inherited its basics and made fewer modifications to produce shorter programs. It is convenient for the machine control unit.

G-codes define the geometry. They contain functions for choosing the coordinate system, programming units, working plane, tool movement, and programming code. M-codes define functions for machine operations. M refers to the Machine in CNC programming. M-code performs functions such as powering the spindle, cooling on or off, and automatically changing tools.

Programmers can use the three different methods of programming in CNC. You can either manually program a semi-automatic machine program or automatic programming with a Computer-Aided Design System. The G code programming language is the most popular and straightforward CNC. Most machine CNC Lathe Machines are G code and M code programming.

Basic CNC programming to cut the taper on a CNC lathe machine

N05 G94 M06 T0101

N10 G00 X0 Z0 M04 S600 N15 G01 X50 F30

N20 G01 Z-40

N25 G01 X80

N30 G01 Z-60

N35 G01 X100

N40 G01 Z-100

N45 G00 X120

N50 G00 Z10

N55 M05

N60 M30

Writing a CNC program

There are steps necessary for you to write a proper CNC program. Errors are rare, and programmers should understand what they think will happen and what the machine does should consent. If programmed incorrectly, CNC machines can malfunction. You must follow all the steps correctly to reduce the chances of making errors.

Moreover, you must read and understand all the information in the manual of the machine you are going to program.

Step 1 You Eliminate Assumptions

Step 2 Create the coordinate system offsets

G54-G59 Are work coordinate system offsets

T and H Tool Numbers and Length Offsets

G90-G91 Incremental vs. Absolute coordinates

G20 or G21. 25

Step 3 Program Tool paths

M03, M04, and M05- Spindle switch

G00 Rapid Move

G01 Linear Cutting Move

G02 and G03 Arc Cutting Move

How to program a chamfer on a CNC lathe

Here is an example of programming a chamfer on a CNC lathe, including a corner rounding.

O1234 (Corner Rounding and Chamfering Example);

T1 M6;

G00 G90 G54 X0. Y0. S3000 M3; (P1)

G43 H01 Z0.1 M08;

G01 Z-0.5 F20.;

Y40. , R10.;            (P2)   

X50. , C5.;             (P3)

Y0.;                   (P4)

G00 Z0.1 M09;

G53 G49 Z0.;

G53 Y0.;


To fully understand the meaning of the codes, below are the codes and the description of what they mean in G code CNC programming. You can read these codes to have an understanding of the CNC programs.

Code    Description

G00       Rapid Motion

G01       Linear Interpolation Motion

G43       Tool Length Compensation +

G49       G43/G44 Cancel

G53       Non-Modal Machine Coordinate Selection

G54       Select Work Coordinate System l

G90       Incremental Programming

M3        Spindle On, Clockwise (S)

M6        Tool Change (T)

M08      Coolant On

M09      Coolant Off

M30      Program End and Reset

S             Spindle speed

T             Tool

How to program a 45-degree chamfer

The following code illustrates how to program a chamfer and Radius with G-01 G code. Put a C for Chamfer and R for Radius in a CNC program with G code. Chamfer is 45 degrees. You can identify the Chamfer by the letter C followed by a value.

E.g., N12 …..

N13 G1 X… Z… C…

N14 …..

And same as the Radius, you can identify it by the letter R followed by a value.

N12 …..

N13 G1 X… Z… R…

N14 …..

A complete example of a G01 chamfer and corner rounding CNC program

N5 ……

N6 G00 X0 Z3

N7 G01 Z0 F0.2

N8 X35 C2

N9 Z-40 R4

N10 X55 Z-52 F0.1

N11 X75 C2

N12 Z-76

N13 G00 X100 Z50

N14 ……

CNC chamfer calculation

Example of how to calculate CNC chamfer

Let’s say you have four chamfers.

1st chamfer dimension = 5×45°

2nd chamfer dimension = 6×30°

3rd chamfer dimension = 6×30°

4th chamfer dimension = 6× 55°

Given that θ¹=?  θ² = 40 θ³=?

θ⁴ = 60 and θ = 78

The formula tan θ = Opp side/ adj side

To calculate the opposite side of the first Chamfer and diameter 1

Given the adj side = 5

tan 45 = opp side/ 5

θ¹ = 40-10 = 30

To calculate the opposite side of the second Chamfer and diameter 3

tan 30 = opp side / 6

θ³ = 40+7 = 47

How to program a radius on a CNC lathe

You have to understand how to work with the machine’s control system to program a radius on a CNC lathe. Use the G code editor, which is preferable and easier to use.

Below is an example of programming a 45-degree chamfer with a .040 radius on the corners of the Chamfer.
















CNC turning radius program

Example of a CNC turning radius program

N10 G50 S1800;

G96 S200 M03;

G00 X0 Z3.0 T0303 M08;

G42 G01 Z0 F0.2;

G03 X20.0 Z-74.385 I40.0 K20.615; (G02 X100.0 Z-74.385 R45.0)

G01 Z-125.0;

G40 U2.0 W1.0;

G00 X200.0 Z200.0 M09;


David D. Hughes

Leave a Reply