Ultimate Guide to CNC Codes

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.

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).

Learn more about the D code

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).

Learn more about the F code

Sets various modes in the machine or prepares the machine to perform a function such as a canned cycle.

Learn more about G codes

Specifies the height offset to be used when turning tool length compensation on (G43) or off (G49)

Learn more about the H code

I CNC Code

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 CNC Code

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 CNC Code

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 CNC Code

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.

Learn more about M codes

Identifies the sequence or line number of the program. They are not required but they can help make a CNC program easier to follow. 

Learn more about the N code

The program number is the first CNC word in the program.

Learn more about the O code

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.

Learn more about the P code

Used with G73 and G83 peck drilling cycles. Q identifies the depth of each drilling peck before the drill backs up to break chips.

Learn more about the Q code

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.

Learn more about the R code

Sets the speed of the spindle.

Units are in revolutions per minute (RPM)

Learn more about the S code

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.

Learn more about 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.

Learn more about the X code

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.

Learn more about the Y code

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.

Learn more about the Z code

; - 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.

Slash Block Skip CNC Code

/ - 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.

Leave a Comment