CNC (Computer Numerical Control) is a technology used to control machining machines using a computer-controlled system. G-code and M-code form the basis of CNC. G-code controls the movement of the cutting tool, while M-code generally controls various functions of the machine.
Some basic G and M codes commonly used:
G Codes:
G00: Rapid positioning
G01: Linear motion (Linear interpolation)
G02: Clockwise circular interpolation
G03: Counterclockwise circular interpolation
G04: Dwell or time delay (Dwell)
G17, G18, G19: Selection of machining in XY, XZ and YZ planes (Plane selection)
G20: Working in inches (Inch mode)
G21: Operation in millimeters (Millimeter mode)
G28: Return to home position)
G90: Absolute coordinate mode (Absolute programming)
G91: Incremental coordinate mode (Incremental programming)
M Codes:
M00: Stop the program (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: Subroutine call
M99: Return from subroutine
These codes are generally used in CNC machining machines. However, each CNC machine can be manufacturer specific and therefore it is important to consult user manuals.