Reference Basic G and M Codes PDF
Reference Basic G and M Codes PDF
URL: https://www.cnccookbook.com/g-code-m-code-reference-list-cnc-mills/
or users machine manufacturers website for full list
G01 The most common workhorse code for feeding during a cut. The
program specs the start and end points, and the control automatically
calculates (interpolates) the intermediate points to pass through that
yield a straight line (hence "linear"). The control then calculates the
Linear interpolation angular velocities at which to turn the axis leadscrews via their
servomotors or stepper motors. The computer performs thousands of
calculations per second, and the motors react quickly to each input.
Thus the actual toolpath of the machining takes place with the given
feedrate on a path that is accurately linear to within very small limits.
G04 Takes an address for dwell period (may be X, U, or P). The dwell
period is specified by a control parameter, typically set to milliseconds.
Some machines can accept either X1.0 (s) or P1000 (ms), which are
equivalent. Choosing dwell duration: Often the dwell needs only to
last one or two full spindle rotations. This is typically much less than
Dwell
one second. Be aware when choosing a duration value that a long
dwell is a waste of cycle time. In some situations it won't matter, but for
high-volume repetitive production (over thousands of cycles), it is worth
calculating that perhaps you only need 100 ms, and you can call it 200
to be safe, but 1000 is just a waste (too long).
G20 Somewhat uncommon except in USA and (to lesser extent) Canada
and UK. However, in the global marketplace, competence with both
G20 and G21 always stands some chance of being necessary at any
time. The usual minimum increment in G20 is one ten-thousandth of an
Programming in inches
inch (0.0001"), which is a larger distance than the usual minimum
increment in G21 (one thousandth of a millimeter, .001 mm, that is,
one micrometre). This physical difference sometimes favors G21
programming.
G52 Temporarily shifts program zero to a new location. It is simply "an offset
from an offset", that is, an additional offset added onto the WCS offset.
This simplifies programming in some cases. The typical example is
moving from part to part in a multipart setup. With G54 active, G52
Local coordinate system
X140.0 Y170.0 shifts program zero 140 mm over in X and 170 mm over
(LCS)
in Y. When the part "over there" is done, G52 X0 Y0 returns program
zero to normal G54 (by reducing G52 offset to nothing). The same
result can also be achieved (1) using multiple WCS origins,
G54/G55/G56/G57/G58/G59; (2) on newer controls, G54.1
P1/P2/P3/etc. (all the way up to P48); or (3) using G10 for
programmable data input, in which the program can write new offset
values to the offset registers.[8] The method to use depends on shop-
specific application.
G53 Takes absolute coordinates (X,Y,Z,A,B,C) with reference to machine
Machine coordinate zero rather than program zero. Can be helpful for tool changes.
system Nonmodal and absolute only. Subsequent blocks are interpreted as
"back to G54" even if it is not explicitly programmed.
G54 to G59 Have largely replaced position register (G50 and G92). Each tuple of
Work coordinate axis offsets relates program zero directly to machine zero. Standard is
systems (WCSs) 6 tuples (G54 to G59), with optional extensibility to 48 more via G54.1
P1 to P48.
G90 Positioning defined with reference to part zero.
Milling: Always as above.
Turning: Sometimes as above (Fanuc group type B and similarly
designed), but on most lathes (Fanuc group type A and similarly
Absolute programming
designed), G90/G91 are not used for absolute/incremental modes.
Instead, U and W are the incremental addresses and X and Z are the
absolute addresses. On these lathes, G90 is instead a fixed cycle
address for roughing.
G90 Fixed cycle, simple
cycle, for roughing (Z- When not serving for absolute programming (above)
axis emphasis)
G91 Positioning defined with reference to previous position.
Milling: Always as above.
Turning: Sometimes as above (Fanuc group type B and similarly
Incremental designed), but on most lathes (Fanuc group type A and similarly
programming designed), G90/G91 are not used for absolute/incremental modes.
Instead, U and W are the incremental addresses and X and Z are the
absolute addresses. On these lathes, G90 is a fixed cycle address for
roughing.
M01 Optional stop Machine only stops at M01 if operator pushes the optional stop button.
M02 Program ends; execution may or may not return to program top (depending
on the control); may or may not reset register values. M02 was the original
program-end code, now considered obsolete, but still supported for
End of program
backward compatibility.[10] Many modern controls treat M02 as equivalent
to M30.[10] See M30 for additional discussion of control status upon executing
M02 or M30.
M04 Spindle on
(counterclockwise See comment above at M03.
rotation)
M05 Spindle stop
M06 Many lathes do not use M06 because the T address itself indexes the turret.
Programming on any particular machine tool requires knowing which method
Automatic tool that machine uses. To understand how the T address works and how it
change (ATC) interacts (or not) with M06, one must study the various methods, such as
lathe turret programming, ATC fixed tool selection, ATC random memory tool
selection, the concept of "next tool waiting", and empty tools.[5]
M07 Coolant on (mist)
M08 Coolant on (flood)
M09 Coolant off
M13 Spindle on (clockwise This one M-code does the work of both M03 and M08. It is not unusual for
rotation) and coolant specific machine models to have such combined commands, which make for
on (flood) shorter, more quickly written programs.
M19 Spindle orientation is more often called within cycles (automatically) or
during setup (manually), but it is also available under program control
via M19. The abbreviation OSS (oriented spindle stop) may be seen in
reference to an oriented stop within cycles.
The relevance of spindle orientation has increased as technology has
advanced. Although 4- and 5-axis contour milling and CNC single-
pointing have depended on spindle position encoders for decades, before
the advent of widespread live tooling and mill-turn/turn-mill systems, it was
not as often relevant in "regular" (non-"special") machining for the operator
(as opposed to the machine) to know the angular orientation of a spindle as
Spindle orientation
it is today, except in certain contexts (such as tool change, or G76 fine
boring cycles with choreographed tool retraction). Most milling of features
indexed around a turned workpiece was accomplished with separate
operations on indexing head setups; in a sense, indexing heads were
originally invented as separate pieces of equipment, to be used in separate
operations, which could provide precise spindle orientation in a world where
it otherwise mostly didn't exist (and didn't need to). But as CAD/CAM and
multiaxis CNC machining with multiple rotary-cutter axes becomes the norm,
even for "regular" (non-"special") applications, machinists now frequently
care about stepping just about any spindle through its 360° with precision.
M30 Today, M30 is considered the standard program-end code, and returns
execution to the top of the program. Most controls also still support the
original program-end code, M02, usually by treating it as equivalent to
M30. Additional info: Compare M02 with M30. First, M02 was created, in
the days when the punched tape was expected to be short enough to splice
End of program, with
into a continuous loop (which is why on old controls, M02 triggered no tape
return to program top
rewinding).[10] The other program-end code, M30, was added later to
accommodate longer punched tapes, which were wound on a reel and thus
needed rewinding before another cycle could start.[10]On many newer
controls, there is no longer a difference in how the codes are executed—
both act like M30.
M104 Set Extruder Head
Sets the extruder Head Temperature
Temperature
M108 Extruder Speed
M109 Build Plate
Sets the Build Plate Temperature if the machine has a heated build plate
Temperature