Refining the Macro
These tips will help you optimize the structure of your part family custom macro.
In the past three columns, I have provided suggestions for developing part family custom macros. I’ll conclude this series by discussing a few more techniques to help you tweak and
optimize the structure.
Minimize program execution time. In my recommended structure, a lot of data must be active before the machining portion of your program can be executed. This data includes variables related to part definition, cutting conditions, cutting tools and system constants. In addition, any error trapping also must be done. All of this can lead to a lengthy pause during program execution.
Since the related (common) variables will remain active until the power is turned off, all of the variable assignment and error trapping commands need only be executed once, unless running a different workpiece.
Here is technique that will eliminate the pause in all but the first execution. It keys on a part number variable included in the part definition program to see if it has changed since the last time the program was executed.
O0001 (Ring turning center program)
G65 P1000 C1.0 (Get current value of #100)
IF [#500EQ#100] GOTO 1 (Test if variable settings are needed)
M98 P1000 (Call part definition program)
M98 P8001 (Call system constraints program)
M98 P8003 (Call cutting conditions program)
M98 P8004 (Call tool selection program)
M98 P8002 (Call error trapping program)
N1 (Side one, process one – rough face and turn)
N2 (Side one, process two – rough bore)
N3 (Side one, process three – finish bore thru and face)
N4 (Side one, process four – finish turn)
M30 (End of program)
The G65 command gets the part number value from the part definition program (O1000) and stores it in common variable #100. This value is then compared to the value of #500, and if they differ (meaning a different workpiece is being run), all the variable assignment and error trapping commands are executed. Then #500 is set to #100 so the next time the program is run for the same part, the time-consuming commands are skipped.
Use a template part definition program. This helps out the person creating part definition programs and ensures that all data is entered.
O1000 (Part definition program)
#100=#0 (Part number)
IF [#3EQ1.0] GOTO 99
#101=#0 (Material specification – 1018 or 1045)
#102=#0 (Inside diameter)
#103=#0 (Outside diameter)
#104=#0 (Bolt circle diameter)
#106=#0 (Slot depth)
#107=#0 (Slot width)
#108=#0 (Hole diameter)
Note that all variables are set to vacant (#0). A test for vacancy can be done in the error trapping program to ensure that each mandatory variable has been assigned a value.
Error-trap suspected problems. At the very least, confirm that all input variables have been assigned a value. Here is an example for the previous part definition program:
N1 IF [#1GT108] GOTO 50 (Start loop to test input variables)
IF [#[#1] NE #0] GOTO 5 (Test current variable)
#3000=100 (Data missing)
N5 #1=#1+1 (Step counter)
GOTO 1 (Go back to test)
N50 (More error trapping here)
You can also test for a variety of potential input mistakes, such as a bolt circle diameter (#104) that is larger than the outside diameter (#103).
Try to eliminate raw material size specification. Last month, we addressed minimizing the amount of process-specific information in input data, including cutting conditions related to different materials. Your custom macro also must “know” the size of the raw material to be machined, but, as with other process-related information, try to keep raw material size
specification out of the part definition program since this information is not on the blueprint. Hopefully, there is some logic related to how raw material size is determined. Build this logic into your custom macro(s).
Try to eliminate program zero assignment. Similarly, do your best to minimize the task of program zero assignment. For a round ring held in a V-block vice, for example, the XY program zero point (center of ring) location can be calculated with simple trigonometric functions, and the appropriate fixture offset registers can be updated from within the part family program. This eliminates the task of program zero assignment.