You are on page 1of 9

UNIT TWO CNC PROGRAMMING 667

BLOCK #170 from point A to point B, then be able to calculate a mul-


N170 M03 S550 tiaxes move. This is called interpolation. In CNC pro-
gramming several common interpolation modes are used.
Spindle start with clockwise rotation at a speed of These modes include linear interpolation, circular inter-
550 rpm. polation, and helical interpolation. Parabolic and cubic
The remaining blocks are essentially repeats using G81 interpolations are also used for multidimensional contour
for drilling with a new speed and feed rate for the material milling requirements.
being machined. At the completion of the program, the tool
is returned to a reference point. The miscellaneous func- Linear Interpolation Linear interpolation is invoked
tion command M30 appears by itself as the last block of the by the preparatory function command G01 and is used for
program. straight-line milling either along any axis or at any angle to
any axis.
The next program example will be used to cut a 4-in.
Linear Interpolation square step (see Figure M-33) around a 4.50-in square alu-
Modes for CNC Milling minum plate.
Drilling is a point-to-point operation. The tool needs only The job will be done on a vertical spindle machin-
to be positioned as quickly and as efficiently as possible to a ing center. The program is developed in the general Fanuc
point where a machining operation is to be done. The path CNC code format. Remember that in the actual input, words
that the tool takes to get to the hole location is not particularly wouldn’t need to have spaces between them. At the end of
important. Milling, on the other hand, requires the cutting each block the EOB key or Enter key must be pressed.
tool to follow a specific path from point to point. This may be
a straight line, an angle, an arc, a circle, or a multidimensional O00030
contour.
Interpolation is a term from mathematics that refers The first block is the program number.
to the establishment of a set of “best-fit” reference points
on a path between two established reference points. One N10 G90 G20 G80 G40
of the greatest capabilities of a CNC machine tool is its N10 is the block or sequence number.
ability to perform continuous path milling. Tool paths
may be in a straight line along any axis, at an angle to G90 Establishes absolute positioning mode
any axis or axes, along an arc (circular) path, or in a mul- G20 G20 designates inch input
tiaxis three-dimensional contour. To do this, the CNC G80 Cancels canned cycles
control must be able to look at a programmed tool path G40 Cancels tool radius compensation

Figure M-33 Milling example.


668 SECTION M COMPUTER NUMERICAL CONTROL AND OTHER ADVANCED MACHINING PROCESSES

This standard “insurance block,” because it ensures that BLOCK #70


certain modal computer modes are canceled before begin- N70 G01 Z-.250 F5.0
ning a new program run. This adds a degree of safety and
prevents the numerical control computer from executing a Modal G01 command invokes a linear interpolation
modal command that may still be resident in memory from command. In block, N70 the tool feeds down to depth at a
a previous program. feed rate of 5 inches per minute.

BLOCK #20 BLOCK #80


N20 M06 T1 N80 G01 Y4.50 F10.0

The M06 tool change command performs an auto- In block N80, the modal G01 command invokes a lin-
matic tool change. The T1 command tells the automatic tool ear interpolation command and feeds the tool to point 2. The
changer to pick tool number 1. In this case, tool number 1 is modal feed rate that was active in block N70 has been changed
a .500 in.-diameter end milling cutter. to a feed rate of 10 inches per minute. The G01 command is
modal and will remain in effect until rapid traverse or another
interpolation mode is invoked. It was repeated in this line only
BLOCK #30 for clarity. The tool is fed around the part in a clockwise direc-
N30 G00 G54 X0.0 Y-1.0 M08 tion. This was done to perform climb milling. In CNC milling,
it is considered best to climb mill. Unlike a conventional milling
The G00 establishes rapid traverse positioning. machine, the CNC’s ball screws will permit climb milling with
Rapid traverse is used only to position the tool to a loca- no backlash problems. Climb milling will produce a better sur-
tion. The G54 activates the workpiece coordinate setting. face finish and possibly better dimensional control of the part.
The work coordinates setting informs the control where
the part is located on the table. The lower left corner of BLOCK #90
the part is the absolute X and Y zero point for this part N90 X4.5
(Figure M-33).
The tool rapidly positions to the absolute workpiece In N90, once again, the G01 modal command executes
coordinates of X0.0 and Y-1.0. This position is off of another linear interpolation to point 3. Because the G90
the part. You don’t want to plunge down onto the part. absolute positioning mode is invoked, it is not necessary to
The M08 starts the coolant. The position coordinates program the Y word address because the Y coordinate posi-
are to the center of the cutter, therefore, to compensate tion is the same as position 2.
for the radius of the cutter the position will have to be
adjusted otherwise the finish part size would be reduced BLOCK #100
by the amount of the cutter radius. Cutter radius com- N100 Y0.0
pensation will be covered later in this section. Cutter
radius compensation allows the programmer to program In N100, the G01 modal command executes another
the exact part shape. linear interpolation to point 5.

