top of page

Teaching CNC with the Key Concepts approach - part six

Part six - Key concept number five: You must provide structure to your CNC programs:

  • Providing structure to CNC programs

  • The four kinds of program format

  • In our CNC curriculums and CD-rom courses, these topics are presented in two lessons.

Providing structure to CNC programs

I like to begin by reminding students that there are only about 40-50 words used in CNC programming. While this may seem like a lot, ask students to think of learning a foreign language that contains only 50 words.

Also point out that students have seen several complete programs to this point in the class - indeed, if they have done any of the exercises included in our workbook, they have actually worked on some programs (filling in the blanks for needed words. They have probably noticed that there is quite a bit of consistency and structure in the programs shown. These programs use the structure we're going to present in this key concept.

Review the structure related topics introduced in previous key concepts, including the meaning of modal, initialized, decimal point programming, and G and M code limitations (three G codes and one M code per command). And remind students of their natural tendency to forget things as they program (making mistakes of omission). It is not uncommon to forget needed words when writing a program. Make sure they know that you'll be presenting a technique that will keep them from having to memorize anything - and will minimize the potential for making mistakes of omission. Provide them with the three reasons why programs must be structured in a strict manner:


Students must have a way to become familiar with the words and commands used to structure a program. I equate this to the road signs you see as you drive an automobile. It's unlikely that you can recite every road sign and its meaning from memory. But when you see a road sign, you easily remember its meaning.

Have students think about the structure used to write CNC programs as a set of road signs for programming. In this key concept, you'll be providing the format needed to write programs. Students can use this format as a crutch as they write their first few programs.


Point out that CNC programs must be written consistently - among tools in a given program, and among all programs. This will provide everyone using the programs to get familiar with programming style. More importantly, programmers must have a way of repeating past successes. If the structure of one program is satisfactory - that is, it satisfies all of the objectives the company wants - using the same structure in another program will ensure continued success. And the format used for consistently written programs will soon be memorized.

Re-running tools

Explain that this is the most important reason to provide structure to programs. There are many times when setup people and operators must run a tool by itself (when trial machining, during program verification, etc.). This means all commands needed by the first tool in the program must be included at the beginning of each tools.

How it's done...

In our curriculums, we provide four sets of program format: program startup format, tool ending format, tool startup format, and program ending format. Armed with these formats, entry level programmers will not have to memorize the various words and commands needed for their programs. Instead, they will copy the structure from a workable program - using it to create their own programs.

What about machine differences?

When teaching, of course, you'll provide formats for your particular machine/s. But be sure to point out that there are many differences among machine tools that affect the way programs must be formatted. Obvious ones include automatic tool changers for machining centers and tailstocks for lathes. Additionally, be sure to point out the most common M code differences from one machine to another.

The four kinds of program format

Again, these include program startup format, tool ending format, tool startup format, and program ending format.

With a workable set of formats developed for your machine/s, show and explain the formats. At this point it is very important that students understand the meaning of every word and command in the formats. This shouldn't provide much of a problem since students have worked on several exercises that have acquainted them with the most common words. But words like G28 and M01 must be explained in detail.

Using your formats, have students write their own program. Once finished, be sure to stress the ability to re-run tools. And make sure they can determine the restart command for each tool.

The formats

Here is a set of formats for a vertical machining center that uses fixture offsets to assigning program zero:

Program startup format

  • O0001 (program number)

  • N001 G17 G20 G23 (Select XY plane, inch mode, cancel stored stroke limit)

  • N002 G40 G50 G64 (Cancel cutter radius compensation, cancel scaling, select normal cutting mode)

  • N003 G67 G69 G80 (Cancel modal custom macro call, cancel rotation, cancel canned cycle)


  • N005 T01 M06 (Load first tool in spindle)

  • N010 G54 G90 S300 M03 T02 (Select fixture offset, absolute mode, turn spindle on fwd at desired RPM, get next tool ready)

  • N015 G00 X5.0 Y5.0 (Move to first XY position)

  • N020 G43 H01 Z0.1 (Instate tool length compensation, move to first Z position)

  • N025 M08 (Turn on the coolant)

  • N030 G01 . . . . F3.0 (In first cutting movement, be sure to include a feedrate)

Tool ending format

  • N075 M09 (Turn the coolant off)

  • N080 G91 G28 Z0 M19 (Return to tool change position, orient the spindle during motion)

  • N085 M01 (Optional stop)

Tool startup format


  • N135 T02 M06 (Ensure that the next station is still ready and make the tool change)

  • N140 G54 G90 S450 M03 T03 (Select fixture offset, select absolute mode, turn spindle on CW at desired RPM, get next tool ready)

  • N145 G00 X4.0 Y4.0 (Move to this tool's first XY position)

  • N150 G43 H02 Z0.1 (Instate tool length compensation, move to first Z position)

  • N155 M08 (Turn on the coolant)

  • N160 G01…. F4.0 (In first cutting movement, be sure to include a feedrate)

Program ending format

  • N310 M09 (Turn coolant off)

  • N315 G91 G28 Y0 Z0 M19 (Return to tool change position in Z, orient spindle during motion)

  • N320 G28 Y0 (Return to zero return position in Y)

  • N325 M30 (End of program)

Be sure to point out the consistencies. Tool startup format is quite similar to program startup format. Tool ending format is similar to program ending format. Once a beginning program has written a few programs, these formats will be memorized.

37 views0 comments


bottom of page