Every
CNC programmer and most of CNC machine operators have a simple chart of all
common G-commands (G-codes) and M-functions (M-codes), usually tucked away
somewhere under the lid of their tool box or they have them posted on any
convenient machine side or cork board. This chapter covers most of those
G-codes that are either uncommon, seldom used, special, or outright mysterious.
Keep in mind that machine manufacturers often add G-codes and M-codes of their
own. These special codes or functions cannot be covered in a general
publication, such as this handbook.
Miscellaneous
functions (M-functions) are not covered here at all, as they are often very
much dependent on the machine tool manufacturer - for that reason, they are not
part of this chapter. The situation is much different with various G-codes,
some standard, some optional - they are covered here.
These
special and less frequently used G-codes are as important as those used on a
daily basis, even if only as accepting them for possible future use.
Programmers often forget that there are many preparatory commands available
that are not used very frequently. In this chapter, the focus will be on those
G-codes that may sometimes become the key to solving a particular problem or
achieving a particular programming goal. Some of these preparatory G-codes have
a direct relationship with each other, in which case, all related commands will
be considered together and explained together.
Divided
into seven groups, seventeen preparatory commands covered in this chapter are:
Although
included in the title, the G28 command is definitely not special - it is used
on a daily basis, virtually in every CNC program. Still, it is described here,
along with its related commands, to provide a single reference to all commands
related to machine zero return. First, some definitions:
Primary Machine Zero Return - G28
The
most common G-code of the four commands listed above is definitely the G28. To
a large extent, G30 shares the same characteristics as G28, except it relates
to a secondary machine zero, if available. For the record, machine zero is the position
of all axes that always remains the same. Machine zero is the master origin of
the machine - origin that is specified by the machine manufacturer. Machine
zero always has the coordinates of X0Y0Z0. Normally, this position is never
changed and is used as a reference point for other required measurements and
adjustments, such as work offsets and tool length offset, for example. In order
to measure work offset or tool length offset accurately, the measuring process
must start from a common point - from a zero -
machine zero, that is
.
As
a command, G28 is different than other G-codes, in the sense that it functions
as
two commands
rolled into one
. Once you
understand this very basic concept, using G28 will be problem free. The
following definition should shed some light on the
'two commands in one'
statement:
The
meaning of the definition should be clear - the tool motion will indeed
terminate at machine zero, but it will take a break along the way - through
another location -
through
an intermediate point.
Consider
the two G28 versions - one in absolute mode, the other in incremental mode
(return along the Z-axis only is shown, where Z0 is the top of part):
G90 G28 Z20.0
... the tool moves
to the position 20 mm above part, then continues to machine zero
G91 G28 Z20.0
... the tool moves
by the distance of 20 mm, then continues to machine zero
This
type of program input is also one of the most common. After all, in order to
make an automatic tool change, the tool must be located at machine zero for the
Z-axis (vertical machining centers) or for the Y-axis (horizontal machining
centers). What makes this command sometimes hard to understand is that it does
not seem to be necessary, it does not seem to have any purpose. In the two common
examples above, that is true. Actually, if the Z-axis alone is used with G28,
the motion to the intermediate point is practically useless. In case of two or
three axes used simultaneously with G28, the situation is much different. The
following example and illustration show the
intended
use
of G28:
…
G90 G00 X14.4 Y9.0
(CURRENT POINT - XY)
Z2.0
(CURRENT POINT - Z)
G01 Z-13.3 F150.0
G28 X14.4 Y9.0 Z2.0
(INTERMEDIATE POINT)
...
Many
programmers have wondered at the actual benefits of this command, as it saves
only a single block of the program. There is a simple idea behind the G28
command - to
bypass
obstacles
on the way to machine
zero when moving two or more axes simultaneously. In a single axis machine zero
return, there are no obstacles to consider, so the intermediate point is
unnecessary, but it still must be programmed. The solution?
The intermediate tool position will
be the same as the current tool position.
The
previous example will be used with a retract move added:
…
G90 G00 X14.4 Y9.0
Z2.0
G01 Z-13.3 F150.0
G00 Z2.0
(SAFE RETRACT)
G28 X14.4 Y9.0 Z2.0
(INTERMEDIATE POINT)
...
Some
programmers prefer to use incremental zero return, with exactly the same
effect:
…
G90 G00 X14.4 Y9.0
Z2.0
G01 Z-13.3 F150.0
G00 Z2.0
(SAFE RETRACT)
G91 G28 X0 Y0 Z0
(INTERMEDIATE POINT)
G90 …
(REINSTATE ABSOLUTE MODE)
...
The
two versions with the safe retract are preferred methods - the G90 method is
favored over the G91 version, as there is no need to change the mode. Use G91
only if absolute position is unknown.
Keep
in mind that
X0Y0Z0
in absolute mode refer to part
zero location,
X0Y0Z0
in incremental mode refer to
no motion
, that is a motion that has a zero length. Zero
motion during machine zero return applies only to the intermediate point - G91
G28 Z0 simply means that there will be no motion to the intermediate point and
the tool will move to machine zero directly. Make sure to include G91 in the
block. Both G90 and G91 examples will have the same effect -
the Z-axis retract above part is
very strongly recommended
. The
best way to see the effect of this often mysterious command is in the single
block mode, where both parts of the zero return motion will be apparent.
Return from Machine Zero - G29
G29
is the virtual opposite of G28 - it's almost that simple. Practical usage of
this command is very questionable. While G28 can be described as the return to
machine zero from the current tool position through an intermediate point, the
G29 is the return
from
the machine zero to the
specified tool position
through
the last intermediate point
. Of
course the last intermediate point must be defined first, often for the
previous tool. For example, here are all critical blocks for two tools:
… (TOOL 01 WORKING)
G90 G00 X50.0 Y30.0
Z2.0
G01 Z-15.0 F150.0 (TOOL IS BELOW THE PART)
G28 X50.0 Y30.0 Z2.0 (XY IS THE CURRENT POINT
THROUGH Z2.0 FIRST)
...
M06 (TOOL 02 WORKING)
...
G90 G29 X75.0 Y40.0 Z2.0 (COORDINATES SPECIFY THE
NEW TARGET LOCATION)
...
What
will be actually happening at the machine? For the first tool T01, machining
will take place at X50.0Y30.0, to the depth of Z-15.0. The tool retracts to
Z2.0, and from this location, all three axes return to machine zero (for
whatever reason). Now, the next tool T02 is working and G29 specifies target
location of X75.0Y40.0 and Z2.0. How the tool will move there is the very
purpose of G29. The control will use the last intermediate point
(X50.0Y30.0Z2.0), moves the tool to this position first,
then
moves to the actual target of X75.0Y40.0Z2.0.
Why? Honestly, beats me.
The
difficulty is not much in the understanding of this command; the difficulty is
mainly related to its application. It is much easier to understand a command
that is used all the time (G28) when compared with a command that is
practically never used (G29). Here is the simple conclusion:
Machine Zero Return Position Check - G27
Although
listed first in the table, this G-code can only be truly understood if several
other G-codes are understood first, particularly G90, G91, and G92 (or G50 on
lathes).
Since
the G27 command is listed in this chapter, it belongs to one of those commands
seldom – if ever - used in CNC programs. First, its definition in the section
title identifies this command as machine zero return
position check
. This command has no practical purpose in
modern programming, but it can be useful to those programmers who still have to
program G92 or G50 position registers for some very old control systems (those
that do
not
support work offsets). Details about G92/G50 are
described in the next section. For now, just accept the fact that G92 registers
the specified XYZ coordinates as the
current
tool position from part zero - not from machine zero
. Here is an example of a typical G27 use in
incremental mode:
…
G90 (ABSOLUTE MODE)
G92 X300.0 Y200.0 Z100.0
(CURRENT TOOL LOCATION AT MACHINE ZERO)
G00 X20.0 Y15.0 Z2.0
(START
LOCATION FOR CUTTING)
G01 Z-5.0 F120.0
(MACHINE TO ABSOLUTE DEPTH OF 5 MM)
G91 G01 X40.0 F150.0
(MACHINE PART IN INCREMENTAL MODE - CUT ¼)
Y30.0
(MACHINE PART IN INCREMENTAL MODE - CUT 2/4)
X-40.0
(MACHINE PART IN INCREMENTAL MODE - CUT ¾)
Y-30.0
(MACHINE PART IN INCREMENTAL MODE - CUT 4/4)
G00 Z7.0
(RETRACT BY 7 MM)
G27 X280.0 Y185.0 Z98.0
(CHECK IF THE MOTION TERMINATES AT MACHINE ZERO)
...
In
the above program, look at the G27 block - it is of special interest. Once the
machining has taken place, all axes will move to the position specified in the
G27 block, which is the incremental motion to the machine zero, from the
current tool position. The big question is - did all axes actually reached the
machine zero? Well, upon the block completion, G27 will perform the check, and
if the machine zero position has been reached, axes confirmation lights will
turn on; if the machine zero position has not been reached, the control will
issue an alarm, and no further program processing will be allowed.
Now,
let's look at the above example more carefully -
will the machine zero lights come
on or will there be an alarm?
The
best approach to understand G27 is to convert the whole program to absolute
mode:
…
G90 (ABSOLUTE MODE)
G92 X300.0 Y200.0 Z100.0
(CURRENT TOOL LOCATION AT MACHINE ZERO)
G00 X20.0 Y15.0 Z2.0
(START LOCATION FOR CUTTING)
G01 Z-5.0 F120.0
(MACHINE TO ABSOLUTE DEPTH OF 5 MM)
G01 X60.0 F150.0
(MACHINE PART IN ABSOLUTE MODE - CUT ¼)
Y45.0
(MACHINE PART IN ABSOLUTE MODE - CUT 2/4)
X20.0
(MACHINE PART IN ABSOLUTE MODE - CUT ¾)
Y15.0
(MACHINE PART IN ABSOLUTE MODE - CUT 4/4)
G00 Z2.0
(RETRACT 2 MM ABOVE PART)
G27 X280.0 Y185.0 Z98.0
(CHECK IF THE MOTION TERMINATES AT MACHINE ZERO)
...
Write
down the last positions of XY and Z - they are usually in two blocks, just
before the G27 command - they are X20.0 Y15.0 Z2.0. Next, subtract each
position from the respective axis in the G92:
X200.0 - 20.0 = X280.0 Y100.0 - 15.0 = Y185.0
Z100.0 - 2.0 = Z198.0
This
example is correct, G27 will confirm that machine zero has been reached in all
three axes.
Using G27
G27
should always be used in the G40 mode (cutter radius offset canceled),
otherwise the tool will not be confirmed at machine zero. Also watch for cases
when the machine lock switch is turned on, for example, during program
verification. In this case, there will be no machine zero check performed. If
you find a practical application for this command, you can use it for both
mills and lathes with same logical approach. Programs written in incremental
mode (G91) benefit the most from this G-code. Under normal situation, use G28
in order to return to machine zero - the position checking is already built in
and it is a much more convenient way of programming.
Secondary Machine Zero Return - G30
Most
vertical machines have only one machine zero. One machine zero is always the
primary machine zero, as there is no other choice. Some horizontal machining centers
- particularly those used with pallet changers - often need a secondary machine
zero location, in order to align two independent pallets, for example. The
applications for both G28 and G30 are exactly the same - in order to return to
the primary machine zero, use G28; in order to return to the secondary machine
zero, use G30. All other conditions listed under the G28 heading apply equally
to G30. Third and fourth machine zero commands are also available on some
controls, but rather rare.
Copyright © 2006
Industrial Press Inc.