Industrial CNC lathe cutting metal components with automated precision.

FANUC G Code and M Code List

for CNC Lathes

G code/M code List

The following list provides common codes used by many manufacturers. Please be aware that machine configurations can vary significantly, so this list may not be an exact match for your specific equipment. In fact, M-Codes above M79 are almost universally customized by the builder. We strongly recommend consulting your machine tool builder's documentation to confirm the correct codes for your application.

Typical G Command for a lathe

There are three G code system: A, B, and C. Select a G code system using bits 7 (GSC) and 6 (GSB) of parameter No. 3401.

G code system Group Function
A B C
*G00 *G00 *G00 01 Positioning (Rapid traverse)
G01 G01 G01 Linear interpolation (Cutting feed)
G02 G02 G02 Circular interpolation CW or helical interpolation CW
G03 G03 G03 Circular interpolation CCW or helical interpolation CCW
G04 G04 G04 00 Dwell
G05 G05 G05 AI contour control (command compatible with high precision contour control)
G05.1 G05.1 G05.1 AI contour control
G05.4 G05.4 G05.4 HRV3 on/off
G07.1
(G107)
G07.1
(G107)
G07.1
(G107)
Cylindrical interpolation
G08 G08 G08 Advanced preview control
G09 G09 G09 Exact stop
G10 G10 G10 Programmable data input
G10.6 G10.6 G10.6 Tool retract and recover
G10.8 G10.8 G10.8 Programmable internal data change
G11 G11 G11 Programmable data input mode cancel
G12.1
(G112)
G12.1
(G112)
G12.1
(G112)
21 Polar coordinate interpolation mode
*G13.1
(G113)
*G13.1
(G113)
*G13.1
(G113)
Polar coordinate interpolation cancel mode
G17 G17 G17 16 XpYp planeselection
*G18 *G18 *G18 ZpXp planeselection
G19 G19 G19 YpZp planeselection
G20 G20 G70 06 Input in inch
G21 G21 G71 Input in mm
*G22 *G22 *G22 09 Stored stroke check function on
G23 G23 G23 Stored stroke check function off
*G25 *G25 *G25 08 Spindle speed fluctuation detection off
G26 G26 G26 Spindle speed fluctuation detection on
G27 G27 G27 00 Reference position return check
G28 G28 G28 Return to reference position
G28.2 G28.2 G28.2 In-position check disable reference position return
G29 G29 G29 Movement from reference position
G30 G30 G30 2nd, 3rd and 4th reference position return
G30.2 G30.2 G30.2 In-position check disable 2nd, 3rd, or 4th reference position return
G31 G31 G31 Skip function
G32 G33 G33 01 Threading
G34 G34 G34 Variable lead threading
G35 G35 G35 Circular threading CW
G36 G36 G36 Circular threading CCW (When bit 3 (G36) of parameter No. 3405 is set to 1) or Automatic tool offset (X axis) (When bit 3 (G36) of parameter No. 3405 is set to 0)
G37 G37 G37 Automatic tool offset (Zaxis) (When bit 3 (G36) of parameter No. 3405 is set to 0)
G37.1 G37.1 G37.1 Automatic tool offset (X axis) (When bit 3 (G36) of parameter No. 3405 is set to 1)
G37.2 G37.2 G37.2 Automatic tool offset (Zaxis) (When bit 3 (G36) of parameter No. 3405 is set to 1)
G38 G38 G38 Tool radius/tool nose radius compensation: with vector held
G39 G39 G39 Tool radius/tool nose radius compensation: corner rounding interpolation
*G40 *G40 *G40 07 Tool radius/tool nose radius compensation : cancel
G41 G41 G41 Tool radius/tool nose radius compensation : left
G42 G42 G42 Tool radius/tool nose radius compensation : right
*G40.1 *G40.1 *G40.1 19 Normal direction control cancel mode
G41.1 G41.1 G41.1 Normal direction control left on
G42 .1 G42 .1 G42 .1 Normal direction control right on
G43 G43 G43 23 Tool length compensation +(Bit 3 (TCT) of parameter No. 5040 must be "1".)
G44 G44 G44 Tool length compensation -(Bit 3 (TCT) of parameter No. 5040 must be "1".)
G43.7
(G44.7)
G43.7
(G44.7)
G43.7
(G44.7)
Tool offset(Bit 3 (TCT) of parameter No. 5040 must be "1".)
G49
(G49.1)
G49
(G49.1)
G49
(G49.1)
Tool length compensation cancel
(Bit 3 (TCT) of parameter No. 5040 must be "1".)
G50 G92 G92 00 Coordinate system setting or max spindle speed clamp
G50.3 G92.1 G92.1 Workpiece coordinate system preset
G50.1 G50.1 G50.1 22 Programmable mirror image cancel
G51.1 G51.1 G51.1 Programmable mirror image
*G50.2
(G250)
*G50.2
(G250)
*G50.2
(G250)
20 Polygon turning cancel
G51.2
(G251)
G51.2
(G251)
G51.2
(G251)
Polygon turning
G50.4 G50.4 G50.4 00 Cancel synchronous control
G50.5 G50.5 G50.5 Cancel composite control
G50.6 G50.6 G50.6 Cancel superimposed control
G51.4 G51.4 G51.4 Start synchronous control
G51.5 G51.5 G51.5 Start composite control
G51.6 G51.6 G51.6 Start superimposed control
G52 G52 G52 Local coordinate system setting
G53 G53 G53 Machine coordinate system setting
G53.1 G53.1 G53.1 Tool axis direction control
G53.2 G53.2 G53.2 Selecting a machine coordinate system with feedrate
G53.6 G53.6 G53.6 Tool center point retention type tool axis direction control
*G54
(G54.1)
*G54
(G54.1)
*G54
(G54.1)
14 Workpiece coordinate system 1 selection
G55 G55 G55 Workpiece coordinate system 2 selection
G56 G56 G56 Workpiece coordinate system 3 selection
G57 G57 G57 Workpiece coordinate system 4 selection
G58 G58 G58 Workpiece coordinate system 5 selection
G59 G59 G59 Workpiece coordinate system 6 selection
G61 G61 G61 15 Exact stop mode
G63 G63 G63 Tapping mode
G64 G64 G64 Cutting mode
G65 G65 G65 00 Macro call
G66 G66 G66 12 Macro modal call A
G66.1 G66.1 G66.1 Macro modal call B
*G67 *G67 *G67 Macro modal call A/B cancel
G68 G68 G68 04 Mirror image on for double turret or balance cutting mode
G68.1 G68.1 G68.1 17 Coordinate system rotation start or 3-dimensional coordinate system conversion mode on
G68.2 G68.2 G68.2 Tilted working plane command
G68.3 G68.3 G68.3 Tilted working plane command by tool axis direction
G68.4 G68.4 G68.4 Tilted working plane command (incremental multi-command)
*G69 *G69 *G69 04 Mirror image off for double turret or balance cutting mode cancel
G69.1 G69.1 G69.1 17 Coordinate system rotation cancel or 3-dimensional coordinate system conversion mode off
G70 G70 G72 00 Finishing cycle
G71 G71 G73 Stock removal in turning
G72 G72 G74 Stock removal in facing
G73 G73 G75 Pattern repeating cycle
G74 G74 G76 End face peck drilling cycle
G75 G75 G77 Outer diameter/internal diameter drilling cycle
G76 G76 G78 Multiple-thread cutting cycle
G71 G71 G72 01 Traverse grinding cycle
G72 G72 G73 Traverse direct sizing/grinding cycle
G73 G73 G74 Oscillation grinding cycle
G74 G74 G75 Oscillation direct sizing/grinding cycle
*G80 *G80 *G80 10 Canned cycle cancel for drilling
Electronic gear box : synchronization cancellation
*G80.4 *G80.4 *G80.4 28 Electronic gear box: synchronization cancellation
G81.4 G81.4 G81.4 Electronic gear box: synchronization start
*G80.5 *G80.5 *G80.5 27 Electronic gear box 2 pair: synchronization cancellation
G81.5 G81.5 G81.5 Electronic gear box 2 pair: synchronization start
G81 G81 G81 10 Spot drilling (FS15-T format)
Electronic gear box : synchronization start
G82 G82 G82 Counter boring (FS15-T format)
G83 G83 G83 Cycle for face drilling
G83.1 G83.1 G83.1 High-speed peck drilling cycle (FS15-T format)
G83.5 G83.5 G83.5 High-speed peck drilling cycle
G83.6 G83.6 G83.6 Peck drilling cycle
G84 G84 G84 Cycle for face tapping
G84.2 G84.2 G84.2 Rigid tapping cycle (FS15-T format)
G85 G85 G85 Cycle for face boring
G87 G87 G87 Cycle for side drilling
G87.5 G87.5 G87.5 High-speed peck drilling cycle
G87.6 G87.6 G87.6 Peck drilling cycle
G88 G88 G88 Cycle for side tapping
G89 G89 G89 Cycle for side boring
G90 G77 G20 01 Outer diameter/internal diameter cutting cycle
G92 G78 G21 Threading cycle
G94 G79 G24 End face turning cycle
G91.1 G91.1 G91.1 00 Maximum specified incremental amount check
G96 G96 G96 02 Constant surface speed control
*G97 *G97 *G97 Constant surface speed control cancel
G96.1 G96.1 G96.1 00 Spindle indexing execution (waiting for completion)
G96.2 G96.2 G96.2 Spindle indexing execution (not waiting for completion)
G96.3 G96.3 G96.3 Spindle indexing completion check
G96.4 G96.4 G96.4 SV speed control mode ON
G98 G94 G94 Feed per minute
*G99 *G95 *G95 Feed per revolution
- *G90 *G90 03 Absolute programming
- G91 G91 Incremental programming
- G98 G98 11 Canned cycle : return to initial level
- G99 G99 Canned cycle : return to R point level

