Skip to content

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.

CodeMeaningExample / Notes
G00Rapid positioningG00 X100. Y50.: move the tool rapidly to the specified position
G01Linear interpolationG01 Z-5. F100: cut in a straight line to Z-5. at the programmed feed
G02Clockwise circular interpolationG02 X50. Y0 I25. J0: machine a clockwise arc
G03Counterclockwise circular interpolationG03 X50. Y0 R25.: machine a counterclockwise arc with radius 25
G04DwellG04 P1000: pause for about 1 second (units depend on system parameters)
G09Exact stop checkG09 G01 X50.: decelerate and stop precisely before the block ends
G10Programmable data inputG10 L2 P1 X0 Y0 Z0: write work coordinate system data
G17Select XY planeCommon for milling, drilling, and XY-plane circular interpolation
G18Select ZX planeCommon for turning or ZX-plane circular interpolation
G19Select YZ planeCommon for YZ-plane circular interpolation
G20Inch unitsG20: interpret subsequent dimensions in inches
G21Metric unitsG21: interpret subsequent dimensions in millimeters
G27Reference position checkCheck whether the current position is the reference position
G28Return to reference positionG91 G28 Z0: return the Z axis to machine reference via an intermediate point
G29Return from reference positionUsually used with G28
G30Return to second/third/fourth reference positionG30 P2 Z0: return to the specified reference position, often for tool changes
G31Skip function / probing skipOften used for probe measurements or skip-signal triggers
G40Cancel cutter radius compensationG40 G01 X0 Y0: move after canceling compensation
G41Cutter radius compensation leftCompensate to the left of the cutting direction; requires a D offset number
G42Cutter radius compensation rightCompensate to the right of the cutting direction; requires a D offset number
G43Positive tool length compensationG43 H01 Z50.: enable H01 tool length compensation
G44Negative tool length compensationLess common; apply tool length compensation in the negative direction
G49Cancel tool length compensationG49: cancel the active length compensation
G50Coordinate system / spindle speed limit settingLathes commonly use G50 S3000 to limit maximum spindle speed
G52Local coordinate system settingG52 X10. Y0: temporarily offset the local coordinate system
G53Machine-coordinate positioningG53 G00 Z0: rapid positioning in machine coordinates
G54Work coordinate system 1G54: select the first work coordinate system
G55Work coordinate system 2G55: select the second work coordinate system
G56Work coordinate system 3G56: select the third work coordinate system
G57Work coordinate system 4G57: select the fourth work coordinate system
G58Work coordinate system 5G58: select the fifth work coordinate system
G59Work coordinate system 6G59: select the sixth work coordinate system
G61Exact stop modeCheck for an exact stop at the end of every machining block
G64Cutting / continuous cutting modeRun smoothly between blocks where possible, reducing pauses
G65Macro callG65 P9000 A10. B20.: call macro program O9000
G66Modal macro callCall the specified macro on subsequent blocks until canceled by G67
G67Cancel modal macro callG67: cancel the G66 modal macro call
G68Coordinate rotationG68 X0 Y0 R45.: rotate coordinates around the specified point
G69Cancel coordinate rotationG69: cancel the active coordinate rotation
G73High-speed peck drilling cycleG73 X0 Y0 Z-20. Q2. F100: deep drilling with short retracts
G74Left-hand / reverse tapping cycleConfirm the exact function for the machine model and parameters
G76Fine boring / threading cycleUsually fine boring on machining centers; often a compound threading cycle on lathes
G80Cancel canned cycleG80: cancel drilling, tapping, boring, and other canned cycles
G81Drilling cycleG81 X0 Y0 Z-10. R2. F100: standard drilling
G82Drilling cycle with dwellG82 X0 Y0 Z-10. R2. P500 F100: dwell at the bottom of the hole
G83Deep-hole drilling cycleG83 X0 Y0 Z-30. R2. Q5. F80: peck drilling for chip removal
G84Tapping cycleG84 X0 Y0 Z-15. R2. F1.5: right-hand tapping
G85Boring cycleFeed in and feed out
G86Boring cycleStop the spindle at the bottom, then retract rapidly
G87Back boring cycleOften used for reverse boring; verify machine support
G88Boring cycleDwell and stop the spindle at the bottom; retract manually or by the specified method
G89Boring cycleFeed out after a dwell at the bottom
G90Absolute coordinate programmingG90 G00 X100.: target an absolute position in the coordinate system
G91Incremental coordinate programmingG91 G00 X10.: move 10 relative to the current position
G92Coordinate system setting / threading cycleMeaning varies by system and turning/milling application; check the manual
G94Feed per minuteG94 F200: feed at 200 mm/min
G95Feed per revolutionG95 F0.2: feed 0.2 mm/rev of the spindle
G96Constant surface speedCommon on lathes: G96 S180 sets 180 m/min
G97Cancel constant surface speed / fixed RPMG97 S1200: set a fixed spindle speed of 1200 rpm
G98Canned cycle return to initial pointReturn to the initial plane at the start of the cycle
G99Canned cycle return to R pointReturn 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.

