Here is our Ultimate Guide to CNC Codes. Below is a list of CNC codes with a description of what they are.
Click on the code if you want to find out more including multiple examples to help you understand how to use them in your programs.
Table of Contents
ToggleA - Rotation Around the X Axis
Rotates around the 4th axis of the machine if equipped.
B - Rotation Around the Y Axis
Rotates around the 5th axis of the machine if equipped.
C - Rotation Around the Z Axis
Rotates around the 6th axis of the machine if equipped.
Specifies the tool diameter offset to be used for cutter compensation (G41 and G42).
Sets the feed rate to be used for movement. The feed rate is used when moving using codes such as G01, G02 & G03.
The feed rate is not used when using rapid travel (G00).
Sets various modes in the machine or prepares the machine to perform a function such as a canned cycle.
Specifies the height offset to be used when turning tool length compensation on (G43) or off (G49)
I - Radius Center in X Axis
Identifies the location of the center of a radius for a circular move relative to the current X axis location.
J - Radius Center in Y Axis
Identifies the location of the center of a radius for a circular move relative to the current Y axis location.
K - Radius Center in Z Axis
Identifies the location of the center of a radius for a circular move relative to the current Z axis location.
L - Number of Subprogram Repetitions
Used with the M98 subprogram call command. L lists how many times the subprogram will be repeated.
M codes turn on and off various machine functions such as the spindle or coolant.
They are also used for program start and stop functions.
Identifies the sequence or line number of the program. They are not required but they can help make a CNC program easier to follow.
The program number is the first CNC word in the program.
When used with an M98 code, P identifies the subprogram number.
When used with G04 or canned cycles, P specifies the amount of time to dwell.
Used with G73 and G83 peck drilling cycles. Q identifies the depth of each drilling peck before the drill backs up to break chips.
When used with G02 and G03, R specifies the size of the circular curve to be machined.
When used with a canned cycle such as G73, R specifies the location of the rapid plane.
Selects a tool to prepare it for tool change. M06 will cause the CNC to swap the currently loaded tool with the one selected with the T code.
Some machines do not require the use of a M06 code and will swap tools by simply using the T code.
Specifies the location to be moved to in the X axis.
The distance will be affected by whether the machine is in absolute (G90) or incremental (G91) mode.
Specifies the location to be moved to in the Y axis.
The distance will be affected by whether the machine is in absolute (G90) or incremental (G91) mode.
Specifies the location to be moved to in the Z axis.
The distance will be affected by whether the machine is in absolute (G90) or incremental (G91) mode.
; - End of Block
Signifies the end of a block of code. A single block will usually consist of one line of code.
Useful when testing code by stepping through the blocks in single block mode.
/ - Block Skip
Used together with a switch on the CNC control.
When the switch is on the machine will read and execute lines that start with the / character. When the switch is off, these lines will be ignored.