MCP First Pages
MCP First Pages
MCP First Pages
Lesson 1:
Machine Configurations
As a programmer, you must understand what makes up a CNC machining center. You must
be able to identify its basic components – you must understand the moving components of the
machine (called axes)– and you must know the various functions of your machine that are
programmable.
Most beginners tend to be a little intimidated when they see a machining center in operation for the first time.
Admittedly, there will be a number of new functions to learn. The first point to make is that you must not let
the machine intimidate you. As you go along in this text, you will find that a machining center is very logical
and is almost easy to understand with proper instruction.
You can think of any CNC machine as being nothing more than the standard type of equipment it is replacing
with very sophisticated and automatic motion control added. Instead of activating things manually by hand-
wheels and manual labor, you will be preparing a program that tells the machine what to do. Virtually
anything that needs to be done on a true machining center can be activated through a program – meaning
anything you need the machine to do can be commanded in a program.
There are two basic types of machining centers that we will be addressing in this text. They are vertical
machining centers and horizontal machining centers. Let’s start by describing the most common features of
each.
Special note: Much of the material in this lesson is also included in the CNC
Machining Center Setup and Operation self-study manual. If you have already
read the setup and operation manual, please consider this lesson as a review.
Lesson 2
Visualizing The Execution Of A CNC Program
A CNC programmer must possess the ability to visualize movements a CNC machine will
make as it executes a program. The better a person can visualize what the machining center will
be doing, the easier it will be to prepare a workable CNC program.
Once again, we stress the importance of basic machining practice as it applies to CNC machining center
usage. A machinist that has experience running a conventional milling machine will have seen machining
operations taking place many times. While this experience by itself does not guarantee the ability to visualize a
machining operation (seeing it happen in your mind), it dramatically simplifies the task of learning how to
visualize a CNC program’s execution.
When a machinist prepares to machine a workpiece on a conventional milling machine, they will have all
related components needed for the job right in front of them. The machine, cutting tools, workholding
setup, and print are ready for immediate use. It is highly unlikely that the machinist will make a basic mistake
like forgetting to start the spindle before trying to machine the workpiece.
On the other hand, a CNC machining center programmer will be writing the program with only the
workpiece drawing to reference. No tooling – no machine – and no workholding setup will be available to
them. For this reason, a programmer must be able to visualize just exactly what will happen during the
execution of the program - and this can sometimes be difficult, since this visualization must take place in the
programmer’s mind. A beginning programmer will be prone to forget certain things - sometimes very basic
things (like turning the spindle on prior to machining the workpiece).
In this lesson, we will acquaint you with those things a programmer must be able to visualize. We will also
show the first (elementary) program example to stress the importance of visualization.
Lesson 3
Program Zero And The Rectangular Coordinate System
A programmer must be able to specify positions through which cutting tools will move as they
machine a workpiece. The easiest way to do this is to specify each position relative to a common
origin point called program zero.
You know that machining centers have three linear axes – X, Y, and Z. You also know these axes move and
that they have a polarity (plus versus minus). In order to machine a workpiece in the desired manner, each
axis must, of course, be moved in a controlled manner. One of the ways you must be able to control each
axis is with precise positioning control.
In the early days of NC (even before CNC, over forty years ago), a programmer was required to specify drive
motor rotation in order to cause axis motion. This meant they had to know how many rotations of an axis
drive motor equated to the desired amount of linear motion for the moving component (table or headstock,
for example). As you can imagine, this was extremely difficult – it was not logical. There is no relationship
between drive motor rotation and motion of the moving component. Today, thanks to program zero and the
rectangular coordinate system, specifying positions through which cutting tools will move is much easier.
The rectangular coordinate system has an origin point that we’ll be calling program zero. It allows you to
specify all positions (we’ll be calling coordinates) from this central location. As a programmer, you will be
choosing the location for program zero – and if you choose it wisely, many of the coordinates you will use in
the program will come directly from your workpiece drawing, meaning the number and difficulty of
calculations required for your program can be reduced.
Graph analogy
We use a simple graph to help you understand the rectangular coordinate system as it applies to CNC. Since
everyone has had to interpret a graph at one time or another, we should be able to easily relate what you
already know to CNC coordinates. Figure 1.13 is a graph showing a company’s productivity for last year.
Graph analogy part one
A graph helps you
visualize conceptual ideas
like time and productivity.
Productivity for last year
100%
90%
80%
70%
Productivity 60%
50%
40%
30%
20%
10%
0%
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
Origin Time
Lesson 4
Introduction To Programming Words
All CNC words include a letter address and a numerical value. The letter address identifies the
word type. The numerical value (number) specifies the value of the word. You should be able to
quickly recognize the most common ones.
You know from Lesson two that CNC programs are made up of commands – and that commands are made
up of words. Words are categorized into types – and each word type has a special meaning to the machine.
Each word type is designated by a letter address. You already know a few the letter addresses, like N for
sequence number, G for preparatory function, X, Y, and Z for axis designations, S for spindle speed, F for
feedrate, and M for miscellaneous (or machine) functions. In this lesson, we’re going to introduce the rest of
the word types.
If you are a beginner looking at the word types for the first time, you may want to read this section a few
times to get better acquainted with these word types. Note that we are not asking you to memorize the word
types – just to get familiar with them. In Key Concept number five – program formatting – we will provide
you with a way to remember each word’s function.
Also, this lesson is only intended to introduce each word, not to give you an in-depth description. When
appropriate, we’ll point you to the lessons that discuss the word type in more detail.
You will find that certain words are seldom used, meaning you will have little or no need for them. Other
words are constantly used, and you will soon have them memorized after writing a few programs.
Some CNC words have more than one function, depending on commanded format. We will be showing you
the primary (most common) function of the word next to the “A” description and the secondary use for the
word next to the “B” description.
Once you’ve seen a word type a few times, it should not be too difficult to remember its function. Again,
most word types are aptly named with a logical letter address. Additionally, only about fifty words are used
consistently when programming, so try to look at learning to program a CNC machining center as like
learning a foreign language that contains only fifty words.
As you continue with this text, use this lesson as a reference. If you come across a word or word type you don’t
recognize, remember to come back to this lesson. You’ve probably already noticed that we provide a quick
reference for CNC words on the inside front and back cover of this text, but information in this lesson is a
little more detailed.
Lesson 5
Preparation Steps For Programming
Any complex project can be simplified by breaking it down into small pieces. This can make
seemingly insurmountable tasks much easier to handle. CNC machining center programming is
no exception. Learning how to break up this complex task will be the primary focus of Lesson
five.
As you now know, preparation will make programming easier, safer, and less error-prone. Now let’s look at
some specific steps you can perform to prepare to write CNC programs.
Lesson 6
Programming The Three Most Basic Motion Types
There are only three motion types used in CNC machining center programs on a regular basis –
rapid, straight-line, and circular motion. You must understand how they are commanded.
While it helps to understand how the machining center will interpolate motion, it is not as important as
knowing how to specify motion commands in a program. This is the focus of Lesson six. Let’s begin our discussion
by showing those things that all motion types share in common.
Motion commonalties
All motion types share five things in common:
First, they are all modal, meaning a motion type will remain in effect until it is changed. If more
than one consecutive movement of the same type must be made, you need only include the
motion type G code in the first command of the series of movements.
Second, each motion type command requires the end point of the motion. The control will
assume the tool is positioned at the starting point of the motion prior to the motion command.
Think of motion commands that form a tool path as being like a series of connect-the-dots.
Third, all motion commands are affected by whether or not you specify coordinates in the
absolute or incremental positioning mode. In the absolute positioning mode (specified by G90),
specified end points will be relative to the program zero point. In the incremental positioning
mode (specified by G91), specified end points will be relative to the tool’s current position. As
stated in Lesson three, you should concentrate on specifying coordinates in the absolute
positioning mode.
Fourth, each motion command requires only the moving axes. If specifying a motion in only
one axis, only one axis specification (X, Y, or Z) need be included in the motion command.
Axes that are not moving can be (and should be) left out of the command.
Fifth, leading zeros can be left out of the G codes related to motion types. This means the
actual G codes used to instate the motion types can be programmed in one of two ways. G00
and G0 (stated G zero-zero and G zero) mean exactly the same thing to the control, as do G01
and G1, G02 and G2, G03 and G3. All examples in this text do include the leading zero.
Lesson 7
Introduction To Compensation
An airplane pilot must compensate for wind direction and velocity when setting a heading. A
race-car driver must compensate for track conditions as they negotiate a turn. A marksman must
compensate for the distance to the target when firing a rifle. And a CNC programmer must
compensate for certain tooling-related problems as programs are written.
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 (just as the marksman does their best in judging the
distance to the target and adjusting the sight). 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.
Lesson 8
Tool Length Compensation
Tool length compensation allows a programmer to ignore the precise length of each tool as a
program is written. It is used for every tool in every program you write – so you must understand
this important CNC feature.
You know that program zero assignment values for the X and Y axes are entered into fixture offsets from the
spindle center to the program zero point in X and Y (while the machine is at its zero return position). So when
you specify a position of X1.0 Y1.0 in a program, the machine will be able to send the spindle center (and tool
center) to this position – relative to program zero.
In the Z axis, you know that the program zero assignment value is entered into the fixture offset from the
spindle nose to the Z axis program zero surface (again, while the machine is at its zero return position). But for
cutting tool positioning, you don’t want to specify Z axis positions from the spindle nose. This would be very
cumbersome – and it would require that you know the precise length of each tool before you could even
write the program. Instead, you specify Z axis positions to the tip of each cutting tool. That is, when you
specify a position of Z0.1, the tool tip will move to this position. In order to be able to program the tool tip in
the Z axis, a feature called tool length compensation must be used. Mastering tool length compensation is the
focus of lesson number eight.
? ?
1 2 ? ? ?
No two tools in your program will have exactly the
same length. And as you are writing the program , 3
4 5
you won’t know how long each tool will be.
Figure 4.4 – Five cutting tools that might be used in by a CNC machining center program
Lesson 9
Cutter Radius Compensation
Cutter radius compensation is only used for milling cutters. Just as tool length compensation lets
you ignore the exact length of cutting tools as you write programs, cutter radius compensation
allows you to ignore the precise diameter of milling cutters used for contour milling.
You know from Lesson six that milling cutters (like end mills) can be used for contour milling operations.
Motions can be linear (straight-line) or circular. To this point, we have shown the contour milling tool path
based upon a milling cutter’s centerline path. As you know, calculating coordinates for a milling cutter’s
centerline path requires that you consider the milling cutter’s radius for every coordinate – which can make
calculating coordinates quite difficult.
In Lesson nine, we’re going to show you how to minimize the calculations that must be done when
determining coordinates needed for contour milling. Instead of using the milling cutter’s centerline
coordinates, you will be using coordinates that are right on the work surface to be milled. And again, these
coordinates are much easier to calculate. Mastering the programming of cutter radius compensation will be
the focus of Lesson nine.
Lesson 10
Fixture Offsets
Tool length and cutter radius compensation allow you to ignore certain attributes of cutting tools as
you writer your CNC programs. In like fashion, fixture offsets allow you to ignore the precise
location of the work holding device/s on the machine table as you write programs.
You know from Lesson three that fixture offsets are used to assign program zero. Based upon our
discussions so far, you know that the distances from the zero return position to the program zero point must
be determined (either measured or calculated). The polarity of these values is almost always negative since the
zero return position is usually close to the plus over-travel limit of each axis. These values are entered into
fixture offset number one to assign program zero. Again, the specific techniques used to assigned program
zero are shown in the self-study manual: CNC Machining Center Setup and Operation – sold separately.
We’ve only shown how to use one program zero point (requiring the use of fixture offset number one). In
this lesson, we’ll be showing when multiple program zero points are required as well as how they are assigned
and programmed.
Fixture offsets should be your program zero assignment method-of-choice over using G92
in the program. You should only use G92 to assign program zero if your machining
center does not have fixture offsets.
Lesson 11
Introduction To Program Structure
Structuring a CNC program is the act of writing a program in a way that the CNC machine
can recognize and execute safely, efficiently, and with a high degree of operator-friendliness.
You know that CNC programs are made up of commands, that each command is made up of words, and that
each word is made up of a letter address and a numerical value.
You also know that programs are executed sequentially – command by command. The machine will read,
interpret, and execute the first command in the program. Then it will move on to the next command. Read –
interpret – execute. It will continue doing so until the entire program has been executed.
And you have seen several complete programs – you have even worked on a few if you have done the
exercises in this text and in the workbook. You have probably noticed that there is quite bit of consistency
and structure in CNC programs.
Our focus in Lesson eleven will be to help you understand more about the structure that is used in CNC
programming.
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 in Lesson twelve will provide you with this help. You’ll be able to use
our given formats as a crutch until you (eventually) have them memorized.
Lesson 12
Four Types Of Program Format
The formats shown in this lesson will keep you from having to memorize most of the words and
commands needed in CNC programming. As you’ll see, a large percentage of most programs is
related to structure.
You know the reasons why programs must be formatted using a strict structure. In Lesson twelve, we’re
going to show the actual formats. We will show two sets of format, one for vertical machining centers and
another for horizontal machining centers. We will also explain every word in each format in detail. We will
also show an example program that stresses the format’s use.
There are four types of program format:
Program startup format
Tool ending format
Tool startup format
Program ending format
Any time you begin writing a new program, follow the program start-up format. You can copy this structure to
begin your program. The actual values of some words will change based on what you wish to do in your own
program, but the structure will remain the same every time you begin writing a new program.
After writing the program start-up format, you write the motions for the first tool’s machining operations.
When finished with the first tool motions, you follow the tool ending format. You then follow the tool start-
up format for the second tool and write the second tool’s machining motion commands. From this point,
you toggle among tool ending format, tool startup format, and machining motion commands until you are
finished machining with the last tool. You then follow the program ending format.
One of the most important benefits of using these formats is that you will not have to memorize anything. You
simply copy the structure of the format.
Our formats assume that you are using fixture offsets to assign program zero. Later in this lesson, we’ll
discuss the changes that must be made to these formats if you must use G92 in the program to assign
program zero. (Again, you should only use G92 to assign program zero if your machining center does not
have fixture offsets.)
Lesson 13
Hole-Machining Canned Cycles
Armed only with what you know so far, programming hole-machining operations is very tedious.
Hole-machining canned cycles will dramatically simplify the programming of these very common
machining operations.
Almost all programs have at least some hole-machining operations. If you have been doing the exercises in this
text and in the workbook, 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 commands, making your program quite long. And we’ve only performed basic drilling operations.
Peck drilling, tapping, boring, and counter-boring operations will require even more commands per hole.
Canned cycles will dramatically simplify the programming of hole-machining operations. Only one command 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
holes by simply listing hole-positions. Again, this will dramatically shorten the program’s length, make
programming easier, less time-consuming, and less error-prone.
The meaning of “canned”
A canned cycle is a series of preset movements that the CNC machine will execute based upon a limited
amount of program information. The zero return command (G28) is a simple kind of canned cycle. G28
actually makes the machine do two things. First, the machine will move to the intermediate position. Second, it
will move to the zero return position.
If you have the single block switch turned on (a function that makes the machine execute one command in the
program at a time), you actually have to activate the cycle twice to make the control complete the G28
command. Again, the first time you activate the cycle (by pressing the cycle start button), the machine executes
the motion to the intermediate position. The second time, it moves to the zero return position.
Hole-machining canned cycles are much more elaborate. Even the standard drilling cycle will make the
machine do at least three things per command. With the chip-breaking peck drilling cycle, one command can
actually generate over one-hundred movements.
Here’s how simple it is to use canned cycles: You instate the canned cycle for the first hole to machine.
With a standard drilling cycle, for example, the instating command includes the cycle type (G81), the first
hole position in XY, the hole’s bottom position in Z (commonly its depth), and the machining feed rate. The
instating command actually machines the first hole. To machine the rest of the holes, you simply list their XY
coordinates, one set per command. After the last hole, you must cancel the cycle with a G80 word.
Here is a list of the most common hole-machining canned cycles in approximate order of popularity:
G80 – Cancel any of the canned cycles
G81 – Standard drilling cycle
G73 – Chip-breaking peck drilling cycle
G83 – Deep hole peck drilling cycle
G82 – Counter-boring cycle
G84 – Right hand tapping cycle
G74 – Left hand tapping cycle
G86 – Standard boring cycle
Lesson 14
Working With Subprograms
There are times when a series of CNC commands must be repeated – within one program –
and sometimes among several programs. Whenever you find yourself writing a series of
commands a second time – you should consider using a subprogram. The longer the series of
commands and the more often they must be repeated, the more a subprogram can help.
You know that a CNC machining center will execute a program in sequential order. It will start with the first
command in the program: read it – interpret it – and execute it. Then it will move on to the next command –
read, interpret, execute. It will continue this process for the entire program.
You also know that there are times when a series of commands in your program must be repeated. We’ve
shown two times so far. One time is when using cutter radius compensation to rough and finish mill using
the same set of coordinates. You must program the finishing tool path coordinates twice, once for the rough
milling cutter (using an offset value that is larger than the actual cutter size) and once for the finish milling
cutter.
Another time when commands must be repeated is when machining holes that require multiple machining
operations (like center drilling, drilling, and tapping a series of holes) – the more holes that must be machined,
the more commands that must be repeated.
In Lesson fourteen, you will learn about a way to change the order of program execution to some extent –
and this will be especially helpful when commands must be repeated.
Lesson 15
Other Special Programming Features
Current model CNC machining centers come with many features to help with special
applications. While some of these features will be of little need to you in the immediate future, it is
important to know they exist. You cannot begin to apply any feature that you don’t know about.
CNC control manufacturers strive to equip their controls with as many helpful programming features as
possible. Those mentioned so far (canned cycles and subprograms) are used on a very regular basis — and
you should strive to master them. However, there are some special programming features that are not used
nearly as regularly. Indeed there are some features that are extremely important to one company but of no
value to another.
As you study this lesson, you need to consider your own company’s CNC applications. If you are in doubt
about the value of a given feature, ask your instructor or an experienced person in your company about its
value to your company. You can minimize your studies about those features your company does not
currently need. You can always come back and study this lesson in greater detail should the need arise.
As you study this lesson, remember that your ingenuity is based predominantly upon your knowledge of what is possible.
You cannot apply a feature of which you are unaware. At the very least, this lesson will acquaint you with
what is possible with special CNC programming features.
The organization of this lesson is not as tutorial as previous lessons. While we will explain each feature in
detail and in tutorial format, we don’t present them in a special order. Here are the topics contained in this
lesson:
?Block delete (also called optional block skip)
?Special techniques with sequence numbers
?G codes that have not yet been introduced (in numerical order)
Lesson 16
Programming Rotary Devices
Many CNC machining centers, and especially horizontal machining centers, are equipped with a
rotary device that allow more than one workpiece surface to be exposed to the spindle for machining
during the CNC cycle. This lesson will explain how they are programmed.
This lesson will only apply to you if your machining center has some kind of rotary device that allows the
workpiece to be rotated during the CNC cycle. For vertical machining centers, you may have an indexer or
rotary table (with full rotary axis) that rests on top of the table. For horizontal machining centers, your machine
is likely to have an indexer or rotary axis built into the table of the machine.