Note:

  • When the power is turned on or the cleared state is set by a reset (bit 6 (CLR) of parameter No. 3402 is set to 1), modal G codes are placed in the following states:
    (1)G codes marked with "*"in G code lists are enabled.
    (2)When the system is cleared due to power-on or reset, whichever specified, either G20 or G21, remains effective.
    (3) Bit 7(G23) of parameter No. 3402 is used to specify whether G22 or G23 is to be selected upon power-on. The selection of G22 or G23 is not, however.changed when the CNC is cleared upon a reset. When the system is cleared due to reset, whichever specified, either G22 or G23, remains effective.
  • G codes of group 00 except G10 and G11 are single-shot G codes.
  • Alarm PS0010 is displayed when a G code not listed in the G code list is specified or a G code without a corresponding option is specified.
  • G codes of different groups can be specified in the same block.If G codes of the same group are specified in the same block, the G code specified last is valid.
  • If a G code of group 01 is specified in a canned cycle for drilling, the canned cycle is canceled in the same way as when a G80 command is specified. G codes of group 01 are not affected by G codes for specifying a canned cycle
  • When G code system A is used for a canned cycle for drilling, only the initial level is provided at the return point.
  • G codes are displayed for each group number.

Reference: 《FANUC Series 0i-MODEL F Plus CONNECTION MANUAL_FUNCTION, B-64693EN/01》

