Understanding Common Fanuc Style 
G-Codes For CNC Milling & Turning Centers.

Word Addresses

X## = X position Y## = Y position Z## = Z position
I## = X arc center J## = Y arc center K## = Z arc center
U## = linear opposite X
sometimes used as incremental (lathe)
V## = linear opposite Y
sometimes used as incremental (lathe)
W## = linear opposite Z
sometimes used as incremental (lathe)
A## = rotary around X B## = rotary around Y C## = rotary around Z
F## = feedrate R## = drill retract Q## = drill peck
## ## ##

 
R+## = arc radius(+) if < 180° R-## = arc radius(-) if > 180°
D## = cutter dia/rad offset H## = tool length offset
P## = dwell time in 10000th sec
 

G-Codes

G00 = Rapid linear move
example: G00 X## Y## Z## (X,Y,Z = position)
G01 = Feed linear move
example: G01 F## X## Y## Z## (F=feedrate to move at)
G02 = Circular move CW
example: G02 X## Y## I## J## (XY=end point, IJ=center point)
G02 = Circular move CW
example: G02 X## Y## R±## (R=size of radius arc to swing. 
R+ if radius < 180°, R- if radius is > 180°)
G03 = Circular move CCW
example: G03 X## Y## I## J## (XY=end point, IJ=center point)
G03 = Circular move CCW
example: G03 X## Y## R±## (R=size of arc radius to swing. 
R+ if radius < 180°, R- if radius is > 180°)
G04 = Dwell time
example: G04 P## (P=time to dwell. P20000 is 2 seconds)
G10 = Zero offset shift
example: G10 X## Y## Z##(X=shift dist. Y=shift dist. Z=shift dist.)
G11 = Zero offset shift cancel
example: G11
G17 = Contour plane is XY (Z = spindle)
example: G17
G18 = Contour plane is ZX (Y = spindle)
example: G18
G19 = Contour plane is YZ (X = spindle)
example: G19
G20 = Inch mode (G70 on older controls)
example: G20
G21 = MM mode (G71 on older controls)
example: G21
G28 = Return to reference point
example: G0 G91 G28 X## Y## Z## 
(Go to machine XYZ home,passing thru XYZ incremental zero)
G29 = Return from reference point
example: G0 G90 G29 X## Y## Z## 
(Go to this XYZ position, returning from home)
G30 = Return to 2nd, 3rd (ect..) reference point
example: Similar to G28
G40 = Cutter (dia.or rad.) compensation off
example: G40 X## Y##
G41 = Cutter compensation to the left of the programmed path
example: G40 X## Y##
G42 = Cutter compensation to the right of the programmed path
example: G40 X## Y##
G43 = Tool length compensation with spindle approach from + side
example: G43 H## Z##
G44 = Tool length compensation with spindle approach from - side
example: G44 H## Z##
G49 = Tool length compensation cancel
example: G49
G45 = Increase end position by tool offset value
example: G45 X## D## (Go to X position, plus offset value in D##)
G46 = Decrease end position by tool offset value
example: G46 X## D## (Go to X position, less offset value in D##)
G47 = Increase end position by twice the offset value
example: G47 X## D## (Go to X position, plus 2x the offset value)
G48 = Decrease end position by twice the offset value
example: G48 X## D## (Go to X position, less 2x the offset value)
G53 = Coordinate system referenced from machine home
example: G53 X## Y## Z## 
(Go to this XYZ position referenced from machine home)
G54 = Work coordinate shift,offset #1
example: G54 X## Y## Z## 
(Go to this XYZ position referenced from WCS #1)
G55 - G59 = Work coordinate shift,offset G55-G59
example: G5# X## Y## Z##
(Go to this XYZ position referenced from WCS G55-G59)
G09 = Exact stop positioning move
example: G09 F## X## Y## Z## (active for single block only)
G61 = Exact stop cutting mode
example: G61 X## Y## Z## (Decelerated at point XYZ, before next move)
G64 = Exact stop mode off
example: G64 X## Y## Z## (Tool is not decelerated at point XYZ)
G63 = Feed overide lock out
example: G63 X## Y## Z##
G62 = Feed compensation on inner corner
example: G62 G02 X## Y## I## J##
G81 = Basic drilling cycle - Feed in , rapid out.
example: G81 X## Y## Z## R## F##
G82 = Counter bore cycle - Feed in, dwell, rapid out.
example: G82 X## Y## Z## R## F## P####
G83 = Peck drilling cycle - Feed in peck amount, rapid out, rapid in within .050 of last peck & repeat until depth is reached.
example: G83 X## Y## Z## R## F## Q##
G84 = Tapping cycle - Feed in, spindle stop, reverse, feed out.
(note: this cycle will vary depending on the machine mfgr.)
example: G84 X## Y## Z## R## F##
G85, G86, G87, G88, G89 = Boring cycles. Function & imput will vary depending on the machine mfgr.  Variations include....
Feed in, feed out.
Feed in, dwell, feed out.
Feed in, dwell, spindle stop, rapid out.
Feed in, dwell, spindle stop, move insert from wall, rapid out.
Rapid in, dwell, start spindle, feed up, dwell, rapid down, dwell
(reverse counter boring, back facing, back boring cycle).
G90 = Absolute coordinate positioning. Points based from XYZ zero.
example: G90 G00 X## Y## Z##
G91 = Incremental coordinate positioning. Point to point positioning.
example: G91 G00 X## Y## Z##
G92 = Absolute Zero Pre-Set - An old format used to set XYZ Zero.
The current position is set to the values shown in the line.
example: G92 X10 Y5 Z-3
After running this command the current position is X10 Y5 Z-3.
Very strange way to shift zero's. Avoid this code if you can.
G94 = Feedrate is read as Inches/Minute. Used mostly for milling.
example: 
G94 
G01 X## Y## Z## F##
G95 = Feedrate is read as Inches/revolution. Used mostly for turning.
example: 
G95
G01 X## Y## Z## F##.###
G96 = Constant surface speed (CSS) control (lathe). Increases the RPM as the tool moved closer to the center line of the part (smaller diameter). This keeps the amount of material (chip load) moving past the tip of the tool constant for and improved tool load, tool wear and surface finish. In the example below, the control will do an internal calculation to keep the tool moving at 200 surface feed/second.
example: G96 S200
G97 = The opposite of constant surface speed control (G96).
example: G97
G98 = Retract the tool to the starting Z height when drilling. Used for high retrect clearance moved between drilled holes. Assume Z is currently at Z+1.0.  Running the line below will rapid to the R plane, drill to the Z depth and return to the starting height of Z+1.00 when the cycle is finished.
example: G98 G81 X## Y## Z-.875 R.100 F##
G99 = Retract the tool to the R plane when the drilling cycle is finished. Regardless of the starting height, the tool will return to Z.100 (the Rplane shown below).
example: G99 G81 X## Y## Z-.875 R.100 F##
G
example: 
G
example: 
G
example: 
G
example: 
G
example: 

M-Function Codes
 
M00 = Program stop
M01 = Optional program stop
M02 = End of program (no rewind or return to start of program)
M03 = Start the spindle in the forward direction (CW)
M04 = Start the spindle in the reverse direction (CCW)
M05 = Stop the spindle / Spindle off.
M06 = Tool change command
M07 = Coolant on mist
M08 = Coolant on flood
M09 = Coolant off
M13 = Spindle on forward, coolant on
M14 = Spindle on reverse, coolant on
M15 = Spindle off, coolant off
M19 = Spindle orientation on. Used to locate the tool tip position for boring tools. Sometimes output with a value that represents the angle of the tool tip orientation.
M20 = Spindle orientation off
M30 = End of program (rewind/return to start of program)
M98 = Call sub program
M99 = Sub program end

Not all of these M Functions work on all machines. 
 

This Page Written By Mike Mattera