O2000 sub (subroutine to rough and finish mill a profile) (assumes profile goes in the +Y direction from the start point) (uses climb milling) (arguments) (#1 = x start point) (#2 = y start point) (#3 = O-number of subroutine with profile) (#4 = start Z level) (#5 = finish Z level) (#6 = tool diameter) (#7 = roughing feed) (#8 = roughing depth per pass) (#9 = finish feed) (#10 = finish pass width) (#11 = diameter of area available for ramp-down) (note: #11 must be bigger than #6 + 4 * #10) (internal variables) (#20 = current z value) O2001 if [#5 GT #4] (DEBUG, Finish Z <#5> is above start Z <#4>) M2 O2001 endif O2002 if [#11 LE #6+4*#10] (DEBUG, ramp down area too small, use a smaller tool?) M2 O2002 endif (negative value would make infinite loop) #8 = [ABS[#8]] (don't want comp on at this point) G40 (initial Z - in the clear) #20 = [#4+#8] (go to starting location) G0X[#1-#11/2]Y[#2-#11/2]Z#20 (turn on comp - oversize tool for roughing) G41.1D[#6+2*#10] (arc move to get comp started - still at safe height) G3F#7I0J[#11/2]X#1Y#2 (calc new Z) #20 = [#20-#8] (roughing loop) O2003 while [#20 GT #5] (helical ramp down) G3I[0-#11/2]J0X#1Y#2Z#20 (mill profile) O[#3] call #20 = [#20-#8] O2003 endwhile (final helical ramp to the proper depth) #20 = #5 G3I[0-#11/2]J0X#1Y#2Z#20 (mill profile at final depth) O#3 call (arc out) G3I[0-#11/2]J0X[#1-#11/2]Y[#2+#11/2] (up to clear material) G0Z[#4+#8] (comp off) G40 (go to starting point for finish pass) G0X[#1-#11/2]Y[#2-#11/2] (turn on comp - finish tool size) G41.1D[#6] (arc to profile start point at safe height) G3F#9I0J[#11/2]X#1Y#2 (helical ramp down to finish depth) G3I[0-#11/2]J0X#1Y#2Z#5 (mill profile) O[#3] call (arc out) G3I[0-#11/2]J0X[#1-#11/2]Y[#2+#11/2] (comp off) G40 (this should result in no net movement) (since it moves by exactly the tool radius) G0X[#1-#11/2]Y[#2+#11/2-#6/2] (get up out of the hole) G0Z[#4+#8] O2000 endsub