Typical M Command for a lathe

M-Code Function Description & Usage
Program Control
M00 Program Stop Unconditional pause. The program stops until the operator presses Cycle Start. Used for manual inspection, etc.
M01 Optional Stop Conditional pause. The program stops only if the "Optional Stop" button on the control panel is turned on.
M02 End of Program Older method to end the program. Not commonly used anymore. Unlike M30, it leaves the program cursor at the end and does not reset to the start.
M30 End of Program & Reset The standard code for ending a main program. It resets the program cursor to the beginning and typically returns the machine to its home position.
M98 Subprogram Call Used to call a subprogram (e.g., M98 P1001 calls subprogram O1001). The "P" address specifies the subprogram number.
M99 Subprogram End / Return Placed at the end of a subprogram. Returns control to the main program after the M98 call. Can include a "P" address to specify a return line number in the main program.
Spindle Control
M03 Spindle Start (Clockwise) Starts the main spindle rotating clockwise (as viewed from the spindle nose towards the tailstock). Requires an S-code to specify speed (e.g., M03 S1000).
M04 Spindle Start (Counterclockwise) Starts the main spindle rotating counterclockwise. Used for reverse cutting operations. Also requires an S-code for speed.
M05 Spindle Stop Stops the spindle rotation. Always used before changing tools or at the end of a program.
M41 Spindle Low Gear Range Selects a low speed range for the spindle (if the machine has gear ranges). Often part of a series (M41-M44) for multiple speed ranges. For machines with mechanically two-speed variable spindles, these codes may be ignored by the electronic speed change system.
M42 Spindle High Gear Range Selects a high speed range for the spindle. Higher ranges (M43, M44) may exist on machines with more gear settings. For machines with mechanically two-speed variable spindles, these codes may be ignored by the electronic speed change system.
M08 Coolant On Turns on the flood coolant. May also activate mist coolant on some machines when combined with M07.
M09 Coolant Off Turns off the flood coolant and all other coolant functions.
Tooling & Automation
M06 Tool Change Not typically used on standard lathes. Standard lathes use the T-code (e.g., T0101) for tool changes. M06 is common on machining centers and lathes with auxiliary tool changers (e.g., for live tooling), usually paired with a T-code to specify the tool (e.g., T03 M06).
Chuck & Tailstock Control
M10/ M11 Chuck Clamp / Unclamp Not universally standardized. Often used to close (M10) and open (M11) the chuck. CRITICAL: Check your machine manual, as the function can be reversed! Some machines use alternative codes like M21/M22.
M12/ M13 Hydraulic Chuck Clamp/Hydraulic Chuck Unclamp On different machine tools, M12/M13 may also be defined for tailstock or cylinder actions. However, most lathes with FANUC systems default to chuck control for these codes.
M21/ M22 Tailstock Body Advance / Retract Moves the entire tailstock body forward or backward (if equipped). Less common than quill control functions. Some machine tools use M23/M24 to control tailstock movement, which depends on the specific machine parameter settings.
Special Functions
M19 Spindle Orientation Stops the spindle at a precise angular position. Required for certain operations like synchronized (C-axis) milling on a lathe, precision boring retraction, and tool changing in some systems. May include an S-code to specify the orientation angle (e.g., M19 S90).


