Professional Documents
Culture Documents
G Preparatory Functions
X X Axis Command
Y Y Axis Command
Z Z Axis Command
R Radius from specified center
A Angle ccw from +X vector
I X axis arc center offset
J Y axis arc center offset
K Z axis arc center offset
F Feedrate
S Spindle speed
T Tool number
M Miscellaneous function
Sequence Numbers
Sequence number, also called N code, is the block (line) identification number in a CNC
program. The common code word used begins with N. N is the first code in a block and
normally has a range of N1 through N9999. Many CNCs do not require the use of N
codes which helps to free system memory. Their main benefits are to allow for easy
searches in long programs and the ability to easily restart a program at almost any line
number. Usually the programmer will skip N numbers between blocks to leave space to
insert forgotten or additional blocks later on. For example N5, N10, N15, etc..
Preparatory Functions
Preparatory functions are G codes. G codes are designated by the letter G and a two digit
numeric value. These codes are the most important functions in CNC programming
because they direct the CNC system to process the coordinate data in a particular manner.
Some examples are rapid traverse, circular interpolation, linear interpolation, and drilling.
G codes are somewhat standardized in industry.
G00 - The Rapid traverse code is used to move the axes quickly between cuts,
tool changes etc. Speeds of 200 IPM (inches per minute) or more are not
uncommon.
ex. G00X0Y-.25
G01 - Linear interpolation is used to clear out material by moving the axes in
straight directions along or thru the stock. Spindle speed, spindle start, and
feedrate must be specified ,for cutting, before executing this code.
ex. G01x3.125Y0F20
G02 - Circular Interpolation clockwise is used to clear out material by moving the
axes in circular directions along or thru the stock. Spindle speed, spindle start, and
feedrate must be specified, for cutting, before executing this code.
ex. G02X.375Y3.I.375J2.5312F20
ex. G03X2.625Y3.I2.625J2.5312F20
G00-G99
Miscellaneous Functions
The M code is used for miscellaneous functions such as coolant on-off, spindle on-off
and direction, tape rewind, and program end. M codes range from M00 through M99. M
codes are assigned by the machine builder, but some standardization does exist.
M00 - Program stop. All spindle rotation, tool motion, and coolant flow is shut off.
M01 - Optional program stop. All spindle rotation, tool motion, and coolant flow is shut
off only if the operator had already activated the "optional stop" switch on the MCU.
M02 - Program stop and rewind. All spindle rotation, tool motion, and coolant flow is
shut off, and the control prepares to start reading the beginning of the program again (the
program rewind may not occur on some machines). All of the machine's functions
(preparatory, miscellaneous, etc. ) will reset to their default state (the condition that the
machine is in when it is first turned on).
M03 - Start of spindle rotation is a clockwise direction, looking out from the spindle face.
M04 - Start of spindle rotation is a counterclockwise direction, looking out from the
spindle face.
M05 - Stopping of spindle rotation.
M06 - Change to the next tool in line. This command is used on machines with sequential
tool changers, where the tools are mounted on the turret or tool changer in the order of
their use.
M07 - Mist coolant turned on.
M08 - Flood coolant turned on.
M09 - Coolant turned off.
M10 - Activation of automatic clamping (of machine slides, workpiece fixture, spindle,
etc.)
M11 - Deactivation of automatic clamping (of machine slides, workpiece fixtures,
spindle, etc.)
M12 - Indexing the turret to point halfway between one tool station and the next. On
CNC lathes equipped with two turrets, this command causes one turret to allow tool
travel clearance for the other one.
M13 - Spindle rotation started in a clockwise direction and coolant turned on (both at the
same time).
M14 - Spindle rotation started in a "counterclockwise" direction and coolant turned on
(both at the same time).
M19 - Spindle rotation stopped at a predetermined (oriented) angular position.
M30 - Program stop and rewind. All spindle rotation, tool motion, and coolant flow is
shut off, and the control prepares to start reading the beginning of the program again. All
of the machine's functions (preparatory, miscellaneous, etc.) will reset to their default
state (the condition that the machine is in when it is first turned on). This code word is
similar to M02. It is used on machines where M02 does not have the program rewind
ability.
M31 - Interlock bypass. It temporarily deactivates a normally provided interlock (restart a
program automatically, stop a program on bar machine lathes when the end of the bar is
sensed. etc.).
M40, M41, M42, M43, M44, M45 - Gear range selection. For example, M40 might cause
the machine to shift into a low gear range, M41 might cause the machine to shift into a
medium or high gear range, and so on.
M98 - Switch from main program to subroutine program.
M99 - Return from subroutine program to main program.
Special Cycles
Special Cycles or Canned Cycles are a preprogrammed sequences of repetitive tool
motion that are built into the control system for common operations such as drilling,
tapping, boring, and pocketing. Its purpose is to reduce the amount of program code that
would normally have to be written. Canned cycles are G codes that are options purchased
with a CNC, but some are standard equipment depending on the manufacturer.
Drilling cycle (G81, G82 or G83) are used to drill multiple holes without programming
each move separately. Using this cycle reduces the amount of code that would normally
have to be written.
Facing cycle (G77) is used to clean up rough stock material (normally on top of the part)
which can be located within a rectangular area. Using this cycle reduces the amount of
code that would normally have to be written.
Rectangular pocket cycle (G78) is used to clear out material which is located within a
rectangular area. Using this cycle reduces the amount of code that would normally have
to be written.
Circular pocket cycle (G79) is used to clear out material which is located within a
circular area. Using this cycle reduces the amount of code that would normally have to be
written.