G-Code Quick Reference

G-Codes (Preparatory)

CodeDescriptionExample
G00Rapid positioningG00 X1.0 Y2.0 Z0.5
G01Linear interpolation (feed)G01 X2.0 Y3.0 F10.0
G02Circular interpolation CWG02 X1.0 Y0 I0.5 J0 F8.0
G03Circular interpolation CCWG03 X1.0 Y0 I0.5 J0 F8.0
G04DwellG04 P500 (500 ms)
G10Data setting (offsets)G10 L2 P1 X0 Y0 Z0
G17XY plane selectionG17
G18XZ plane selectionG18
G19YZ plane selectionG19
G20Inch modeG20
G21Metric modeG21
G28Return to home positionG28 G91 Z0
G40Cutter compensation cancelG40
G41Cutter compensation leftG41 D1 X1.0 F10.0
G42Cutter compensation rightG42 D1 X1.0 F10.0
G43Tool length compensation +G43 H1 Z1.0
G44Tool length compensation −G44 H2 Z1.0
G49Tool length compensation cancelG49
G53Machine coordinate systemG53 G00 Z0
G54Work coordinate system 1G54
G55Work coordinate system 2G55
G56Work coordinate system 3G56
G57Work coordinate system 4G57
G58Work coordinate system 5G58
G59Work coordinate system 6G59
G80Cancel canned cycleG80
G81Drill cycleG81 X1.0 Y1.0 Z-0.5 R0.1 F5.0
G82Spot drill / counterbore (dwell)G82 X1.0 Y1.0 Z-0.25 R0.1 P200 F4.0
G83Peck drill cycleG83 X1.0 Y1.0 Z-1.0 R0.1 Q0.15 F5.0
G84Tapping cycleG84 X1.0 Y1.0 Z-0.75 R0.1 F25.0
G85Bore cycle (feed out)G85 X1.0 Y1.0 Z-0.5 R0.1 F4.0
G86Bore cycle (rapid out)G86 X1.0 Y1.0 Z-0.5 R0.1 F4.0
G90Absolute positioningG90
G91Incremental positioningG91
G92Set work coordinate offsetG92 X0 Y0 Z0
G94Feed per minuteG94 F200
G95Feed per revolutionG95 F0.010
G96Constant surface speedG96 S400
G97Cancel CSS / direct RPM modeG97 S1500
G98Return to initial Z levelG98
G99Return to R planeG99

M-Codes (Miscellaneous)

CodeDescription
M00Program stop (unconditional)
M01Optional stop
M02End program
M03Spindle on — clockwise
M04Spindle on — counter-clockwise
M05Spindle stop
M06Tool change
M07Mist coolant on
M08Flood coolant on
M09Coolant off
M10Clamp
M11Unclamp
M19Spindle orient
M30End program and rewind
M48Enable feed/speed override
M49Disable feed/speed override
M98Call subprogram
M99Return from subprogram

Address Codes

LetterMeaning
ARotary axis A
BRotary axis B
CRotary axis C
DTool diameter offset number
FFeed rate
GPreparatory function
HTool length offset number
IArc center offset in X
JArc center offset in Y
KArc center offset in Z
LLoop count / repetitions
MMiscellaneous function
NLine (sequence) number
OProgram number
PDwell time / subprogram number
QPeck depth (drilling cycles)
RArc radius / retract plane
SSpindle speed
TTool number
XX-axis position
YY-axis position
ZZ-axis position

Common Programming Patterns

Simple Face Milling Pass

G90 G54 G00 X0 Y0       (Absolute mode, WCS 1, rapid to start)
G43 H1 Z1.0             (Tool length comp, approach Z)
M03 S3000               (Spindle on CW at 3000 RPM)
G01 Z-0.050 F20.0       (Feed down to depth of cut)
G01 X6.0                (Feed across workpiece)
G00 Z1.0                (Rapid retract)
M05                     (Spindle stop)
G28 G91 Z0              (Return home Z)
M30                     (End program)

Peck Drilling

G90 G54 G00 X1.0 Y1.0   (Position over hole)
G43 H2 Z1.0             (Tool length comp)
M03 S2500               (Spindle on)
G83 X1.0 Y1.0 Z-1.0 R0.1 Q0.15 F5.0
                         (Peck drill: 0.15" pecks to -1.0" depth)
G80                     (Cancel canned cycle)
G00 Z1.0                (Retract)
M05
M30

Circular Interpolation (Arc)

G90 G54 G17              (Absolute, WCS 1, XY plane)
G00 X0 Y-0.5             (Rapid to arc start)
G43 H3 Z0.1
M03 S4000
G01 Z-0.125 F15.0        (Feed to depth)
G02 X0 Y-0.5 I0 J0.5 F12.0
                          (Full circle CW, center at 0, 0)
G00 Z1.0
M05
M30

Lathe-Specific G-Codes

CodeDescription
G70Finish cycle
G71Rough turning cycle
G72Rough facing cycle
G73Pattern repeat cycle
G74Peck drilling cycle (Z-axis)
G75Grooving cycle (X-axis)
G76Threading cycle (multi-pass)
G92Threading cycle (single pass)
G96Constant surface speed (CSS)
G97Direct RPM mode