CNC Programming
CNC stands for Computer Numerical Control is the way that all CNC machines across the world are programmed and operated. The CNC program controls the movement of the machine’s axises, through a computer that connects to the machine’s electrical drives and sensors; essentially where and how to move without the use of a manual operator. Different types of machines can cause a program to be more or less complex. For instance, a 5 axis CNC machine program would be more complex than a 3-axis CNC machine. Workpiece geometry and features would determine the machine necessary to manufacture the component. CNC programming is utilized in many of our machines including our mills, lathes and gear hobbing equipment.
CNC programming, or g-code, was developed in the 60s by the Electronics Industry Association as language RD-274D, but took up the name g-code because many bits of the language start with “G”. What gets transmitted to the machine is a text file containing g-code that then goes through a controller that will run the machine. A CNC machine controller will process the g-code produced by a CAM software or manually programmed; and while different machines can use different controller, all CNC machines are controlled through g-code. The different controllers create a different dialect to the g-code. The dialect will indicate different but important details of the program and machine or program defaults. Some g-code dialect will add presets features for programming such as special parameters or capabilities that are not found in other dialects. CAM, computer-aided manufacturing, programs generate their own g-code that can be used to machine a workpiece, but many of these programs need to have further troubleshooting to insure efficiency and reduce the cut time.
G-code programs can be broken into blocks due to the low memory that early CNC machines had. A single line of code can be a set of several instructions for the machine. Each set of g-code on a line is called a block. CNC machines read code from left to right and then top to bottom. It will not perform one instruction before it finishes the previous. For example, if your programs says to turn off the coolant then travel to the home position, it will not travel until it turns off the coolant. M-codes are machine that differ between controllers and specific machines. These bits of code control special function on a CNC machine like coolant or spindle instructions.
LATHE G- & M- CODE TABLE:
G0 |
RAPID MOVEMENT |
G92 |
THREAD CYCLE |
G1 |
LINEAR MOVEMENT |
G97 |
RUNNING RPM |
G2 |
RADIUS CW |
G98 |
CANNED CYCLE INITIAL POINT |
G3 |
RADIUS CCW |
G99 |
CANNED CYCLE PLANE |
G4 |
DWELL |
M0 |
PAUSE |
G17 |
XY SELECTION |
M1 |
OPTIONAL STOP |
G18 |
XZ SELECTION |
M3 |
SPINDLE CW |
G19 |
YZ SELECTION |
M4 |
SPINDLE CCW |
G32 |
THREAD CYCLE |
M5 |
SPINDLE STOP |
G50 |
RPM HIGH LIMIT |
M8 |
COOLANT ON |
G80 |
CANCEL CYCLE |
M9 |
COOLANT OFF |
G83 |
PECK DRILLING |
M30 |
END OF PROGRAM |
G84 |
TAP CYCLE |
MILL G- & M- CODE TABLE:
G0 |
RAPID MOVEMENT |
G83 |
PECK DRILLING |
G1 |
LINEAR MOVEMENT |
G84 |
TAPPING |
G2 |
RADIUS CW |
G90 |
INCREMENTAL MOVEMENT |
G3 |
RADIUS CCW |
G91 |
ABSOLUTE MOVEMENT |
G4 |
DWELL |
G94 |
INCHES PER MIN. |
G17 |
XY SELECTION |
G95 |
TOOL REVOLUTION |
G18 |
XZ SELECTION |
M1 |
OPTIONAL STOP |
G19 |
YZ SELECTION |
M3 |
SPINDLE CW |
G40 |
CANCEL CYCLE |
M4 |
SPINDLE CCW |
G41 |
CUT COMP. LEFT |
M5 |
SPINDLE TOP |
G42 |
CUT COMP. RIGHT |
M6 |
CHANGE TOOL |
G43 |
OFFSET Z AXIS |
M8 |
COOLANT ON |
G80 |
CANCEL CYCLE |
M9 |
COOLANT OFF |
G81 |
DRILLING |
M30 |
END OF PROGRAM |