You know that to truly qualify a program (keep it from ever having to be changed in the future), you must eliminate those things that change from one time the job is run to the next. But certain variables may be beyond the control of CNC people. If, for example, you run a cast iron often, it’s likely that you experience raw material size variations on a regular basis.
Consider, for example, face milling a surface. If the surface is cast, and if the amount of material to be machined varies from one time the job is run to the next, the number of passes the face mill makes will have to be changed.
Unfortunately, this is one of those times when you may be constantly chasing your tail. The next time the job is run, the amount of stock on the surface may vary again, requiring yet another program change. Indeed, you may have to make a program change every time the job is run. You may even experience this kind of variation within one lot of castings, meaning the program may have to be changed several times, even during a single production run!
If it is not feasible to keep this surface from varying (the casting vendor may be beyond your control), the next best thing is to make it as easy as possible to change the program to adapt to the varying surfaces. With custom macro B (or any version of parametric programming), you can make it so simple that any setup person will be able to quickly and easily change the program.
At the beginning of your program, include two variables:
O0001 (Main program)
#120 = 0.25 (STOCK ON CAST SURFACE)
#121 = 0.1 (Z DEPTH PER MILLING PASS)
N005 T01 M06 (Normal beginning of program)
We’ve used variable #120 to specify how much stock is on the surface and #121 to specify the Z depth, the maximum depth the milling cutter will take per pass.
Once the milling cutter is placed in the spindle and brought to its approach position in XY, give these commands to specify how milling will be done:
N040 G43 Z1.015 (Rapid in Z to within 1 inch of final surface position)
N045 G65 P9001 S#120 D#121 C2001.0 (Mill surface)
Our technique requires that you rapid the tool in Z to within precisely 1 inch of the final Z surface you wish the rough milling cutter to mill—not that we’re going to be leaving 0.015 finishing stock with this rough milling cutter.
In line N045, we’re calling custom macro O9001. S (set to #120 above) specifies the amount of stock in Z to be removed, and D specifies the depth per pass (#121 above). C specifies the program number for a subprogram that includes the XY motions for each pass. Note that our XY program (O2001 in this example) can include any conceivable set of motions. Thus, there is no limit to what kind of movements can be done. But you do have to break them off into another program.
Here is an example for the XY motion program:
O2001 (Program containing XY motions)
N001 G01 X5.75 F4.0
N005 M99 (End of program)
Now, here is the custom macro that makes the multiple passes:
O9001 (Program number)
#110 = #5001 (Attain current abs position in X)
#111 = #5002 (Attain current abs position in Y)
#112 = #5003 (Attain current abs position in Z)
#102 = FUP [#19/#7] (Calculate number of passes)
#103 = #19/#102 (Recalculate depth per pass)
#104 = 1 (Pass counter)
#105 = #112 – 1.0 + #19 - #103 (Calculate Z position for current pass)
N9001 IF [#104 GT #102] GOTO 9005 (If finished, exit)
G00 Z#105 (Rapid to current Z surface to mill)
G01 (Instate cutting mode)
G65 P#3 (Make XY motions for this pass)
G00 Z#112 (Retract to initial Z position)
X#110 Y#111 (Move to initial XY position)
#104 = #104 + 1 (Step counter)
#105 = #105 - #103 (Step Z surface to mill)
GOTO 9001 (Go back to test)
N9005 M99 (End of custom macro)
At first, this technique may appear to be a little complicated to program, but remember that the goal is to make it as quick and as easy as possible for the setup person or operator to adapt to casting size variations. Frankly speaking, it couldn’t get much easier for that person. He or she will simply change one or two values at the beginning of the program.
Also, program O9001 is universal. It will work for any Z surface in any program, meaning that the leg work of proving it out will only be necessary the first time you use it. From then on, it can remain in your control on a permanent basis. (Remember that you can even protect programs in the O9000 series from accidental editing or deleting.)