BLOCK #110
BLOCK #40
N110 X-1.0
N40 G43 H01
In N110, the G01 modal command executes another
A G43 activates a Z tool length offset. The H01 is the
linear interpolation to point 5. Point 5 is off the part. Feed-
particular height offset for tool 1.
ing the tool off of the part will ensure that no tool marks will
be left on the finished part.
BLOCK #50
N50 M03 S1600 N120 Z.10

Spindle start with clockwise rotation at a speed of 1600 In N120, the tool feeds up to a Z-axis clearance position.
rpm. As you become a more experienced programmer a rapid
move to a clearance position might be more appropriate.
BLOCK #60 BLOCK #130
N60 G00 Z0.1 N130 G28

Rapid traverse position mode positions the tool to a On line N130, the machine returns to a reference point.
clearance point .10 in. above the top of the part. Some CNC machines may require additional coordinate
UNIT TWO CNC PROGRAMMING 669

4.00''

t
cu
of
ction
Angular re
Di
interpolated
tool path

Y Axis 3.000
3.00'' 4.00''

X Axis

4.000
Cutter
Nxx G01 X 4.000 Y 3.000

Figure M-34 Milling at an angle using linear interpolation


requires simultaneous motion in two or more axes. .50''
.25''

entries. On most machines the reference point is a machine Figure M-35 Workpiece drawing of the hexagonal boss angular
home position. The home position of the machine is nor- linear interpolation program.
mally at the furthest extent of machine travels.

M30 mathematics to calculate the tool motions required. A skilled


programmer will be able to use trigonometry or use a CNC
The miscellaneous function command M30 resets the programming system to generate the required code. Only
program back to the beginning. M30 always appears by itself the portion of the program used to mill the hexagon outline
as the last block of the program. is shown. Other linear interpolation cuts will be needed to
mill off the material outside the hexagon feature.
Angular Linear Interpolations Angular milling is also Keep in mind that when cutting any geometric shape
done in the G01 linear interpolation mode. Two or more axes inside or outside, the final dimension of the shape will be
are programmed simultaneously to generate the required an- smaller or larger by one diameter of the cutter, because an
gular tool path. Figure M-34 shows an example of an angular amount equal to the cutter radius will be removed from each
path being milled in the X–Y plane by the following codes. side of the feature. Therefore, the cutter radius must be com-
pensated for when the positioning moves are programmed.
Nxx G90 G01 Z−.350 F10.0 Cutter compensation can be programmed by the appro-
priate G codes. The advantage in using cutter radius com-
The cutting tool feeds into the work at 10 ipm to the pensation is that drawing dimensions may be used directly
required depth using G01 linear interpolation. without the need to recalculate dimensions. For the purpose
of this example, cutter radius compensation will not be used.
Nxx X4.000 Y3.000 This topic will be discussed in more detail later in this unit.
In this example, cutter radius is compensated for by
G01 is modal and remains in effect from the previous expanding the dimension of the hexagonal feature an amount
block. The simultaneous programming of the X and Y axes equal to the cutter diameter plus the .020-in. finish allow-
permits the computer to generate the angular linear interpo- ance. The distance across the flats then becomes 3.540 in.,
lated tool path as shown. allowing for a .250-in. cutter radius all around and .020-in.
finish allowance on all sides.
Nxx G00 Z.350 The other important consideration in milling regular
polygons is getting around the corners properly. In each lin-
At the end of the cut, G00 rapid is invoked, and the cut- ear interpolation move, the cutter must travel far enough so
ter is withdrawn from the work. that it is tangent to the projected angle line of the next surface.
The tool motions for climb milling the shape are illustrated in
Basic Angular Linear Interpolation Program This Figure M-36. The illustration also shows the cutter overtravel
example consists of a hexagonal boss milled on a plate required to arrive at the tangent positions so as to be properly
(Figure M-35). A job of this type may require some aligned for the next angular interpolation motion.
670 SECTION M COMPUTER NUMERICAL CONTROL AND OTHER ADVANCED MACHINING PROCESSES

