You are on page 1of 4

CNC CODE FORMAT IN ISO / EIA / WORD-ADDRESS FORMAT

A profile cutting application will typically require 4 basic motion codes viz. r
apid motion along a line in idle mode - G00, cutting motion along a line - G01,
cutting motion along a clockwise arc - G02 and cutting motion along an anticlock
wise arc - G03.
These 4 codes are fairly universal, though some controllers represent them as G0
, G1, G2 and G3 respectively, without using the middle "0". Also, some controlle
rs refer to the letter "R" at the end of "G01" code to denote rapid motion, inst
ead of supporting a separate "G00" code. Some other controllers follow another d
ifferent style, using codes like G11/G12/G13 (relative mode, described below) or
G21/G22/G23 (absolute mode, described below) or G31/G32/G33 (absolute mode with
decimal shift, described below) for line/arc motions, with letter "R" denoting
rapid motion. Still, by and large, most controllers use G00-G03 codes for line/a
rc movements.
For all the above mentioned codes, the user must specify the X and Y coordinates
of the endpoint, where the cutter is supposed to go at the end of this motion.
In case of G00/G01, X & Y refer to the endpoint of the line. In case of G02/G03,
X & Y refer to the endpoint of the arc. In case of an arc, one must also specif
y I & J values, to denote the coordinates of the centre of the arc.
Note, there is no need to specify the start point of the line / arc in the motio
n codes. The end point of the previous line / arc becomes the start point of the
next line / arc and hence, the controller already knows the start point of the
line / arc. For the very first cutter movement, the neutral position (also calle
d home position) of the cutter becomes the start point. In general, the cutting
machine operator brings the cutter at a specific location (usually, one of the f
our corners of a rectangular stock) before starting any cutting operation and th
is point is called the neutral position.
The coordinates are written either in mm or inch and this is indicated at the st
art of the program. Generally, G71 (or, G21 in some cases) indicates coordinates
in mm and G70 (or, G20 in some cases) indicates coordinates in inch. Some contr
ollers may not offer this flexibility and may always require the codes in specif
ic units only. Normally, the default unit is mm.
Some controllers follow strict specifications regarding the number of digits to
be specified after the decimal point while writing X/Y/I/J values. Normally, 1-2
digits after the decimal point are found acceptable to most controllers.
The above-mentioned coordinates can be specified in one of the two modes viz. re
lative (incremental) or absolute. In relative mode, all the coordinates are writ
ten with respect the start point of the current entity. In absolute mode, all th
e coordinates are written with respect to fixed origin i.e. (0,0). This classifi
cation is found universally in all controllers while specifying X & Y values. It
is also true for I & J values in relative mode. However, in absolute mode, some
controllers interpret I/J as absolute values whereas some other controllers int
erpret I/J as relative values. The codes for relative and absolute mode are G91
and G90 respectively, for most controllers. These codes are written at the top o
f the program and usually, the programming mode is not altered later on. The def
ault mode is usually relative.
It is not always necessary to write all X/Y/I/J values for each line/arc motion.
In relative mode, one may skip that value which is equal to zero. In absolute m
ode, one may skip that value which does not change. For instance, while writing
a horizontal line, one need not specify the Y value in relative as well as absol
ute mode. While specifying a full circle in relative mode, only I & J values are
required. (In fact, one may also omit I/J value, if the X/Y coordinate of the c
entre of the circle is same as that of the start point.) While the rules for ski
pping X/Y/I/J values are same for almost all controllers, rules for skipping may
differ in absolute mode, for certain controllers. (In absolute mode, some contr
ollers allow skipping if the value remains same, whereas some others allow skipp
ing if the value is zero.)
The codes may be specified in certain controllers insist on inserting the "+" si
gn in front of all the positive values of X/Y/I/J fields. However, in general, o
ne may omit the "+" sign while writing non-negative X/Y/I/J values for most cont
rollers.
Many controllers allow the use of decimal shift or fixed format facility. Here,
all the X/Y/I/J values are multiplied by 10 and there is no decimal point (".")
to be found in the entire code. The code for indicating decimal shift differs ac
ross controllers.
In general, G00-G03 codes are modal i.e. you have to specify them only when the
type of motion changes. For example, for specifying a rectangle using four strai
ght lines, it is sufficient to specify G01 code in the first statement only. For
the next 3 statements, one may specify the X/Y values only, without writing the
G01 code.
Each cutting machine has a transverse axis and a rail axis. The rail axis is usu
ally bigger, offering longer cutting length as compared to the transverse axis.
It is necessary to know how +X and +Y axes are located along the transverse and
rail axes, before loading a cnc code file on the cutting machine, because the X-
Y axes assumed by the cnc code file may not match with the machine X-Y axes. If
there is a mismatch, the codes in the cnc file may have to be rotated by either
90, 180 or 270 degrees at the time of cnc code generation itself. Most cad/cam p
ost processors allow the axes rotation facility at the time of cnc code generati
on.
Before starting a cutting operation, the operator has to set the neutral positio
n of the cutter manually to one of the 4 corners of the stock. Closer the neutra
l position to him, the better. It is necessary that the cnc program generated by
the cad/cam software uses this neutral point as the origin i.e. (0,0). Most cad
/cam software support options for setting the default neutral position as well a
s editing the coordinates of the neutral position anytime before generating cnc
codes. However, the location of the neutral position changes if the codes are ro
ated by 90/180/270 degrees for X-Y axis alignment, as discussed above. In other
words, the default angle of X-Y axes as well as default neutral position are rel
ated and must be defined carefully. This is usually a one-time activity for each
cutting machine. (However, while cutting offcuts, it may be necessary to define
neutral position manually at a non-standard location and the operator may have
to be informed about its location, before cutting an offcut stock.)
The above description is related to the movement of the cutter along a 2-D profi
le. However, in a cnc code file, one may also come across additional codes, as e
xplained below.
Most controllers support built-in facility for offsetting a 2-D profile. These c
ontrollers can receive the actual profile dimensions from the cnc code file, off
set the same by cutter radius and automatically generate the path to be traced b
y the centre of the cutter. In such cases, the cnc code file must specify the cu
tter compensation direction i.e. whether the cutter is located on the left side
of the profile or on the right side. Generally, the direction of tool compensati
on is specified at the beginning of a cutting cycle and is not altered until the
end of that cutting cycle is reached. In general, the left/right compensation d
irection may be different for different cutting cycles. (Note, the kerf value i.
e. the cutter diameter is usually entered by the operator on the cnc control pan
el at the start of the cutting process and hence, need not be specified for each
profile.) Normally, the cutter compensation is kept off during the non-cutting
phase and the code for that is G40. The code for left compensation is G41 and th
at for right compensation is G42. These codes are fairly universal, except for s
ome controllers where M69/M67/M68 are used for indicating zero, left and right k
erf compensations. (Note, certain controllers do not have the built-in offset fa
cility and in such cases, the cad/cam software must calculate and write the path
traced by the centre of the cutting tool in the cnc code file. Though it is not
recommended, it becomes a necessity for certain controllers.)
In most 2-D cutting applications, one must specify torch on / off commands in th
e cnc file at the beginning / end of a cutting cycle, using the relevant M-codes
. These codes differ vastly across different controllers and they can be found o
nly from the relevant controller manuals.
Some controllers require dwell to be specified at the beginning of a cutting cyc
le. Usually, the dwell is specified using G04 code. The dwell time may either be
programmed by the operator on the control panel or within the cnc code file, as
required.
Some controllers require feed (cutting speed) to be specified in the cnc code fi
le. This is usually done at the start of the program. Howver, some controllers m
ay also require feed value for every line/arc to be cut. Normally, feed is speci
fied using F-code and is written in mm per minute.
Some controllers require toolsize (kerf value i.e. flame diameter) at the beginn
ing or the end of the cnc code file. The toolsize is usually specified using T-c
ode, in mm.
Most controllers support comment lines within cnc code file, which are ignored b
y the controller. Some controllers allow comments to be written within round bra
ckets "()", whereas others treat the entire statement following characters ";" o
r "#" as a comment line.
Many controllers support line numbers which appear at the start of a new stateme
nt in a cnc code file. The line numbers usually start with character N. Some con
trollers follow strict specification regarding the length of the line number, th
ough 4 digits after N are usually acceptable to most controllers.
Most controllers can handle and ignore white spaces (space & tab characters) wit
hin a cnc code file. Some controllers follow strict specification regarding the
white spaces, which can be found from the relevant controller manual.
In general, each controller requires a specific set of statements at the beginni
ng and at the end of a cnc code file. Normally, a cnc code file begins with % si
gn. The code M02 or M30 is used to denote the end of the program, usually follow
ed by a % sign in the last line. However, that is not mandatory for all controll
ers.
Some controllers require program name to be written at the top of the cnc code f
ile. Some controllers follow strict specification regarding the format/compositi
on of program name. Wherever required, program name is written immediately after
the % symbol at the top of the cnc file and is usually restricted to maximum 8
characters.
Some controllers require the name of the cnc code file in a specific format, wit
h specified extension, like CNC or NC. This can be found from the relevant contr
oller manual.
Finally, the sequence in which the above codes appear in a cnc code file differs
across controllers as well as across users. This is usually true at the start/e
nd of a cutting cycle as well as start/end of the entire program. Study of the s
ample cnc code files sent by the user usually reveal the programming style that
would be found acceptable at the customer's end.

You might also like