Typical MDI Commands for a Lathe

Basic Operations

T0101; Selects tool 1 with offset 1
S1000 M03; Spindle clockwise at 1000 RPM
G00 X50.0 Z5.0; Rapid move to X50 Z5
G01 X45.0 Z-20.0 F0.2; Linear feed to X45 Z-20 at 0.2mm/rev

Movement Commands

G00 X.. Z.. ;
G00 Rapid positioning
X.. X-axis position (diameter value)
Z.. Z-axis position

G01 X.. Z.. F.. ; 
G01 Linear interpolation
X.. X-axis position
Z.. Z-axis position
F.. Feed rate (mm/rev or in/rev)

G02 X.. Z.. R.. F.. ;
G02 Clockwise circular interpolation
X.. End point X position
Z.. End point Z position
R.. Radius of arc
F.. Feed rate

G03 X.. Z.. R.. F.. ;
G03 Counter-clockwise circular interpolation
X.. End point X position
Z.. End point Z position
R.. Radius of arc
F.. Feed rate

Cycle Commands

G90 X.. Z.. F.. ;
G90 Simple turning cycle
X.. Final diameter
Z.. Final Z position
F.. Feed rate

G92 X.. Z.. F.. ;
G92 Threading cycle
X.. Final diameter
Z.. Final Z position
F.. Thread pitch

G94 X.. Z.. F.. ;
G94 Face turning cycle
X.. Final diameter
Z.. Final Z position
F.. Feed rate

Tool Compensation

G40; Cancel tool nose radius compensation
G41; Tool nose radius compensation left
G42; Tool nose radius compensation right

Reference Points

G28 U0 W0;
G28 Return to reference point
U0 X-axis return (incremental)
W0 Z-axis return (incremental)

G50 X.. Z.. ;
G50 Work coordinate system setting
X.. X-axis zero position
Z.. Z-axis zero position

Special Functions

G96 S.. M03;
G96 Constant surface speed mode
S.. Surface speed (m/min or ft/min)
M03 Spindle clockwise

G97 S.. M03;
G97 Constant RPM mode
S.. RPM
M03 Spindle clockwise

G99 F.. ;
G99 Feed per revolution mode
F.. Feed rate (mm/rev or in/rev)

G98 F.. ;
G98 Feed per minute mode
F.. Feed rate (mm/min or in/min)

Drilling Cycles

G74 Z.. R.. Q.. F.. ;
G74 Face grooving/peck drilling cycle
Z.. Final Z position
R.. Retract amount
Q.. Peck depth
F.. Feed rate

G75 X.. R.. Q.. F.. ;
G75 Grooving cycle
X.. Final diameter
R.. Retract amount
Q.. Peck depth
F.. Feed rate

Example Command Sequences

  • Simple Turning Operation:

G99 G96 S200 M03; (Feed/rev, CSS 200m/min, spindle on)T0101; (Select tool 1)G00 X55.0 Z2.0; (Rapid approach)G01 X50.0 Z-30.0 F0.15; (Turning cut)G00 X55.0 Z2.0; (Retract)M05; (Spindle stop)M30; (Program end)

  • Thread Cutting Operation:

G97 S500 M03; (Constant RPM 500)T0202; (Select threading tool)G00 X30.0 Z5.0; (Approach position)G92 X29.0 Z-20.0 F1.5; (Threading cycle)X28.5; (Second pass)X28.2; (Third pass)X28.05; (Final pass)G00 X50.0 Z50.0; (Retract)M30;

Note: For Fanuc lathes, remember that:

  1. X values are typically diameter values (not radius)
  2. Feed rates are usually in mm/rev or in/rev (G99 mode)
  3. Tool changes use T-codes (not M06)
  4. G28 uses incremental U/W values (not absolute X/Z) for reference returns

Other Articles

Related Articles

Here are some related technical resources you may also find helpful:

Technical Categories

Browse our full set of technical resources: 

Back to Previous Page

Click here to return to the previous category page.

→ Back to Common alarm List

Back to Technical Support Home

Return to the Technical Support main page to explore all resources.

→ Technical Support Main Page

Get in touch with REACO CNC

Request Repair Consultation

Have a technical issue or need repair assistance?

Looking for a part quote?

Hours of Operation Mon - Fri: 8 AM to 8 PM(Beijing Time, UTC+8)

Email: sales@reacocnc.com