Figure M-36 The angular linear Point Point Cutter Surface projection
interpolated tool path around the 2 3
hexagonal boss, illustrating how to
move the cutter around the corners
properly.
Hex
corner
Point Point
1 4
Tangent
points
Cut
direction
Point Tangent
5 points
Surface
Hex projection
Entry Cutter corner
point

Centerline
of tool path

BLOCK #10 BLOCK #20


N10 G91 G01 Z−.350 F10.0 (spindle is already running) N20 X1.0129 Y1.770

The tool has been positioned .100 over the entry point G01 linear interpolation moves the cutter to point 2.
and is plunged into the work to the required depth. The The X-axis motion is now positive. The Y-axis motion
Z-.350 command moves the tool down the .100 it is above remains positive.
the work and the .250 part thickness. G91 invokes incre-
mental positioning mode. BLOCK #30
N30 X2.0438

BLOCK #20 Modal G01 takes the cutter to point 3.


N20 X–1.0219 Y1.770
BLOCK #40
In this linear interpolation sequence, G01 and the feed N40 X1.0219 Y–1.770
rate is modal from the previous block. The move takes
the cutter to point 1 (Figure M-36). The dimensions pro- Modal G01 takes the cutter to point 4.
grammed are based on the part dimensions and the offset
due to the radius of the cutter. BLOCK #50
Because cutter radius compensation is not used, the
N50 X–1.0129 Y–1.770
tool path must be programmed to compensate for the cut-
ter radius. The finished dimension across the hex flats is Modal G01 takes the cutter to point 5.
3 in. The hex will be milled .020 in. oversized on all sides to
allow for a second finish pass. Because a .500-in.-diameter BLOCK #60
end mill will be used without cutter radius compensation,
the cutter paths must be planned to compensate for finish N60 X–2.0438
allowance and cutter radius. Adding .020 in. on all sides and
compensating for a cutter radius of .250 in. creates a new Modal G01 takes the cutter back to point of entry.
rough cut hex dimension of 3.540 in. across the flats. From
the center of the hexagon to the center of the cutter, mea- BLOCK #70
sured on the Y axis, is calculated to be 1.770 in. Calculations N70 X.0115 Y.020
must be made to determine the amount of -X@axis travel to
generate the required 30-degree angle of the hex flat to the Modal G01 moves the cutter in for the final pass. This
Y axis. This amount is 1.0291 in. move must be done correctly if the final dimensions are to
UNIT TWO CNC PROGRAMMING 671

be achieved. For the cutter to be positioned correctly, it must see that a Y-axis move of only .020 in. will not position the
move inward toward the center of the hexagon along a radial cutter correctly for the finish cut. The X-axis motion is also
line passing through the corner of the hex and the part center. required to keep the cutter centerline on the radial projec-
This requires a move in both the X and Y axes (Figure M-37). tion line to the center of the hex boss. The amount of X-axis
The illustration shows an overview of the cutter position motion is calculated trigonometrically based on the .020-in.
for roughing and for finishing. Note how the cutter must final machining allowance and the angle along which the
move in so that it is tangent to the projected surfaces of the cutter most move toward the center of the feature.
finished hexagon. Figure M-38 shows a detail of the tool The rest of the program would remove the .020-in. fin-
motion. For the cutter to be correctly positioned and tangent ish allowance from the sides of the hexagon and machine
to the projected surfaces of the finished hex feature, a small the final dimension across the flats. A new hex dimension of
X-axis motion of .0115 in. is required along with the .020 3.500 would be used to compensate for the cutter radius of
in on the Y axis. This angular interpolation motion moves .250 in. This will also necessitate new X and Y dimensions to
the cutter in along a radial line extending through the center be calculated, because this final shape is smaller. We will not
of the hex boss. The illustration shows the cutter centerline examine the finish portion of the program. The axis motions
locations for both the roughing and finishing cuts. You can would be the same as for the roughing cuts. Final linear

