Horn USA
Published

Changing Program Behavior

User-defined codes allow you to make minor method changes to machine workpieces without reprogramming.

Share

CNC programmers dread process and engineering changes because they require program changes. The more workpieces involved, the more programs that must be changed. Consider any method change that would affect all of the workpieces you run on a given machine. How many programs would you need to change to accommodate this method change?

Of course, major process or engineering changes unavoidably will require reprogramming the affected workpieces, especially if those changes require modification of tool paths or machining methods. But with method changes that are minor, and with a little ingenuity, you may be able to handle the issue without having to change a single CNC program.

For example, I know of one company that wanted a machining center to execute a set of G10 commands for entering workpiece coordinate system offsets, not just at the beginning of every machining program, but at the beginning of every cutting tool sequence. The work-offset-setting commands are stored in a subprogram:
O1000 (Work-offset-setting commands)
G90 G10 L2 P1 X-12.2736 Y-8.1127 Z-13.2635
G10 L2 P2 X-15.3766 Y-8.3165 Z-13.3266
G10 L2 P3 X-18.9376 Y-8.3472 Z-13.3887
G10 L2 P4 X-21.1027 Y-8.2716 Z-13.3173
M99

Every time the setup person prepares a new job, he or she measures work offsets and modifies program O1000 accordingly. The beginning of every one of the machining programs currently includes a subprogram-calling command:
N005 M98 P1000 (Enter work offsets)

The method change necessary in this example involves calling the work-offset-entering sub­program at the beginning of every cutting tool sequence, not just at the beginning of the machining program. (This shop has had operators run from the middle of the program for the first workpiece, skipping the subprogram-calling command, but this caused the machine to use work offset settings from the previous job and could have resulted in a crash.)

One way to handle this method change would be to add the subprogram-calling command to the beginning of every tool sequence. However, if an average of 10 cutting tools were to be used in each program, nine program modifications would be required per program. If the company runs 300 programs on the machine, that equates to 2,700 error-prone program modifications.

When you are faced with modifying many programs, and especially when program structure is involved, another alternative with FANUC CNCs is user-created G, M and T codes. These may make it possible to modify the way an existing CNC word works in order to achieve the desired result.

The solution for the shop in our example was to simply modify the G codes related to setting the workpiece coordinate system (G54-G59). Since the appropriate command for invoking workpiece-coordinate-system offsets was already specified at the beginning of every tool sequence, there was no need to modify any machining programs. Now, when G54 is executed to invoke offset number one, it executes a custom macro program that first calls the work-offset-setting subprogram and then executes G54.

Creating user-defined G codes is pretty simple. It requires a parameter change and is documented in the custom macro section of the FANUC operator’s manual. For a 0iF FANUC CNC, for example, parameter number 6050 species the G code number that will call program O9010. If it is set to a value of 54, the CNC will execute program O9010 whenever G54 is executed. For our example, here is program O9010:
O9010 (G54 program)
M98 P1000 (Call work-offset-setting program)
G54 (Perform the normal function of G54)
M99

In this subprogram, G56 will perform its normal function: It will not cause the CNC to execute program O9010 again. Other user-defined G codes must be created for other needed work-coordinate-system-setting G codes, like G55, G56 and so on.

Another application for user-created codes is  related to where the machine axes are directed just before the program ends. Maybe you want to come up with a convenient and consistent workpiece loading position. You can simply modify the M30 (or M02) end-of-program word so that when it is executed, the CNC will run the related subprogram. In the subprogram, you would specify the position to which you want the axes to move, then specify the end-of-program word. Here is an example of the subprogram, which assumes M30 is the program-ending word:
O9001 (Called when M30 is executed)
G53 X-12.5 Y-10.0 Z0 (Position is specified
relative to the machine’s reference position)
M30

In order for this to work, of course, the related parameter must also be changed. For a FANUC 0iF control, parameter number 6071 is related to program O9001. For this example, it would be set to a value of 30 so that when the CNC executes an M30 word, it will call program O9001. 

Iscar
Try TRIM® Cutting and Grinding Fluid FREE!
IMCO
Sumitomo
Horn USA
Walter USA
T.J. Davies
Z-Carb HPR | Series Z5
Ingersoll Cutting Tools
SolidCAM
IMTS 2024
The view from my shop.

Related Content

Basics

Threading On A Lathe

The right choices in tooling and technique can optimize the thread turning process.

Read More
Milling Tools

10 Tips for Titanium

Simple process considerations can increase your productivity in milling titanium alloys.

Read More
SPONSORED

How to Reduce Cycle Times by 70% and More on Your Existing CNCs and Dramatically Improve Tool Life Too

By employing advanced high efficiency milling techniques for the entire machining routine, SolidCAM’s iMachining technology can drastically reduce cycle times while vastly improving tool life compared to traditional milling.

Read More
Turn/Mill

A New Milling 101: Milling Forces and Formulas

The forces involved in the milling process can be quantified, thus allowing mathematical tools to predict and control these forces. Formulas for calculating these forces accurately make it possible to optimize the quality of milling operations.

Read More

Read Next

Hexagon Adopts the Suite Life

Hexagon has rearranged its software portfolio into five process-based suites, which include software for every step in the workflow as well as a new program that connects everything, increasing automation and collaboration.

Read More

3 Mistakes That Cause CNC Programs to Fail

Despite enhancements to manufacturing technology, there are still issues today that can cause programs to fail. These failures can cause lost time, scrapped parts, damaged machines and even injured operators.

Read More
Turn/Mill

5 Tips for Running a Profitable Aerospace Shop

Aerospace machining is a demanding and competitive sector of manufacturing, but this shop demonstrates five ways to find aerospace success.

Read More
Z-Carb HPR | Series Z5