Controller reference
Fanuc G-Code and M-Code List (Mill & Lathe)
97 G-codes and 27 M-codes explained for Fanuc controls.
Fanuc controls (0i, 30i, 31i, 32i and the older 16/18/21 series) define the ISO G-code dialect that most other controls copy. Lathes normally run G-code system A, where incremental moves use U and W and the canned cycles are G70–G76 and G90/G92/G94. Option packages (macros, AICC, 5-axis) decide which advanced codes are available.
Fanuc G-codes (97)
| Code | Function | Machine |
|---|---|---|
G00 | Rapid Positioning | Both |
G01 | Linear Interpolation (Feed Move) | Both |
G02 | Circular Interpolation Clockwise | Both |
G03 | Circular Interpolation Counter-Clockwise | Both |
G04 | Dwell | Both |
G05.1 | AI Contour Control / High-Speed Look-Ahead | Mill |
G07.1 | Cylindrical Interpolation | Both |
G08 | Advanced Preview Control (Look-Ahead) | Mill |
G09 | Exact Stop (one block) | Both |
G10 | Programmable Data Input (Set Offsets) | Both |
G11 | Programmable Data Input Cancel | Both |
G15 | Polar Coordinate Command Cancel | Mill |
G16 | Polar Coordinate Command | Mill |
G17 | XY Plane Selection | Mill |
G18 | XZ Plane Selection | Both |
G19 | YZ Plane Selection | Mill |
G20 | Inch Input | Both |
G21 | Metric Input | Both |
G22 | Stored Stroke Check On | Both |
G23 | Stored Stroke Check Off | Both |
G25 | Spindle Speed Fluctuation Detection Off | Lathe |
G26 | Spindle Speed Fluctuation Detection On | Lathe |
G27 | Reference Position Return Check | Both |
G28 | Return to Reference Point (Machine Home) | Both |
G30 | Return to 2nd/3rd/4th Reference Point | Both |
G31 | Skip Function (Probing Move) | Both |
G32 | Thread Cutting (Single Pass, Lathe) | Lathe |
G33 | Thread Cutting (Spindle-Synchronised Motion) | Mill |
G34 | Variable Lead Thread Cutting | Lathe |
G36 | Automatic Tool Compensation X (Lathe) | Lathe |
G37 | Automatic Tool Length Measurement | Both |
G39 | Corner Offset Circular Interpolation | Mill |
G40 | Cutter Radius Compensation Cancel | Both |
G41 | Cutter Radius Compensation Left | Both |
G41.1 | Normal Direction Control (Left / Right) | Mill |
G42 | Cutter Radius Compensation Right | Both |
G43 | Tool Length Compensation (+) | Mill |
G43.4 | Tool Centre Point Control (TCPC) | Mill |
G44 | Tool Length Compensation (−) | Mill |
G45 | Tool Position Offset (Increase) | Mill |
G49 | Tool Length Compensation Cancel | Mill |
G50 | Max Spindle Speed Clamp (Lathe) / Scaling Cancel (Mill) | Both |
G50.1 | Programmable Mirror Image Cancel | Mill |
G51 | Scaling | Mill |
G51.1 | Programmable Mirror Image | Mill |
G51.2 | Polygon Turning | Lathe |
G52 | Local Coordinate System | Both |
G53 | Machine Coordinate System (One Block) | Both |
G53.1 | Tool Axis Direction Control | Mill |
G54 | Work Coordinate System 1 | Both |
G54.1 | Additional Work Coordinate Systems | Mill |
G55 | Work Coordinate System 2 | Both |
G56 | Work Coordinate System 3 | Both |
G57 | Work Coordinate System 4 | Both |
G58 | Work Coordinate System 5 | Both |
G59 | Work Coordinate System 6 | Both |
G60 | Single Direction Positioning | Mill |
G61 | Exact Stop Mode | Both |
G62 | Automatic Corner Override | Mill |
G63 | Tapping Mode | Mill |
G64 | Cutting Mode (Continuous Path) | Both |
G65 | Macro Call (Non-Modal) | Both |
G66 | Modal Macro Call | Both |
G67 | Modal Macro Call Cancel | Both |
G68 | Coordinate System Rotation | Mill |
G68.2 | Tilted Working Plane (3+2) | Mill |
G69 | Coordinate Rotation Cancel | Mill |
G70 | Finishing Cycle (Lathe) | Lathe |
G71 | Stock Removal in Turning (Roughing Cycle) | Lathe |
G72 | Stock Removal in Facing | Lathe |
G73 | Pattern Repeating (Lathe) / High-Speed Peck Drilling (Mill) | Both |
G74 | Left-Hand Tapping (Mill) / Face Peck Drilling (Lathe) | Both |
G75 | Grooving Cycle (Lathe X) | Lathe |
G76 | Threading Cycle (Lathe) / Fine Boring (Mill) | Both |
G80 | Cancel Canned Cycle | Both |
G81 | Drilling Cycle (Spot Drill) | Mill |
G82 | Drilling Cycle with Dwell (Counterbore / Spot) | Mill |
G83 | Peck Drilling Cycle (Deep Hole) | Mill |
G84 | Tapping Cycle (Right-Hand) | Mill |
G85 | Boring Cycle (Feed In, Feed Out) | Mill |
G86 | Boring Cycle (Spindle Stop, Rapid Out) | Mill |
G87 | Back Boring Cycle | Mill |
G88 | Boring Cycle (Dwell, Manual Retract) | Mill |
G89 | Boring Cycle (Dwell, Feed Out) | Mill |
G90 | Absolute Programming (Mill) / OD Turning Cycle (Lathe) | Both |
G91 | Incremental Programming | Mill |
G92 | Coordinate System Setting (Mill) / Threading Cycle (Lathe) | Both |
G92.1 | Cancel G92 Offset / Coordinate Preset | Both |
G93 | Inverse Time Feed | Mill |
G94 | Feed per Minute (Mill) / Facing Cycle (Lathe) | Both |
G95 | Feed per Revolution (Mill) | Mill |
G96 | Constant Surface Speed (CSS) | Lathe |
G97 | Constant RPM (CSS Cancel) | Lathe |
G98 | Initial Plane Return (Mill) / Feed per Minute (Lathe) | Both |
G99 | R-Plane Return (Mill) / Feed per Revolution (Lathe) | Both |
G107 | Cylindrical Mapping / Interpolation | Both |
G112 | Polar Coordinate Interpolation On (Lathe) | Lathe |
Fanuc M-codes (27)
| Code | Function | Machine |
|---|---|---|
M00 | Program Stop | Both |
M01 | Optional Stop | Both |
M02 | End of Program | Both |
M03 | Spindle On Clockwise | Both |
M04 | Spindle On Counter-Clockwise | Both |
M05 | Spindle Stop | Both |
M06 | Tool Change | Mill |
M07 | Mist Coolant On | Both |
M08 | Flood Coolant On | Both |
M09 | Coolant Off | Both |
M10 | Clamp / Brake On (builder specific) | Both |
M11 | Clamp / Brake Off (builder specific) | Both |
M13 | Spindle CW + Coolant On (builder specific) | Both |
M14 | Spindle CCW + Coolant On (builder specific) | Both |
M19 | Spindle Orientation | Both |
M23 | Thread Chamfer (Pull-Out) On — Lathe | Lathe |
M24 | Thread Chamfer (Pull-Out) Off — Lathe | Lathe |
M29 | Rigid Tapping Mode (Fanuc) | Both |
M30 | Program End and Rewind | Both |
M41 | Low Gear | Both |
M42 | High Gear | Both |
M48 | Feed/Speed Override Enable | Both |
M49 | Feed/Speed Override Disable | Both |
M60 | Pallet Change / Automatic Work Change | Mill |
M98 | Subprogram Call | Both |
M99 | Subprogram Return / Loop | Both |
M198 | Subprogram Call from External Memory | Both |
Options, machine builders and software versions change which codes are available. Always confirm in the programming manual for your exact machine.