Figure M-37 Overview of the


roughing and finishing cuts around
the hex boss showing the tool
Finish path inward toward the hex center
en e
ter

cut line
he l lin

for the final cut.


to adia
xc

Rough
R

Hex
cut line corner

Tangent
Cutter at point
start of finish cut

Cutter at Tangent
start of rough cut point .020 in.
finish cut
allowance

Hex
Cutter in corner Figure M-38 Detail showing the
finishing
position Finish cut line X-axis motion required to position
Y Axis the cutter properly for the finish
Rough cut line cut.

Centerline
of cutter at
finish cut entry

Centerline
of cutter at
rough cut entry Y=.020

X=.0115
X Axis

Cutter in
rough position
672 SECTION M COMPUTER NUMERICAL CONTROL AND OTHER ADVANCED MACHINING PROCESSES

interpolation blocks would mill the remaining material to compensation dimension may be invoked and the part fin-
machine to part to the finish dimensions. ish machined to the drawing specifications. Cutter radius
Keep in mind that there are always many ways to compensation is canceled by the G40 command, which may
accomplish almost any CNC machining task. The preceding appear in the initial insurance block of the program.
program examples are intended to familiarize you with the
use of some simple programming codes and common inter-
Circular Interpolation
polation modes. When programming, always look for the
most efficient tool paths and optimum feeds and speeds to Up to this point, we only looked at straight-line moves. If
fully realize the productivity of the CNC machine tool. a CNC machine was only capable of straight-line moves,
it would be very limited. One of the most important fea-
Cutter Radius Compensation CNC programming for tures of a CNC machine is the ability to do circular cutting
milling and drilling is always based on the center of the cutting motions. CNC machines are capable of cutting an arc of any
tool. Because every cutter has a certain diameter and radius, it specified radius. Arc or radius cutting is known as circular
should be apparent that the outside dimensions of the work- interpolation. Circular interpolation is carried out with a
piece will be reduced by the amount of the cutter radius. When G02 or G03 code.
an inside feature is machined, the workpiece dimensions will
be increased by the cutter radius. This will necessitate that the
Programming Circular Moves
programmer manually correct the tool path to compensate for
the cutter radius. The CNC control can do the offsets for us. There are two basic methods used to program circular moves:
By invoking cutter radius compensation using G41 and G42 IJ and radius.
codes, a part may be programmed using the actual drawing
dimensions. The amount of cutter compensation is determined
Programming Circular Interpolation
by the D word address, and this information is contained in the
cutter radius compensation offset file. Using the IJ Method
The direction of radius compensation is determined When we start cutting an arc, the tool is already positioned
by observing the tool path direction in the first sequence as at the start point of the arc (see Figure M-40). First, we need
the cutter approaches the workpiece (Figure M-39). G41 is to tell the direction of the arc. Is it a clockwise (G02) or coun-
radius compensation to the left side of the tool path. G42 terclockwise (G03) arc? The second piece of information the
is radius compensation to the right side of the tool path. control needs is the end point of the arc. The last piece of
Another advantage of cutter radius compensation is that information is the location of the center of the arc.
the cutter radius dimension may be intentionally pro- Arc Direction (G02, G03) Circular interpolation can be
grammed larger or smaller than it actually is. This will leave carried out in two directions, clockwise and counterclock-
a finish machining allowance. After the roughing cut, a new wise. There are two G-codes that specify arc direction (see
Figure M-40). The G02 code is used for circular interpola-
Workpiece tion in a clockwise direction. The G03 code is used for cir-
Uncompensated cular interpolation in a counter-clockwise direction. Both
cutter path G02 and G03 codes are modal and also use a feed rate (F)
code, just like a G01.
Arc Start Point The arc start point is the coordi-
nate location where the arc starts. The tool is moved to
G41 left cutter G42 right cutter
compensation compensation
the arc start point in the line prior to the arc generation
line. Simply stated, the start point of the arc is the point
where the machine is positioned as it starts to cut the arc
(see Figure M-41).

