If you’ve already learned all of the Preparatory and Miscellaneous function codes, it’s time to move on to the Letter codes for CNC programming. Most of the letters of the alphabet are used on milling machines.
Just like the G and M codes, not every machine uses the same Letter codes. Also, there are several letters that are used in more than one function, but that depends on the input units.
Below is a list of the most commonly used letter codes when programming on a milling center. However, I recommend reading through your machine’s manual to confirm that they have the same function, or if your machine uses different letters/codes.
A – Rotary or indexing axis around the X-axis (unit in degrees)
B – Rotary or indexing axis around the Y-axis (unit in degrees)
P – Subprogram number call; Work offset number (used with G10); Dwell time in milliseconds; Block number in main program when used with M99
Q – Depth of peck in fixed cycles G73 & G83; Shift amount in fixed cycle G76 & G87
R – Retract point in fixed cycles
S – Spindle speed in Rotations per minute (RPM)
T – Tool function
X – X-axis coordinate value designation
Y – Y-axis coordinate value designation
Z – Z-axis coordinate value designation
Most of these letters you will be using over and over again in your programs. A and B are used if you have a four or five axis machine, otherwise you won’t need to use them.
Some letters have multiple uses that you may have to incorporate in your program. “P”, for example, can call out the time that you want to dwell (pause) with a tool, or it can call up a subprogram number.
It’s up to you to learn these if you want to know how to create and edit programs. A lot of the letters are easy to remember, so if you already memorized all of most of the G/M codes then this is a piece of cake.
Miscellaneous Functions is another name for M-Codes. How are they different from the G-codes in my previous post? The G-code is a preparatory command for CNC programming, which presets, or prepares, the machine to use a certain cycle or mode. An M-code is an actual machine function.
A machine function is something that the actual machine does, whether it’s turning on the spindle or ending your program. Not every machine is the same because there are many different CNC machine manufacturers, as well as different controllers, so I recommend reading through your machine’s manual to see what M-codes you can use.
M00 – Compulsory program stop
M01 – Optional stop
M02 – End of program (no rewind, usually with reset)
M03 – Spindle on (rotate CW for R/H tools)
M04 – Spindle on reverse (CCW for R/H tools)
M05 – Spindle stop
M06 – Automatic tool change (ATC)
M07 – Coolant mist ON (optional)
M08 – Coolant ON
M09 – Coolant OFF
M19 – Spindle orientation
M30 – Program end (always resets & rewinds)
M48 – Feedrate override cancel OFF (deactivated)
M49 – Feedrate override cancel ON (activated)
M60 – Automatic pallet change (APC)
M78 – B axis clamp (nonstandard)
M79 – B axis unclamp (nonstandard)
M98 – Subprogram call
M99 – Subprogram end
Unlike a G-code, you can only use one M-code per line/block of code. Using an M03 and M04 is not possible because they do two opposite functions.
The more M-codes you try out, the more efficient you can become. M98 can significantly decrease programming and possibly cycle time because it calls up a sub-program that can be repeated over and over any given number of times.
There are more Miscellaneous functions than listed above, which are referred to as ‘machine specific codes’. You will have to learn the codes used by your individual machine and controller to get the most out of your CNC machine, whether it’s a milling or turning center.
To be able to program CNC code, you must know most, if not all, of the G-codes and what they do. A CNC machinist will know how and when to use each code so that that part will run the most efficient. The program address “G” is a preparatory command. It prepares or presets the control system to use a certain mode or operation. Below is the list of G-codes that are used in most modern CNC Milling machines: