Programming
Copyright 1997 by Mark Bennett.
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.
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.
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.
D
E
H
L
O
P
Q
S Spindle speed
T Tool number
X Longest axis perpendicular to the spindle
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.
G0 Linear interpolation at rapid
G1 Linear interpolation at feedrate
G2 Clockwise circular interpolation
G54 Activate zero shift number 1
G55 Activate zero shift number 2
G56 Activate zero shift number 3
G57 Activate zero shift number 4
Datum shift
G92 Set or cancel datum shift
Program control codes
M0 Program stop
M2 End of cycle
M30 End of program
Spindle
M3 Spindle start clockwise
M4 Spindle start counter clockwise
M5 Spindle stop
Tool
M6 Tool change
Coolant
M7 Mist coolant on
M8 Flood coolant on
M9 Coolant off