Arc End Point


Cutter approach Cutter approach
path, left side path, right side The arc end point is the coordinate position for the end point
of the arc. The arc start point and arc end point set up the tool
path, which is generated according to the arc center position
Cutter (see Figure M-42).

Start position
Arc Center Points
Figure M-39 G41 and G42 milling cutter radius compensation To generate an arc path, the controller has to know where
left and right is invoked as the cutter approaches the the center of the arc is. When using the IJ method, a par-
workpiece. ticular problem arises. How do we describe the position of
UNIT TWO CNC PROGRAMMING 673

Figure M-40 The critical pieces of


information needed to cut an arc
are the arc start point, arc direction,
arc end point, and arc centerpoint
location.

Figure M-41 Arc start point, end-point, and centerpoint


location.

Figure M-43 Absolute method of defining the centerpoint of the arc.

letter addresses will be used. If we were cutting an arc on


a turning center, the X–Z axes would be the primary axes,
and the IK letter addresses would be used to describe the arc
centerpoint.
The type of controller you are using dictates how these
secondary axes are located. With most controllers, such as
the Fanuc controller, the arc centerpoint position can be
described as the incremental distance from the arc start
point to the arc center (see Figure M-42).
On some controls, the arc centerpoint position can be
Figure M-42 The centerpoint of the arc is the incremental
described as the absolute location of the arc centerpoint
distance from the start point position to the arc center position.
from the workpiece zero point (see Figure M-43).
If the arc centerpoint is located below or to the left of
the start point, a negative sign (−) must precede the coor-
the arc center? If we use X, Y, Z coordinate position words
dinate dimension (see Figure M-44). In the example on the
to describe the end point of the arc, how will the control-
right of Figure M-44 the arc centerpoint is below the start
ler discriminate between the end point coordinates and the
point and also to the left of the start point. Note the I value
arc center coordinates? The answer is that we use different
is −.435. This means that the arc center is −.435 in the
letters to describe the same axes. Secondary axes addresses
x direction from the start point. The J value is −1.952 in
are used to designate arc centerpoints. The secondary axes
the Y direction. This means that the arc center is −1.952
addresses for the axes are:
in the Y direction from the start point. This can be
I = X axis coordinate of an arc centerpoint confusing. Please study the example until you thoroughly
J = Y axis coordinate of an arc centerpoint understand it.
Remember that the I and J values are normally incre-
K = Z axis coordinate of an arc centerpoint
mental. The I and J values must be the incremental distance
Because we will be cutting an arc in only two axes direc- and direction. The direction is shown by the plus or minus
tions, only two of three secondary addresses will be used to sign. Also remember that the distance and direction is taken
generate an arc. When cutting arcs in the X–Y axes, the IJ from the start of the arc to the center of the arc.
674 SECTION M COMPUTER NUMERICAL CONTROL AND OTHER ADVANCED MACHINING PROCESSES

Figure M-44 Incremental method


of specifying arc centerpoint.

