G & M Codes

Today there are a lot of CNC controls. Some of the best known are Fanuc, Siemens, Okuma and Heidenhain. In addition to the controls mentioned, there are many others. Common to all these controls is that they are built around codes consisting of a letter and some numbers. See below a G and M code list for a Fanuc and a Siemens controls and their functions. A number of these commands are ISO designations and will be found on other types of controls.

Preparatory codes


Fanuc G codesSiemens G codes

G00: Rapid Moves
G01: Linear Interpolation
G02: Circular Interpolation CW
G03: Circular Interpolation CCW
G04: Dwell time in secs
G17 - XY Plan
G18 - XZ plan G19 - YZ plan
G28: Rapid to machine zero point
G40: Cancel Radius Compensation
G41: Radius Compensation Left
G42: Radius Compensation Right
G43: Length Compensation
G54: Work Shift 1
G55: Work Shift 2
G56: Work Shift 3
G57: Work Shift 4
G58: Work Shift 5
G59: Work Shift 6
G80: Cancel Cycle Call
G81: Drilling Cycle
G84: Tapping Cycle
G90: Absolute Coordinates
G91: Incremental Coordinates

G00: Rapid Moves
G01: Linear Interpolation
G02: Circular Interpolation CW
G03: Circular Interpolation CCW G04: Dwell time in secs
G09: Path speed control
G17: XY plan
G18: XZ plan G19: YZ plan
G40: Cancel Radius Compensation
G41: Radius Compensation Left
G42: Radius Compensation Right
G53: Coordinated ref to M/C Zero
G54: Work Shift 1
G55: Work Shift 2
G56: Work Shift 3
G57: Work Shift 4
G58: Work Shift 5
G59: Work Shift 6
G60: Position before next Block
G64: Continuous Path Control
G70: Program is in Inches
G71: Program is in MM
G90: Absolute Coordinates
G91: Incremental Coordinates

Example of a CNC program for a Fanuc control

O1000 Program Number
N10 G40 G80Reset Radius Compensation, End Cycle, for safety
N20 G28 G91 Z0Return to Safe Position for Tool Change
N30 T02 M06 (50mm End Mill.)Tool Change to Tool Number 2
N40 G90 G54 S1000 F500 M03Set Absolute Coordinates, Call Work Shift, Set Spindle Speed, Set Feed, Start Spindle Forward
N50 G00 G43 H02 Z100Set Rapid, Call Length compensation from offset table for Tool 2, move to position Z100 above Z programming g zero.
N60 G00 X-30 Y-30 Z5Rapid movement in X, Y and Z.
N70 G01 Z-5Linear motion in Z.
N80 G41 D22 X10 Y10Linear movement and apply Radius compensation (D value = 25 from offset table)
N90 Y90Linear motion in Y.
N100 X90Linear motion in X.
N110 Y10Linear motion in Y.
N120 X10Linear motion in X.
N130 G00 X-30 Y-30 G40Rapid movement in X and Y, Cancel Radius Compensation
N140 G28 G91 Z0Rapid Return to Safe Position
N150 M30Program Stop and Reset