Copyright 1997 by Mark Bennett. These pages may be copied or printed for personal use so long as they remain complete and include this copyright message.

These pages are available to download as a 82k zip file which may be freely installed on any machine.

This is a rough starter guide to CNC programming not a machine manual, no responsibility can be taken by the site operators for any loss or damage resulting from the application of the principles described here. Read your manuals for precise details of your machines.


Program structure

Address letters



How to put it all together

Reference Pages


I'm a CNC Programmer with almost 10 years experience mainly on 4 and 5 axis Routers machining thermoformed plastic components.

Although there are standards for CNC controls most machine manufacturers have their own ways of doing things. In my experience these are the most common features across a range of machines. This is a rough starter guide to programming, not a machine tool manual.

Read your manuals to gain knowledge about your specific machines.

Program Structure

A "CNC Program" is made up of one or more "BLOCKS". Each block contains one or more "WORDS". A word is generally an "ADDRESS REGISTER" followed by a "VALUE".

An example of a Block is N540 G2 X30 Y-20 R-12 M8

It contains the words N540, G2, X30, Y-20, R-12 and M8.

The Addresses N, G, X, Y, R and M are used with the values 540, 2, 30, -20, -12 and 8

The machine control executes each block in turn. Additionally the words in a block are executed in a specific order. For example an M code instruction is executed before any axis movement in the block, so in the above block the coolant will come on at the start of the axis travel.

Some controls only allow each address letter once in a block, others allow a number of codes in the same block.

Some controls also demand leading zeros on values and codes, for example G02 not G2.

A block starts with a block number, it is normal practice to start at one hundred and go up in tens. This allows extra blocks to be added easily.

Generally it is only necessary to program changes, once a mode has been programmed it will remain active until another code from the same group is programmed.

Address register letters


G codes are preparatory functions, they control the way the machine generates axis movement.

Most G codes come in groups, for example G17, G18 and G19 are a group. Only one code in a group may be active at any one time, programming another code in that group switches to another mode.


Plane selection

Cutter radius compensation

Zero shift

Fixed cycles

Positioning mode

Datum shift


Program control codes




How to put it all together