FANUC Machine Code Quick Reference
This guide is a quick reference for common address codes and instructions in FANUC CNC programs. Before programming a real machine, check the machine manufacturer's manual, system parameters, and site safety procedures. Some M codes and macro functions are customized by machine builders.
G Codes (Preparatory Functions)
G codes define preparatory machining functions such as motion, coordinate modes, units, compensation, and canned cycles. Most G codes are modal: they remain active until replaced by another code in the same group.
| Code | Meaning | Example / Notes |
|---|---|---|
G00 | Rapid positioning | G00 X100. Y50.: move the tool rapidly to the specified position |
G01 | Linear interpolation | G01 Z-5. F100: cut in a straight line to Z-5. at the programmed feed |
G02 | Clockwise circular interpolation | G02 X50. Y0 I25. J0: machine a clockwise arc |
G03 | Counterclockwise circular interpolation | G03 X50. Y0 R25.: machine a counterclockwise arc with radius 25 |
G04 | Dwell | G04 P1000: pause for about 1 second (units depend on system parameters) |
G09 | Exact stop check | G09 G01 X50.: decelerate and stop precisely before the block ends |
G10 | Programmable data input | G10 L2 P1 X0 Y0 Z0: write work coordinate system data |
G17 | Select XY plane | Common for milling, drilling, and XY-plane circular interpolation |
G18 | Select ZX plane | Common for turning or ZX-plane circular interpolation |
G19 | Select YZ plane | Common for YZ-plane circular interpolation |
G20 | Inch units | G20: interpret subsequent dimensions in inches |
G21 | Metric units | G21: interpret subsequent dimensions in millimeters |
G27 | Reference position check | Check whether the current position is the reference position |
G28 | Return to reference position | G91 G28 Z0: return the Z axis to machine reference via an intermediate point |
G29 | Return from reference position | Usually used with G28 |
G30 | Return to second/third/fourth reference position | G30 P2 Z0: return to the specified reference position, often for tool changes |
G31 | Skip function / probing skip | Often used for probe measurements or skip-signal triggers |
G40 | Cancel cutter radius compensation | G40 G01 X0 Y0: move after canceling compensation |
G41 | Cutter radius compensation left | Compensate to the left of the cutting direction; requires a D offset number |
G42 | Cutter radius compensation right | Compensate to the right of the cutting direction; requires a D offset number |
G43 | Positive tool length compensation | G43 H01 Z50.: enable H01 tool length compensation |
G44 | Negative tool length compensation | Less common; apply tool length compensation in the negative direction |
G49 | Cancel tool length compensation | G49: cancel the active length compensation |
G50 | Coordinate system / spindle speed limit setting | Lathes commonly use G50 S3000 to limit maximum spindle speed |
G52 | Local coordinate system setting | G52 X10. Y0: temporarily offset the local coordinate system |
G53 | Machine-coordinate positioning | G53 G00 Z0: rapid positioning in machine coordinates |
G54 | Work coordinate system 1 | G54: select the first work coordinate system |
G55 | Work coordinate system 2 | G55: select the second work coordinate system |
G56 | Work coordinate system 3 | G56: select the third work coordinate system |
G57 | Work coordinate system 4 | G57: select the fourth work coordinate system |
G58 | Work coordinate system 5 | G58: select the fifth work coordinate system |
G59 | Work coordinate system 6 | G59: select the sixth work coordinate system |
G61 | Exact stop mode | Check for an exact stop at the end of every machining block |
G64 | Cutting / continuous cutting mode | Run smoothly between blocks where possible, reducing pauses |
G65 | Macro call | G65 P9000 A10. B20.: call macro program O9000 |
G66 | Modal macro call | Call the specified macro on subsequent blocks until canceled by G67 |
G67 | Cancel modal macro call | G67: cancel the G66 modal macro call |
G68 | Coordinate rotation | G68 X0 Y0 R45.: rotate coordinates around the specified point |
G69 | Cancel coordinate rotation | G69: cancel the active coordinate rotation |
G73 | High-speed peck drilling cycle | G73 X0 Y0 Z-20. Q2. F100: deep drilling with short retracts |
G74 | Left-hand / reverse tapping cycle | Confirm the exact function for the machine model and parameters |
G76 | Fine boring / threading cycle | Usually fine boring on machining centers; often a compound threading cycle on lathes |
G80 | Cancel canned cycle | G80: cancel drilling, tapping, boring, and other canned cycles |
G81 | Drilling cycle | G81 X0 Y0 Z-10. R2. F100: standard drilling |
G82 | Drilling cycle with dwell | G82 X0 Y0 Z-10. R2. P500 F100: dwell at the bottom of the hole |
G83 | Deep-hole drilling cycle | G83 X0 Y0 Z-30. R2. Q5. F80: peck drilling for chip removal |
G84 | Tapping cycle | G84 X0 Y0 Z-15. R2. F1.5: right-hand tapping |
G85 | Boring cycle | Feed in and feed out |
G86 | Boring cycle | Stop the spindle at the bottom, then retract rapidly |
G87 | Back boring cycle | Often used for reverse boring; verify machine support |
G88 | Boring cycle | Dwell and stop the spindle at the bottom; retract manually or by the specified method |
G89 | Boring cycle | Feed out after a dwell at the bottom |
G90 | Absolute coordinate programming | G90 G00 X100.: target an absolute position in the coordinate system |
G91 | Incremental coordinate programming | G91 G00 X10.: move 10 relative to the current position |
G92 | Coordinate system setting / threading cycle | Meaning varies by system and turning/milling application; check the manual |
G94 | Feed per minute | G94 F200: feed at 200 mm/min |
G95 | Feed per revolution | G95 F0.2: feed 0.2 mm/rev of the spindle |
G96 | Constant surface speed | Common on lathes: G96 S180 sets 180 m/min |
G97 | Cancel constant surface speed / fixed RPM | G97 S1200: set a fixed spindle speed of 1200 rpm |
G98 | Canned cycle return to initial point | Return to the initial plane at the start of the cycle |
G99 | Canned cycle return to R point | Return to the R plane at the end of the cycle |
M Codes (Auxiliary Functions)
M codes control auxiliary actions such as spindle rotation, coolant, tool changes, program stops, and clamping. Machine builders often extend or redefine M codes; follow the machine manual on site.
| Code | Meaning | Example / Notes |
|---|---|---|
M00 | Program stop | Stop unconditionally; resume with Cycle Start |
M01 | Optional stop | Stop only when the panel's optional stop switch is enabled |
M02 | End program | End the program, usually without rewinding to its beginning |
M03 | Spindle forward | S1200 M03: rotate forward at 1200 rpm |
M04 | Spindle reverse | S800 M04: rotate in reverse at 800 rpm |
M05 | Spindle stop | Stop the current spindle rotation |
M06 | Automatic tool change | T01 M06: select tool 1 and change tools |
M08 | Coolant on | Start cutting fluid / coolant pump |
M09 | Coolant off | Stop coolant |
M10 | Clamp / lock | Often clamps a fixture, fourth axis, or chuck; machine-dependent |
M11 | Unclamp / unlock | Often releases a fixture, fourth axis, or chuck; machine-dependent |
M13 | Spindle forward and coolant on | Commonly equivalent to M03 + M08 |
M14 | Spindle reverse and coolant on | Commonly equivalent to M04 + M08 |
M19 | Spindle orientation | Orient before tool changes, boring retracts, or positioned machining |
M30 | End program and reset | End the program and usually return to its beginning |
M48 | Enable feed / spindle overrides | Allow override switches; confirm system parameters |
M49 | Disable feed / spindle overrides | Ignore override settings; confirm system parameters |
M60 | Pallet change | Common APC pallet exchange on machining centers; depends on configuration |
M98 | Subprogram call | M98 P1000 L2: call subprogram O1000 twice |
M99 | Subprogram return / loop | Return to the main program from a subprogram; may loop in a main program |
T Codes (Tools)
T codes specify tool numbers, offset numbers, or initiate a tool change. Machining centers and lathes often use very different formats.
| Code | Meaning | Example / Notes |
|---|---|---|
T01 | Select tool 1 | Machining centers commonly use T01 M06 for an automatic tool change |
T12 | Select tool 12 | T12 M06: call tool 12 from the magazine |
T0101 | Tool number + offset number | Common lathe format: first two digits select tool, last two select offset |
T0100 | Call tool and cancel offset | On lathes, commonly retains the tool number while canceling the offset |
T0000 | Cancel tool / offset | On lathes, commonly cancels the active tool compensation state |
S Codes (Spindle)
S codes set spindle speed or a constant surface speed target, usually alongside M03, M04, G96, or G97.
| Code | Meaning | Example / Notes |
|---|---|---|
S1200 | Set spindle speed | S1200 M03: spindle forward at a target 1200 rpm |
S800 | Set a lower speed | S800 M04: spindle reverse at a target 800 rpm |
G97 S1500 | Fixed RPM mode | Cancel constant surface speed and set spindle speed to 1500 rpm |
G96 S180 | Constant surface speed mode | Common on lathes; set surface speed to 180 m/min |
G50 S3000 | Maximum spindle speed limit | Limit top speed while turning at constant surface speed |
F Codes (Feed)
F codes set cutting feed rates. Feed units depend on modes such as G94 and G95.
| Code | Meaning | Example / Notes |
|---|---|---|
F100 | Set feed value | G01 Z-5. F100: feed at 100 in the current feed mode |
G94 F200 | Feed per minute | Common units: mm/min, e.g. 200 mm/min |
G95 F0.2 | Feed per revolution | Common units: mm/rev, e.g. 0.2 mm per spindle revolution |
G01 X50. F150 | Linear cutting feed | Used with cutting motions such as G01, G02, and G03 |
G00 | Rapid motion is not controlled by F | Rapid positioning speed is normally controlled by machine parameters and overrides |
Coordinate and Common Address Words
Address words provide coordinates, radii, offset numbers, cycle parameters, or macro arguments for G/M/T/S/F instructions.
| Code | Meaning | Example / Notes |
|---|---|---|
X | X-axis coordinate | X100.: move the X axis to or by 100 |
Y | Y-axis coordinate | Y50.: move the Y axis to or by 50 |
Z | Z-axis coordinate | Z-10.: move the Z axis to or by -10 |
A | A rotary axis | Usually a fourth axis rotating about X |
B | B rotary axis | Usually rotates about Y |
C | C rotary axis | Usually rotates about Z |
U | Incremental X address | Common on lathes, indicating an X-direction increment |
V | Incremental Y address | Indicates a Y-direction increment; availability depends on configuration |
W | Incremental Z address | Common on lathes, indicating a Z-direction increment |
I | Arc-center X offset | In G02 X50. Y0 I25. J0, I is the arc-center X offset |
J | Arc-center Y offset | In G03 X0 Y50. I0 J25., J is the arc-center Y offset |
K | Arc-center Z offset | Common for arcs in ZX/YZ planes |
R | Arc radius / canned-cycle R point | G03 X50. Y0 R25.; R2. is the return plane for drilling |
P | Dwell time / program number / parameter | G04 P1000; M98 P1000 calls a subprogram |
Q | Depth per cut / peck amount | G83 Z-30. Q5.: drill 5 per peck |
D | Cutter radius offset number | G41 D01: apply D01 radius offset |
H | Tool length offset number | G43 H01 Z50.: apply H01 length offset |
L | Repeat count / parameter selection | M98 P1000 L3: repeat subprogram 3 times |
N | Block number | N100 G01 X50.: a block number helps locate code |
O | Program number | O1000: define or call a numbered program |
Common Combinations
| Code | Meaning | Example / Notes |
|---|---|---|
G21 G17 G40 G49 G80 G90 | Safe machining-center initialization | Metric, XY plane, cancel radius/length offsets and cycles, absolute mode |
G54 G00 X0 Y0 | Select coordinates and position rapidly | Rapidly move to the work origin after selecting G54 |
T01 M06 | Change to tool 1 | Common machining-center tool-change format |
S1200 M03 | Spindle forward | Set 1200 rpm and start forward rotation |
G43 H01 Z50. | Enable tool length compensation | Apply H01 and move to safe height Z50. |
M08 / M09 | Coolant on / off | Turn coolant on at the start of machining and off at the end |
G91 G28 Z0 | Z-axis return to reference | Often used to retract and home; beware of incremental-mode risks |
M05 M30 | Stop spindle and end program | Common combination at program end |
Usage Notes
| Code | Meaning | Example / Notes |
|---|---|---|
G00 | Rapid moves can cause collisions | Use single-block, dry run, and reduced override on the first run |
G90 / G91 | Confirm absolute / incremental mode | Especially important during homing, array machining, and macros |
G54-G59 | Verify work coordinate systems | Check zero, fixture, offsets, and program before machining |
M codes | Often customized by builders | Consult the machine manual for clamping, chip removal, air blast, door locks, etc. |
T / H / D | Match tools and offsets | Verify tool, length offset, and radius offset numbers against installed tools |

