G-Codes and M-Codes

Below are the most common G- and M-codes with their functions called out. The codes highlighted in red are appropriate for use on Sherline CNC machines with the Linux System. We include this list near the end of the instructions that come with your Sherline Linux CNC machine. You can also find a complete list of G-codes on your Sherline Linux computer at Applications>CNC>G-code Quick Reference. These are the G-codes used with our Sherline CNC machines (Click on the links below for more details on the Sherline CNC Packages).

For a list of the G and M-codes used on our Accu-Pro machines with the MASSO control, go to the MASSO G and M-Codes page.


Common G-Codes

g00 rapid positioning
g01 positioning at a given feed rate
g02 circular/helical interpolation (clockwise)
g03 circular/helical interpolation (counterclockwise)
g07 Lathe diameter mode
g08 Lathe radius mode
g04 dwell
g10 coordinate system origin setting
g17 xy plane selection
g18 xz plane selection
g19 yz plane selection
g20 inch system selection
g21 millimeter system selection
g40 cancel cutter diameter compensation
g41 start cutter diameter comp. left
g42 start cutter diameter comp. right
g43 tool length offset (plus)
g49 cancel tool length offset
g53 motion in machine coordinate system
g54 use preset work coordinate system 1
g55 use preset work coordinate system 2
g56 use preset work coordinate system 3
g57 use preset work coordinate system 4
g58 use preset work coordinate system 5
g59 use preset work coordinate system 6
g59.1 use preset work coordinate system 7
g59.2 use preset work coordinate system 8
g59.3 use preset work coordinate system 9
g80 cancel motion mode (includes canned)
g81 drilling canned cycle
g82 drilling with dwell canned cycle
g83 chip-breaking drilling canned cycle
g84 right hand tapping canned cycle
g85 boring, no dwell, feed out canned cycle
g86 boring, spindle stop, rapid out canned
g87 back boring canned cycle
g88 boring, spindle stop, manual out canned
g89 boring, dwell, feed out canned cycle
g90 absolute distance mode
g91 incremental distance mode
g92 offset coordinate systems
g92.2 cancel offset coordinate systems
g93 inverse time feed mode
g94 feed per minute mode
g98 initial level return in canned cycles
g99 “R” level return in canned cycles

A more complete list of G- and M-Codes

For those interested, here is a more complete list of common codes.

G00 Rapid move G0 X# Y# Z# up to eight axes or G0 Z# X#
G01 Feed Rate move G1 X# Y# Z# up to eight axes or G1 Z# X#
G02 Clockwise move
G03 Counter Clockwise move
G04 Dwell time G04 L#
G08 Spline Smoothing On
G09 Exact stop check, Spline Smoothing Off
G10 A linear feed rate controlled move with a decelerated stop
G11 Controlled Decel stop
G28 Return to clearance plane
G33 Threading (Lathe)*
*NOTE: G33 and G33.1 will not work on Sherline CNC mills or lathes because the spindle and the axis are not synchronized.
G35 Bypass error checking on next line
G40 Tool compensation off
G41 Tool compensation to the left
G42 Tool compensation to the right
G43 Tool length compensation – negative direction
G44 Tool length compensation – positive direction
G49 Tool length compensation canceled
G53 Cancel work coordinate offsets
G54-G59 Work coordinate offsets 1 through 6
G61 Spline contouring with buffering mode off
G64 Spline contouring with buffering mode on
G65 Mill out rectangular pocket
G66 Mill out circular pocket
G67 Flycut
G68 Mill out rectangular pocket with radius corners
G70 Inch mode
G71 Millimeter mode
G74 Peck drilling (Lathe) G83 Z# X# R#
G81 Drill cycle G81 X# Y# Z# R#
G82 Dwell cycle G82 X# Y# Z# R#
G83 Peck cycle G83 X# Y# Z# R#
G84 Tapping cycle G84 X# Y# Z# R# C#
G85 Boring cycle 1 G85 X# Y# Z# R#
G86 Boring cycle 2 G86 X# Y# Z# R#
G88 Boring cycle 3 G88 X# Y# Z# R#
G89 Boring cycle 4 G89 X# Y# Z# R#
G90 Absolute mode
G91 Incremental mode
G92 Home coordinate reset G92 X# Y# Z#
G94 IPM mode (Lathe) default
G95 IPR mode (Lathe)
G96 Constant Surface Feed On (Lathe)
G97 Constant Surface Feed Off (Lathe)

Common M-Codes

Default M-codes are used on most machine types. User customizable M codes will change based on application and user definition.

M00 Program Stop
M01 Program Optional Stop
M02 End the Program
M03 Spindle On Clockwise, Laser, Flame, Power ON
M04 Spindle On Counter Clockwise
M05 Spindle Stop, Laser, Flame, Power OFF
M06 Tool Change
M08 Coolant On
M09 Coolant Off
M10 Reserved for tool height offset
M13 Spindle On, Coolant On
M30 End the Program when macros are used
M91 Readout Display Incremental
M92 Readout Display Absolute
M97 Go to or jump to line number
M98 Jump to macro or subroutine
M99 Return from macro or subroutine
M100 Machine Zero Reset
M199 Mid program start