How to Read a CNC Program

Updated: Jul 5, 2021

Learning CNC Programming

I have been machining for over 12 years to this date. Being able to read programs is a very valuable skill that can help you from mistakes before running the program. Below I explain a basic program and how to read one. The top part I explain what the program is doing and after the program you can go to the bottom to see the full program without explanations.

What is CNC Programming?

CNC programming is a skill in which a programmer or a machinist that knows programs use a certain software that tells the CNC machine to make certain movements, cuts, tool-paths, and activates certain commands that is needed to create a part.

CNC Code

Mainly known g and m codes to let the CNC machine activate movements or commands to run a part.

Reading a CNC Mill Program



This is the program number where this program can be located.

(T1 D=0.3937 CR=0. TAPER=118DEG - ZMIN=-0.2 - CENTER DRILL)

(T2 D=0.5 CR=0. TAPER=118DEG - ZMIN=-1.2 - DRILL)

These are the tool descriptions. Note that any thing within the () parenthesis will not be read by the machine

N1 G90 G94 G17 G49 G40 G80

Each line of code or movement are normally started with an N. Also what is not seen is at the end of each line are ; which on the machine are called end of blocks.

Normally the first line of code are cancelations and defining the planes. ( visit this page for gcodes)

N2 G20

N3 G28 G91 Z0.

N4 G90


N5 T1 M06

This line selects the tool which is tool 1 indicated by T1.

The M06 is to activate tool change.

N6 T2

This line is to bring the next tool up to the pot to perform a quick change when the tool is ready for a M06

N7 S5000 M03

Activate spindle with M03 and the spindle speed is 5000 rpm which is indicated by S5000.

N8 G54

G54 is a work center which on mills have from G54-G59

N9 M08

Activate coolant

N10 G00 X1.4142 Y1.4142

G00 is a rapid movement to the location listed

N11 G43 Z0.6 H01

G43 sets the tool length together with the H value. The H01 is the offset of the tool geometry which is set in the offset menu on the CNC machine. This tool will go .6 inches away from the z set height of the tool which is indicated by Z0.6

N12 G00 Z0.2

Again this is a rapid movement down to Z0.2

N13 G98 G81 X1.4142 Y1.4142 Z-0.2 R0.2 Q.1 F13.3

this is whats called a canned cycle. A canned cycle is a repeat cycle of a certain operation indicated within the code listed. G98 is where this tells the cycle to retract to the initial level after each part of the canned cycle. G81 is a peck drilling cycle. The cycle drills to Z-0.2 for each hole and retracts to R.02 after each drill. The Q indicates that the peck will go .1 at a time then pull back out.

N14 X0. Y2.

N15 X-1.4142 Y1.4142

N16 X-2. Y0.

N17 X-1.4142 Y-1.4142

N18 X0. Y-2.

N19 X1.4142 Y-1.4142

N20 X2. Y0.

Each of the above movements will be in canned cycle and automatically go to each hole after the next.

N21 G80

G80 cancels the canned cycle

N22 Z0.6

This will retract to Z.6

N23 M05

M05 stops the spindle

N24 G28 G91 Z0.

This cycle makes the tool go to its Z home position. G91 activates incremental value

N25 G90

Activates absolute value

N26 G49

This deactivates the tools G43 length offset


This program is the same to the above program that drills through the part with a different tool, offset, and depth.

N27 M09

N28 M01

N29 T2 M06

N30 T1

N31 S5000 M03

N32 G54

N33 M08

N34 G00 X1.4142 Y1.4142

N35 G43 Z0.6 H02

N36 G00 Z0.2

N37 G83 X1.4142 Y1.4142 Z-1.2 R0.2 Q0.125 F40.

N38 X0. Y2.

N39 X-1.4142 Y1.4142

N40 X-2. Y0.

N41 X-1.4142 Y-1.4142

N42 X0. Y-2.

N43 X1.4142 Y-1.4142

N44 X2. Y0.

N45 G80

N46 Z0.6

N47 M09

N48 G28 G91 Z0.

N49 G90

N50 G49

N51 G28 G91 X0. Y0.

N52 G90

N53 M30


30 views0 comments