Digital Readout Kit for Mills, Lathes, & Grinding
Published

Key CNC Concept #5—The Importance Of Program Formatting

Simplicity and consistency are the hallmarks of good programming.

Share

This is the fifth article in a 10 part series about the key concepts of CNC. To start at the beginning, read this article.

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.

This is the fifth article in a 10 part series about the key concepts of CNC. To start at the beginning, read this article.

Next Article - Key Concept Number 6 - Methods for CNC Programming.

CHIRON Group, one stop solution for manufacturing.
SolidCAM
The view from my shop.
Kennametal
IMTS 2024
MMS Top Shops
IMTS 2024
MMS Made in the USA
Starrett 2900 Series Digital Indicator
DN Solutions
benchmark international advanced manufacturing trade show
Mazak - Innovative manufacturing for medical

Related Content

Basics

7 CNC Parameters You Should Know

Parameters tell the CNC every little detail about the specific machine tool being used, and how all CNC features and functions are to be utilized.

Read More
Measurement

6 Machine Shop Essentials to Stay Competitive

If you want to streamline production and be competitive in the industry, you will need far more than a standard three-axis CNC mill or two-axis CNC lathe and a few measuring tools.

Read More

From Tradition to Transformation: Century-Old Manual Machine Shop Adds CNCs

After 122 years of working with manual mills and lathes, this fifth-generation shop acquired assets of a local CNC machining business and hired the owner. Here’s how it’s going a year later.

Read More

3 Examples of Machines that Combine Manufacturing Methods

Certain “hybrid” machines combine some form of additive manufacturing with CNC subtractive manufacturing. Columnist Mike Lynch, President of CNC Concepts Inc., explores three types of these machines here.

Read More

Read Next

Shop Management Software

ERP and Process Changes Increase Shop’s Revenue 64% YoY

Implementing ProShop has led to a massive process overhaul at Marzilli Machine. From 2020 to 2021, revenue increased 64% without capital investment.

Read More
CNC Turnkey Package for Knee Mills and Lathes