% (Joseph Peitz, may10 2013) (the universal box end-wrench program : 12pt, 6, 8, and other ) (two subroutines here:) (first subroutine cuts the number of flats passed in) (eg: make a ten sided wrench for a ten sided nut) () (second subroutine cuts twice the number of flats passed in) (eg: cut a 12 pointed wrench for a six sided nut) () (each subroutine takes 4 params: bolt diameter, number of flats, currentx,) (currenty positions) (if your nut has an even number of points, the distance across opposing flats) (through nut axis is the size wrench to make. If odd, twice the distance ) (from the center of one flat to the axis of the nut is needed) () (zero the cutter on the part centerline, holes are offset from that in x dir) (handle width is width of the first nut) (first nuthole must be the bigger one) (wrench looks like: O=O when finished) (length of equal sign is length specified, actual wrench will include) (the diameter of each nuthole and its width. linewidth of O is same ) (for both ends, diameter of O depends on hole sizes) (a 5/64 diameter endmill is assumed, I've cut 10mm wrenches) (if you use a larger cutter you may have to finish corners with a file) (no g-code cutter comp is used in the program, you can change the head) (dimensions and make it as tight or loose as you wish) (here subroutines:) (both assume that other code has made a plunge,cutter has been zeroed,) (plate or sheet is firmly attached to the slide) () (this routine cuts one pass, one point for each flat) o1000 sub # = #2 # = #3 # = #4 # = [#1/[cos[180.0/#]]] #305 = # #301 = # #303 = [[360.0/#] / 2.0] #306 = [#*[sin[180.0/#]]] #305 = [#305 + [#306 * cos[270.0 + #303]]] #301 = [#301 + [#306 * sin[270.0 + #303]]] o140 while [#303 lt 360.000] g1 x [#305] y [#301] #303 = [#303 + [360.0/#]] #305 = [#305 + [#306 * cos[270.0 + #303]]] #301 = [#301 + [#306 * sin[270.0 + #303]]] o140 endwhile g1 x [#] y [#] o1000 endsub () (heres the subroutine that makes one pass with two points per flat) o1001 sub # = #2 # = #3 # = #4 # = [#1/[cos[180.0/#]]] #305 = # #301 = # #303 = [[360.0/#] / 2.0] #306 = [#*[sin[180.0/#]]/[2.0*[1.0+cos[180.0/#]]]] #305 = [#305 + [#306 * cos[270.0 + #303]]] #301 = [#301 + [#306 * sin[270.0 + #303]]] g1 x [#305] y [#301] o140 while [#303 lt 360.000] #303 = [#303 -[360.0/[#*2.0]]] #305 = [#305 + [#306 * cos[270.0 + #303]]] #301 = [#301 + [#306 * sin[270.0 + #303]]] g1 x [#305] y [#301] #303 = [#303 + [360.0/[#]]] #305 = [#305 + [#306 * cos[270.0 + #303]]] #301 = [#301 + [#306 * sin[270.0 + #303]]] g1 x [#305] y [#301] o140 endwhile g1 x [#] y [#] o1001 endsub (here starts the main program) (protocol leadin) g17 g20 g40 g49 g54 g80 g90.1 g94 g10 l2 p1 x0 y0 z0 (make axis set 1 be absolute) t1 m6 (tellit we're using a tool, 3/16 endmill used here hardcoded) f 100 g0 x0 y0 z0 (end protocol) (wrench looks like O=o and the space between the -'s of the equal sign) (are the radius of the holes at each end. with very small o, we'll get) (O>o as our output) # = [5.0/64.0] (a 5/64 diameter endmill) # = [3.000 - #] (this is the dimension for the bigger opening:,our bolt size) (this is a very snug fit, this setting leaves endmill wobble) (about .002, as the only clearance and adjust this if its too tight) (make cutterdiam be 5.0/64 - .005 and get .007 clearance....) # = 5.0 # = [0.50 - #] (this is the size of the smaller bolthead) # = 4.0 (the number of flats on the smaller bolt) # = 2.00 # = [0.37] (both ends have same thick) # = 4.0 (number of times to go around) # = 0.0250 (passesneeded times passdepth = sheet thickness) (use passdepth = 0.005 for aluminum or steel) # = 100.0 (ok for plastic or wood) (use 5.0 meaning 5% for steel or aluminum) #100 = [3.0000] (5/64 endmill, 1.74 hex head) #101 = [0.5000 - 5/64] (width of 2nd squarehole comp 2 sides) #102 = 2.5 (length of wrench handle) #103 = 4 (the number of passes each #105 inches deep) #105 = 0.0250 (depth of cut per pass wood) (derived params) #200 = [#/[2.0*[cos[[180.0/#]]]]+#] (x-offset to center of first hexhole) #201 = 0.000 (y-offset to axis of wrench) (this is where we start cutting) g1 f # z +.250 (retract ) g0 x # y 0.0 #302 = 0 o100 while [#302 lt #] #302 = [#302 + 1] g1 f # z - [#302 * #] (start with a plunge cut here) o1000 call [#] [#] [#] [0.0] (o1001 call [#] [#] [#] [0.0]) (o1001 call [#] [#*2.0] [#] [0.0]) o100 endwhile g1 f # z +.250 (retract ) #206 = [#+[#/[2.0*[cos[180.0/#]]]]] (206 is radius of 2nd hole) #207 = [#200 + [#200 *.8660]] (#207 = [#207+[#/2.0]] +cutter comp) (#207 = [#207-#] wall thicknesses) #208 = [cos[asin[[#-#]/[2*#]]]] #207 = [#207 + [# * #208]] (#210 = [#207 -[#206 *.8660]] ) #210 = #207 (210 is intersection of handle and 2nd circle) (#207 = [#207 + [#206 * [cos[asin[[# / 2] /#206]]]]]) #207 = [#207 + [#206 * 0.8660]] (.8660 is half cos 30) #208 = [#207 - #206 + # ] (208 is the cut point of the smaller hole) g0 x #208 y 0.0 (go to the cut point of the 2nd hole) #302 = 0 o110 while [#302 lt #] #302 = [#302 + 1] g1 f # z - [#302 * #] (start with a plunge cut here) o1000 call [#] [#] [#208] [0.0] (o1001 call [#] [#] [#208] [0.0]) o110 endwhile (nowgo and cut the dumbbell) g1 z +.25 (retract) g0 x0 y0 #302 = 0 o150 while [#302 lt #] #302 = [#302 + 1] g1 f # z - [#302 * #] (start plunge ) g2 x [#200 + [#200 * .8660]] y [#200 / 2] i [#200] j 0 (back into handle) g1 x [#210] y [#206 /2] g2 x [#210] y -[#206/2] i [#207] j0 g1 x [#200 + [#200 * 0.8660]] y -[#200 / 2] g2 x 0 y 0 i [#200] j 0 o150 endwhile g1 z +.25 g0 x0 y0 m2 %