G and M Codes

There are many CNC controls today, some of the best known are: Fanuc, Siemens, Okuma and Heidenhain. In addition to the mentioned controls, there are many others. Common to all these CNC controls is that they are built around codes that consist of a letter and some numbers. Below is an ISO G and M code list for an Okuma and a Siemens controller, which are the controls this task set refers to. The task set can also be used for most controllers that operate with ISO codes.

Prepatory Codes (G codes)


Okuma ControlSiemens Control

G00 Rapid Traverse
G01 Linear Interpolation
G02 Circular Interpolation CW
G03 Circular Interpolation CCW
G04 Dwell
G40 Radius Comp Off
G41 Radius Comp On Left
G42 Radius Comp On Right
G50 Max Speed rpm
G71 Threading
G73 Grooving Cycle
G74 Drilling Cycle
G75 Automatic Chamfering
G76 Automatisk Radiusing
G77 Tapping RH
G78 Tapping LH
G80 End of Contour Def
G81 Start of Long Contour Def
G82 Start of Trav Contour Def
G85 Rough Turn Cycle Long
G87 Rough Turn Cycle Form
G95 Feed in mm/rev
G96 Constant Surface Speed
G97 Speed in direct rpm

G00 Rapid Traverse
G01 Linear Interpolation
G02 Circular Interpolation CW
G03 Circular Interpolation CCW
G04 Dwell
G09 Complete the block Non-Modal
G17 XY interpolation
G18 XZ interpolation
G19 YZ interpolation
G40 Radius Comp Off
G41 Radius Comp On Left
G42 Radius Comp On Right
G53 Programming to M/C Zero
G54 Zero Offset
G55 Zero Offset
G56 Zero Offset
G57 Zero Offset
G60 Complete the block-Modal
G64 Constant Path
G70 Progamming in inches
G71 Programming in mm
G90 Absolute Programming
G91 Incrementel Programming
G94 tilspænding i millimeter pr. minut
G95 Feed in mm/rev.
G96 Constant Surface Speed
G97 Speed in direct rpm

Program M Codes


Okuma ControlSiemens Control

M00 Program stop
M01 Option stop
M02 Program End
M03 Spindle Start Forward
M04 Spindle Start Reverese
M05 Spindle Stop
M08 Coolant On
M09 Coolant off
M19 Spindle Orientation
M23 Thread Chamnfer on
M32 Thread Infeed Straight
M33 Thread Infeed side to side
M34 Thread Infeed Angle
M73 Gevindmønster 1
M74 Gevindmønster 2
M75 Gevindmønster 3
M85 No Return in G85

M00 Program Stop
M01 Option Stop
M30 Program End, Reset
M03 Spindle Start Forward
M04 Spindle Start Reverese
M05 Spindle Stop
M06 Tool Change
M08 Coolant Start
M09 Coolant stop
M17 Sub Program End

Okuma and Siemens Program Example

The (P1-8) in these programs refer to points in the drawing below.


Okuma Program ExampleOkuma Program Example

N10 G00 X500 Z800
N20 G50 S3000
N30 T010101
N40 G95 G96 S300 F0.2 M03
N50 G00 X0 Z5
N60 G01 Z0 M08 (P1)
N70 X40 (P2)
N80 Z-18.5 (P3)
N90 X70
N100 Z-40 (P4)
N110 X102.5 Z-68.15 (P5)
N120 Z- 95 (P6)
N130 X126 (P7)
N140 Z-115 (P8)
N150 G00 X500 Z800 M09
N160 M02

N10 G00 G95 G96 G90 D0
N20 T01 M06
N30 G00 G54 D1 X0 Z5 S2200 F0.08 M03
N50 G00 X0 Z5
N60 G01 Z0 M08 (P1)
N70 X40 (P2)
N80 Z-18.5 (P3)
N90 X70
N100 Z-40 (P4)
N110 X102.5 Z-68.15 (P5)
N120 Z- 95 (P6)
N130 X126 (P7)
N140 Z-115 (P8)
N150 G00 X280 Z500 D0 M09
N160 T00
N170 M06
N180 M02