Key CNC Concept #5—The Importance Of Program Formatting

Simplicity and consistency are the hallmarks of good programming.

Article From: 4/1/1997 Modern Machine Shop,

As stated in key concept number one, the CNC control will execute a part program exactly as it is written so all commands necessary to make the machine do the required operations must be sequenced in the proper order. And of course, part of learning how to program is understanding the program structure a CNC machine requires.

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, those first few programs will be much easier.

It's like 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 he will recognize its meaning. In the same way, it is unlikely that even an experienced CNC programmer can 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 your 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 multiple tool jobs. Almost all CNC machining center and turning center programs require 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 the 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 ac-curacy 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 (without editing the program).

Here is an example of a time when the programmer must include some redundant information at the beginning of a tool in order to provide the operator the ability to rerun the tool. As in our previous ten-tool example, we still wish to run tool number five a second time. Say that tools four and five both happen to run at 500 rpm. Say the last tool in the program (tool number ten) runs at 1500 rpm. Spindle speed is modal. While writing the program, say the programmer decides to leave out the S500 word at the beginning of tool five, expecting it to carry over from tool four.

If the program is run in the normal (sequential) manner, everything will work just fine. But when the operator attempts to rerun tool number five it will start at the same spindle speed as the last tool in the program (1500 rpm), not 500 rpm!

To alleviate this problem, 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 miniprogram 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 multitool program into smaller and easier-to-handle pieces.

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 startup format, tool ending format, tool startup format, and program ending format. The programmer will begin every program with program startup format. Then come the cutting operations with the first tool. When finished cutting, the programmer will follow the format to end the tool (tool ending format), then the tool startup format to begin the second tool. The programmer will then toggle among cutting information, tool ending format and tool startup format until 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) make up the program startup format. At the completion of line N015, the tool is ready to begin machining. Lines N020 and N025 make up the cutting commands for the first tool. (In line N030, the feed rate should be considered part of program startup format.) Lines N030 and N035 form the tool ending format. Lines N040 through N055 are tool startup format. (In line N060, the feed rate 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. Note that there are only four commands that do any cutting in this program. The bulk of the program is just format.

By breaking up the program in this manner, you can see just how much of it is nothing more than standard format that can be copied from one program to another. Of course, certain word values like spindle speeds, feed rates, axis positions, and tool station and offset numbers will change with each program. But the basic structure can be copied, keeping you from leaving out important information.

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 machine 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 examples given within your machine tool builder's programming manual.

Comments are reviewed by moderators before they appear to ensure they meet Modern Machine Shop’s submission guidelines.
blog comments powered by Disqus

Editor's Picks

Key CNC Concept #2—Know Your Machine

If you already know basic machining practice as it relates to the CNC machine you will be working...

Key CNC Concept 10—Verifying CNC Programs Safely

For the most part, CNC controls will follow the instructions given in a program to the letter. Wi...

Key CNC Concept #1—The Fundamentals Of CNC

Though the thrust of this presentation is to teach you CNC usage, it helps to understand why thes...

Key CNC Concept #3—Understanding CNC Motion Types

Effectively commanding motion on most CNC machines requires more than describing how the CNC mach...

Key CNC Concept #6—Methods For CNC Programming

Presented here are three methods of developing CNC programs, manual programming, conversational (...

Key CNC Concept #9—The Key Sequences Of Operation

This concept examines the sequences of operation of a CNC machine by way of reference material re...

Key CNC Concept #4—The Forms Of Compensation

Though applied for different reasons on different machine types, all forms of compensation allow ...

Key CNC Concept #7—Know The Machine From An Operator's Viewpoint

This perspective for a good programmer is a practical one, since the CNC operator must understand...

Key CNC Concept #8—The Modes Of Machine Operation

This concept introduces the three basic modes of operation, presents examples of when they are us...


Supplier Categories

Siemens Answers with the Most Innovative CNC Solutions for Machine Tool Technology
Channel Partners
  • Techspex