Six Key Concepts Needed To Master CNC Programming
Six Key Concepts Needed To Master CNC Programming
Six Key Concepts Needed To Master CNC Programming
CNC Programming
Mike Lynch - CNC Concepts, Inc. - 847-639-8847 - lynch@cncci.com
Outline
Key Concept 1: Know your machine from a programmer's viewpoint
o Machine configurations: components, axes, and programmable functions
o Visualizing program execution
o Understanding program zero
o Introduction to programming words
Key Concept 2: You must prepare to create CNC programs
o The importance of preparation
o Preparation steps: mark-up print, create the process, select tooling and cutting conditions, do the math, plan the
setup
Key Concept 3: Understand the basic motion types
o Motion commonalities
o Motion types: rapid, linear, circular
Key Concept 4: Compensation lets you deal with unpredictable tooling-related variables
o Reasons for compensation, trial machining
o Tool length compensation
o Cutter radius compensation
o Fixture offsets
Key Concept 5: Provide structure to your CNC programs
o Reason to provide structure: familiarization, consistency, rerunning tools
o Four types of program format: Program start, tool end, tool start, program end
Key Concept 6: You have special features to simplify programming
o Canned cycles
o Sub-programing
o Other special features
Six Key Concepts Needed to Master CNC Programming
With this kind of machine, notice that the cutting tool does not move in the X and Y-axis. The table and therefore the part moves
in X and Y in relation to the tool. The tool only actually moves in the Z-axis.
Axis polarity
Though not depicted in figure 1.2, each axis has a polarity (plus and minus direction). As the table moves to the left, it is moving
in the X-plus direction. As it moves to the right, it is moving in the X-minus direction. As the table moves toward you, it is moving
in the Y-plus direction. As it moves away from you, it is moving in the Y-minus direction. As the headstock/cutting tool moves up,
it is moving in the Z-plus direction. As it moves down, it is moving in the Z-minus direction.
Since the cutting tool does not move in the X and Y axes, it can be a little confusing (especially for programmers) to understand
polarity by looking at table motion. From a programmer’s viewpoint, it is much easier to understand polarity if you imagine that
the cutting tool is moving in all axis. Figure 1.3 shows how to visualize polarity with this method.
Z+
Programmers should view Y+
polarity as if the tool is
moving in all axes
X-
X X+
Y-
Z-
If you imagine that the cutting tool is moving in X and Y, determining polarity will be easier. As the cutting tool moves to the
right, it is moving in the X-plus direction. (But remember, the cutting tool does not really move to the right in the X-axis–it is the
relative motion of the tool and part as the table moves to the left–which again, is the X-plus direction.) As the cutting tool moves
to the left, it is moving in the X-minus direction. As the tool moves away from you, it is moving in the Y-plus direction. As it
moves toward you, it is moving in the Y-minus direction. In Z, of course, the tool is really moving with the axis, so polarity is
much easier to understand–up is Z-plus, down is Z-minus.
Spindle
The spindle of all machining centers can be programmed in at least three ways, activation (start/stop), direction (forward/reverse),
and speed (in revolutions-per-minute or rpm). Some machining centers also provide multiple power or gear ranges (like the
transmission of an automobile).
Spindle speed
You can precisely control how fast the spindle of a machining center rotates in one rpm increments. An S-word is used to specify
spindle speed. If you want the spindle to rotate at 350 rpm, program S350. Since spindle speed is specified in whole numbers, you
must not include a decimal point with the S-word. Also, the S-word by itself does not actually start or activate the spindle.
Spindle activation and direction
You can control which direction the spindle rotates–forward or reverse–and stop the spindle using M-codes. The forward direction
is used for right-hand tooling. It will appear as counter-clockwise when viewed from in front of (below) the spindle. The reverse
direction is used for left-hand tooling and will appear as clockwise when viewed from in front of the spindle.
Three M-codes control spindle activation. M03 turns the spindle on in the forward direction. M04 turns the spindle on in a reverse
direction. M05 turns the spindle off.
Spindle range
Some, especially larger machining centers, have two or more spindle ranges. Spindle ranges are like the gears in an automobile
transmission. Lower ranges are used for power–higher ranges are used for speed. With most modern machining centers, spindle
range selection is automatic and transparent. The spindle range will be automatically selected when you specify a spindle speed (S-
word). For this reason, some programmers don’t even know the machine that they are programming has two or more spindle
ranges! For older machines, you may have to change gears in the program using M-codes–check the machine tool builder’s
programming manual.
Feedrate
As you know, a machining center has three linear axes, X, Y, and Z. You must be able to control how quickly these axes move,
especially during machining. Feedrate is the rate at which the cutting tool will move during a machining operation. It is a
programmable function for all machining centers. Feedrate is specified with an F-word (F for feedrate). For most machining
centers, feedrate is specified in the distance moved in a minute, either inches-per-minute or millimeters-per-minute.
Most cutting tool manufacturers provide feedrate recommendations in distance-per-revolution or distance-per-tooth/flute. That is
in inches-per-rev (ipr) or millimeters-per-rev (mmpr). To determine the inches-per-minute (ipm) feedrate, you must multiply the
inches-per-revolution (ipr) value by the spindle speed used in the program in rpm.
Modern CNCs allow feedrate to be specified directly in distance-per-revolution (inches-per-revolution or millimeters-per-
revolution) - which minimizes calculations. If both feedrate specifications are allowed (inches-per-minute and inches-per-
revolution), G-codes are used to specify the feedrate type.
G94 is used to select feed-per-minute mode and G95 is used to select feed-per-revolution mode. Any F-word following a G94 will
be considered as a feed-per-minute feedrate. Any F-word following a G95 will be considered as a feed-per-revolution feedrate.
To make programs as flexible as possible, it is recommended that G94 feed-per-minute be used for all normal machining; after all
it is a simple calculation. The one application that will benefit from using feed-per-revolution programming is tapping, where the
feedrate must be equal to the threads-per-revolution.
Coolant
Coolant is the fluid used to flush chips away from the cutting area. It also cools and lubricates the cutting operation. All machining
centers provide flood coolant capability. Flood coolant is turned on and off with an M-code–M08 coolant on; M09 coolant off.
When raw material comes to the machine in the form of short slugs (like round bars cut to length), the application is called
chucking (or chucker) work. The raw material is secured solely by the workholding device (commonly a three-jaw chuck).
With longer slugs (longer than about three to four times the raw material diameter), the workholding device by itself will not be
sufficient to secure the workpiece for machining. For these applications, some form of work support device/s must be used
(commonly a tailstock and/or steady-rest). This application is called shaft work.
With bar work, the raw material comes to the turning center in the form of a long bar (from four to fifteen feet long [1.2-5 meters],
depending upon the type of bar feeder being used). Bar work requires a special bar support and feeding device (called a bar
feeder). The bar is fed through the headstock and spindle into the working area. A workpiece is machined and cut off from the
bar. The bar is then fed again for another workpiece to be machined.
Figure 1.1 shows a universal style slant bed turning center. The headstock houses a spindle to which the workholding device is
mounted. Our illustration shows a three-jaw chuck, but other types of workholding devices can be used (collet chuck, expanding
mandrel, etc.). To the right of the workholding device is the tailstock, which is used to support the right end of long workpieces –
again, for shaft work. The turret of the turning center is used to hold cutting tools and it can be quickly rotated from one tool
station to another. Current turning centers have turrets that hold from six to twelve cutting tools.
Figure 1.1 – A universal style slant bed turning center with its door removed
Directions of motion (axes) for a universal style slant bed turning center
All turning centers have at least two linear axes of motion. The turret (and cutting tool) will move along with these two axes. By
linear, we mean the axis moves along a straight line.
Figure 1.2 – The two most basic axes of motion for a CNC turning center
The diameter-controlling axis (up/down motion of the turret as shown in Figure 1.2) is the X-axis. The length-controlling axis
(right/left motion of the turret as shown in Figure 1.2) is the Z-axis. Figure 1.2 shows these directions of motion along with the
polarity (+/-) for each.
These two most basic directions of motion will remain exactly the same for almost all types of turning centers (only a handful of
turning center manufacturers stray from what we show in Figure 1.2.) The X-axis will always be the diameter-controlling axis –
and X minus is always the direction that causes the cutting tool to move to a smaller diameter (toward the spindle centerline). The
Z-axis will always be the length controlling axis – and Z minus will always be the direction that causes the cutting tool to move
toward the workholding device.
X is specified in diameter
Though we may be a little ahead of ourselves, the X-axis is designated in diameter for almost all turning centers. That is, if a
diameter of 3.0 inches must be machined, the designation for the X-axis will be X3.0. There are some (especially older) turning
centers that require the X-axis to be specified with radial values. For these machines, the word X1.5 will cause the tool to be
positioned to a 3.0 inch diameter. Note that it is much easier to work with a turning center when the X-axis if it is designated in
diameter – which is why most current model turning centers do so.
Spindle
The spindle of all turning centers can be programmed in at least three ways, activation (start/stop), direction (forward/reverse), and
speed (in either surface feet/meters per minute or revolutions per minute). Many turning centers additionally provide multiple
power ranges (like the transmission of an automobile).
Spindle speed
You can precisely control how fast the spindle of a turning center rotates. An S-word is used for this purpose. There are two
ways to specify spindle speed. When the spindle is in rpm mode, an S-word of S500 specifies a speed of 500 revolutions per
minute (rpm). When the spindle is in constant surface speed mode, an S-word of S500 specifies a speed of 500 surface feet per
minute (sfm), assuming you are working in the inch measurement system. (If you work in the Metric measurement system, S500
will specify 500 meters per minute when in constant surface speed mode.)
We will describe the two spindle speed modes – as well as how to determine how and when to use them.
Feedrate
You know that all turning centers have at least two linear axes, X and Z. You also know that the cutting tool (for most turning
centers) moves along with these two axes. It is the motion of the cutting tool while it is in contact with the workpiece that causes
machining to occur. It is important that the motion rate (how quickly the tool moves) be appropriate to the machining operation
being performed. In CNC turning center terms, this motion rate is called feedrate.
An F-word is used to specify feedrate. And like spindle speed, feedrate can be specified in two ways. It can be specified in per
minute fashion or in per revolution fashion. As the names imply, when feedrate is specified in per minute fashion, it specifies how
far the cutting tool will move during one minute. When feedrate is specified in per revolution fashion, it specifies how far the
cutting tool will move during one spindle revolution.
Also as with spindle speed (at least in constant surface speed mode), feedrate specification is related to the measurement system
you use. In the inch mode, feedrate is specified in either inches per minute (ipm) or inches per revolution (ipr). In metric mode,
feedrate is specified in either millimeters per minute (mmpm) or millimeters per revolution (mmpr).
F-word – Feedrate specification
G20 – Inch mode
G21 – Metric mode
G98 – Feed per minute mode
G99 – Feed per revolution mode
Here are a few examples of feedrate specification:
N010 G20 G98 F4.0 (4.0 inches per minute)
N020 G20 G99 F0.015 (0.015 inches per revolution)
N030 G21 G98 F100.0 (100.0 millimeters per minute)
N040 G21 G99 F0.5 (0.5 millimeters per revolution)
With gang style turning centers, of course, there is no turret to index. Only two things will happen with the previous command:
geometry and wear offset number four will be selected.
Most programmers will make the wear offset number the same number as the turret station number and geometry offset number.
Coolant
All turning centers allow programmable control of flood coolant. Coolant is commonly used to cool the workpiece during
machining and to lubricate the machining operation. Two M-codes are used to control coolant. Almost all turning center
manufacturers use M08 to turn on flood coolant and M09 to turn it off.
Program Structure
Like the sentences that make up a set of instructions, a CNC program is made up of blocks. Each block is made up of words. Each
word is made up of a letter address (N, X, Z, T, etc.) and a numerical value. The figure below shows the beginning of a CNC
program that illustrates this basic program structure.
CNC program:
Now here is a CNC program to drill the 0.500 diameter hole in the workpiece on a CNC machining center.
O0001 (Program number)
N010 G20 G90 (Select inch & absolute programming modes)
N020 G54 (Set the program zero point)
N030 T01 M06 (Load the drill into spindle)
N040 S600 M03 (turn spindle on CW at 600 RPM)
N050 G00 X1.0 Y1.0 (Move tool above the hole in X and Y)
N060 G43 H01 Z0.1 M08 (Rapid to workpiece surface, instate tool length compensation, turn coolant on)
N070 G01 Z-1.0 F3.5 (Drill hole at 3.5IPM)
N080 G00 Z0.1 M09 (Retract drill, coolant off)
N090 G91 G28 Z0. M05 (Rapid to Z-ref position, spindle off)
N100 G28 X0. Y0. (Rapid to X/Y reference positions)
N110 M30 (End of program)
controlled manner. One of the ways you must be able to control each axis is with precise positioning within the workpiece
coordinate system.
The workpiece coordinate system has an origin point that is called the workpiece coordinate system zero. It allows you to specify
all positions or coordinates from this central location. As a programmer, you will be choosing the location for the workpiece
coordinate system zero–and if you choose it wisely, many of the coordinates you will use in the program will come directly from
your workpiece engineering drawing, meaning the number and difficulty of the calculations required to create a program can be
reduced.
A Graph Analogy
A simple graph helps understanding of the CNCs workpiece coordinate system. Since everyone has had to interpret a graph at one
time or another, we can relate what you already know to CNC coordinates. The figure below is a graph showing a company’s
productivity over a year.
In the figure above, the horizontal base line represents time. The increment of the time baseline is specified in months. One whole
year is the range January through December. The vertical baseline represents productivity. The increment for this baseline is
specified in 10% increments and ranges from 0% to 100% productivity. The point at which the horizontal baseline and the vertical
baseline cross is called the origin.
In order to make this graph, a person must have the productivity data for the year. To plot the point for January, they locate
January on the horizontal baseline and then move up vertically until they are parallel with the value of 90% on the vertical
baseline. To plot the point for February, they locate February on the horizontal baseline and then move up vertically until they are
parallel with the value of 80% on the vertical baseline. This procedure is repeated for every month of the year. Once all of the
points are plotted, a line or curve can be passed through each point to show anyone at a glance how the company did last year.
A graph is very similar to the workpiece coordinate system used with CNC. Look at the figure below.
For the workpiece coordinate system used with CNC machining centers, the horizontal baseline represents the positions or
coordinates of the X-axis. The vertical baseline represents the positions or coordinates of theY-axis. (The Z-axis is at a right-angle
to the page, toward and away from you. For now, let’s concentrate on the X and Y axes.)
The increment of each base line is given in linear units. Working in the inch mode, each increment is given in smallest increment
programmable on the CNC. For many CNCs, the smallest programmable increment is 0.0001 inches, meaning each CNC axis has
a very fine grid. If you work in the metric mode, the increment will be in millimeters. In the metric mode, the smallest
programmable increment typically is 0.001 mm.
The range for each axis is the amount of travel in the axis (from one over-travel limit to the other).
Understanding Polarity
In the graph example previously illustrated, all the points plotted are above and to the right of the origin point. The area above and
to the right of the two baselines is called a quadrant. This particular quadrant is quadrant number one where the coordinates in both
axes are positive. The person creating the productivity graph intentionally planned for coordinates to fall in quadrant number one
in order to make the graph easy to read. It is not uncommon on CNC machines that end points within the program fall in other
quadrants. When this happens, at least one of the coordinates must be specified as negative or minus value.
Each CNC axis has a polarity. You also know that since sometimes the cutting tool moves and sometime the table moves, it can be
confusing to remember which way is plus and which way is minus. (Consider the X and Y axes of a C-frame style vertical
machining center, for example. As the table moves to the left, it is moving in the X plus direction.) To make things easier, we
asked you to view polarity as if the tool was actually moving in each axis.
The workpiece coordinate system makes determining the polarity of coordinates used in a program very simple. The figure below
shows the polarity for the X-axis in the workpiece coordinate system.
Notice that polarity is based upon the location of the workpiece coordinate system zero–as it will be for all axes. For X, anything
to the right of the workpiece coordinate system zero is positive (plus). Anything to the left of workpiece coordinate system zero is
negative (minus).
A CNC will assume that a coordinate is positive (plus) unless a minus sign is specified. The CNC word X2.0, for example,
specifies a position along the X-axis of positive 2.0-inches. Some CNCs may generate an alarm if the plus sign is included within
the word, meaning you must let the control assume positive values. It is common practice to only include a polarity sign for
negative (-) values.
The workpiece coordinate system zero must also be specified in the Z-axis. The figure below shows the XZ plane (looking at a
vertical machining center from the front).
Anything above workpiece coordinate system zero in Z is positive (plus). Anything below workpiece coordinate system zero point
is negative (minus).
Notice that we have selected the top of the workpiece as the workpiece coordinate system zero in Z (which is a common program
zero point for vertical machining center applications). Any tool position above the top of the workpiece is positive (plus) in Z. Any
position below the top of the workpiece is negative (minus) in Z.
Figure 1.20: Movements can be specified in both the absolute and incremental positioning mode.
As you can see, absolute positioning makes more sense. Coordinates often match print dimensions – but even when they don’t–the
point of reference for each position is the same–the workpiece coordinate system zero. Incremental positioning doesn’t make much
sense. Positions are nothing more than a whole series of disjointed movements, each taken from the tool’s previous position.
Notice how this form guides you to document the sequence of machining operations that your program will use. Months or years
after a CNC program is developed, there may be a need to revise it. If the person doing the revision can review a completed
machining process planning form for the workpiece, it will be much easier to make the necessary changes.
The last reason we will give to plan the process first is to simply help you remember the operations to perform during
programming. Remember, beginners tend to make mistakes of omission. You will have enough to think about when it comes to
remembering the various commands needed in the program. The process planning form is a step-by-step set of instructions to
machine the workpiece. It can be used as a check-list. Without this form, you will be prone to omitting important operations from
the CNC program.
Figure 2.3: Example Machining Process Planning Form with Feeds and Speeds
9
3.0
0.75
2.0 7 8
1.125
0.5 1 2 3
X Y Z
Figure 2.7: Example showing how to document the math needed in a program
In the Z column of the coordinate sheet in the figure above, notice there are three values. The first (0.1) is the approach position.
The same approach distance is used for all tools. The second (-0.12) is the hole bottom position for the center drill. The third (-1.0
or -1.5) is the hole bottom position for the drill.
Sketch of setup:
Fixture/vise:
Clamps:
Other notes:
This universal setup sheet does not include a detailed list of components for the cutting tools used in the program. Many
companies do include a more complete tool list, possibly on a separate page. This setup sheet also does not include a complete list
of the workholding tools. Again, many companies do include this kind of information so someone (probably other than the setup
person) can be gathering all needed components even before the setup is made.
What is Interpolation?
When a single linear axis is moving (X, Y, or Z), the motion will be along a perfectly straight line. For example, look at the figure
below.
Figure 3.21: A perfectly straight motion will occur if only one axis is moving
When milling the left side of the workpiece (left view above), only the Y-axis is moving. And since the Y-axis is a linear axis, the
motion is perfectly straight and parallel to the Y-axis. When milling the lower surface (middle view above), only the X-axis is
moving and the motion is perfectly straight and parallel to the X-axis. The same goes for milling the right side (right view above)–
only the Y-axis is moving and the motion has to be perfectly straight.
But notice that the upper side of this workpiece is tapered. It will require that both the X and Y axes to move in a coordinated
manner, as shown in the figure below.
Figure 3.22: Milling the upper side of this workpiece requires both the X and Y axes move in a controlled manner
Two axes must move if the tool motion is at an angle as shown in the figure above. In CNC terms, this kind of motion is called
interpolation.
The CNC breaks the two-axis motion up in to a series of very tiny steps. The step size for current FANUC CNCs is 0.000000001
millimeters or 0.0000000004-inches. Even with older CNCs the steps are so small that you cannot see or measure them with most
measuring devices. The smaller the step size, the finer the machine’s resolution and the more precisely it will follow your
commanded motions. For all intents-and-purposes, all machined surfaces will appear to be perfectly straight and without steps.
Actually, it should be comforting to know that there are only three primary ways to cause axis motion–rapid, linear interpolation,
and circular interpolation. Just about every motion a CNC machining center makes can be divided into one of these categories.
Once you master these three motion commands, you will be able to generate the motions required to machine a workpiece. The
figure below illustrates these 3 primary motion types.
End point
Rapid motion
End point
End point
End point Linear motion
Linear motion
End point
Figure 3.23: The three kinds of motion available with all CNC machining centers
As you will see, it is actually quite easy to specify motion commands within a CNC program. In general, each motion will require
you to specify the kind of motion (rapid, linear interpolation, or circular interpolation) along with the motion’s end-point (the
coordinates at the end of the motion). Linear and circular interpolated motion additionally require that you specify the rate at
which the axes will move (feedrate). Circular interpolation also requires that you specify either the radius of the arc or the
coordinates of the center of the arc.
Due to this very fast–and somewhat scary–motion rate, most machine tool builders will allow you to override the machine’s rapid
rate during a program’s verification using a multi-position switch called rapid traverse override. Though this feature varies from
machine to machine, most machining centers allow you to slow the rapid rate significantly. This relieves some of the stress of
running a program for the first time, and minimizes the potential for problems if a mistake has been made in a rapid motion
command.
The figure below shows an example of rapid motion.
surfaces to be machined, retracting tools to the machine’s tool changing position, and any other non-cutting operation that occurs
(getting from one cutting position to another). A good rule-of-thumb is “If the tool is not cutting, it should be moving at rapid”.
Certain other commands automatically cause the machine to move at its rapid rate. A G28 command, which sends the axes to the
zero return position will also be done at the rapid rate. The command,
N100 G91 G28 Z0.0
for example, will send the machine to its Z-axis zero return position. This is the tool change position for most vertical machining
centers. Though a G00 is not included in this command, the machine will move at its rapid rate during this move.
CW CCW
Like linear interpolation, circular interpolation requires that a feedrate be specified (with an F-word). Feedrate is specified in
distance-per-minute (inches- or millimeters-per-minute). And, feedrate is modal. Even if a feedrate is originally specified in a
linear interpolations command, it will remain effective during subsequent circular interpolation commands.
Also as with linear interpolation motion, circular interpolation commands require that the end point of the circular motion be
specified. The tool’s position prior to the circular interpolation motion is the starting point for the circular motion.
Figure 3.6: Outside radius tool centerline path versus inside radius tool centerline path.
With an outside radius as shown above, you must add the cutter radius to the workpiece radius to come up with the cutter’s
centerline path radius. If milling an inside radius (as would be the case when milling a circular pocket), you must subtract the
milling cutter’s radius from the workpiece radius to come up with the cutter’s centerline path radius. The figure below shows a full
example of circular motion.
Before a marksman can fire a rifle, they must judge the distance to the target. If the target is judged to be fifty yards away, the
sight on the rifle will be adjusted accordingly. When the marksman adjusts the sight, they are compensating for the distance to the
target. But even after this preliminary adjustment and before the first shot is fired, the marksman cannot be absolutely sure that the
sight is adjusted perfectly. If they’ve incorrectly judged the distance–or if some other variation (like wind) affects the sight
adjustment–the first shot will not be perfectly in the center of the target.
After the first shot is fired, the marksman will know more. If the shot is not perfectly centered, another adjustment will be needed.
And the second shot will be closer to the center of the target than the first. Depending upon the skill of the marksman, it might be
necessary to repeat this process until the sight is perfectly adjusted.
With all forms of CNC compensation, the setup person will do their best to determine the compensation values needed to perfectly
machine the workpiece. But until machining actually occurs, the setup person cannot be sure that their initial compensation values
are correct. After machining, they may find that another variation (like tool pressure) is causing the initial adjustment to be
incorrect. Depending upon the tolerances for the surfaces being machined, a second adjustment may be required. After this second
adjustment, machining will be more precise.
There is even a way to make an initial adjustment (prior to machining) that ensures excess material will remain on the machined
surface after the first machining attempt (this technique is called trial machining). This guarantees that the workpiece will not be
scrapped when the cutting tool machines for the first time–and is especially important for very tight (small) tolerances. With tight
tolerances, even a small machining imperfection will cause a scrap workpiece.
Once the cutting tool has machined for the first time, the setup person will stop the cycle and measure the surface. If they have
used the trial machining technique, there will be more material yet to remove. They will then make the appropriate adjustment and
re-run the cutting tool. The second time the cutting tool machines, the surface will be within its tolerance band, probably right at
the target dimension.
Tolerances
All dimensions have tolerances. You must program the mean value of the tolerance band for every coordinate you include in your
programs. The mean value, of course, is right in the middle of the tolerance band.
Companies vary when it comes to how tight (small) the tolerances are that they machine on their CNC machining centers.
Generally speaking, overall tolerances over about 0.010 inch (about 0.25 mm) are considered pretty open (easy to hold with
today’s CNC machining centers). Tolerances between 0.002 and 0.010 inch (0.050–0.25 mm) are common, and still not considered
to be very tight. But tolerances under 0.002 inches can be more difficult to hold. And under 0.0005 inch (0.0013 mm)–which many
companies do regularly hold on their CNC machining centers–can be quite challenging–especially when many workpieces must be
produced.
precisely to the target value, trial machining should not be necessary. Examples include the depth of many (blind) holes and a
certain milling operations.
As stated, trial machining is only required when machining tight tolerances. Though the actual cut-off point for when trial
machining is required varies based upon the skill of the setup person and the operation being performed, it is not uncommon to
trial machine for dimensions that have tolerances under about 0.002 inch (0.050 mm). This includes finish boring operations and
many milling operations.
Understanding Offsets
All three compensation types use offsets. Offsets are storage locations for values. They are very much like memories in an
electronic calculator. With a calculator, if a value is needed several times during your calculations, you can store the value in one
of the memories. When the value is needed, you simply type one or two keys and the value returns. In similar fashion, the setup
person or operator can enter important tooling-related values into offsets. When they are needed by the program, a command
within the program will invoke the value of the offset. And by the way, just as a calculator’s memory value has no meaning to the
calculator until it is invoked during a calculation, neither does a CNC offset have any meaning to the CNC control until it is
invoked by a CNC program.
Like the memories of most calculators, offsets are designated with offset numbers. Offset number one may have a value of 6.5439.
Offset number two may have a value of 6.2957. For cutting tool related offsets, offset numbers are made to correspond in some
way to tool station numbers. For example, the tool length compensation value for the cutting tool placed in station number one is
commonly entered in offset number one.
Unlike the memories of an electronic calculator that will be lost when the calculator’s power is turned off, CNC offsets are more
permanent. They will be retained even after the machine’s power is turned off–and until an operator or setup person changes them.
Offsets are used with each compensation type to tell the control important information about tooling. From the marksman analogy,
you can think of offset values as being like the amount of sight adjustment a marksman must make prior to firing a shot. Tooling
related information entered into offsets includes each cutting tool’s length, each milling cutter’s radius, and program zero
assignment values for work holding devices.
Offset Organization
Machining center controls vary with regard to how many offsets are available and how they are organized. First of all, rest assured
that you will always have enough offsets to handle your applications. Most machine tool builders supply many more offsets than
are required even in the most elaborate applications (an exception to this statement may sometimes be with regard to workpiece
coordinate system setting offsets). Most machining centers have two distinct sets of offsets, one for cutting tools (tool offsets) and
another for the workpiece coordinate system zero (work offsets).
Offsets Related to Cutting Tools
All cutting tools will require a tool length compensation offset. Milling cutters that perform side milling operations will
additionally require a cutter radius compensation offset. Today’s CNCs also separate the tool offsets into geometry (the value
measured at initial setup) and wear (the value determined by trial machining or tool wear). CNC manufacturers vary when it comes
to how offsets are organized and displayed.
Figure 4.1: Display screen having four values per offset number
Today’s CNCs typically have four fields of data available for each tool pocket in the tool changer magazine. That means the tool
length offset (H-word – example, H01) has the same number as the cutter radius offset (D-word, example, D01) and the tool
number (T-word – example, T01). The tool length offset has two components, geometry and wear. The tool length geometry offset
is the nominal length of the tool measured by the setup person. The tool length wear offset is used for fine tuning due to trial
machining or tool wear. The cutter radius offset also has two components, geometry and wear. The tool wear geometry offset is the
nominal radius of the cutter measured by the setup person. The cutter radius wear offset is used for fine tuning due to trial
machining or tool wear. The CNC adds the respective geometry and wear offsets together to compensate for the tool length or the
cutter radius.
Figure 4.5: Five cutting tools that might be used in by a CNC machining center program
Tool length compensation will allow you to write programs even though you don’t know how long the cutting tools will be at
production time.
Tool’s Length Will Vary Each Time it is Assembled
When a cutting tool is assembled more than once (even with the same components), its length will usually vary. Consider, for
examples, straight shank tools that are placed in collet holders. Each time you assemble the tool, it will be of a different length.
Tool length compensation will allow you to use the same program over and over again, even though each tool’s length changes
from one time the job is run to the next.
Tool Data is Entered Separately from the Program
The same program will work regardless of how long each cutting tool is. The program tells the control where to look for the length
of each tool. During setup, the setup person (or someone) assembles and measures each cutting tool. The length of each tool is then
placed in the appropriate location (a tool offset register).
Sizing and Trial Machining Must Often be Done
During a given tool’s life a tool will wear and cause the surface being machined to change. Tool length compensation allows the
setup person and operator to easily hold size for Z-axis related dimensions (pocket depths, hole-depths, etc.). The program need
not be changed when workpiece dimensions must be adjusted.
2.0
1.0
Program
1.0 1.0 1.0
zero
4.0
Tool 1: 1/4 drill
Tool 2: 3/8 drill
0.5
Tool 3: 1/2 drill
3. A command instating cutter radius compensation that brings the milling cutter (in X and/or Y) to the first surface to mill
Let’s discuss these commands one at a time.
The XY motion to the prior position
This positioning movement brings the center of the milling cutter to a position in X and Y that makes it possible to instate the
cutter radius compensation. It is usually done at rapid–with the milling cutter is well clear of the workpiece. Indeed, this motion is
usually done while the milling cutter is above the workpiece in the Z-axis.
We call the end-point for this motion the prior position because it is the XY position just prior to the instating command. The next
XY motion will instate cutter radius compensation.
The prior position must be at least the milling cutter’s radius (the value stored in the cutter radius compensation offset) away from
the surface to mill. And it is important to choose a prior position that allows the milling cutter to form a ninety degree angle (right
angle) with the first surface to be milled.
That is a lot to remember, so let’s look at an example. The figure below shows the prior position.
3
Milling the left side of a workpiece
Stock to be machined
Program zero
1
2 4.5
Prior Position Must be equal to or greater
than the cutter radius
When a 1.000 inch cutter moves to the position specified in block N040, it will be perfectly flush with the first surface to mill.
While this will work as a prior position for a 1.000 end mill, it does not allow for any variation (like trial machining and sizing)
during the production run. You have set the maximum cutter size to a 1.000 diameter end mill. If the setup person enters anything
larger than 0.500 inch in the cutter radius compensation offset, the machine will generate an alarm. (The machine will think the
cutter is already violating the first surface to mill.)
Let’s revise the prior positioning movement to
N015 G00 X-0.6 Y-0.6
Now there is plenty of clearance between our planned 1.000 end mill and the first surface to machine. In fact, an end mill up to
1.200 inches in diameter can be used without generating an alarm. So, one way to determine maximum cutter size is to double the
distance from the prior position to the first surface to mill. (Note that there are some other limiters for maximum cutter size. You’ll
see them as we continue.)
Block N040 is the movement to the prior position in the X and Y axes. Block N050 instates tool length compensation and moves
the end mill to just above the work surface. Block N060 moves it to the Z-axis work surface (still at rapid). Note that you could
include Z-1.1 in block N050 instead of Z0.1 to bring the end mill directly to the Z-axis work surface. This is a matter of
programming style.
Instate cutter radius compensation and position the cutting tool to the first surface to mill
At this point, the tool is positioned ready to instate cutter radius compensation. The instating command will include three things: 1:
a G41 or G42 specifying the relationship between the milling cutter and the tool path, 2: a D-word specifying the offset number
containing the cutter radius compensation value, 3: a motion to the first work surface to be machined.
G41 or G42?
One of two G-codes will be used in the instating command.
G41–milling cutter is to the left of the its path
G42–milling cutter is to the right of its path
One way to determine which of G41 or G42 you must use is to look in the direction the milling cutter will be moving as it
machines the work surface and ask “Which side of the work surface is the milling cutter on?” If the milling cutter is on the left
side of the work surface, you will use G41 in the instating command. If the cutter is on the right side of the work surface, you will
use G42. Selecting the G41 or G42 tells the CNC on which side to instate the value stored in the cutter radius offset. The figure
below shows some examples.
3
Milling the left side of a workpiece
Stock to be machined
Program zero
1
2 4.5
Prior Position Must be equal to or greater
than the cutter radius
The instating command moves the milling cutter from the prior position (point number 1) to the first work surface to machine
(point number 2). Again, notice that point number 2 is right on the work surface. Also, the instating command can be done at rapid
(G00) if the milling cutter clears the workpiece during the motion–or in a straight line motion (G01) with a feedrate if it does not.
You are not allowed to instate cutter radius compensation during a circular motion command (G02 or G03).
Since points one and two in our example are well clear of the workpiece in the Y-axis (with our 1.00 planned cutter size), we’ll
make the instating command at rapid. Here are the commands so far:
O0001 (Program number)
N010 G20 G90 G94 G54
N020 T01 M06 (1.0 end mill)
N030 S350 M03 T02 (( start spindle fwd at 350 rpm, and get tool station one ready)
N040 G00 X-0.6 Y-0.6 (Rapid to prior position)
N050 G43 H01 Z0.1 (Instate tool length compensation)
N060 Z-1.1 M08 (End mill is now at Z-axis work surface and coolant is on)
N070 G41 D01 X0.0 (Instate cutter radius compensation)
3 10 2
4 9
4.0
0.25 5 8
6 7
1.25 end mill (planned
cutter size)
6.0
0.2
Figure 4.10: More elaborate example of a work surface tool path using cutter radius compensation
The work surface tool path takes the milling cutter from point 2 to point 3 (linear interpolation motion)–from point 3 to point 4
(circular interpolation motion)–from point 4 to point 5 (linear interpolation motion)–and so on through point number 10.
Remember that since you are programming the work surface tool path, the radius of all circular motions (R-word) will be the
actual workpiece radius, R0.125 for each circular motion in our example.
When the milling cutter reaches point number 10, it is finished milling the contour, but if you allow it to retract in Z at point 10, it
will leave a nasty witness mark on the workpiece (a gouge-line on the side of the milled surface). Most programmers will come up
with one more work surface tool path motion to bring the milling cutter away from the last surface to mill. This is best done in a
circular motion (commonly called an arc-out motion). The size of this arc must, of course, be larger than the radius of the largest
planned cutter. It must also include enough clearance to allow the largest planned cutter to move away from the last surface being
milled.
For our example, when using the planned cutter size (1.25 inch in diameter), the 0.975 arc-out radius will provide 0.350 inch
motion away from the last surface milled (0.975 arc-out radius minus 0.625 milling cutter radius). This distance provides clearance
for the 0.25 inch step around the contour. When the cutter reaches point number 11, it will be completely clear of the workpiece
(by 0.1 inch) when using a 1.25 diameter cutter.
Step 3: Cancel Cutter Radius Compensation
Like many CNC features, cutter radius compensation is modal. The machine will continue to keep the milling cutter on the right or
left side of all programmed motions until cutter radius compensation is cancelled. A G40 word is used to cancel cutter radius
compensation. The very next X and/or Y coordinate (either within the G40 command or after it) will be a taken as a centerline
position.
Though it is not always possible to do so, we recommend retracting the milling cutter in the Z-axis prior to canceling cutter radius
compensation. This way, the cutter will be clear of the workpiece should an unexpected X and/or Y movement take place during
cancellation.
3
Milling the left side of a
workpiece
Stock to be machined
Program zero
1
2 4.5
Prior Position Must be equal to or greater than
the cutter radius
Here is the entire milling operation, including the cancellation of cutter radius compensation:
O0001 (Program number)
N010 G20 G90 G94 G54
N020 T01 M06 (1.0 end mill)
N030 S350 M03 T02 (( start spindle fwd at 350 rpm, and get tool station one ready)
N040 G00 X-0.6 Y-0.6 (Rapid to prior position)
N050 G43 H01 Z0.1 (Instate tool length compensation)
N060 Z-1.1 M08 (End mill is now at Z-axis work surface and coolant is on)
N070 G41 D01 X0.0 (Instate cutter radius compensation)
N080 G01 Y3.6 F5.0 (Mill left side)
N090 G00 Z.01 M09 (Retract cutter above work surface, turn off coolant)
N100 G40 (Cancel cutter radius compensation)
N100 G91 G28 Z0 M19 (Move to tool change position, orient spindle)
N110 M01 (Optional stop)
.
.
.
In block N090, we retract the tool to above the workpiece–then in block N100, we cancel cutter radius compensation. From this
point on, any XY position specified in the program will be to the spindle centerline.
Example
3 10 2
4 9
4.0
0.25 5 8
6 7
1.25 end mill (actual
cutter size)
The milling cutter will be milling the 0.25 inch step around the outside of this workpiece. The planned cutter size is a 1.25
diameter end mill (having a 0.625 radius). Based upon the distance from point one to point two in the program, the maximum
cutter size for this program is 1.45 inches in diameter.
Program with comments:
O0026 (Program number)
N010 G20 G90 G94 G54
(1.25 end mill in station 1)
N020 S400 M03 (Start spindle fwd at 400 rpm)
N030 G00 X6.725 Y4.475 (Rapid to prior position pt 1)
N040 G43 H01 Z0.1 (Instate tool length compensation)
N050 G01 Z-0.2 F40.0 (Fast feed to work surface)
N060 G42 D01 Y3.75 (Instate cutter radius compensation to pt 2)
N070 X0.375 F5.0 (Mill to point 3)
N080 G03 X.25 Y3.625 R.125 (Circular mill to point 4)
N090 G01 Y0.375 (Mill to point 5)
N100 G03 X.375 Y0.25 R.125 (Circular mill to point 6)
N110 G01 X5.625 (Mill to point 7)
N120 G03 X5.75 Y.375 R.125 (Circular mill to point 8)
N130 G01 Y3.625 (Mill to point 9)
N140 G03 X5.625 Y3.75 R.125 (Circular mill to point 10)
N150 G02 X4.65 Y4.725 R.975 (Arc-off the work surface to point 11)
N160 G00 Z0.1 (Retract to above the work surface in Z)
N170 G40 (Cancel cutter radius compensation)
N180 G91 G28 Z0.0 (Rapid to Z-axis zero return position)
N190 G28 X0.0 Y0.0 (Rapid XY to zero return position)
N200 M30 (End of program)
Since the cutter is 0.725 away from the right side of the workpiece in block N030, we’re allowing the fast-feed approach in line
N050 (at 40.0 ipm). In block N070, when milling begins, we include the cutting feedrate.
Admittedly, you don’t have to know how geometry offsets work to use them. But it’s important to know that nothing magical is
happening. Additionally, this presentation should help you understand the function of each value involved with program zero
assignment.
Wear offsets
Like geometry offsets, wear offsets are more related to CNC operators.
You know that the tolerances commonly held on CNC turning centers are quite small. It is not unusual to see at least one overall
tolerance of under 0.001 inch (0.254 mm) on turned workpieces.
You also know that each cutting tool has its own program zero assignment – and that there are several ways to assign program
zero. And you know that unless you are using a properly calibrated tool touch-off probe, mistakes with program zero assignment –
even minor ones – as well as the effects of tool pressure, make it difficult to perfectly assign program zero. That is, even after
program zero is assigned, there is no guarantee that every tool will machine the workpiece perfectly – or even within specified
tolerances. The tighter the tolerances you must hold, the greater the potential there will be for sizing problems.
Wear offsets provide a way to make minor adjustments when machined surfaces are not within their tolerance bands – or when
they’re close to a tolerance limit.
There are at least four times when a typical CNC setup person or operator will use wear offsets:
During setup and after mounting a cutting tool in the turret - After machining with the new tool, if the setup
person discovers that the cutting tool has not machined a surface within the tolerance band, or if the surface
is close to a tolerance limit, they can change a wear offset to make the needed adjustment.
When trial machining – Trial machining is done when the setup person or operator is worried that a cutting
tool (that has just been placed in the turret) will not machine within the tolerance band. Wear offsets are
commonly used with which to make trial machining adjustments (Remember, if you are using a properly
calibrated tool touch-off probe, you shouldn’t need to trial machine.)
When compensating for tool wear – As a cutting tool wears, it will cause the surfaces it machines to grow or
shrink in size. Wear offsets are used to keep cutting tools machining on-size for their entire lives.
-After a dull tool is replaced – Again, during a cutting tool’s life, tool wear commonly causes the need for sizing
adjustments in wear offsets. When a dull tool is replaced with a new one, the wear offset must be set back to
its initial value – otherwise the new tool will machine too much material from the workpiece.
Every dimension has a tolerance. You know that each tolerance will have a high limit (largest acceptable dimension), a low limit
(smallest acceptable dimension), and a mean value (the dimension right in the middle of the tolerance band.
You also know that each dimension to be machined on a workpiece will have a target value – this is the dimension you shoot for
when an adjustment must be made. Many CNC people use the mean value of the tolerance band as the target value. That is, when
an adjustment must be made, they target the mean value. While there are times when this may not be appropriate (large lot sizes
with small tolerances). That is, for each surface needing an adjustment, we’ll be targeting the mean value.
You know that the deviation is the amount of needed adjustment. It is the difference between the measured value and the target
value. In all cases, there will be a polarity to the deviation (plus or minus). The current wear offset value must be either increased
or decreased by the amount of the deviation. The polarity is determined by judging which way the cutting tool must move (plus or
minus) in order to bring the dimension back to the target value.
Programmed point
Radius
Radius
Radius
Programmed point
Programmed point
Boring bar
Turning tool Grooving tool
Figure 4.12 – All single point tools have a small radius on the cutting edge
For cutting tools used in the United States, the actual size of the radius will be specified in inches – and there are four standard tool
nose radius sizes for turning and boring inserts:
1/64 inch (0.0156)
1/32 inch (0.0316)
3/64 inch (0.0468)
1/16 inch (0.0625)
Though you may consider these radii to be quite small, this small nose radius on the edge of the cutting tool will be sufficient to
cause a small deviation from the programmed shape of your workpiece – at least when angular and circular surfaces must be
machined.
Remember that you are programming the extreme edges of the cutting tool in each axis. This is illustrated in Figure 4.12 (specified
as programmed point). Notice the small gap between the programmed point and the actual cutting edge.
This small gap will not affect the turning of diameters (parallel to the Z-axis) and the machining of faces (parallel to the X-axis).
Figure 4.13 shows this.
The tool nose radius will not affect diameters and faces
Figure 4.13 – The tool nose radius will not affect the machining of straight turns and faces
When a cutting tool is turning diameters and machining faces, the point programmed and cutting edge are in direct contact with the
workpiece surface being machined.
But when angular (tapered) surfaces and circular surfaces must be machined, the gap between the programmed point and the
cutting edge will affect machining – as Figure 4.14 shows.
The tool nose radius will affect the machining of tapers and arcs
Deviation caused
by tool nose radius
Deviation
Deviation caused
by tool nose radius
Programmed
points
Figure 4.14 – Tool nose radius affects the machining of angular and circular surfaces
Figure 4.17 – Drawing illustrates how to decide between G41 and G42
Notice that G42 is always used for turning toward the chuck and G41 is always used for facing (toward the spindle center) and
boring operations.
Once you know which side of the surface to be machined the tool is on (left or right), you simply include the appropriate G-code
(G41 or G42) in the cutting tool’s approach movement.
Programming motion commands to machine the workpiece
Once you’ve instated tool nose radius compensation, you simply program the movements to finish turn or bore the workpiece
using work surface coordinates. Again, these programmed coordinates are right on the work surface. The control will
automatically keep the cutting edge radius on the specified side of the workpiece (left or right), and tangent to surfaces being
machined.
Once tool nose radius compensation is instated, the machine will simply keep the tool on the left or right side of all programmed
surfaces until tool nose radius compensation is canceled.
An example program
Figure 4.19 shows the workpiece to be used for our first example program. Again, we’re only finishing this workpiece – the
roughing has already been done by another tool.
Figure 4.19 – Drawing for tool nose radius compensation example program
Familiarization
You must have some way to get familiar with CNC programming. You’ll need some help writing your first few programs. The
formats we show will provide you with this help. You’ll be able to use our given formats as a crutch until you (eventually) have
them memorized.
Consistency
If you have been doing the exercises in this text, you’ve already worked on a few actual programs, filling in the blanks with
needed CNC words. You have also seen several complete example programs in this course. You probably noticed that these
programs are written in a very consistent manner. And the commands within each tool of each program are consistent with the
other tools in the program.
When all the machining operations are programmed, you finish the program with the program-end structure.
One of the most important benefits of using the structured program format is that you do not have to memorize anything. You
simply copy the structures and edit the appropriate words.
The structured program formats assume that you are using workpiece coordinate system offsets to assign program zero. If you
come across a very old machine that does not support workpiece coordinate offsets.
Example program:
Here is an example program that stresses the use of program structure . Although the program is quite simple (it is actually the
same program shown earlier during our discussion of tool length compensation), it shows all of the principles of program
formatting. Pay primary attention to the strict structure followed for each tool. The program can be broken into mini-programs,
each making up one tool. Again, each tool is independent of the rest of the program.
2.0
1.0
Program
1.0 1.0 1.0
zero
Tool 1: 1/4 drill 4.0
Tool 2: 3/8 drill
0.5
Tool 3: 1/2 drill
Figure 5.3: Example program to demonstrate the used of structured program format
(1/4 DRILL)
N100 T01 M06 (LOAD TOOL IN SPINDLE)
N110 G54 G90 S1200 M03 T02 (START SPINDLE, READY NEXT TOOL)
Tool-startup
N120 G00 X1.0 Y1.0 (MOVE TO XY APPROACH POSITION)
structure
N130 G43 H01 Z0.1 (INSTALL TOOL LEN. COMP., MOVE TO Z APPROACH PSN)
N140 M08 (COOLANT ON)
N150 G01 Z-0.65 F4.0 (CUTTING MOVES WITH FEEDRATE)
N160 G00 Z0.1 (RETRACT FROM HOLE)
N170 M09 (COOLANT OFF)
Tool-end
N180 G91 G28 Z0 M19 (TOOL CHG. PSN., PRE-ORIENT SPINDLE)
structure
N190 M01 (OPTIONAL STOP)
(3/8 DRILL)
N200 T02 M06 (LOAD TOOL IN SPINDLE)
N210 G54 G90 S1000 M03 T03 (START SPINDLE, READY NEXT TOOL)
Tool-startup
N220 G00 X2.0 Y1.0 (MOVE TO XY APPROACH POSITION)
structure
N230 G43 H02 Z0.1 (INSTALL TOOL LEN. COMP., MOVE TO Z APPROACH PSN)
N240 M08 (COOLANT ON)
N250 G01 Z-0.7 F5.0 (CUTTING MOVES WITH FEEDRATE)
N260 G00 Z0.1 (RETRACT FROM HOLE)
N270 M09 (COOLANT OFF)
Tool-end
N280 G91 G28 Z0 M19 (TOOL CHG. PSN., PRE-ORIENT SPINDLE)
structure
N290 M01 (OPTIONAL STOP)
N310 G54 G90 S800 M03 T01 START SPINDLE, READY NEXT TOOL)
N320 G00 X3.0 Y1.0 (MOVE TO XY APPROACH POSITION)
N330 G43 H03 Z0.1 (INSTALL TOOL LEN. COMP., MOVE TO Z APPROACH PSN)
N340 M08 (COOLANT ON)
N350 G01 Z-0.75 F6.0 (CUTTING MOVES WITH FEEDRATE)
N360 G00 Z0.1 (RETRACT FROM HOLE)
N370 M09 (COOLANT OFF)
Tool-end
N380 G91 G28 Z0 M19 (TOOL CHG. PSN., PRE-ORIENT SPINDLE)
structure
N390 M01 (OPTIONAL STOP)
N400 G91 G28 Z0 M19 (RETURN TO Z ZERO RETURN PSN, PRE-ORIENT SPINDLE)
Program-end
N410 G28 X0 Y0 (RETURN TO XY ZERO RETURN – LOAD/UNLOAD PSN)
structure
N420 M30 (END OF PROGRAM)
N080 is the optional stop (M01) that gives the setup person or operator the ability to stop the machine (with the optional stop
on/off switch) to see what this tool has done. This is very helpful during the program’s verification – and whenever trial machining
must be done.
Program ending structure
Follow these commands to end a program.
N210 G00 X8.0 Z6.0 (Move to tool change position)
N215 M30 (End of program)
Program ending structure is almost identical to tool ending structure. The only difference is that you end with M30 (end of
program) instead of M01. M30 will turn off anything that’s still running (spindle & coolant), rewind the program to the beginning
for the next workpiece, and stop the cycle.
With some machines, there may be additional commands required to end the program. If the machine has automatic doors, for
example, you will want to include a command (usually an M-code) to open the door at the end of the program.
Machines with bar feeders will require commands to advance the bar.
Example program showing structure for turning centers
Figure 5.2 is the drawing we use to stress turning center structure.
Drawing for example programs that stress the use of program formatting
Process:
Tool 1: Rough face
Tool 2: Drill 7/8 hole
Tool 3: Rough bore
Tool 4: Finish bore
Tool 5: Finish face and turn
Program:
O0002 (Program number)
(ROUGH FACING TOOL)
N002 G99 G20 G23 (Ensure that initialized modes are still in effect)
N004 G50 S5000 (Limit spindle speed to machine’s maximum)
N005 T0101 M41 (Index turret, select spindle range)
N010 G96 S400 M03 (Start spindle in forward direction at 400 sfm)
N015 G00 X2.2 Z0.005 M08 (1) (Rapid to starting position, start coolant)
N020 G01 X-0.062 F0.012 (2) (Select per revolution feedrate mode, face workpiece at 0.012 ipr)
N025 G00 Z0.1 (3) (Rapid away)
N030 X6.0 Z5.0 (Rapid to tool change position)
N035 M01 (Optional stop)
(7/8 DRILL)
N040 T0202 M41 (Index turret, select spindle range)
N045 G97 S354 M03 (Start spindle forward at 354 rpm)
N050 G00 X0 Z0.1 M08 (4) (Rapid into position, start coolant)
N055 G01 Z-2.2 F0.008 (5) (Drill hole at 0.008 ipr)
N060 G00 Z0.1 (4) (Rapid out of hole)
N065 X6.0 Z5.0 (Rapid to tool change position)
N070 M01 (Optional stop)
(3/4 ROUGH BORING BAR)
N075 T0303 M42 (Index turret, select spindle range)
N080 G96 S350 M03 (Start spindle forward at 350 sfm)
N085 G00 X1.19 Z0.1 M08 (6) (Rapid into position, start coolant)
N090 G01 Z-1.37 F0.007 (7) (Begin boring operation at 0.007 ipr)
N095 X0.875 (8)
N100 G00 Z0.1 (9) (Rapid out of hole)
N105 X5.0 Z6.0 (Rapid to tool change position)
N110 M01 (Optional stop)
(3/4 FINISH BORING BAR)
N115 T0404 M42 (Index turret, select spindle range)
N120 G96 S400 M03 (Start spindle forward at 400 sfm)
N125 G00 X1.375 Z0.1 M08 (10) (Rapid into position, start coolant)
N130 G01 Z0 F0.005 (11) (Begin finish boring at 0.005 ipr)
N135 G02 X1.25 Z-0.0625 R0.0625 (12)
N140 G01 Z-1.375 (13)
N145 X1.1 (14)
N150 X1.0 Z-1.425 (15)
N155 Z-2.0 (16)
N160 G00 X0.8 (17)
N165 Z0.1 (18) (Rapid out of hole)
N170 X6.0 Z5.0 (Rapid to tool change position)
N175 M01 (Optional stop)
(FINISH FACE AND TURN TOOL)
N180 T0505 M42 (Index turret, select spindle range)
N185 G96 S450 M03 (Start spindle forward at 450 sfm)
N190 G00 X2.075 Z0 M08 (19) (Rapid into position, start coolant)
N195 G01 X1.05 F0.006 (20) (Start finish facing and turning at 0.006 ipr)
N200 G00 Z0.1 (21)
N205 X1.75 (22)
N210 G01 Z0 (23)
N215 G03 X1.875 Z-0.0625 R0.0625 (24)
N220 G01 Z-1.0 (25)
N225 X2.2 (26)
N230 G00 X6.0 Z5.0 (Rapid back to tool change position)
N235 M30 (End of program)
G02-G03 helical interpolation - For thread milling, machining external threads and when holes are too large to
tap
Other G-codes not discussed to this point
M-codes not addressed to this point
Rotary devices
Here is a list of common special programming features for turning centers:
One pass canned cycles
Multiple repetitive cycles
Sub-programming
Example of machining center program simplification feature: Hole machining canned cycles
Almost all programs have at least some hole-machining operations. If you have been doing the exercises in this text, you have seen
how tedious, time consuming, and error-prone it can be to program hole-machining operations with G00 and G01. You know that
with G00 and G01, each hole will require at least three blocks, making the program quite long. And we have only performed basic
drilling operations. Peck drilling, tapping, boring, and counter-boring operations will require even more blocks per hole.
Canned Cycles for Drilling will simplify the programming of hole-machining operations. Only one bock is required per hole,
regardless of the machining style (drill, peck drill, tap, ream, bore, counter-bore, etc.). Additionally, canned cycles are modal,
meaning once you instate a canned cycle, you can continue machining additional holes with the same geometry by simply
programming the coordinates of the hole. This will dramatically shorten the program’s length, make programming easier, less
time-consuming, and less error-prone.
Here is a list of the most common hole-machining canned cycles as FANUC names them in approximate order of popularity:
G80 – Cancel any of the canned cycles
G81 – Drilling cycle
G73 – High-speed peck drilling cycle (breaks chips as the hole is machined)
G83 – Peck drilling cycle (causes the drill to retract between pecks)
G82 – Counter-boring cycle
G84 – Right hand tapping cycle (also used for rigid tapping)
G74 – Left hand tapping cycle (also used for rigid tapping)
G86 – Boring cycle (rapids out of the hole)
G89 – Boring cycle with dwell (pauses at hole bottom, rapids out)
G76 – Fine boring cycle (leaves no witness mark in hole)
G85 – Boring cycle (retracts from hole at the programmed feedrate)
Example
Here is a simple example program that stresses the points made so far. Figure 6.6 shows the workpiece. We’re simply drilling four
holes using the drilling cycle, G81.
Example of turning center program simplification feature: Rough turning and boring multiple repetitive cycle
If a roughing pass ends at a chamfer, taper, or radius, calculating the end point for the pass will require more difficult math
calculations (including trigonometry), even for relatively simple workpieces. Figure 6.6 shows an example workpiece for which
programming rough turning will be more difficult.
Stock to be removed
Figure 6.6 – Drawing that stresses the difficulty of programming roughing passes long-hand
Though this is a relatively simple workpiece, notice how much stock must be removed by the rough turning operation. To program
this long hand (without any special cycles), a programmer will have to plan and program several roughing passes based on a
previously determined depth-of-cut. This creates a real problem for manual programmers. And consider the additional difficulty if
one or more of the roughing passes ends in the middle of the large taper or fillet radius. Trigonometry will be required in both
cases.
Knowing how difficult it can be to program individual turning or boring passes, FANUC has designed three very helpful multiple
repetitive cycles for roughing:
G71 - Rough turning and rough boring
G72 - Rough facing
G73 - Pattern repeating
With roughing multiple repetitive cycles, you only need to describe the finish pass of the workpiece surface being roughed. Based
on this finish pass definition and one very simple command, the control will completely rough the entire workpiece.
After the control finishes the first phase of G71, the workpiece will have a series of steps (like a staircase) and it will not be close
to its proper size (it will not have the appropriate amount of finishing stock on all surfaces). None of the steps left by the first phase
of G71 will be larger than the depth-of-cut specified in the G71 command. Figure 6.8 shows what the workpiece will look like
after the first phase of the G71 command.
Figure 6.8 – What workpiece will look like after phase one of G71 command
In the second phase of G71, the machine will return to the starting point of the finish pass definition and make one sweeping semi-
finish pass over the entire workpiece. It will stay away from the finished surface by the finishing stock values specified in the G71
command. Figure 6.9 shows the motions generated during the second phase of the G71 command.
This is all accomplished by one command (the G71 command) together with the finish pass definition. G71 makes it very easy to
program even very lengthy and complex rough turning and boring operations. In essence, the machine will figure out how to make
all of the roughing passes for you, in much the same way a computer aided manufacturing (CAM) system does.
Example showing G71 for rough turning and G70 for finish turning
Admittedly, the G71 command probably sounds a little complicated at this point. When you see an example, things should clear up
a bit. And regardless of how difficult you find this to be, it is well worth your time to study until you thoroughly understand the
G71 and G70 commands. You will save countless programming hours when you master them.
Figure 6.10 shows the workpiece to be used for our first example program. Tool number one is the rough turning tool and tool two
is the finish turning tool. The end of this workpiece has been previously faced to size.
Program:
O0010 (Program number)
(ROUGH TURNING TOOL)
N003 G99 G20 G23 (Ensure that initialized states are still in effect)
N004 G50 S4000 (No need for limiting, limit to machine’s maximum speed)
N005 T0101 M41 (Select roughing tool and low spindle range)
N010 G99 G96 S400 M03 (Turn spindle on fwd at 400 sfm)
N015 G00 X3.5 Z0.1 M08 (Rapid to convenient starting position, point 1, start coolant)
N020 G71 P025 Q085 U0.040 W0.005 D1250 F0.015 (Rough turn entire workpiece based on what is between lines N025
and N085)
N025 G00 X1.25 (First block of finish pass definition, rapid to point 2)
N030 G01 Z0 F0.008 (Feed to point 3)
N035 X1.5 Z-0.125 (Feed to point 4)
N040 Z-1.0 (Feed to point 5)
N045 X1.75 (Feed to point 6)
N050 X2.0 Z-2.0 F0.005 (Feed to point 7)
N055 Z-2.75 F.008 (Feed to point 8)
N060 G02 X2.5 Z-3.0 R.25 (Circular move to point 9)
N065 G01 X2.75 (Feed to point 10)
N070 X3.0 Z-3.125 (Feed to point 11)
N075 Z-3.5 (Feed to point 12)
N080 X3.25 (Feed to point 13)