Key concept number five: You must understand how to format programs
As stated during key concept number one, the CNC control will execute a CNC
program in sequential order exactly as it is written. All commands necessary to
make the machine do the required operations must be included in the CNC program
in the proper order. And of course, part of learning how to program is
understanding the program structure a CNC machine requires.
To this point, you have been exposed to several features and programming
functions related to programming. With all the new ideas and commands
introduced, you may be getting somewhat confused trying to keep them all
straight. You may be worried about how you're going to memorize all of this.
One of the main reasons to strictly format CNC programs has to do with
making it easy to write your first few programs. When writing your first
program, the related commands will by no means be memorized. However, if you
have good example formats to go by, writing your first few programs will be
much easier.
We relate this to driving a car. It is unlikely that any driver can recite
from memory all road signs used to direct traffic. However, when a driver sees
a road sign, it is quite likely the driver will recognize its meaning. In the
same way, it is unlikely that even an experience CNC programmer could recite
every word used with CNC programming. But when even a relative newcomer to CNC
sees a command, it is likely its meaning will be remembered. One of our
intentions with program formatting is to keep you from having to memorize all
commands needed for programming. Instead, you will be looking at an example and
simply recollecting the function of each command.
A second reason for strict program formatting is consistency. Once you have
a format that works, use it. If you use the same format (or structure) for all
programs you write, you will be able to repeat past successes. If all
programmers in you company use the same format for a given CNC machine, each
programmer will be easily able to work on another's program.
The third (and most important) reason for strictly formatting programs is
related to multi tool jobs. Almost all CNC machining center and turning center
programs require that more than one tool in the program. For this kind of
program, there will be MANY times when it will be necessary to rerun only one
tool in the program a second, third, or fourth time.
Say for example, you have a machining center program that uses ten tools.
After running a workpiece, you determine that the fifth tool in the program did
not go quite deep enough. After fixing the problem (changing tool offset or Z
position in program), you will need to run the fifth tool again. However, you
would NOT want to run the entire program just to get to tool number five. Doing
so would be a waste of time and may actually cause unwanted problems with
workpiece accuracy and finish. Instead, you will want to be able to run ONLY
tool five a second time.
To do so will require that ALL information necessary to get the machine
running (just like at the beginning of the program) is included at the
beginning of tool five. If the programmer makes certain assumptions related to
modal information from a previous tool, it may not be possible to run tool
number five by itself.
Here is an example of a time when the programmer must include some redundant
information at the beginning of a tool in order to give the ability to rerun
the tool. In our previous ten tool example, we still wish to run tool number
five a second time. Say that tools four and five both run at 500 RPM. Say the
last tool in the program (tool number ten) runs at 1500 RPM. Spindle speed is
modal. The programmer may decide to leave out the S500 word at the beginning of
tool five, expecting it to carry over from tool four. After running the entire
program, it is determined that tool number five did not go deep enough. The
operator fixes the problem and intends to run only tool number five. In this
case, tool number five will start at the same spindle speed as the last tool in
the program (1500 RPM), not 500 RPM! This is but one time when redundant
information must be programmed from tool to tool in order to give the
capability to rerun tools.
At the beginning of each tool, the programmer MUST include all information
necessary to begin the tool, even if it means including some redundant
information. In essence, the programmer must treat each tool as a mini-program
that can run separate from the rest of the program. When you think about it,
this actually simplifies the programming task, allowing the programmer to break
a seemingly complicated multi-tool program into smaller and easier to handle
pieces. Each tool makes up one piece of the program.
The four kinds of program format
For machines that have the ability to perform operations with several tools,
there are four kinds of program format: program start-up format, tool ending
format, tool start-up format, and program ending format. The programmer will
begin every program with program start-up format. At the completion of program
start-up format, the tool will be ready to begin cutting. At this point, the
programmer will program the cutting operations with the first tool. When
finished cutting, the programmer will follow the format to end the tool (tool
ending format). Then tool start-up format to begin the second tool. The
programmer will then toggle among cutting information, tool ending format and
tool start-up format until the finished cutting with the last tool. At this
point, the programmer will follow the format to end the program.
For an example of the four kinds of program format, refer to the program
given during our discussion of tool length compensation (key concept number
four). This program uses two tools and follows the strict format we are now
discussing. Let's determine what commands are related to each kind of format.
The first four commands (beginning with the program number) makeup the
program start-up format. At the completion of line N015, the tool is ready to
begin machining. Lines N020 and N025 makeup the cutting commands for the first
tool. (In line N030, the feedrate should be considered part of program start-up
format.) Lines N030 and N035 form the tool ending format. Lines N040 through
N055 are tool startup format. (In line N060, the feedrate should be considered
part of tool startup format.) Lines N060 and N065 are the cutting commands for
the second tool. And lines N070 and N075 are program ending format.
By breaking up the program in this manner, you should be able to see just
how much of the program is nothing more than program format that can be copied
from one program to another. Of course, certain word values like spindle
speeds, feedrates, axis positions, and tool station and offset numbers will
change based on the program you are currently writing. But the basic structure
can be copied, keeping you from leaving out important information. Note that
there are only four commands that do any cutting in this program. The bulk of
the program is just format.
How do you come up with program format information for your machine?
The best way is to take an example program that is currently running
successfully and break it up in the manner shown above. When doing this,
analyze just what each tool is doing to determine the various types of format.
Ensure that each tool contains all information needed to run independently.
If you are working from scratch with a new CNC machines and have no
examples to go by, contact your machine tool builder to gain an understanding
of how your programs should be formatted. You may also find example programs
given within your machine tool builder's programming manual.