SmithyCNC uses the robost EMC2 (Enhanced Machine Control) as the computer
numerical control system for the SmithyCNC EZ-Trol system. While the EZ-Trol
systems allows you to create and import dbx files with its CAD program and
convert the file into G-Code with its CAM System, there may be instances where
the user finds it helpful to review the actual G-Code or the user may find, in
some cases it is quicker and easier to directly enter the G-Code into the EZ-Trol
system.
This Programmer’s Reference Guide is the product of several authors writing for
linuxCNC.org. As you find it to be of value in your work, we invite you to contribute to its revision and growth."
The RS274/NGC, the program language for numerically controlled machines, is
based on lines of code. Each line (also called a "block") may include commands
to a machining center to do several different things. Lines of code may be collected in a file to make a program or run a block at a time in MDI mode.
A typical line of code consists of an optional line number at the beginning followed by one or more "words." A word consists of a letter followed by a number
(or something that evaluates to a number). A word may either give a command
or provide an argument to a command. For example, "G1 X3" is a valid line of
code with two words. "G1" is a command meaning "move in a straight line at
the programmed feed rate", and "X3" provides an argument value (the value of
X should be 3 at the end of the move). Most RS274/NGC commands start with
either G or M (for General and Miscellaneous). The words for these commands
are cal
led "G codes" and "M codes."
The RS274/NGC language does not specify a special code for the start of a pro-
am. When the “Interpreter”, however, deals with files it expects certain pro-
gr
am end codes. These codes include M2, M30, or M60. Whenever the
gr
Interpreter encounters one of these codes it assumes that the current line is the
last line of the program. Lines of a file that occur after the end of a program
code are not to be executed. The interpr
A file may also be demarcated with percents in the following way. The first nonblank l
surrounded by white space, and later in the file (normally at the end of the file)
there may be a similar line. Demarcating a file with percents is optional if the
fi
nal
contents of a file demarcated by percents stop after the second percent line.
Anything after that is ignored.
ine of a file ma
le has an M2 or M30 at the end, but is r
le has a per
f a fi
led i
y contain nothing but a percent sign, "%", possibly
cent line at the beginning but not at the end. The useful
eter does not even read them.
equired if not. An error will be sig-
1-2
SmithyCNC Programmer’s Reference Manual: Language Overview
1.1 Format of a line
A permissible line of input RS274/NGC code consists of the following four parts,
in the order listed.
1. An optional block delete character, which is a slash "/"
.
2. An optional line number.
3. Any number of words, parameter settings, and comments. (up to 256 charac-
ters).
4. An end of line marker (carriage return or line feed or both).
Any input not explicitly allowed is illegal and will cause the Interpreter to signal
an error. There are three additional things that affect all parts of a program.
Spaces and tabs are allowed anywhere on a line of code and do not change the
meaning of the line, except inside comments. This makes some strange-looking
input legal. The line "g0x +0. 12 34y 7"is equivalent to "g0 x+0.1234 y7", f
example.
or
Blank lines are allowed in the input. They are ignored.
Input is case insensitive, except in comments, i.e., any letter outside a comment
may be in upper or lower case without changing the meaning of a line.
1.2 Line Number
A line number is the letter N followed by an integer (with no sign) between 0
and 99999 written with no more than five digits (000009 is not OK, for example). Line numbers may be repeated or used out of order, although normal practice is to avoid such usage. Line numbers may also be skipped, and that is normal pr
the proper place if used.
actice. A l
ine number is not required to be used, but must be in
SmithyCNC Programmer’s Reference Manual: Language Overview
A word is a letter other than N followed by a real value.
Words may begin with any of the letters shown in Table1.1. The table includes
N for completeness, even though, as defined above, line numbers are not
words. Several letters (I, J, K, L, P, R) may have different meanings
in different contexts.
Table 1-1: Words and their meanings
LetterMeaing
AA Axis of machine
BB Axis of machine
CC Axis of machine
DTool Radius compensation number
FFeedrate
GGeneral Function (See Table 1-5)
HTool length offset index
IX offset for arcs and G87 canned cycles
JY offset for arcs and G87 canned cycles
K
MMiscel
NLine Number
P
QFeed increment in G83 canned cycle
RArc radius or canned cycle plane
SSpindle Speed
TTool Selection
XX
YY
ZZ-Axis of machine
Z offset for arcs and G87 canned cycles
Spindle-Motion Ratio f
lanous function (S
Dwell time in canned cycles and with G4.
ey used wi
K
-Axis of machine
Axis of machine
-
th G10.
or G33 synchr
able 1-7)
ee T
onized movements
1-4
SmithyCNC Programmer’s Reference Manual: Language Overview
1.3.1 Number
The following rules are used for (explicit) numbers. In these rules a digit is a single
character between 0 and 9.
* A number consists of (1) an optional plus or minus sign, followed by (2) zero to
many digits, followed, possibly, by (3) one decimal point, followed by (4) zero to
many digits - provided that there is at least one digit somewhere in the number.
* There are two kinds of numbers: integers and decimals. An integer does not have
a decimal point in it; a decimal does.
* Numbers may have any number of digits, subject to the limitation on line length.
Only about seventeen significant figures will be retained, however (enough for all
known applications).
* A non-zero number with no sign as the first character is assumed to be positive.
Notice that initial (before the decimal point and the first non-zero digit) and trailing
(after the decimal point and the last nonrequired. A number written with initial or trailing zeros will have the same value
when it is read as if the extra zeros were not there.
zero digi
t) zeros ar
e allowed but not
Numbers used for specific purposes in RS274/NGC are often restricted to some
finite set of values or some to some range of values. In many uses, decimal num-
or parameters
bers must be close to integers; this includes the values of index
and carousel slot numbers, for example), M codes, and G codes multiplied by ten. A
decimal number which is supposed be close to an integer is considered close
enough i
1.3.2 Parameter Value
A par
must ev
number, and the value of the parameter value is whatever number is stored in the
numbered parameter.
The # character takes precedence over other operations, so that, for example,
"#1+2" means the number f
alue f
v
parameter 3. The # character may be repeated; for example ##2 means the value
of the parameter whose index is the (integer) value of parameter 2.
f it is within 0.0001 of an integer.
lowed b
ameter v
aluate to an integer between 1 and 5399. The integer is a par
ound in parameter 3. Of course, #[1+2] does mean the value found in
alue is the pound char
ound b
acter # f
y adding 2 to the v
ol
y a r
alue of par
es (f
eal value. The real value
ameter
ameter 1, not the
SmithyCNC Programmer’s Reference Manual: Language Overview
An expression is a set of characters starting with a left bracket [ and ending
with a balancing right bracket ]. In between the brackets are numbers, parameter values, mathematical operations, and other expressions. An expression may
be evaluated to produce a number. The expressions on a line are evaluated
when the line is read, before anything on the line is executed. An example of an
expression is [ 1 + acos[0] - [#3 ** [4.0/2]]].
Binary operations appear only inside expressions. There are four basic mathematical operations: addition (+), subtraction (-), multiplication (*), and division
(/). There are three logical operations: non-exclusive or (OR), exclusive or
(XOR), and logical and (AND). The eighth operation is the modulus operation
(MOD). The ninth operation is the "power" operation (**) of raising the number
on the left of the operation to the power on the right. The relational operators
are equality (EQ), inequality (NE), strictly greater than (GT), greater than or
equal to (GE), strictly less than (LT), and less than or equal to (LE).
The binary operations are divided into three groups. The first group is: power.
The second gr
addition, subtraction, logical non-exclusive or, logical exclusive or, and logical
and. If operations are strung together (for example in the expression [2.0 / 31.5
- 5.5 / 11.0]), operations in the first gr
tions in the second group and operations in the second group before operationsin the third group. If an expression contains more than one operation from
the same group (such as the first / and * in the example), the oper
left is performed first. Thus, the example is equivalent to: [((2.0 / 3) * 1.5) (5.5 / 11.0)] , which simplifies to [1.0 - 0.5] , which is 0.5.
The logical operations and modulus are to be performed on any real numbers,
not just on integers. The number zero is equivalent to logical false, and anynonzero number is equivalent to logical true.
1.3.4 Unary Operation Value
A unary operation value is either "ATAN" followed by one expression divided by
another expression (for example "ATAN[2]/[1+3]") or any other unary operation
name followed by an expression (for example "SIN[90]"). The unary operations
e: ABS (absolute v
ar
gent), COS (cosine), EXP (e r
(round up), LN (natural logarithm), ROUND (round to the nearest whole number), SIN (sine), SQRT (square root), and TAN (tangent). Arguments to unary
operations which take angle measures (COS, SIN, and TAN) are in degrees.
oup is: multiplication, division, and modulus. The thir
oup are to be performed bef
alue), ACOS (ar
aised to the giv
c cosine), A
en power), FIX (round down), FUP
SIN (ar
c sine), ATAN (arc tan-
d group is:
ore opera-
ation on the
1-6
SmithyCNC Programmer’s Reference Manual: Language Overview
Values returned by unary operations which return angle measures (ACOS, ASIN,
and ATAN) are also in degrees.
The FIX operation rounds towards the left (less positive or more negative) on a
number line, so that FIX[2.8] =2 and FIX[-2.8] = -3, for example. The FUP
operation rounds towards the right (more positive or less negative) on a number
line; FUP[2.8] = 3 and FUP[-2.8] = -2, for example.
1.4 Parameter Setting
A parameter setting is the following four items one after the other: (1) a pound
character # , (2) a real value which evaluates to an integer between 1 and
5399, (3) an equal sign = , and (4) a real value. For example "#3 = 15" is a
parameter setting meaning "set parameter 3 to 15."
A parameter setting does not take effect until after all parameter values on the
same line have been found. For example, if parameter 3 has been previously set
to 15 and the line "#3=6 G1 x#3" is interpreted, a straight move to a point
where x equals 15 will occur and the value of parameter 3 will be 6.
1.5 Comments and Messages
Printable characters and whi
parenthesis always starts a comment. The comment ends at the first right
parenthesis found thereafter. Once a left parenthesis is placed on a line, a
matching right parenthesis must appear bef
may not be nested; it is an error if a left parenthesis is found after the start of a
comment and before the end of the comment. Here is an example of a line containing a comment: "G80 M5 (stop motion)". Comments do not cause a
machining center to do anything.
A comment contains a message if "MSG," appears after the left parenthesis and
y other printing char
e an
or
bef
space and lower case char
the right parenthesis are considered to be a message. Messages should be displayed on the message display device. Comments not containing messages need
not be displayed there.
A comment can also be used to speci
ee section [sub:G38.2:-
S
te space inside parentheses is a comment. A left
e the end of the line. Comments
or
acters. V
acters ar
Straight-Probe].
ariants of "MSG," which include whi
lowed. The r
e al
y a fi
f
le f
est of the characters before
or the r
esults of G38.2 probing.
te
SmithyCNC Programmer’s Reference Manual: Language Overview
A line may have any number of G words, but two G words from the same modal
group (see Section [sec:Modal-Groups]) may not appear on the same line.
A line may have zero to four M words. Two M words from the same modal
group may not appear on the same line.
For all other legal letters, a line may have only one word beginning with that
letter.
If a parameter setting of the same parameter is repeated on a line, "#3=15
#3=6", for example, only the last setting will take effect. It is silly, but not
illegal, to set the same parameter twice on the same line.
If more than one comment appears on a line, only the last one will be used;
each of the other comments will be read and its format will be checked, but it
will be ignored thereafter. It is expected that putting more than one comment
on a line will be very rare.
1.7 Item order
The three t
ning of this section) are word, parameter setting, and comment. Imagine that
these three types of item are divided into three groups by type.
The first group (the words) may be reordered in any way without changing the
meaning of the line.
If the second group (the parameter settings) is reordered, there will be no
change in the meaning of the line unless the same parameter is set more than
once. In this case, only the last setting of the parameter will take effect. For
example, after the l
ameter 3 wi
par
the line is interpreted, the value of parameter 3 will be 15.
If the third group (the comments) contains more than one comment and is
reordered, only the last comment will be used.
If each gr
line, then the three groups may be interleaved in any way without changing the
meaning of the line. For example, the line "g40 g1 #3=15 (foo) #4=-7.0" has
five items and means exactly the same
ypes of item whose order ma
ine "#3=15 #3=6" has been interpr
l be 6. If the or
l
oup is k
ept in order or reordered without changing the meaning of the
der is reversed to "#3=6 #3=15" and
y vary on a line (as given at the begin-
eted, the v
alue of
1-8
SmithyCNC Programmer’s Reference Manual: Language Overview
thing in any of the 120 possible orders (such as "#4=-7.0 g1 #3=15 g40 (foo)")
for the five items.
1.8 Commands and Machine Modes
In RS274/NGC, many commands cause a machining center to change from one
mode to another, and the mode stays active until some other command changes
it implicitly or explicitly. Such commands are called "modal". For example,
ifcoolant is turned on, it stays on until it is explicitly turned off. The G codes for
motion are also modal. If a G1 (straight move) command is given on one line,
for example, it will be executed again on thenext line if one or more axis words
is available on the line, unless an explicit command is given on that next
line using the axis words or cancelling motion.
"Non-modal" codes have effect only on the lines on which they occur. For example, G4 (dwell) is non-modal.
SmithyCNC Programmer’s Reference Manual: Language Overview
Modal commands are arranged in sets called "modal groups", and only one
member of a modal group may be in force at any given time. In general, a
modal group contains commands for which it is logically impossible for two
members to be in effect at the same time - like measure in inches vs. measure
in millimeters. A machining center may be in many modes at the same time,
with one mode from each modal group being in effect. The modal
groups are shown in Table 1-2.
SmithyCNC Programmer’s Reference Manual: Language Overview
For several modal groups, when a machining center is ready to accept commands, one member of the group must be in effect. There are default settings
for these modal groups. When the machining center is turned on or otherwise
re-initialized, the default values are automatically in effect.
Group 1, the first group on the table, is a group of G codes for motion. One of
these is always in effect. That one is called the current motion mode.
It is an error to put a G-code from group 1 and a G-code from group 0 on the
same line if both of them use axis words. If an axis word-using G-code from
group 1 is implicitly in effect on a line (by having been activated on an earlier
line), and a group 0 G-code that uses axis words appears on the line, the activty
of the group 1 G-code is suspended for that line. The axis word-using G-codesfrom group 0 are G10, G28, G30, and G92.
It is an error to include any unrelated words on a line with O- flow control.
SmithyCNC Programmer’s Reference Manual: Language Overview
1-11
Programmer’s Reference Guide
G Codes
Smithy CNC EZ-TROL SYSTEMS
2
SmithyCNC Programmer’s Reference Manual:G Codes
G-CODE OVERVIEW
G codes of the RS274/NGC language are shown in Table 5and described following that.
In the command prototypes, the hypen (-) stands for a real value. As described
earlier, a real value may be (1) an explicit number, 4, for example, (2) an
expression, [2+2], for example, (3) a parameter value, #88, for example, or (4)
a unary function value, acos[0], for example.
In most cases, if axis words (any or all of X-, Y-, Z-, A-, B-, C-) are given, they
specify a destination point. Axis numbers are in the currently active coordinate
system, unless explicitly described as being in the absolute coordinate system.
Where axis words are optional, any omitted axes will have their current value.
Any items in the command prototypes not explicitly described as optional are
ed. It is an error if a required item is omitted.
requir
In the prototypes, the values following letters are often given as explicit numbers. Unless stated otherwise, the expl
example, G10 L2 could equal
parameter 100 were 2, G10 L#100 would also mean the same. Using real values
which are not explicit numbers as just shown in the examples is rarely useful.
If L- is written in a prototype the "-" will often be referred to as the "L number".
Similarly the "-" in H- may be called the "H number", and so on for any other
ter.
let
ly well be written G[2*5] L[1+1]. If the value of
icit numbers can be real values. For
2.1 G0: Rapid Linear Motion
For rapid linear motion, program G0 X- Y- Z- A- B- C-, where all the axis words
are optional, except that at least one must be used. The G0 is optional if the
current motion mode is G0. This will produce coordinated linear motion to the
destination point at the current traverse rate (or slower if the machine will notgo
ast). It is expected that cut
that f
ecuting.
ex
It is an error if:
* all axis words are omitted.
ting wi
l not tak
l
e place when a G0 command is
2-2
ter radius compensation is active, the motion will differ from the above;
If cut
see Chapter [cha:Cutter-Radius-Compensation]. If G53 is programmed on the
same line, the motion will also differ; see Section [sub:G53:-Move-in].
SmithyCNC Programmer’s Reference Manual: G-Codes
2.2 G1: Linear Motion at Feed Rate
For linear motion at feed rate (for cutting or not), program G1 X- Y- Z- A- B- C-,
where all the axis words are optional, except that at least one must be used.
The G1 is optional if the current motion mode is G1. This will produce coordinated linear motion to the destination point at the current feed rate (or slower
if the machine will not go that fast).
It is an error if:
* all axis words are omitted.
If cutter radius compensation is active, the motion will differ from the above;
see Chapter [cha:Cutter-Radius-Compensation]. If G53 is programmed on the
same line, the motion will also differ; see Section [sub:G53:-Move-in].
2.3 G2, G3: Arc at Feed Rate<sub:G2,-G3:-Arc>
A circular or helical arc is specified using either G2 (clockwise arc) or G3 (counterclockwise arc). The axis of the circle or helix must be parallel to the X, Y, or
Z-axis of the machine coor
perpendicular to the axis) is selected with G17 (Z-axis, XY-plane), G18 (Y-axis,
XZ-plane), or G19 (X-axis, YZ-plane). If the arc is circular, it lies in a plane parallel to the selected plane.
dinate system. The axis (or
, equivalently, the plane
ine of RS274/NGC code mak
If a l
otational ax
the r
and finishes when the XYZ motion starts and finishes. Lines of this sort are
dly ever programmed.
har
If cutter radius compensation is active, the motion will differ from what is
described here. See Chapter [cha:Cutter-Radius-Compensation].
Two formats are allowed for specifying an arc. We will call these the center format and the r
current motion mode.
2.3.1 Radius format arcs
In the radius format, the coordinates of the end point of the arc in the selected
plane ar
C- R- (or use G3 instead of G2). R is the radius. The axis words are all optional
ex
e specified along with the radius of the arc. Program G2 X- Y- Z- A- B-
cept that at least one of the two wor
es turn at a constant r
adius f
ormat. In both formats the G2 or G3 is optional if it is the
es an ar
c and includes rotational axis motion,
ate so that the rotational motion starts
ds f
or the ax
es in the selected plane
SmithyCNC Programmer’s Reference Manual: G Codes
2-3
SmithyCNC Programmer’s Reference Manual:G Codes
must be used. The R number is the radius. A positive radius indicates that the
arc turns through 180 degrees or less, while a negative radius indicates a turn
of 180 degrees to 359.999 degrees. If the arc is helical, the value of the end
point of the arc on the coordinate axis parallel to the axis of the helix is also
specified.
It is an error if:
* both of the axis words for the axes of the selected
plane are omitted
* the end point of the arc is the same as the current point.
It is not good practice to program radius format arcs that are nearly full circles
or are semicircles (or nearly semicircles) because a small change in the location
of the end point will produce a much larger change in the location of the center
of the circle (and, hence, the middle of the arc). The magnification effect is
large enough that rounding error in a number can produce out-of-tolerance cuts.
Nearly full circles are outrageously bad, semicircles (and nearly so) are only very
bad. Other siz
are OK.
e arcs (in the range tin
y to 165 degrees or 195 to 345 degrees)
Here is an example of a r
an arc: G17 G2 x 10 y 15 r 20 z 5.
That means to make a clockwise (as viewed f
helical arc whose axis is parallel to the Z-axis, ending where X=10, Y=15, and
Z=5, with a radius of 20. If the starting value of Z is 5, this is an arc of a circle
allel to the XY-plane; otherwise it is a helical arc.
par
2.3.2 Center format arcs
n the center f
I
plane ar
rent location. In this format, it is OK if the end point of the arc is the same as
the current point. It is an error if:
* When the arc is projected on the selected plane, the distance from the current
point to the center di
mor
ters are being used).
When the XY-plane is selected, program G2 X- Y- Z- A- B- C- I- J- (or use G3
e speci
e than 0.0002 inch (i
ormat, the coor
fied along wi
adius format command to mill
rom the positive Z-axis) circular or
dinates of the end point of the ar
th the of
om the distance from the end point to the center by
r
ers f
f
f
f inches are being used) or 0.002 millimeter (if millime-
fsets of the center of the arc from the cur-
c in the selected
2-4
SmithyCNC Programmer’s Reference Manual: G-Codes
instead of G2). The axis words are all optional except that at least one of X and Y
must be used. I and J are the offsets from the current location (in the X and Y
directions, respectively) of the center of the circle. I and J are optional except
that at least one of the two must be used. It is an error if:
* X and Y are both omitted
* or I and J are both omitted.
When the XZ-plane is selected, program G2 X- Y- Z- A- B- C- I- K- (or use G3
instead of G2). The axis words are all optional except that at least one of X and Z
must be used. I and K are the offsets from the current location (in the X and Z
directions, respectively) of the center of the circle. I and K are optional except that
at least one of the two must be used. It is an error if:
* X and Z are both omitted,
* or I and K are both omitted.
When the YZ
G3instead of G2). The axis words are all optional except that at least one of Y and
Z must be used. J and K are the offsets from the current location (in the Y and Z
directions, r
at least one of the two must be used. It is an error if:
* Y and Z are both omi
* or J and K are both omitted.
Here is an example of a center format command to mill an arc: G17 G2 x10 y16 i3
j4 z9.
That means to mak
c whose axis is par
ical ar
with its center offset in the X direction by 3 units from the current X location and
offset in the Y direction by 4 units from the current Y location. If the current location has X=7, Y=7 at the outset, the center will be at X=10, Y=11. If the starting
value of Z is 9, this is a circular arc; otherwise it is a helical arc. The radius of this
c would be 5.
ar
In the center format, the radius of the arc is not specified, but it may be found easily as the distance from the center of the circle to either the current
point or the end point of the arc.
-plane is selected, program G2 X
espectively) of the center of the circle. J and K ar
tted
e a clockwise (as viewed f
lel to the Z
al
-axis, ending where X=10, Y=16, and Z=9,
- Y- Z- A- B- C- J- K- (or use
e optional except that
axis) circular or hel-
-
e z
om the posi
r
tiv
SmithyCNC Programmer’s Reference Manual: G Codes
2-5
SmithyCNC Programmer’s Reference Manual:G Codes
2.4 G33: Spindle-Synchronized Motion
For spindle-synchronized motion, code G33 X- Y- Z- K- where K gives the distance
moved in XYZ for each revolution of the spindle. This syntax is subject to
change (In particular, to use F- instead of K-). For instance, G33 Z1 K.0625 produces a 1 inch motion in Z over 16 revolutions of the spindle. This command might
be part of a program to produce a 16TPI thread.
All the axis words are optional, except that at least one must be used. This will produce coordinated linear motion to the destination point at a rate dependant on
the speed of the spindle.
It is an error if:
* all axis words are omitted.
* the spindle is not turning when this command is executed
* the requested linear motion exceeds machine velocity
limits due to the spindle speed
2.5 G4: Dwell
For a dwell, program G4 P- . This will keep the ax
time in seconds specified by the P number. It is an error if:
* the P number is negative.
es unmoving for the period of
2.6 G10: Set Coordinate System Data<sub:G10:-Set-Coordinate>
The RS274/NGC language view of coor
ection[sub:Coordinate-Systems].
S
o set the coor
T
P - X- Y- Z- A- B- C-, where the P number must evaluate to an integer in
ange 1 to 9 (corr
the r
The coordinates of the origin of the coordinate system specified by the P number
eset to the coor
e r
ar
tem). Only those coordinates for which an axis word is included on the
line will be reset.
dinate values for the origin of a coordinate system, program G10 L2
esponding to G54 to G59.3) and al
dinate v
alues giv
dinate systems is described in
l axis wor
en (in terms of the absolute coor
ds are optional.
dinate sys-
2-6
It is an error if:
* the P number does not evaluate to an integer in the
ange 1 to 9.
r
SmithyCNC Programmer’s Reference Manual: G-Codes
If origin offsets (made by G92 or G92.3) were in effect before G10 is used, they will
continue to be in effect afterwards.
The coordinate system whose origin is set by a G10 command may be active or
inactive at the time the G10 is executed.
Example: G10 L2 P1 x 3.5 y 17.2 sets the origin of the first coordinate system (the
one selected by G54) to a point where X is 3.5 and Y is 17.2 (in absolute
coordinates). The Z coordinate of the origin (and the coordinates for any rotational
axes) are whatever those coordinates of the origin were before the line was
executed.
Program G17 to select the XY-plane, G18 to select the XZ-plane, or G19 to select
the YZ-plane. The effects of having a plane selected are discussed in Section
[sub:G2,-G3:-Arc] and Section [sub:G81-to-G89:]
2.8 G20, G21: Length Units
Program G20 to use inches for length units. Program G21 to use millimeters.
It is usually a good idea to program either G20 or G21 near the beginning of a program before any motion occurs, and not to use either one anywher
program. It is the responsibility of the user to be sure all numbers are appropriate
for use with the
current length units.
e else in the
2.9 G28, G30: Return to Predefined Absolute Position<sub:G28,-
G30:-Return>
wo positions are defined (by parameters 5161-5166 for G28 and parameters 5181-
T
or G30). The par
5186 f
and the machine's nativ
eturn to the pr
o r
T
G28 X- Y- Z- A- B- C- (or use G30 ...). All axis words are optional. The path is made
erse mo
v
a
y a tr
b
a traverse move to the predefined position. If no axis words are programmed, the
intermediate point is the current point, so only one move is made.
G28 and G30 do not use home switches to find the predefined position. They merely command a r
that the machine has already been homed.
apid motion to the posi
ameter v
e coor
edefined posi
e from the current position to the programmed position, followeby
Program G38.2 X- Y- Z- A- B- C- to perform a straight probe operation. The axis
words are optional, except that at least one of them must be used. The tool in the
spindle must be a probe.
It is an error if:
* the current point is the same as the programmed point.
* no axis word is used
* cutter radius compensation is enabled
* the feed rate is zero
In response to this command, the machine moves the controlled point (which
should be at the end of the probe tip) in a straight line at the current feed rate
toward the programmed point. In inverse time feed mode, the feed rate is such that
the whole motion from the current point to the programmed point would take the
specified time. If the pr
obe does not trip during the move, an error is signal
led.
After successful probing, parameters 5061 to 5066 will be set to the coordinates of
the location of the controlled point at the time the probe tripped.
A comment of the form (PROBEOPEN fi
the coordinate of each successful straight probe in it. The file must be
closed with (PROBECLOSE).
ter radius compensation may be performed only if the XY-plane is active.
Cut
o turn cut
T
programmed path when the tool radius is positive), program G41 D- . To turn
ter r
cut
grammed path when the tool radius is positive), program G42 D- . The D word is
optional; i
used. If used, the D number should normally be the slot number of the tool
in the spindle, although this is not required. It is OK for the D number to be zero; a
ter r
ter radius compensation on left (i.e., the cutter stays to the left of the
adius compensation on right (i.e.
e is no D wor
f ther
d, the r
f
, the cut
adius of the tool currently in the spindle will be
ter stays to the right of the pro-
2-8
SmithyCNC Programmer’s Reference Manual: G-Codes
radius value of zero will be used.
It is an error if:
* the D number is not an integer, is negative or is larger than the number of
carousel slots,
* the XY-plane is not active,
* or cutter radius compensation is commanded to turn on when it is already on.
The behavior of the machining center when cutter radius
compensation is on is described in Chapter [cha:Cutter-Radius-Compensation]
To use a tool length offset from the tool table, program G43 H-, where the H number is the desired index in the tool table. It is expected that all entries in
this table will be positive. The H number should be, but does not have to be, the
same as the slot number of the tool currently in the spindle. It is OK for the H
number to be zero; an offset value of zero will be used.
It is an error if:
* the H number is not an integer
ousel slots.
car
, is negative, or is larger than the number of
2.12.2 G43 H-1 I- K-
To use a tool length offset from the program, use G43 H-1 I- K-, where I- gives the
X tool offset (for lathes) and K- gives the Z tool offset (for lathes and mills).
It is an error if:
* motion is commanded on the same line as G43 H-1
2.12.3 G49
set, pr
o use no tool length of
T
am using the same of
It is OK to pr
using no tool length offset if none is currently being used.
ogr
f
ogram G49.
set already in use. It is also OK to program
f
SmithyCNC Programmer’s Reference Manual: G Codes
2-9
SmithyCNC Programmer’s Reference Manual:G Codes
2.13 G53: Move in absolute coordinates<sub:G53:-Move-in>
For linear motion to a point expressed in absolute coordinates, program G1 G53 XY- Z- A- B- C- (or use G0 instead of G1), where all the axis words are
optional,except that at least one must be used. The G0 or G1 is optional if it is the
current motion mode. G53 is not modal and must be programmed on each line on
which it is intended to be active. This will produce coordinated linear motion to the
programmed point. If G1 is active, the speed of motion is the current feed rate (or
slower if the machine will not go that fast). If G0 is active, the speed of motion is
the current traverse rate (or slower if the machine will not go that fast).
It is an error if:
* G53 is used without G0 or G1 being active,
* or G53 is used while cutter radius compensation is on.
See Section [sub:Coordinate-Systems] for an overview of coordinate systems.
2.14 G54 to G59.3: Select Coordinate System<sub:G54-to-
G59.3:>
To select coordinate system 1, program G54, and similarly for other coordinate systems. The system-number-G-code pairs are: (1-G54), (2-G55), (3-G56), (4-G57), (5G58), (6-G59), (7-G59.1), (8-G59.2), and (9-G59.3).
It is an error if:
* one of these G-codes is used while cutter radius
compensation is on.
ection [sub:Coor
ee S
S
dinate-
Systems] for an overview of coordinate systems.
2.15 G61, G61.1, G64: Set Path Control Mode<sub:G61,-G61.1,-
G64:>
Program G61 to put the machining center into exact path mode, G61.1 for exact
stop mode, or G64 P- f
program for the mode that is already active. See Section [sub:Path-Control-Mode]
or a discussion of these modes.
f
or continuous mode wi
th optional tolerance. It is OK to
2-10
2.16 G80: Cancel Modal Motion
am G80 to ensur
ogr
Pr
an error if:
e no axis motion wi
ll occur. It is
SmithyCNC Programmer’s Reference Manual: G-Codes
* Axis words are programmed when G80 is active, unless
a modal group 0 G code is programmed which uses axis words.
Program G76 P- Z- I- J- R- K- Q- H- to perform a
threading canned cycle. It is an error if:
* The active plane is not the ZX plane
* Other axis words, such as X- or Y-, are specified
* The R- degression value is less than 1.0.
* All the required words are not specified
* J-, K- or H- is negative
The "drive line" is a safe line outside the thread material. The "drive line" goes from
the initial location to the Z- value specified with G76. The Z extent of the
thread is the same as the drive line.
The "thread pitch", or distance per revolution, is given by the P- value.
The "thread peak" is given by the I- value, which is an offset from the drive line.
Negative I values indicate external threads, and positive I values indicate
internal threads. Generally the material has been turned to this size before the
canned cy
The "ini
bey
The "f
beyond the "thread peak" position. K- is positive, even when I- is negative.
The "depth degression" is given by the R- value. R1.0 selects constant depth on
The "compound slide angle" Q- is the angle (in degrees) describing to what extent
cessiv
suc
side of the tool to remove more material than the other. A positive Q value causes
cle.
y the J- value. The first threading cut will be J
tial cut depth" is giv
ond the "thread peak" position. J- is positive, even when I- is negative.
l thread depth" is given by the K- value. The final threading cut will be K
ul
eading passes. R2.0 selects constant ar
e thr
e passes should be offset along the drive line. This is used to cause one
en b
alues between 1.0 and
ea. V
SmithyCNC Programmer’s Reference Manual: G Codes
2-11
SmithyCNC Programmer’s Reference Manual:G Codes
the leading edge of the tool to cut more heavily. Typical values are 29,
29.5 or 30.
The number of "spring passes" is given by the H- value.
Spring passes are additional passes at full thread depth. If no additional passes are
desired, program H0.
Each pass begins at a position on the drive line. It consists of
1. An X traverse to the depth for this pass
2. A pause for the spindle to reach index position
3. A spindle-synchronized Z feed along the thread
4. A traverse to the original X
5. On all passes but the last, a traverse Z move to the
beginning point for the next pass
The tool will pause briefly before each threading pass, so a relief groove will be
required at the entry unless the beginning of the thr
material.
The exi
a slow spindle, the exit move might take only a small fraction of a revolution. If the
spindle speed is increased after several passes are complete, subsequent exit moves
will require a larger portion of a revolution, resulting in a very heavy cut during the
exit move. This can be avoided by providing a relief groove at the exit, or by
not changing the spindle speed whi
The sample pr
pr
t move (traverse to original X) is not synchronized to the spindle speed. With
le threading.
am g76.ngc shows the use of the G76 canned cycle, and can be
ogr
eviewed and ex
ecuted on an
y machine using the sim/lathe.ini configur
ead is past the end of the
ation.
2.18 G81 to G89: Canned Cycles<sub:G81-to-G89:>
The canned cy
section. Two examples are given with the description of G81 below.
All canned cycles are performed with respect to the currently selected plane. Any of
the thr
of the descriptions assume the XY-plane has been selected. The behavior is always
analogous i
ee planes (XY
cles G81 through G89 have been implemented as described in this
, YZ, ZX) ma
f the YZ or XZ
y be selected. Thr
-plane is selected.
oughout this section, most
2-12
SmithyCNC Programmer’s Reference Manual: G-Codes
Rotational axis words are allowed in canned cycles, but it is better to omit them. If rotational
axis words are used, the numbers must be the same as the current position numbers so that
the rotational axes do not move.
All canned cycles use X, Y, R, and Z numbers in the NC code. These numbers are used to
determine X, Y, R, and Z positions. The R (usually meaning retract) position is along the axis
perpendicular to the currently selected plane (Z-axis for XY-plane, X-axis for YZ-plane, Y-axis for
XZ-plane). Some canned cycles use additional arguments.
For canned cycles, we will call a number "sticky" if, when the same cycle is used on several
lines of code in a row, the number must be used the first time, but is optional on the rest of
the lines. Sticky numbers keep their value on the rest of the lines if they are not
explicitly programmed to be different. The R number is always sticky.
In incremental distance mode: when the XY-plane is selected, X, Y, and R numbers are treated
as increments to the current position and Z as an increment from the Z-axis position before the
move involving Z takes place; when the YZ or XZ-plane is selected, treatment of the axis words
is analogous. In absolute distance mode, the X, Y, R, and Z numbers are absolute positions in
the current coordinate system.
The L number is optional and represents the number of repeats. L=0 is not allowed. If the
repeat featur
sequence of motions is repeated in several equally spaced places along a straight line. In
absolute distance mode, L>1 means "do the same cycle in the same place several times,"
tting the L word is equivalent to specifying L=1. The L number is not sticky.
Omi
e is used, it is normally used in incremental distance mode, so that the same
When L>1 in incremental mode with the XY-plane selected, the X and Y positions are determined by adding the given X and Y numbers either to the current X and Y positions (on the
first go-around) or to the X and Y positions at the end of the previous go-around (on the
repetitions). The R and Z positions do not change during the repeats.
act move at the end of each repeat (called "clear Z" in the descriptions
The height of the r
below) is determined b
ve the R position and the retract mode is G98, OLD_Z), or otherwise to the R position.
is abo
ection [sub:G98,-G99:-
ee S
S
It is an error if:
* X, Y, and Z words are all missing during a canned cycle,
* a P number is required and a negative P number is used,
* an L number is used that does not ev
otational axis motion is used during a canned cycle,
* r
etr
y the set
et]
S
ting of the r
aluate to a positive integer,
act mode: ei
etr
ther to the original Z posi
tion (if that
SmithyCNC Programmer’s Reference Manual: G Codes
2-13
SmithyCNC Programmer’s Reference Manual:G Codes
* inverse time feed rate is active during a canned cycle,
* or cutter radius compensation is active during a canned cycle.
When the XY plane is active, the Z number is sticky,
and it is an error if:
* the Z number is missing and the same canned cycle was not already active,
* or the R number is less than the Z number.
When the XZ plane is active, the Y number is sticky, and it is an error if:
* the Y number is missing and the same canned cycle was not already active,
* or the R number is less than the Y number.
When the YZ plane is active, the X number is sticky, and it is an error if:
* the X number is missing and the same canned cycle was not already active,
* or the R number is less than the X number.
2.18.1 Preliminary and In-Between Motion
At the very beginning of the execution of any of the canned cycles, with the XYplane selected, if the current Z position is below the R position, the Z-axis
is traversed to the R position. This happens only once, r
In addition, at the beginning of the first cycle and each repeat, the following one or
two moves are made
erse parallel to the XY-plane to the given XY-position,
v
1. a str
2. a straight traverse of the Z-axis only to the R position, if it is not already at the R
position.
If the XZ or YZ plane is activ
gous.
aight tr
a
e, the pr
eliminary and in-between motions are analo-
egardless of the v
alue of L.
2-14
2.18.2 G81: Drilling Cycle
The G81 cy
- A
- Z
Y
cle is intended for drilling. Program G81 X-
-
- L
- R
- C
- B
SmithyCNC Programmer’s Reference Manual: G-Codes
1. Preliminary motion, as described above.
2. Move the Z-axis only at the current feed rate to the Z position.
3. Retract the Z-axis at traverse rate to clear Z.
Example 1. Suppose the current position is (1, 2, 3) and the XY-plane has been selected, and the following line of NC code is interpreted.
G90 G81 G98 X4 Y5 Z1.5 R2.8
This calls for absolute distance mode (G90) and OLD_Z retract mode (G98) and calls for
the G81 drilling cycle to be performed once. The X number and X position are 4. The Y
number and Y position are 5. The Z number and Z position are 1.5. The R number and
clear Z are 2.8. Old Z is 3. The following moves take place.
1. a traverse parallel to the XY-plane to (4,5,3)
2. a traverse parallel to the Z-axis to (4,5,2.8)
3. a feed paral
4. a traverse parallel to the Z-axis to (4,5,3)
Example 2. Suppose the current position is (1, 2, 3) and the XY-plane has been selected, and the following line of NC code is interpreted.
G91 G81 G98 X4 Y5 Z-0.6 R1.8 L3
This calls for incremental distance mode (G91) and OLD_Z retract mode (G98) and calls
or the G81 dri
f
the Y number is 5, the Z number is -0.6 and the R number is 1.8. The ini
is 5 (=1+4), the ini
the Z posi
The first move is a traverse along the Z-axis to (1,2,4.8), since old Z < clear Z.
The first repeat consists of 3 moves.
1. a traverse parallel to the XY-plane to (5,7,4.8)
eed parallel to the Z-axis to (5,7, 4.2)
2. a f
averse parallel to the Z-axis to (5,7,4.8)
3. a tr
lel to the Z-axis to (4,5,1.5)
lling cycle to be repeated three times. The X number is 4,
tial Y position is 7 (=2+5), the clear Z position is 4.8 (=1.8+3), and
tion is 4
.2 (=4
.8-0.6). Old Z is 3.
tial X posi
tion
SmithyCNC Programmer’s Reference Manual: G Codes
2-15
Loading...
+ 90 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.