What do G codes and M codes actually do on a FANUC?
An NC program contains two different families of command. G codes (preparatory function) tell the control how to move: rapid or feed, linear or circular interpolation, which plane to work in, which compensation to apply. M codes (auxiliary function) command the machine itself: start the spindle, turn the coolant on, change the tool, end the program.
The difference matters: FANUC defines what a G code means, while the machine tool builder defines most of what an M code means. The source manual states it plainly — which M code corresponds to which machine function is determined by the machine tool builder. That is why M19 orients the spindle on one machine and does something entirely different on another.
The detail that catches people out on lathes: three G code systems (A, B, C)
This is the single biggest source of confusion on the shop floor. On FANUC lathe controls, the same operation is written with a different number depending on the machine’s G code system. There are three: A, B and C. Which one is active is selected by the machine tool builder via parameter.
| System A | System B | System C | Function |
|---|---|---|---|
| G20 / G21 | G20 / G21 | G70 / G71 | Inch / mm input |
| G50 | G92 | G92 | Coordinate system setting or max spindle speed clamp |
| G32 | G33 | G33 | Threading |
| G70 | G70 | G72 | 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 | OD / ID grooving cycle |
| G76 | G76 | G78 | Multiple-thread cutting cycle |
| G90 | G77 | G20 | OD / ID single turning cycle |
| G92 | G78 | G21 | Threading cycle |
| G94 | G79 | G24 | End face turning cycle |
| G98 / G99 | G94 / G95 | G94 / G95 | Feed per minute / feed per revolution |
| G50.3 | G92.1 | G92.1 | Workpiece coordinate system preset |
G90 is a single turning cycle. On a milling machine, G90 is absolute programming. Same number, completely different job. Before copying a program from another machine, find out which G code system yours is running.Most lathes in service run System A. All three systems are shown side by side in the lathe table below.
FANUC Machining Center (Milling) G Code List
Series 0i-MODEL F machining center system. Codes in brackets are alternative notations.
| G code | Function |
|---|---|
| Motion and interpolation | |
| G00 | Positioning (rapid traverse) |
| G01 | Linear interpolation (cutting feed) |
| G02 | Circular interpolation CW or helical interpolation CW |
| G03 | Circular interpolation CCW or helical interpolation CCW |
| G04 | Dwell |
| G04.1 | G code preventing buffering |
| G05.1 | AI advanced preview control / AI contour control / nano smoothing |
| G05.4 | HRV3 on/off |
| G07.1 (G107) | Cylindrical interpolation |
| G08 | AI advanced preview control |
| G09 | Exact stop |
| G31 | Skip function |
| G31.8 | EGB axis skip |
| G33 | Threading |
| Data input, plane and units | |
| G10 | Programmable data input |
| G10.6 | Tool retract and recover |
| G11 | Programmable data input mode cancel |
| G15 / G16 | Polar coordinates command cancel / on |
| G17 | XpYp plane selection |
| G18 | ZpXp plane selection |
| G19 | YpZp plane selection |
| G20 (G70) | Input in inch |
| G21 (G71) | Input in mm |
| G22 / G23 | Stored stroke check on / off |
| Reference position and coordinate systems | |
| G27 | Reference position return check |
| G28 | Automatic return to reference position |
| G28.2 | In-position check disable reference position return |
| G29 | Movement from reference position |
| G30 | 2nd, 3rd and 4th reference position return |
| G30.2 | In-position check disable 2nd/3rd/4th reference return |
| G52 | Local coordinate system setting |
| G53 | Machine coordinate system setting |
| G53.1 | Tool axis direction control |
| G54 (G54.1) | Workpiece coordinate system 1 selection |
| G55 | Workpiece coordinate system 2 selection |
| G56 | Workpiece coordinate system 3 selection |
| G57 | Workpiece coordinate system 4 selection |
| G58 | Workpiece coordinate system 5 selection |
| G59 | Workpiece coordinate system 6 selection |
| G92 | Workpiece coordinate system setting or max spindle speed clamp |
| G92.1 | Workpiece coordinate system preset |
| Tool compensation | |
| G37 | Automatic tool length measurement |
| G38 | Tool radius compensation: preserve vector |
| G39 | Tool radius compensation: corner circular interpolation |
| G40 | Tool radius / tool nose radius compensation cancel |
| G41 | Tool radius compensation left |
| G42 | Tool radius compensation right |
| G40.1 / G41.1 / G42.1 | Normal direction control cancel / left / right |
| G43 | Tool length compensation + |
| G44 | Tool length compensation − |
| G43.7 | Tool offset |
| G45 / G46 | Tool offset: increase / decrease |
| G47 / G48 | Tool offset: double increase / double decrease |
| G49 (G49.1) | Tool length compensation cancel |
| Scaling, mirroring, rotation | |
| G50 / G51 | Scaling cancel / on |
| G50.1 / G51.1 | Programmable mirror image cancel / on |
| G68 / G69 | Coordinate system rotation or 3-D coordinate conversion on / off |
| G68.2 | Tilted working plane indexing |
| G68.3 | Tilted working plane indexing by tool axis direction |
| G72.1 / G72.2 | Figure copying (rotary / linear) |
| Motion mode and macro | |
| G60 | Single direction positioning |
| G61 | Exact stop mode |
| G62 | Automatic corner override |
| G63 | Tapping mode |
| G64 | Cutting mode (continuous path) |
| G65 | Macro call |
| G66 / G66.1 | Macro modal call A / B |
| G67 | Macro modal call cancel |
| Canned cycles for drilling | |
| G73 | High-speed peck drilling cycle |
| G74 | Left-handed tapping cycle |
| G76 | Fine boring cycle |
| G80 | Canned cycle cancel |
| G81 | Drilling / spot drilling cycle |
| G82 | Drilling or counter boring cycle |
| G83 | Peck drilling cycle |
| G84 | Tapping cycle |
| G84.2 / G84.3 | Rigid tapping / left-handed rigid tapping (FS10/11 format) |
| G85 | Boring cycle |
| G86 | Boring cycle |
| G87 | Back boring cycle |
| G88 / G89 | Boring cycles |
| G98 / G99 | Canned cycle return: initial level / R point level |
| Programming mode, feed and spindle | |
| G90 | Absolute programming |
| G91 | Incremental programming |
| G91.1 | Checking the maximum incremental amount specified |
| G93 | Inverse time feed |
| G94 | Feed per minute |
| G95 | Feed per revolution |
| G96 | Constant surface speed control |
| G97 | Constant surface speed control cancel |
| G160 / G161 | In-feed control cancel / on (grinding) |
| G75, G77, G78, G79 | Grinding cycles (plunge, direct sizing, surface) |
| G50.4 / G51.4 | Cancel / start synchronous control |
| G50.5 / G51.5 | Cancel / start composite control |
| G50.6 / G51.6 | Cancel / start superimposed control |
| G80.4 / G81.4 | Electronic gear box: synchronization cancel / start |
FANUC Lathe G Code List (Systems A / B / C)
The three columns show the three G code systems. Read the column that matches your machine.
| A | B | C | Function |
|---|---|---|---|
| Motion and interpolation | |||
| G00 | G00 | G00 | Positioning (rapid traverse) |
| G01 | G01 | G01 | Linear interpolation |
| G02 | G02 | G02 | Circular interpolation CW |
| G03 | G03 | G03 | Circular interpolation CCW |
| G04 | G04 | G04 | Dwell |
| G05.1 | G05.1 | G05.1 | AI contour control |
| G07.1 | G07.1 | G07.1 | Cylindrical interpolation |
| G09 | G09 | G09 | Exact stop |
| G12.1 / G13.1 | G12.1 / G13.1 | G12.1 / G13.1 | Polar coordinate interpolation on / off |
| G31 | G31 | G31 | Skip function |
| Threading | |||
| G32 | G33 | G33 | Threading (constant lead) |
| G34 | G34 | G34 | Variable lead threading |
| G35 | G35 | G35 | Circular threading CW |
| G36 | G36 | G36 | Circular threading CCW or automatic tool offset (parameter dependent) |
| Units, plane, stroke | |||
| G20 | G20 | G70 | Input in inch |
| G21 | G21 | G71 | Input in mm |
| G17 / G18 / G19 | same | same | XpYp / ZpXp / YpZp plane selection |
| G22 / G23 | same | same | Stored stroke check on / off |
| G25 / G26 | same | same | Spindle speed fluctuation detection off / on |
| Reference position and coordinate systems | |||
| G27 | G27 | G27 | Reference position return check |
| G28 | G28 | G28 | Return to reference position |
| G29 | G29 | G29 | Movement from reference position |
| G30 | G30 | G30 | 2nd, 3rd, 4th reference position return |
| G50 | G92 | G92 | Coordinate system setting / max spindle speed clamp |
| G50.3 | G92.1 | G92.1 | Workpiece coordinate system preset |
| G52 | G52 | G52 | Local coordinate system setting |
| G53 | G53 | G53 | Machine coordinate system setting |
| G54…G59 | same | same | Workpiece coordinate system 1…6 |
| Tool compensation | |||
| G40 | G40 | G40 | Tool nose radius compensation cancel |
| G41 | G41 | G41 | Tool nose radius compensation left |
| G42 | G42 | G42 | Tool nose radius compensation right |
| G38 / G39 | same | same | Compensation with vector held / corner circular |
| G43.7 | G43.7 | G43.7 | Tool offset |
| G49 | G49 | G49 | Tool length compensation cancel |
| G50.1 / G51.1 | same | same | Programmable mirror image cancel / on |
| G68 / G69 | same | same | Mirror image for double turret or balance cutting mode on / off |
| Multiple repetitive turning cycles | |||
| G70 | G70 | G72 | 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 | OD / ID grooving and cut-off cycle |
| G76 | G76 | G78 | Multiple-thread cutting cycle |
| Single turning cycles | |||
| G90 | G77 | G20 | OD / ID single turning cycle |
| G92 | G78 | G21 | Threading cycle |
| G94 | G79 | G24 | End face turning cycle |
| Drilling cycles (live tooling) | |||
| G80 | G80 | G80 | Canned cycle cancel for drilling |
| G83 | G83 | G83 | Cycle for face drilling |
| G83.5 / G83.6 | same | same | High-speed peck drilling / peck drilling |
| G84 | G84 | G84 | Cycle for face tapping |
| G84.2 | G84.2 | G84.2 | Rigid tapping cycle (FS10/11-T format) |
| G85 | G85 | G85 | Cycle for face boring |
| G87 | G87 | G87 | Cycle for side drilling |
| G88 | G88 | G88 | Cycle for side tapping |
| G89 | G89 | G89 | Cycle for side boring |
| Feed, spindle and macro | |||
| G96 | G96 | G96 | Constant surface speed control |
| G97 | G97 | G97 | Constant surface speed control cancel |
| G98 | G94 | G94 | Feed per minute |
| G99 | G95 | G95 | Feed per revolution |
| G61 / G64 | same | same | Exact stop mode / cutting mode |
| G63 | G63 | G63 | Tapping mode |
| G65 | G65 | G65 | Macro call |
| G66 / G66.1 / G67 | same | same | Macro modal call A / B / cancel |
| G10 / G11 | same | same | Programmable data input on / cancel |
FANUC M code list — and why there is no such thing as a “standard” one
Most of the “FANUC M code list” tables circulating online are misleading. The source manual is explicit: when a number is specified after address M, a code signal and a strobe signal are sent to the machine. Which M code corresponds to which machine function is determined by the machine tool builder.
In other words, the great majority of M codes are defined not by FANUC but by the company that built the machine. The authoritative list is always in the machine tool builder’s manual.
The M codes FANUC itself fixes
These are handled by the control and are not left to the builder:
| M code | Function | Behaviour |
|---|---|---|
| M00 | Program stop | Automatic operation stops after the block is executed. All modal information remains unchanged. Restarted with cycle start. |
| M01 | Optional stop | Like M00, but only effective when the Optional Stop switch on the operator’s panel is on. |
| M02 | End of program | Indicates the end of the main program. Automatic operation stops and the CNC is reset. |
| M30 | End of program | Like M02; control returns to the start of the program after the block is executed. |
| M98 | Subprogram call | Code and strobe signals are not sent to the machine; handled inside the control. |
| M99 | End of subprogram | Returns control to the main program. No signal is sent. |
| M198 | Subprogram call from an external device | Handled by the control. |
Widely used but builder-defined M codes
The following mean the same thing on most machines, but that is not guaranteed. Verify against your own machine’s manual:
| M code | Common meaning |
|---|---|
| M03 / M04 | Spindle on clockwise / counter-clockwise |
| M05 | Spindle stop |
| M06 | Tool change |
| M08 / M09 | Coolant on / off |
| M19 | Spindle orientation |
| M29 | Rigid tapping mode (on most milling machines, before G84) |
| M10 / M11 | Clamp / unclamp (indexer, chuck, tailstock — varies by builder) |
| M07 | Mist coolant |
| M48 / M49 | Feedrate override enable / disable |
How many M codes can go in one block?
By default only one. Parameters extend this:
- Parameter 3404 bit 7 (M3B) = 1 → up to three M codes per block
- Parameter 11630 bit 5 (M5B) = 1 → up to five M codes per block
M codes written in one block are output to the machine at the same time, which reduces cycle time.
Modal and one-shot G codes
G codes are organised into groups and behave in two ways:
- Modal codes take effect in the block where they are written and stay in effect until another code from the same group is written. Once
G01is commanded, it does not have to be repeated on the following lines. - One-shot codes (group 00) are effective only in the block where they appear:
G04dwell,G28reference return,G65macro call.
If two codes from the same group appear in one block, the last one wins. Codes from different groups can be combined freely — G90 G54 G00 X0 Y0 is a valid line.
The codes most often confused on the shop floor
G90 on a mill is not G90 on a lathe
On a milling machine G90 is absolute programming. On a System A lathe control G90 is the single turning cycle. This is the single most common mistake when moving a program between machines.
G98 / G99 mean two different things
On a mill, G98/G99 set the return level of a drilling cycle (initial level / R point). On a System A lathe, G98/G99 are the feed units (per minute / per revolution).
The G20/G21 versus G70/G71 trap
In systems A and B, G20/G21 select inch/mm. In system C the same job is done by G70/G71 — whereas in system A G70/G71 are the finishing and roughing cycles. One line written in the wrong system makes the machine do something entirely different.
Mixing up the H number with the D number on G43
G43 H.. is tool length compensation; G41/G42 D.. is tool radius compensation. Writing D where H belongs produces an unexpected plunge in Z.
Using G96 without a G50 / G92 speed clamp
Under constant surface speed (G96) the spindle speeds up as the diameter falls. Facing towards centre, the speed runs into the machine’s limit. Clamp the maximum with G50 S.... in system A, or G92 S.... in systems B and C.
Frequently asked questions
Are FANUC G codes the same on every series?
The core codes (G00, G01, G02, G03, G04, G17–G19, G40–G43, G54–G59, G80–G89, G90/G91) are the same across all series. The differences are in the advanced and optional codes: G05.1 AI contour control, G68.2 tilted working plane indexing, G51.4 synchronous control and similar are absent on older series or may not have been purchased as options. The lists on this page are based on Series 0i-MODEL F.
How do I find out which G code system my lathe uses?
The practical way is to look at an existing program. If threading is written with G32 it is System A; if it is written with G33 it is System B or C. If the feed unit is set with G99 per revolution it is System A; with G95 it is B or C. The definitive answer is in the machine tool builder’s manual — the system is selected by parameter.
Where do I find the complete M code list?
There is no complete M code list in the FANUC manual, because most M codes are defined by the machine tool builder. The codes handled by the control itself are only M00, M01, M02, M30, M98, M99 and M198. For everything else you need your machine builder’s manual. General M code lists online show common usage only; they are not binding.
Can I write more than one M code in a block?
By default no — one M code per block. With bit 7 (M3B) of parameter 3404 set, three M codes are allowed; with bit 5 (M5B) of parameter 11630 set, five. They are output to the machine simultaneously, which shortens cycle time.
What is the difference between G54 and G92?
G54–G59 select workpiece coordinate systems stored in the offset table; the values are entered on screen and persist. G92 on a mill (G50 on a System A lathe) sets the coordinate system from within the program, relative to the tool’s current position. Modern practice favours G54–G59; G92/G50 is mostly used for the maximum spindle speed clamp.
What does modal mean?
A modal code takes effect where it is written and stays in effect until another code from the same group replaces it. Once G01 is commanded it does not need repeating on the following lines. Group 00 codes are one-shot: G04, G28, G65 and similar.
What is the difference between G81 and G83?
G81 drills in a single pass and retracts — for shallow holes and spot drilling. G83 is the peck drilling cycle: it advances by the Q depth, retracts, breaks the chip and plunges again. Use G83 for deep holes where chip evacuation and drill life matter. G73 is high-speed peck drilling; it does not fully retract from the hole, only backs off a short distance.
Which G codes should go at the top of a program?
A safety line puts the modal state into a known condition. Common on milling: G17 G21 G40 G49 G80 G90 G54. On a lathe (System A): G21 G40 G97 G99 plus G50 S.... for a speed clamp where needed. This prevents a compensation or cycle mode left over from the previous program from carrying across.
Sources
- FANUC — Series 0i-MODEL F, Common to Lathe System / Machining Center System, OPERATOR’S MANUAL, document no. B-64604EN/01: Section 3.1 G code list in the machining center system, Section 3.2 G code list in the lathe system (Systems A/B/C), Section 11.1 Auxiliary function (M function), Section 11.2 Multiple M commands in a single block, Section 13.3 Subprogram (M98, M99)
- FANUC — Series 0i-MODEL F For Lathe System OPERATOR’S MANUAL, B-64604EN-1/01
- FANUC — Series 0i-MODEL F For Machining Center System OPERATOR’S MANUAL, B-64604EN-2/01