Introduction to G Codes and M Codes
Fanuc M-Code G-Code, G codes (preparatory commands) and M codes (auxiliary commands) are essential instructions used to control machine tools.
- G codes govern motion, positioning, and machining operations (e.g., linear interpolation, circular movements, tool compensation).
- M codes manage auxiliary functions (e.g., spindle control, coolant activation, tool changes).
These Fanuc M-Code G-Code vary slightly depending on the machine type (lathe, mill, etc.) and Fanuc control version. Always consult your machine’s manual for specifics.
Common Fanuc G Codes
Machining Centers
| Code | Description |
|---|---|
| G00 | Rapid positioning (fast traverse) |
| G01 | Linear interpolation (straight-line motion) |
| G02 | Circular interpolation (clockwise) |
| G03 | Circular interpolation (counterclockwise) |
| G04 | Dwell (pause) |
| G05 | non standard g-code |
| G17 | XY plane selection |
| G18 | XZ plane selection |
| G19 | YZ plane selection |
| G20 | Programming in inches |
| G21 | Programming in millimeters |
| G22 | |
| G28 | Return to reference position (home) |
| G29 | Return from reference point |
| G30 | Return to secondary reference position |
| G40 | Cancel tool radius compensation |
| G41 | Tool radius compensation left |
| G42 | Tool radius compensation right |
| G43 | Tool length compensation (positive) |
| G44 | Tool length compensation (negative) |
| G49 | Cancel tool length compensation |
| G54–G59 | Work coordinate system (WCS) selection |
| G61 | Exact stop check (precision mode) |
| G90 | Absolute programming |
| G91 | Incremental programming |
| G92 | Set position by programming |
| G94 | Per-minute feedrate mode |
| G95 | Per-revolution feedrate mode |
| G100–G199 | Macro programs (varies by configuration) |
LATHES
| Code | Description |
|---|---|
| G00 | Rapid positioning (fast traverse) |
| G01 | Linear interpolation (straight-line motion) |
| G02 | Circular interpolation (clockwise) |
| G03 | Circular interpolation (counterclockwise) |
| G04 | Dwell (pause) |
| G05 | non standard g-code |
| G10 | Data setting |
| G11 | Data setting mode cancel |
| G15 | Polar coordinates command cancel |
| G16 | Polar coordinates command |
| G17 | XY plane selection |
| G18 | XZ plane selection |
| G19 | YZ plane selection |
| G20 | Programming in inches |
| G21 | Programming in millimeters |
| G22 | Stored stroke check function on |
| G23 | Stored stroke check function off |
| G27 | Reference point return check |
| G28 | Return to reference position (home) |
| G30 | Return to secondary reference position |
| G40 | Cancel tool radius compensation |
| G41 | Tool radius compensation left |
| G42 | Tool radius compensation right |
| G43 | Tool length compensation (positive) |
| G44 | Tool length compensation (negative) |
| G49 | Cancel tool length compensation |
| G54–G59 | Work coordinate system (WCS) selection |
| G61 | Exact stop check (precision mode) |
| G90 | Absolute programming |
| G91 | Incremental programming |
| G92 | Set position by programming |
| G94 | Per-minute feedrate mode |
| G95 | Per-revolution feedrate mode |
| G100–G199 | Macro programs (varies by configuration) |
Common Fanuc M Codes
| Code | Description |
|---|---|
| M00 | Program stop |
| M01 | Optional stop |
| M02 | Program end |
| M03 | Spindle on (clockwise) |
| M04 | Spindle on (counterclockwise) |
| M05 | Spindle stop |
| M06 | Tool change |
| M07 | Mist coolant on (air cooling) |
| M08 | Flood coolant on |
| M09 | Cooling (air cooling, water cooling, central outlet) OFF |
| M10 | Chuck CLAMP |
| M11 | Chuck UNCLAMP |
| M12 | QUILL OUT |
| M13 | QUILL IN / 4th axls clamp |
| M14 | 4th axls unclamp |
| M15 | 5th axls clamp |
| M16 | 5th axls unclamp |
| M17 | AUTO DOOR CLOSE |
| M18 | AUTO DOOR OPEN |
| M19 | Spindle orientation |
| M20 | Open tool magazine door |
| M21 | Close tool magazine door |
| M23 | CHAMFERING ON / Main shaft center water opening |
| M24 | CHAMFERING OFF / Main shaft center water outlet is closed |
| M25 | LNS BAR FEEDER EXTEND |
| M26 | BAR FEEDER ON |
| M27 | BAR FEEDER OFF |
| M28 | PART CATCHER EXTEND / Enable external data input |
| M29 | PART CATCHER RETRACT / Disable external data input |
| M30 | Program end and return to start |
| M31 | CHUCK BYPASS ON |
| M32 | CHUCK BYPASS OFF |
| M37 | CHIP CONVEYOR CW |
| M38 | CHIP CONVEYOR STOP |
| M43 | SETTER DOWN |
| M44 | SETTER UP |
| M47 | SOFT LIMIT 2 VALID |
| M48 | SOFT LIMIT 3 VALID |
| M49 | SOFT LIMIT 2/3 UNVALID |
| M41–M49 | Tool changer preparation |
| M51 | ERROR DETECT OFF |
| M52 | ERROR DETECT ON |
| M53 | STEADY CLAMP |
| M54 | STEADY UNCLAMP |
| M55 | TAIL STOCK CLAMP |
| M56 | TAIL STOCK UNCLAMP |
| M61–M69 | Tool selection (machine-specific) |
| M79 | Tool reset (suitable for arm type tool store) |
| M97 | PARTS COUNTED |
| M98 | Subprogram call |
| M99 | Subprogram return |
| M100–M199 | Customizable codes (user-defined) |
Notes
- Variations: Codes may differ by machine manufacturer or Fanuc control version.
- Documentation: Always refer to your machine’s manual for exact code definitions.
- Compatibility: Codes depend on the machine type (e.g., lathe vs. mill).
For exhaustive lists of Fanuc M-Code G-Code, consult Fanuc technical manuals or your machine’s programming guide.
Discover more from digit chain
Subscribe to get the latest posts sent to your email.