Circular Interpolation Using Figure M-48 shows an arc that is less than 180 degrees.
the Radius Method The code to machine this arc would be G02 X2.0625 Yl.0625
R-2.5. G02 means that it is a clockwise arc. The X value is the
Circular interpolation can also be programmed using the distance in the X axis from the start point to the end point.
radius value. The general format is G02 (or G03) X Y R. Note that it is positive in this example. The Y value is the
Figure M-45 shows an example of a circular cut using the distance from the start point to the end point in the Y direc-
radius method. The code for this cut would be G02 X8.250 Y tion. Note that it is positive in this example. The R value is
4.250 Rl0.0. The G02 means that it will be a clockwise circular the value of the radius of the arc. Note that it must be nega-
cut. The X value is 8.250 in. (incremental value) from the start tive in this example because the arc is less than 180 degrees.
point to the end point in the X direction. The Y value is 8.250 in. The radius method cannot be used to program a full
(incremental value) from the start point to the end point in circle. The IJ method should be used for full circles.
the Y direction. The R value is the length of the radius value.
In this example, it is a plus 10.0 in.
Study Figure M-46. Note that there are two potential
Parabolic and Cubic Interpolations
arcs with the same start point and same end point. Note also These advanced interpolation modes are usually used to cre-
that there are two possible centerpoints. One arc is greater ate three-dimensional shapes such as those used on forming
than 180 degrees and the second one is less than 180 degrees. dies for automobile parts.
We tell the controller which one to use by giving the radius
value a plus or minus sign.
Figure M-47 shows an arc that is more than 180 degrees.
The code to machine this arc would be G02 X2.0625 Yl.0625
R2.5. G02 means that it is a clockwise arc. The X value is the
distance in the X axis from the start point to the end point.
Note that it is positive in this example. The Y value is the dis-
tance from the start point to the end point in the Y direc-
tion. Note that it is positive in this example. The R value is
the value of the radius of the arc. Note that it must be positive
in this example because the arc is more than 180 degrees.

Figure M-46 Specifying which arc to machine.

Figure M-45 When using absolute centerpoint positioning, the


centerpoint is the coordinate position from the part zero. Figure M-47 Arc of more than 180 degrees.
UNIT TWO CNC PROGRAMMING 675

rate for tapping with a floating tool holder is programmed


10 percent short of the tap lead by the formula
spindle rpm
Feed rate in ipm = * .9
threads per inch
The spindle speed will be controlled by several factors, includ-
ing the type of tap, the material being tapped, and the depth
of the tapped hole. Gun taps and spiral point types that lift
Figure M-48 Arc of less than 180 degrees. chips from the hole are recommended (Figure M-50). Some
types of CNC tapping may be able to usethread-forming taps
Tapping (Figure M-51). This type of tap has no flutes and produces no
Tapping is another extremely useful capability of the CNC chips.
machine tool, especially on the machining center (Figure A tapping sequence for a .375-16 UNC tap at 300 rpm
M-49). Tapping, like drilling, is a canned cycle invoked by a might look like this:
G84 code. During the cycle, the tap goes to depth, and then
the spindle reverses and the tap is withdrawn. G84 is a modal Nxx M03 S300
command, so it is important to turn it off with G80 where the Nxx G84 Z−1.125 F18.75
cycle is not to be executed, such as over a point where there is
no drilled hole to be tapped. The -Z depth is the distance from the end of the tap
It is recommended that a .50 in. offset above the top of at the .500-in. offset level to the point where the tap is to be
the workpiece be used when tapping. Increasing the offset to reversed near the bottom of the hole. It is important to drill
.50 in. ensures that the tap will screw completely out of the the tap drill hole to the correct depth and to program the
hole as it retracts. Some CNC’s use a special spring-loaded tap depth so that the tap will not bottom out and break. The
or floating tool holder for tapping. This tool holder allows feed rate is calculated by the formula noted earlier. Tapping
the tap to pull out ahead of the Z-axis down feed so that the rpm will be determined by the material being tapped, the
spindle is not crushing down on the tap as it feeds. The feed type of tap used, and the depth of the tapped hole.
Feed rate = 300 rpm>16 tpi = 18.75 ipm * .9 = 16.875 ipm
Recommended tapping speeds in surface feet per min-
ute are shown in Figure M-52. Surface feet per minute rates
from the figure have to be expressed in terms of tool rpm.

Figure M-50 Spiral pointed taps will push chips ahead of the
tap in through holes. For blind holes, the spiral fluted taps will lift
chips from the hole (Kennametal, Inc.).

Figure M-51 The thread-forming or fluteless tap produces no


Figure M-49 Tapping on the CNC vertical spindle machining chips, eliminating chip disposal problems. This type of tap is
center (Courtesy of Haas Automation, Inc.). suitable for tapping ductile materials (Kennametal, Inc.).

You might also like