You are on page 1of 7

N Sequence Number

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.

Commonly used G Codes

 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

 G03 - Circular Interpolation counter-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. G03X2.625Y3.I2.625J2.5312F20

G00-G99

These codes are not completely standardized

 G00 - Rapid traverse positioning.


 G01 - Linear tool motion at a specified feed rate.
 G02 - Circular tool motion in a clockwise direction.
 G03 - Circular tool motion in a counterclockwise direction.
 G04 - A temporary dwell, or delay in tool motion.
 G05 - A permanent hold, or stopping of tool motion. It is canceled by the machine
operator.
 G08 - Smooth acceleration up to the specified feed rate while other machine functions are
occuring (before the tool contacts the workpiece).
 G09 - An exact stop of one tool motion before the machine goes on to the next.
(Nonmodal.)
 G17 - Selection of the X-Y plane (on machining centers).
 G18 - Selection of the X-Z plane (on machining centers).
 G19 - Selection of the Y-Z plane (on machining centers).
 G20 - Inch data input (on foreign-made machines).
 G21 - Metric data input (on foreign-made machines).
 G22 - Activation of the stored axis travel limits, which are used to establish a safety
boundary.
 G23 - Deactivation of the stored axis travel limits.
 G27 - Return to the machine home position via a programmed intermediate point (a point
somewhere between the current location of the tool and the machine home position). The
machine's control will automatically calculate the distance to home position once the tool
has reached this intermediate location.
 G28 - Return to the machine home position via a programmed intermediate point (a point
somewhere between the current location of the tool and the machine home position). The
machine's control will automatically cualculate the distance to home position once the
tool has reached this intermediate location.
 G29 - Return to the workpiece or fixture from the machine home positon via the
intermediate point that was programmmed in the block containing G28. Any new or old
point on the workpiece of fixture can be programmed, but the tool will first travel to the
intermediate point before going there.
 G32, G33 - Thread cutting with a constant lead. If multiple-pass single-point threading is
done, this command will synchronize the start of each pass at exactly the same point
every time so as to avoid the chance of double-threading the workpiece.
 G34 - Thread cutting with an increasing lead.
 G35 - Thread cutting with a decreasing lead.
 G40 - Cancellation of any previously programmed tool radius compensation (better
known as cutter radius compensation, or CRC).
 G41 - Application of cutter radius compensation to the left of the workpiece with respect
to the direction of tool travel. This feature allows the finished surface of the workpiece to
be the programmed cutter path, and the tool will automatically be offset to the left of this
path by a distance equal to its radius. On a machining center, G41 is used in climb
milling.
 G42 - Application of cutter radius compensation to the right of the workpiece with
