Changing Program Behavior
User-defined codes allow you to make minor method changes to machine workpieces without reprogramming.
Share
Kurt Manufacturing Company
Featured Content
View MoreHwacheon Machinery America, Inc.
Featured Content
View MoreCNC 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 subprogram 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.
Related Content
6 Variations That Kill Productivity
The act of qualifying CNC programs is largely related to eliminating variations, which can be a daunting task when you consider how many things can change from one time a job is run to the next.
Read MoreThe Best Point of Reference for Program Zero Assignment Entries
Correctly specified program zero assignment and coordinate position values enable the CNC to determine how far to move the cutting tool during each positioning motion.
Read MoreTips for Designing CNC Programs That Help Operators
The way a G-code program is formatted directly affects the productivity of the CNC people who use them. Design CNC programs that make CNC setup people and operators’ jobs easier.
Read MoreHelp Operators Understand Sizing Adjustments
Even when CNCs are equipped with automatic post-process gaging systems, there are always a few important adjustments that must be done manually. Don’t take operators understanding these adjustments for granted.
Read MoreRead Next
5 Rules of Thumb for Buying CNC Machine Tools
Use these tips to carefully plan your machine tool purchases and to avoid regretting your decision later.
Read MoreBuilding Out a Foundation for Student Machinists
Autodesk and Haas have teamed up to produce an introductory course for students that covers the basics of CAD, CAM and CNC while providing them with a portfolio part.
Read MoreRegistration Now Open for the Precision Machining Technology Show (PMTS) 2025
The precision machining industry’s premier event returns to Cleveland, OH, April 1-3.
Read More