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)

CodeFunctionMachine
G00Rapid PositioningBoth
G01Linear Interpolation (Feed Move)Both
G02Circular Interpolation ClockwiseBoth
G03Circular Interpolation Counter-ClockwiseBoth
G04DwellBoth
G05.1AI Contour Control / High-Speed Look-AheadMill
G07.1Cylindrical InterpolationBoth
G08Advanced Preview Control (Look-Ahead)Mill
G09Exact Stop (one block)Both
G10Programmable Data Input (Set Offsets)Both
G11Programmable Data Input CancelBoth
G15Polar Coordinate Command CancelMill
G16Polar Coordinate CommandMill
G17XY Plane SelectionMill
G18XZ Plane SelectionBoth
G19YZ Plane SelectionMill
G20Inch InputBoth
G21Metric InputBoth
G22Stored Stroke Check OnBoth
G23Stored Stroke Check OffBoth
G25Spindle Speed Fluctuation Detection OffLathe
G26Spindle Speed Fluctuation Detection OnLathe
G27Reference Position Return CheckBoth
G28Return to Reference Point (Machine Home)Both
G30Return to 2nd/3rd/4th Reference PointBoth
G31Skip Function (Probing Move)Both
G32Thread Cutting (Single Pass, Lathe)Lathe
G33Thread Cutting (Spindle-Synchronised Motion)Mill
G34Variable Lead Thread CuttingLathe
G36Automatic Tool Compensation X (Lathe)Lathe
G37Automatic Tool Length MeasurementBoth
G39Corner Offset Circular InterpolationMill
G40Cutter Radius Compensation CancelBoth
G41Cutter Radius Compensation LeftBoth
G41.1Normal Direction Control (Left / Right)Mill
G42Cutter Radius Compensation RightBoth
G43Tool Length Compensation (+)Mill
G43.4Tool Centre Point Control (TCPC)Mill
G44Tool Length Compensation (−)Mill
G45Tool Position Offset (Increase)Mill
G49Tool Length Compensation CancelMill
G50Max Spindle Speed Clamp (Lathe) / Scaling Cancel (Mill)Both
G50.1Programmable Mirror Image CancelMill
G51ScalingMill
G51.1Programmable Mirror ImageMill
G51.2Polygon TurningLathe
G52Local Coordinate SystemBoth
G53Machine Coordinate System (One Block)Both
G53.1Tool Axis Direction ControlMill
G54Work Coordinate System 1Both
G54.1Additional Work Coordinate SystemsMill
G55Work Coordinate System 2Both
G56Work Coordinate System 3Both
G57Work Coordinate System 4Both
G58Work Coordinate System 5Both
G59Work Coordinate System 6Both
G60Single Direction PositioningMill
G61Exact Stop ModeBoth
G62Automatic Corner OverrideMill
G63Tapping ModeMill
G64Cutting Mode (Continuous Path)Both
G65Macro Call (Non-Modal)Both
G66Modal Macro CallBoth
G67Modal Macro Call CancelBoth
G68Coordinate System RotationMill
G68.2Tilted Working Plane (3+2)Mill
G69Coordinate Rotation CancelMill
G70Finishing Cycle (Lathe)Lathe
G71Stock Removal in Turning (Roughing Cycle)Lathe
G72Stock Removal in FacingLathe
G73Pattern Repeating (Lathe) / High-Speed Peck Drilling (Mill)Both
G74Left-Hand Tapping (Mill) / Face Peck Drilling (Lathe)Both
G75Grooving Cycle (Lathe X)Lathe
G76Threading Cycle (Lathe) / Fine Boring (Mill)Both
G80Cancel Canned CycleBoth
G81Drilling Cycle (Spot Drill)Mill
G82Drilling Cycle with Dwell (Counterbore / Spot)Mill
G83Peck Drilling Cycle (Deep Hole)Mill
G84Tapping Cycle (Right-Hand)Mill
G85Boring Cycle (Feed In, Feed Out)Mill
G86Boring Cycle (Spindle Stop, Rapid Out)Mill
G87Back Boring CycleMill
G88Boring Cycle (Dwell, Manual Retract)Mill
G89Boring Cycle (Dwell, Feed Out)Mill
G90Absolute Programming (Mill) / OD Turning Cycle (Lathe)Both
G91Incremental ProgrammingMill
G92Coordinate System Setting (Mill) / Threading Cycle (Lathe)Both
G92.1Cancel G92 Offset / Coordinate PresetBoth
G93Inverse Time FeedMill
G94Feed per Minute (Mill) / Facing Cycle (Lathe)Both
G95Feed per Revolution (Mill)Mill
G96Constant Surface Speed (CSS)Lathe
G97Constant RPM (CSS Cancel)Lathe
G98Initial Plane Return (Mill) / Feed per Minute (Lathe)Both
G99R-Plane Return (Mill) / Feed per Revolution (Lathe)Both
G107Cylindrical Mapping / InterpolationBoth
G112Polar Coordinate Interpolation On (Lathe)Lathe

Fanuc M-codes (27)

CodeFunctionMachine
M00Program StopBoth
M01Optional StopBoth
M02End of ProgramBoth
M03Spindle On ClockwiseBoth
M04Spindle On Counter-ClockwiseBoth
M05Spindle StopBoth
M06Tool ChangeMill
M07Mist Coolant OnBoth
M08Flood Coolant OnBoth
M09Coolant OffBoth
M10Clamp / Brake On (builder specific)Both
M11Clamp / Brake Off (builder specific)Both
M13Spindle CW + Coolant On (builder specific)Both
M14Spindle CCW + Coolant On (builder specific)Both
M19Spindle OrientationBoth
M23Thread Chamfer (Pull-Out) On — LatheLathe
M24Thread Chamfer (Pull-Out) Off — LatheLathe
M29Rigid Tapping Mode (Fanuc)Both
M30Program End and RewindBoth
M41Low GearBoth
M42High GearBoth
M48Feed/Speed Override EnableBoth
M49Feed/Speed Override DisableBoth
M60Pallet Change / Automatic Work ChangeMill
M98Subprogram CallBoth
M99Subprogram Return / LoopBoth
M198Subprogram Call from External MemoryBoth

Options, machine builders and software versions change which codes are available. Always confirm in the programming manual for your exact machine.

Other controls