Common G-Codes
& M-Codes

 

Regardless of manufacturer, control, software, or off-line (CAM) programming system, nearly all CNC machines use preparatory (G) and miscellaneous function (M) codes, and a combination of defining parameters, to execute the operations required to produce parts.  Most G codes direct the motion of the machine in some manner, while M codes control anciallary functions such as spindle on / off, coolant on / off, tool changes, etc.  It is not essential for the engineering student to memorize these commands, as you would expect of the machinist or CNC programmer, but listing the more commonly used codes here, will allow an engineer, utilizing a CAM software package off-line, to understand the relationship to the executed machine codes.

 

Common (Mill & Lathe) G-Codes

                        Feed Move Group

*G00   Rapid linear move. [X,Y,Z] Moves the machine at the fastest rate possible to the X,Y,Z location specified

*G01   Linear feed move [X,Y,Z,F] Moves the machine a the specified feed rate (F) to the X,Y,Z location specified

*G02   Circular feed move; CW [X,Y,Z,F,R (or I,J,K)] Moves the machine, in a clockwise circular path to the X,Y,Z, location specified with radius R, or with a center point defined relative to the start point in the X,Y,& Z axis by I, J,& K respectively.

*G03   Circular feed move; CCW [X,Y,Z,F,R (or I,J,K)] Same as G02, but opposite direction of movement.

_________________________________

 

  G04   Dwell  (P) Causes the machine to pause for a period determined by parameter P.  If P<value> has a decimal point, the dwell is  x.x seconds; otherwise dwell is in milliseconds.

 

  G28   Return to machine home.  Causes the machine to return to it’s X0,Y0,Z0 position at a rapid rate.

 

_________________________________

                        Coordinate System Group

*G53   Machine coordinate system (MCS). Cancels G-54 thru G59

*G54-G59 Work coordinate offsets.  Allows the user to establish one or more alternative coordinate systems to correspond to individual work coordinate systems (WCS)

_________________________________

                       

                        Units Group

*G70   Inch Programming (This facility uses inch programming unless otherwise stated)

*G71   Metric Programming

_________________________________

 

                        Common Canned Cycles (See Canned Cycles Page)

  G80   Cancel all canned cycles

  G81   Basic drill cycle

  G83   Peck drilling cycle

  G84   R.H. tapping cycle

  G85   Basic boring cycle

  G86   Boring cycle, spindle stop at bottom, rapid out

_________________________________

 

                        Absolute / Incremental Mode

*G90   Absolute Programming Mode  All X,Y,Z coordinates determined from a single from a single origin.

*G91   Incremental Programming Mode  Next X,Y,Z, coordinates are determined from current location

 

_________________________________

 

                        Feedrate Mode Selection

*G94   Feedrate input in inches (or millimeters) per minute.  Primarily used on mills

*G95   Feedrate input in inches (or millimeters) per revolution.   Primarily used on lathes

 

 

Common (Mill & Lathe) M-Codes

 

 

  M00   Machine stop  stops the machine, requiring the operator to restart the program to continue.

  M01   Optional stop  stops the machine as above only when the optional stop button has been pressed prior to this command in the program

  M02   Program end  tells the machine control that the program is complete

  M03   Spindle start clockwise (S) at the RPM specified by the S word accompanying the code

  M04   Spindle start counter clockwise as above

  M05   Spindle stop

  M06   Tool change (T) commands to machine to exchange the tool currently in use for the one called by the T word

  M07 / M08 Coolant on  If the machine is equipped with only one coolant system, it is generally commanded by the M08

  M09   Coolant off

  M19   Spindle orientation

  M30   Program stop and rewind to program start

 

_______________________________________

 

Lathe Only G-codes

 

  G33   Thread cutting, constant lead  [      ]

  G34   Thread cutting, increasing lead   [      ]

  G35   Thread cutting, decreasing lead  [     ]

 

  G50   Maximum Spindle RPM for constant surface speed operation

______________________________________

 

                        Lathe specific canned cycles (See Canned Cycles Page)

 

  G73   OD or ID roughing cycle [      ]

  G74   Rough facing cycle [       ]

 

______________________________________

 

Mill Only G-codes