respect to the direction of tool travel. On a machining center, G42 is used in conventional
milling.
 G43 - Activation of tool length compensation in the same direction of the offset value (as
it is stored in the control's memory). If the dimension stored in the offset register has a
negative value, the tool length compensation will be applied in the negative axis
direction. If the dimension stored in the offset register has a positive value, the tool length
compensation will be applied in the positive axis direction.
 G44 - Activation of tool length compensation in the opposite direction of the offset value
(as it is stored in the control's memory). If the dimension stored in the offset register has a
negative value the tool length compensation will be applied in the positive axis direction.
If the dimension stored in the offset register has a positive value the tool length
compensation will be applied in the negative axis direction.
 G50 - Establishment of the zero point (absolute zero) in reference to the current tool
positon. This command is commonly used on foreigh-made CNC lathes in place of G92.
 G53 - Indication that all positioning data is that block is in reference to the machine home
positon. It caused the control to temporarily ignore the floating zero position. (Used in
absolute programming.)
 G54, G55, G56, G57 - Indication that all positioning data is in reference to the floating
zero position on a particular fixture in a machining operation. For example, G54 would
cause all dimensions to refer to the floating zero on the first fixture, G55 would cause all
dimensions to refer to the floating zero on the second fixture, and so on. (Used in
absolute programming)
 G59 - Repositioning of the floating zero. The new location is programmed incrementally
from the current zero positon.
 G60 - An exact stop of one tool motion before the machine goes on to the next. (Modal)
 G63 - Cancellation of feed-rate override. Used on tapping and threading operations (in
inch-per-minute programmming) where the programmed feed rate must be maintained in
relation to the spindle speed.
 G64 - Cancellation of G60. Allows a slight overlap of the different tool motions so that a
smooth blending of contoured surfaces will result. When G60 is used, a dwell mark will
be left by the tool at the intersection of motions.
 G70 - Inch data input (on American-made machines).
 G70 - Canned cycle for finish turning on a lathe (foreign-made).
 G71 - Metric data input (on American-made machines).
 G71 - Canned cycle for multiple-pass turning on a lathe (foreign-made).
 G72 - Canned cycle for multiple-pass facing on a lathe (foreign-made).
 G73 - Canned cycle for multiple-pass pattern repeat on a lathe (foreign-made).
 G74 - Canned cycle for pecking in the Z axis on a lathe (foreign-made).
 G75 - Canned cycle for pecking in the X axis on a lathe (foreign-made).
 G76 - Canned cycle for multiple-pass single-point threading on a lathe (foreign-made).
 G80 - Cancellation of canned cycles on a machining center.
 G81 - Canned cycle for basic drilling on a machining center. Causes automatic feed in,
and rapid out.
 G82 - Canned cycle for drilling with a dwell on a machining center. Causes automatic
feed in, dwell at the bottom, and rapid out.
 G83 - Canned cycle for peck drilling on a machining center. Causes feed in in multiple
pecks and rapid out.
 G84 - Canned cycle for basic tapping on a machining center. Causes automatic feed in,
reversal of spindle rotation, and feed out.
 G85 - Canned cycle for basic boring on a machining center. Causes automatic feed in and
feed out.
 G86 - Canned cycle for alternate boring on a machining center. Causes automatic feed in,
stopping of spindle rotation, and rapid out.
 G87 - Canned cycle for alternate boring on a machining center. Causes automatic feed in
and stopping of spindle rotation. The machine operator then manually retracts the tool
from the hole.
 G88 - Canned cycle for alternate boring on a machining center. Causes automatic feed in,
dwell at the bottom, and stopping of spindle rotation. The machine operator then
manually retracts the tool from the hole.
 G89 - Canned cycle for alternate boring on a machining center. Causes automatic feed in,
dwell at the bottom, and feed out.
 G90 - Absolute positioning. All positioning data will be in reference to the current zero
point (also called the absolute zero). (Modal)
 G90 - Canned cycle for single-pass turing on a lathe (foreign-made).
 G91 - Incremental positioning. All positioning date will be in reference to the current tool
location. (Modal)
 G92 - Establishes the zero point (absolute zero) in reference to the current tool position.
 G92 - Canned cycle for single-pass threading on lathe (foreign-made).
 G94 - Inch-per-minute programming. The programmed feed rate will be in inches per
minute. G
 95 - Inch-per-revolution programming. The programmed feed rate will be in inches per
revolution of the spindle.
 G96 - Constant-surface-speed programming. As the diameter turned on a lathe becomes
smaller, the spindle speed will increase to maintain the programmed surface speed.
Inversely, as the diameter turned on a lathe becomes larger, the spindle speed will
decrease.
 G97 - Revolutions-per-minute programming. The spindle speed will be maintained at the
same RPM , no matter what diameter is being turned on the lathe.
 G98 - Inch-per-minute programming. The programmed feed rate will be in inches per
minute (on foreign-made machines).
 G99 - Indication that all positioning data in that block is in reference to the machine
home position. It causes the control to temporarily ignore the floating zero position
(G92). This command is similar to G53. (Used on some American-made machines.)
 G99 - Inch-per-revolution programming. The programmed feed rate will be in inches per
revolution of the spindle (on foreign-made machines).

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.

Commonly used M codes

 M02 - Program end


 M03 - Start of spindle rotation clockwise
 M04 - Start of spindle rotation counterclockwise
 M07 - Start of mist coolant
 M08 - Start of flood coolant
M00-M99

 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.

You might also like