CNC Program Block

This article is not just for starter level cnc machinists, others can read it as a refresher to their cnc programming skills.

While seeing a cnc program on a cnc machine whether that is a cnc lathe cnc mill cnc grinding machine, you will see one thing in common CNC Program Blocks.

CNC Program Blocks

Every cnc program is a sequence of many cnc program blocks which are written together to form a complete tool-path for one or many tools.
This tool-path tells cnc machine how a cnc machinist want his component be machined.
Every single cnc program block adds/alters/modifies some useful information to a cnc program.

Fanuc CNC Control

Fanuc CNC Control

Structure of A CNC Program Block

A cnc program block is normally written as

N50 G01 X100 Y-50.02 F100 M08

As you can see in above cnc program block these are Six Words separated by Spaces.
Every word is a group of alphanumeric characters,
every word is lead by a character as above N, G, X, Y, F, M
and remaining part consist of some signed/unsigned numeric value as above give 50, 01, 100, –50.02, 100, 08

CNC Programming Commands

Everyone of these words has a very important value in cnc programming
You can see these words as commands or instructions, there are plenty of commands,
some are standard which are commonly found in a cnc program for any cnc machine control.
some are cnc machine and cnc control dependent, vary from cnc control to control.

But the essence is that a cnc machinists must at least know/understand some of widely used cnc program commands.
N50 G01 X100 Y-50.02 F100 M08
(this is the same cnc program code given above)

Sequence Numbers N in CNC Program Blocks

N50 – is the sequence number, in real word you see many lists which are written with serial-numbers, why serial-numbers are given, they just make sorting, searching like tasks easy.
same way every cnc program block is given a serial number to make searching, arranging cnc program blocks easy.

You (CNC machinists) are not required to use them, you can even write cnc programs without using sequence numbers (N).
But cnc program block sequence numbers (N) make life easier, as while you will start learning cnc canned-cycle programming you will see we can’t program without sequence number at all (or at least we have to number at least one or two cnc program blocks G71, G72).

G-Code Programming

Then the next word comes G01
Every cnc program word which start with leading G is called a G-code.
G-codes are widely used /understood cnc machinists can’t even dream programming without G-codes (latest cnc controls give us other ways to program but still they provide a way to program in conventional G-Code style).

Every G-code has such a vast functionality and sequence of operation associated with it that every G-code might take a full length tutorial to explain it’s working.
Many are already briefly explained here even with program example code which show their use inside cnc program.

G01 is the G-code for Linear-Interpolation meaning that, you want the cnc machine tool to go to a specific position with a controlled feed (read below Tool Feed)
as you have to tell the specific position and feed amount.


N50 G01 X100 Y-50.02 F100 M08
(this is the same cnc program code given above)

after G01 you see X100
X denotes to an Axis of CNC machine.
CNC lathe machine normally have Two-Axis X and Z

CNC Lathe Machine Axis X, Z

CNC Lathe Machine Axis X, Z

CNC milling machine have normally Three-Axis X, Y, Z

CNC Mill Axis X Y Z

CNC Mill Axis X Y Z

as X100 means that you want the tool to move 100 (mm or inch can be set by G-code) in X-axis direction.
then comes Y-50.02
this tells cnc machine to move tool to –50.02 (mm or inch) in Y-axis direction.

Tool Feed

F100 here F stands for Feed, Every motion command requires Feed be given so tool can be moved with that amount of feed to a given position.

Feed is either given as Feed per Minute or Feed per Revolution.

M-Code in CNC Programming

M08 here M stands for M-code (Miscellaneous code).
You might think M-codes as machine-codes as they mostly control the behavior of cnc machines.
There are many M-codes some are found in every cnc machine control like M08 this is the code to order cnc machine to open the coolant (Coolant ON), as to spin the spindle we use M02 or M03 to stop spindle we use M05.