CodeMeaningExample / Notes
M00Program stopStop unconditionally; resume with Cycle Start
M01Optional stopStop only when the panel's optional stop switch is enabled
M02End programEnd the program, usually without rewinding to its beginning
M03Spindle forwardS1200 M03: rotate forward at 1200 rpm
M04Spindle reverseS800 M04: rotate in reverse at 800 rpm
M05Spindle stopStop the current spindle rotation
M06Automatic tool changeT01 M06: select tool 1 and change tools
M08Coolant onStart cutting fluid / coolant pump
M09Coolant offStop coolant
M10Clamp / lockOften clamps a fixture, fourth axis, or chuck; machine-dependent
M11Unclamp / unlockOften releases a fixture, fourth axis, or chuck; machine-dependent
M13Spindle forward and coolant onCommonly equivalent to M03 + M08
M14Spindle reverse and coolant onCommonly equivalent to M04 + M08
M19Spindle orientationOrient before tool changes, boring retracts, or positioned machining
M30End program and resetEnd the program and usually return to its beginning
M48Enable feed / spindle overridesAllow override switches; confirm system parameters
M49Disable feed / spindle overridesIgnore override settings; confirm system parameters
M60Pallet changeCommon APC pallet exchange on machining centers; depends on configuration
M98Subprogram callM98 P1000 L2: call subprogram O1000 twice
M99Subprogram return / loopReturn 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.

CodeMeaningExample / Notes
T01Select tool 1Machining centers commonly use T01 M06 for an automatic tool change
T12Select tool 12T12 M06: call tool 12 from the magazine
T0101Tool number + offset numberCommon lathe format: first two digits select tool, last two select offset
T0100Call tool and cancel offsetOn lathes, commonly retains the tool number while canceling the offset
T0000Cancel tool / offsetOn 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.

CodeMeaningExample / Notes
S1200Set spindle speedS1200 M03: spindle forward at a target 1200 rpm
S800Set a lower speedS800 M04: spindle reverse at a target 800 rpm
G97 S1500Fixed RPM modeCancel constant surface speed and set spindle speed to 1500 rpm
G96 S180Constant surface speed modeCommon on lathes; set surface speed to 180 m/min
G50 S3000Maximum spindle speed limitLimit 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.

CodeMeaningExample / Notes
F100Set feed valueG01 Z-5. F100: feed at 100 in the current feed mode
G94 F200Feed per minuteCommon units: mm/min, e.g. 200 mm/min
G95 F0.2Feed per revolutionCommon units: mm/rev, e.g. 0.2 mm per spindle revolution
G01 X50. F150Linear cutting feedUsed with cutting motions such as G01, G02, and G03
G00Rapid motion is not controlled by FRapid 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.

CodeMeaningExample / Notes
XX-axis coordinateX100.: move the X axis to or by 100
YY-axis coordinateY50.: move the Y axis to or by 50
ZZ-axis coordinateZ-10.: move the Z axis to or by -10
AA rotary axisUsually a fourth axis rotating about X
BB rotary axisUsually rotates about Y
CC rotary axisUsually rotates about Z
UIncremental X addressCommon on lathes, indicating an X-direction increment
VIncremental Y addressIndicates a Y-direction increment; availability depends on configuration
WIncremental Z addressCommon on lathes, indicating a Z-direction increment
IArc-center X offsetIn G02 X50. Y0 I25. J0, I is the arc-center X offset
JArc-center Y offsetIn G03 X0 Y50. I0 J25., J is the arc-center Y offset
KArc-center Z offsetCommon for arcs in ZX/YZ planes
RArc radius / canned-cycle R pointG03 X50. Y0 R25.; R2. is the return plane for drilling
PDwell time / program number / parameterG04 P1000; M98 P1000 calls a subprogram
QDepth per cut / peck amountG83 Z-30. Q5.: drill 5 per peck
DCutter radius offset numberG41 D01: apply D01 radius offset
HTool length offset numberG43 H01 Z50.: apply H01 length offset
LRepeat count / parameter selectionM98 P1000 L3: repeat subprogram 3 times
NBlock numberN100 G01 X50.: a block number helps locate code
OProgram numberO1000: define or call a numbered program

Common Combinations ​

CodeMeaningExample / Notes
G21 G17 G40 G49 G80 G90Safe machining-center initializationMetric, XY plane, cancel radius/length offsets and cycles, absolute mode
G54 G00 X0 Y0Select coordinates and position rapidlyRapidly move to the work origin after selecting G54
T01 M06Change to tool 1Common machining-center tool-change format
S1200 M03Spindle forwardSet 1200 rpm and start forward rotation
G43 H01 Z50.Enable tool length compensationApply H01 and move to safe height Z50.
M08 / M09Coolant on / offTurn coolant on at the start of machining and off at the end
G91 G28 Z0Z-axis return to referenceOften used to retract and home; beware of incremental-mode risks
M05 M30Stop spindle and end programCommon combination at program end

Usage Notes ​

CodeMeaningExample / Notes
G00Rapid moves can cause collisionsUse single-block, dry run, and reduced override on the first run
G90 / G91Confirm absolute / incremental modeEspecially important during homing, array machining, and macros
G54-G59Verify work coordinate systemsCheck zero, fixture, offsets, and program before machining
M codesOften customized by buildersConsult the machine manual for clamping, chip removal, air blast, door locks, etc.
T / H / DMatch tools and offsetsVerify tool, length offset, and radius offset numbers against installed tools