% (Cutter runs outside the rectangle) (The origin is at the centre of the rectangle) (Z=0 at the top surface) (Position the Controlled Point above the centre of the rectangle) (before using this program) (#80 holds the length of the rectangle) (#81 holds the width of the rectangle) (#82 holds the final depth of cut) (#83 holds the depth of cut at each pass) (#84 holds the cutter diameter) (#85 holds the Safe Z height) (#90 will hold half the length of the rectangle) (#91 will hold half the width of the rectangle) (#92 will hold the current depth of cut) (#93 will hold the number of passes) (#94 will hold half the length of the toolpath) (#95 will hold half the width of the toolpath) O300 sub (Subroutine to cut around the periphery) (Position the cutter at the left front corner - F,) G0 X[-1*#90] Y[-1*#95] (Cut vertically to set the depth) G1 Z#92 (Cut the straight part of the length, to G) G1 X#90 Y[-1*#95] (Quarter circle around the corner, to H) G3 X#94 Y[-1*#91] I0 J#84 (Cut the width, to K) G1 Y#91 (Quarter circle around the top right corner, to L) G3 X#90 Y#95 I[-1*#84] J0 (Same for the next width and corner, to M then N) G1 X[-1*#90] G3 X[-1*#94] Y#91 I0 J[-1*#84] (Down to P, then around to F) G1 Y[-1*#91] G3 X[-1*#90] Y[-1*#95] I[#84] J0 (Add the extra depth of cut in preparation for the next cut) #92=[#92 + #83] O300 endsub (Main program) (initialisation block) #80 = 100 (Set the length) #81 = 50 (Set the width) #82 = -22 (Set the final depth of cut) #83 = -5 (Set the depth at each pass) #84 = 5 (Set the cutter radius) (Set the Safe Z height) #85 = 10 (Calculate half the length of the rectangle) #90 = [#80/2] (and add on the radius of the cutter to find half the length of the toolpath) #94 = [#90 + #84] (Calculate half the width of the rectangle) #91 = [#81/2] (and add on the radius of the cutter to find half the length of the toolpath) #95 = [#91 + #84] (Set the initial value of the current depth of cut) #92 = #83 (Calculate the number of passes of the cutter) (to get as close as possible to the final depth) (without cutting below the final depth) #93 = FIX[#82/#83] (Make this point -at the centre of the rectangle- 0, 0 temporarily) G92 X0 Y0 (Set the feed rate) F100 (Now loop around the periphery) O400 Repeat [#93] O300 call (calls the subroutine to cut around the periphery) O400 endrepeat (Final pass at full depth) #92 = #82 (Make the current depth of cut = the final depth) (Then perform the final pass just once) O300 call (Go back to the temporary origin) G0 X0 Y0 (Now restore the original co-ordinates) G92.1 M30 %