G & M Codes

G&M Codes make up the most of the contents of the CNC program. The definition of each class of code and specific meanings of the most important codes are covered next.

G-Codes

Codes that begin with G are called preparatory words because they prepare the machine for a certain type of motion. The most common G-codes are shown in Table 5.3 and a complete list and their meaning is included in Appx D - G-M Codes Reference.

Note: Older controls required G-codes to be written with a leading zero, like G01. Most machines now allow the leading zero to be omitted, as shown in the table below.

Code

Meaning

G0Rapid motion. Used to position the machine for non-milling moves.
G1Line motion at a specified feed rate.
G2Clockwise arc.
G3Counterclockwise arc.
G4Dwell.
G28Return to machine home position.
G40Cutter Diameter Compensation (CDC) off.
G41Cutter Diameter Compensation (CDC) left.
G42Cutter Diameter Compensation (CDC) right.
G43Tool length offset (TLO).
G54Fixture Offset #1.
G55Fixture Offset #2.
G56Fixture Offset #3.
G57Fixture Offset #4.
G58Fixture Offset #5.
G59Fixture Offset #6.
G80Cancel drill cycle.
G81Simple drill cycle.
G82Simple drill cycle with dwell.
G83Peck drill cycle.
G84Tap cycle.
G90Absolute coordinate programming mode.
G91Incremental coordinate programming mode.
G98Drill cycle return to Initial point (R).
G99Drill cycle return to Reference plane (last Z Height)

Table 5.3: Common G-Codes

M-Codes

Codes that begin with M are called miscellaneous words. They control machine auxiliary options like coolant and spindle direction. Only one M-code can appear in each block of code.

The table below lists the most common M codes and their meaning. A complete list of M-codes is included in Appx D - G-M Codes Reference.

Code

Meaning

M0Program stop. Press Cycle Start button to continue.
M1Optional stop. Only executed if Op Stop switch on the CNC control is turned ON.
M2End of program.
M3Spindle on Clockwise.
M4Spindle on Counterclockwise.
M5Spindle stop.
M6Change tool.
M8Coolant on.
M9Coolant off.
M30End program and press Cycle Start to run it again.

Table 5.4: Common M-Codes