What is G-code
G-code is a programming language used to control CNC (Computer Numerical Control) machines. It provides a set of instructions that tells the machine how to move its tools, control its speed, and perform various operations such as cutting, drilling, milling, or 3D printing.
G Codes and Descriptions
| G-Code | Description |
|---|---|
| G0 | Rapid positioning |
| G1 | Linear interpolation |
| G2 | Clockwise circular/helical interpolation |
| G3 | Counterclockwise circular/Helical interpolation |
| G4 | Dwell |
| G10 | Coordinate system origin setting |
| G12 | Clockwise circular pocket |
| G13 | Counterclockwise circular pocket |
| G15/G16 | Polar Coordinate moves in G0 and G1 |
| G17 | XY Plane select |
| G18 | XZ plane select |
| G19 | YZ plane select |
| G20/G21 | Inch/Millimetre unit |
| G28 | Return home |
| G28.1 | Reference axes |
| G30 | Return home |
| G31 | Straight probe |
| G40 | Cancel cutter radius compensation |
| G41/G42 | Start cutter radius compensation left/right |
| G43 | Apply tool length offset (plus) |
| G49 | Cancel tool length offset |
| G50 | Reset all scale factors to 1.0 |
| G51 | Set axis data input scale factors |
| G52 | Temporary coordinate system offsets |
| G53 | Move in absolute machine coordinate system |
| G54 | Use fixture offset 1 |
| G55 | Use fixture offset 2 |
| G56 | Use fixture offset 3 |
| G57 | Use fixture offset 4 |
| G58 | Use fixture offset 5 |
| G59 | Use fixture offset 6 / use general fixture number |
| G61/G64 | Exact stop/Constant Velocity mode |
| G68/G69 | Rotate program coordinate system |
| G70/G71 | Inch/Millimetre unit |
| G73 | Canned cycle – peck drilling |
| G80 | Cancel motion mode |
| G81 | Canned cycle – drilling |
| G82 | Canned cycle – drilling with dwell |
| G83 | Canned cycle – peck drilling |
| G85/G86/G88/G89 | Canned cycle – boring |
| G90 | Absolute distance mode |
| G90.1 | Absolute IJK mode |
| G91 | Incremental distance mode |
| G91.1 | Incremental IJK mode |
| G92 | Offset coordinates and set parameters |
| G92.x | Cancel G92 etc. |
| G93 | Inverse time feed mode |
| G94 | Units Per Min. |
| G98 | Rapid Height By Z Height |
| G99 | Rapid Height By R Height |
What is M Code
In CNC (Computer Numerical Control) machining, M codes—often called miscellaneous codes—are commands that control various machine functions that aren’t directly related to the tool’s movement (which is typically handled by G codes). They are used to manage auxiliary functions of the machine, such as starting or stopping the spindle, turning the coolant on or off, pausing the program, and initiating tool changes.
M Codes and Descriptions
| M Code | Description |
|---|---|
| M00 | Mandatory Program Stop |
| M01 | Optional or Planned Program Stop |
| M02 | Program End |
| M03 | Spindle On Forward/Clockwise |
| M04 | Spindle On Reverse/Counterclockwise |
| M05 | Spindle Stop |
| M07 | Mist Coolant On |
| M08 | Flood Coolant On |
| M09 | Coolant Off |
| M10 | Pallet Clamp On |
| M11 | Pallet Clamp OFF |
| M13 | Spindle Clockwise and Coolant On |
| M19 | Spindle Orientation |
| M30 | Program End and Rewind |
| M48 | Enable Feed/Speed Overrides |
| M49 | Disable Feed/Speed Overrides |
| M52 | Unload last tool from spindle |
| M60 | Automatic pallet change |
| M98 | Subprogram Call |
| M99 | Return From Subprogram / Rewind |