Skip to Content

G and M Codes of CNC Machines

CNC G and M Code Usage

CNC (Computer Numerical Control) is a technology used to control processing machines using a computer-controlled system. The basis of CNC is G-code and M-code. G-code controls the movement of the cutting tool, while M-code generally controls the various functions of the machine.


Some basic G and M codes that are commonly used:


G-Codes:

G00: Rapid positioning

G01: Linear motion (Linear interpolation)

G02: Clockwise circular interpolation

G03: Counterclockwise circular interpolation

G04: Wait or time delay (Dwell)

G17, G18, G19: Machining selection in XY, XZ and YZ planes (Plane selection)

G20: Working in inch mode

G21: Working in millimeter mode

G28: Return to home position

G90: Absolute coordinate mode (Absolute programming)

G91: Incremental coordinate mode (Incremental programming)


M Codes:

M00: Program stop

M01: Optional stop

M03: Spindle on, clockwise rotation

M04: Spindle on, counterclockwise rotation

M05: Spindle stop

M06: Tool change

M08: Coolant on

M09: Coolant off

M30: End of program, rewind and reset

M98: Calling a subroutine

M99: Returning from a subroutine


These codes are commonly used on CNC machining machines. However, each CNC machine can be manufacturer specific and therefore it is important to consult the user manuals.

Discover How CNC Technology Can Reduce Your Manufacturing Costs!
ADVANTAGES OF CNC MACHINES