%
(Joseph Peitz, may20 2013 revision #3)
(bug fixes, added independent wall thicknesses)
(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 nut at each end)
(wrench looks like: O=O when finished)
(length of equal sign is length specified, actual wrench will include)
(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 an english sherline mill is assumed)
(preliminary code was run on a Sherline model 2000 )
g17 g20 g40 g49 g54 g80 g90.1 g94
g10 l2 p1 x0 y0 z0 (make axis set 1 be absolute)
(This says to use tool m6, in the tools file, but its not used)
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)
# = [4.500 - #]
(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
# = [3/8 - #]
(this is the size of the smaller bolthead, actually a socket wrench)
# = 4.0 (the number of flats on the smaller bolt)
# = [4.01]
# = [0.550]
# = [0.400]
# = 2.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 air)
(# = 10.0 ok for plastic or wood)
(use 5.0 meaning 5% for steel or aluminum)
(derived params)
#200 = [#/[2.0*[cos[[180.0/#]]]]+#]
(200 is x-offset to center of first hexhole)
#201 = 0.000 (y-offset to axis of wrench)
#206 = [#+[#/[2.0*[cos[180.0/#]]]]]
(206 is radius of 2nd hole)
#207 = [#200 * 2.0]
#207 = [#207 + [#]]
#210 = [#207 + [#206 * 0.1340]]
(210 is intersection of handle and 2nd circle)
#207 = [#207 + [#206]]
(207 is center of second hole)
#208 = [#207 - #206 + # ]
(208 is the cut point of the smaller hole)
#310 = [#207 - #200]
(DEBUG, Center to center length is [#310] )
(MSG, press pause button "||" to proceed)
M0
(this is where we start cutting the first hole)
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]
o100 endwhile
g1 f # z +.250 (retract )
(cut the second hole here)
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
g1 z +.25 (retract)
(cut the outer border of the wrench)
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
%