%
(subroutine for a nine pointed star in progress, borrows from)
(wrench for setup)
(each sub takes x,y,length of flat and a compass point )
(compass point locates axis of the bolthead)
(the first cut is made in the direction specified, due east is)
(zero degrees, 240 degrees puts the axis of a six or 12 point)
(bolthead parallel to the line y = 0 and 225 degrees for a square)
(does one pass around the bolthead and returns)
(makes a 360 degree pass around the head, calling with fractional)
(degrees may cause some problems, so always use whole degrees)
(notes on cutting odd shapes with this code:)
(this subroutine pivots the figure on the point passed in through)
(compass point. We'd really like to rotate the figure about its central)
(point instead of just doing a pivot. Another subroutine that called)
(this one could work, that one will do a move based on the rotation )
(required in order to get this one working first)
(cuts a nine armed star, if caller made a plunge)
(180-150 = 30, the apex angle: bisect this for bias)
o403 sub
#305 = #1 (x )
#301 = #2 (y )
#306 = #3 (length of one flat )
#304 = #4 (flat compass point )
#304 = [#304 + 15.00] (bias)
#308 = [0]
o143 while [#304 lt [360.000 + #4]]
#304 = [#304 +150]
#305 = [#305 + [#306 * cos[#304]]]
#301 = [#301 + [#306 * sin[#304]]]
g1 x [#305] y [#301]
#304 = [#304 -110]
#305 = [#305 + [#306 * cos[#304]]]
#301 = [#301 + [#306 * sin[#304]]]
g1 x [#305] y [#301]
o143 endwhile
o403 endsub
(cuts a any sided hole, if caller made a plunge)
(fifth param is number of sides)
(sixth is the radius of a circumscribing circle)
(call with the third param == 0)
(this just makes a n-sided polygon, not a star shaped one)
o404 sub
#305 = #1 (x )
#301 = #2 (y )
#306 = [2 * #6 * [sin[[360.0 / #5] / 2.0]]] (length of one flat 2rsinO/2 )
#304 = #4 (point compass point )
(#304 = [#304 - [360.0/ #5]/ 2 + 180] bias)
#304 = [#304 - [90.0 - [180.0 / #5]] + 180.0]
(DEBUG, usin #304 forbias)
#308 = 0
o143 while [#308 lt #5]
#308 = [#308 + 1]
#305 = [#305 + [#306 * cos[#304]]]
#301 = [#301 + [#306 * sin[#304]]]
g1 x [#305] y [#301]
#304 = [#304 + [360.0 / #5]]
o143 endwhile
o404 endsub
(cuts a any sided star, if caller made a plunge)
(call with the third param == 0 its not used)
(fourth is compass point)
(fifth param is number of arms)
(sixth is the radius of larger circumscribing circle)
(seventh is the radius of smaller circumscribing circle)
(arms extend from the inner circle to outer circle)
(makes a n-armed star)
(perhaps the basis of a gear cutting pgm...)
o405 sub
#305 = #1 (x )
#301 = #2 (y )
(#306 = [2 * #6 * [sin[[360.0 / #5] / 2.0]]] length of one flat 2rsinO/2 )
#311 = [[cos[180 / #5]] * #6] (intermediate calc)
#313 = [[sin [180/ #5]] * #6]
#309 = [atan[ #311 - #7] / [#313]] (our positive angle)
#310 = [2 * #309] (our negative angle)
#306 = [[#311 - #7] / [sin[#309]]] (length of a single cut)
#312 = [90.0 -[asin[#311/#6]] ]
#304 = [#4 + 90.0 + #312 - #309 ]
#313 = [- #312 + #309]
#309 = [ #310]
#308 = 0
o143 while [#308 lt #5]
#308 = [#308 + 1]
#304 = [#304 + #309]
#305 = [#305 + [#306 * cos[#304]]]
#301 = [#301 + [#306 * sin[#304]]]
g1 x [#305] y [#301]
#304 = [#304 - #310]
#305 = [#305 + [#306 * cos[#304]]]
#301 = [#301 + [#306 * sin[#304]]]
g1 x [#305] y [#301]
#304 = [#304 + [360.0 / #5]]
o143 endwhile
o405 endsub
(cuts a any sided piecrust or chain sprocket, )
(fifth param is number of ~ which is made from a g2 and a g3 move)
(traces one g2 and g3 arc centered on chord for each chord)
(sixth is the radius of the chord endpoint circumscribing circle)
(seventh is the radius of the g3 ~ piece)
(the g2 ~ piece will have diam chord length - #6 diam)
(call with the third param == 0)
o406 sub
#305 = #1 (x )
#301 = #2 (y )
#306 = [2 * #6 * [sin[[360.0 / #5] / 2.0]]] (length of one flat 2rsinO/2 )
(DEBUG, chord length is #306)
#304 = #4 (point compass point )
(#304 = [#304 - [360.0/ #5]/ 2 + 180] bias)
#304 = [#304 - [90.0 - [180.0 / #5]] + 180.0]
#358 = 0
o143 while [#358 lt #5]
#358 = [#358 + 1]
#311 = #305
#312 = #301
(center of g3:)
#307 = [#305 + [#7 * cos[#304]]]
#308 = [#301 + [#7 * sin[#304]]]
(center of g2 :)
#309 = [[#311 + [2 * [#7 * cos[#304]]]] + [[[#306 - 2 * #7]/2] * cos[#304]]]
#310 = [[#312 + [2 * [#7 * sin[#304]]]] + [[[#306 - 2 * #7]/2] * sin[#304]]]
(update the base params here)
#305 = [#305 + [#306 * cos[#304]]]
#301 = [#301 + [#306 * sin[#304]]]
(g1 x [#305] y [#301])
(next two ops make inner/outer semicircles, diam = chord len.)
(idea: a parameter called shared chord could make a useable way to add circles)
(G2 x [#305] y [#301] i [#311 + [#306/2 * cos[#304]]] j[#312 + [#306/2 * sin[#304]]] ~/2 picks radius as 1/2 chord auto )
(G3 x [#305] y [#301] i [#311 + [#306/2 * cos[#304]]] j[#312 + [#306/2 * sin[#304]]] ~/2 picks radius as 1/2 chord auto )
G3 x [#311 + 2 * #7 * cos[#304]] y [#312 + 2 * #7 * sin[#304]] i [#307] j[#308]
(o406 break)
G2 x [#305] y [#301] i [#309] j[#310]
#304 = [#304 + [360.0 / #5]]
o143 endwhile
o406 endsub
(cuts a n-sided polygon with arcs centered on each side)
(traces one g3 with chord midpoint as center)
(sixth is the radius of the base polygon)
(seventh is the radius of the leaf piece, the partial circle)
(eighth is the chord width shared by the circle and base figure)
(using a separte subroutine see o408 for circles outside the polygon)
(shared chordlength is centered on the midpoint of each chord)
o407 sub
#305 = #1 (x )
#301 = #2 (y )
#306 = [2 * #6 * [sin[[360.0 / #5] / 2.0]]] (length of one flat 2rsinO/2 )
#304 = #4 (point compass point )
#304 = [#304 - [90.0 - [180.0 / #5]] + 180.0]
#358 = 0
o143 while [#358 lt #5]
#358 = [#358 + 1]
#311 = #305
#312 = #301
#307 = [#305 + [#7 * cos[#304]]] (center of g3:)
#308 = [#301 + [#7 * sin[#304]]]
/#309 = [#311+[#306/2*[cos[#304]]]+[[#7 + #7*[cos[asin[#8/[2*#7]]]]]*[cos[90.0+#304]]]]
/#310 = [#312+[#306/2*[sin[#304]]]+[[#7 + #7*[cos[asin[#8/[2*#7]]]]]*[sin[90.0+#304]]]]
#309 = [#311+[#306/2*[cos[#304]]]+[[#7 ]*[cos[-90.0+#304]]]]
#310 = [#312+[#306/2*[sin[#304]]]+[[#7 ]*[sin[-90.0+#304]]]]
(update the base params here)
#305 = [#305 + [#306 * cos[#304]]]
#301 = [#301 + [#306 * sin[#304]]]
g1 x[#311+[[#306-#8]/2]*cos[#304]] y[#312+[[#306-#8]/2] *sin[#304]]
G3 x[#311+[[#306+#8]/2]*cos[#304]] y[#312+[[#306+#8]/2] *sin[#304]] i[#309] j[#310]
(o407 break)
g1 x [#305] y [#301]
#304 = [#304 + [360.0 / #5]]
o143 endwhile
(last half circle outside the while loop)
o407 endsub
(cuts a n-sided polygon with circles centered on each side)
(traces one g3 circle with chord midpoint as center)
(sixth is the radius of the base polygon)
(seventh is the radius of the leaf piece )
(eighth is the distance from chord center to subcircle center)
(CAUTION: measuring from chord center will be incorrect for most apps)
(CAUTION: this routine does a retract and re-plunge to #666)
(making a routine for circles outside of a circle next ??)
o408 sub
#305 = #1 (x )
#301 = #2 (y )
#306 = [2 * #6 * [sin[[360.0 / #5] / 2.0]]] (length of one flat 2rsinO/2 )
#304 = #4 (point compass point )
#304 = [#304 - [90.0 - [180.0 / #5]] + 180.0]
#358 = 0
o143 while [#358 lt #5]
#358 = [#358 + 1]
#311 = #305
#312 = #301
#307 = [#311+[[#306]/2] *cos[#304]] (polygon side centerpoint)
#308 = [#312+[[#306]/2] *sin[#304]]
#309 = [[#307]+[[#8-#7]*[cos[90.0+#304]]]] (sub center edgepoint)
#310 = [[#308]+[[#8-#7]*[sin[90.0+#304]]]]
(update the base params here)
#305 = [#305 + [#306 * cos[#304]]]
#301 = [#301 + [#306 * sin[#304]]]
g1 x[#307] y[#308]
(here we need a retract and a goto edge of subcircle)
g1 z [+.25]
g0 x[#309] y[#310]
g1 z -[#666] (plunge for subcircle cutting)
G3 i[#309 + #7*[cos[90.0+#304]]] j[#310+#7*[sin[90.0+#304]]] (full circle)
g1 z [+.25] (retract after cutting the circle)
(return to center chord)
g0 x[#307] y[#308] (back to chord midpoint)
g1 z -[#666] (continue the cut)
(o408 break)
g1 x [#305] y [#301]
#304 = [#304 + [360.0 / #5]]
o143 endwhile
o408 endsub
(cuts a circle with n circles centered about, round gasket? )
(sixth is the radius of the base circle)
(seventh is the radius of the small circles )
(eighth is the distance from circle circum to subcircle center)
(CAUTION: this routine does a retract and re-plunge to #666)
o409 sub
#305 = #1 (x )
#301 = #2 (y )
#306 = [2 * #6 * [sin[[360.0 / #5] / 2.0]]] (length of one flat 2rsinO/2 )
#304 = #4 (point compass point )
#314 = [#4]
#304 = [#304 - [90.0 - [180.0 / #5]] + 180.0]
#313 = [#4 + 180.0]
#358 = 0
o143 while [#358 lt #5]
#358 = [#358 + 1]
#314 = [#314 + 360.0/#5]
#311 = #305
#312 = #301
#307 = [#311+[#306 *cos[#304]]] (arc endpoint)
#308 = [#312+[#306 *sin[#304]]]
#309 = [[#307]+[[#8-#7]*[cos[#314]]]] (sub center edgepoint)
#310 = [[#308]+[[#8-#7]*[sin[#314]]]]
(update the base params here)
#305 = [#305 + [#306 * cos[#304]]]
#301 = [#301 + [#306 * sin[#304]]]
g3 x[#307] y[#308] i [#1 + #6*[cos[#313]]] j [#2 + #6*[sin[#313]]]
(here we need a retract and a goto edge of subcircle)
g1 z [+.25]
g0 x[#309] y[#310]
g1 z -[#666] (plunge for subcircle cutting)
G3 i[#309 + #7*[cos[#314]]] j[#310+#7*[sin[#314]]] (full circle)
g1 z [+.25] (retract after cutting the circle)
(return to main circle)
g0 x[#305] y[#301] (back to chord endpoint)
g1 z -[#666] (continue the cut)
#304 = [#304 + [360.0 / #5]]
o143 endwhile
o409 endsub
(setup for cutting aluminum, .010 z feed, 5% slew)
(zero the cutter on the part centerline, hole is offset from that by compas)
(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)
(measurements based on a open end wrench dimensions)
f 100
g0 x0 y0 z0
(end protocol)
(12mm is .4724, a 5/64 endmill is .078125 and 2/32 is .0625)
(theres usually .004 slop in wrench-bolthead and this eliminates)
(raw params are numbered starting from 100, processed params are 200)
(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)
#100 = [1.5000 - 5/64] (5/64 endmill, 1.74 hex head)
#101 = [1.5000 - 5/64] (width of 2nd squarehole comp 2 sides)
#102 = 1.5 (length of wrench handle)
#103 = 3
#104 = [7 / 16] (wall thickness both walls have same thickness)
#105 = 0.0500 (depth of cut per pass test)
#106 = 90 (cutting feed rate, test pgm)
(derived params)
#200 = [#100/1.7320 + #104] (x-offset to center of first hexhole)
#201 = 0.000 (y-offset to axis of wrench)
(#100 /2 /radius = cos 30 ....)
(we're cutting a six sided figure here, correct for length to centerpt)
#205 = [#200 - [#100 / 1.7320]] (x-offset to hex point center)
(this is where we start cutting)
g1 f #106 z +.250 (retract )
(g0 x #200 y -[ #100 / 1.7320] go to the center point bottom)
g0 x #205 y 0.00
#306 = [0.1546 * #100] (length of single flat, ugly to derive)
#302 = 0
o100 while [#302 lt #103]
#302 = [#302 + 1]
#305 = [#200]
(the depth has got to start being a fixed parameter so we can retract)
#666 = [#302 * #105]
g1 f #106 z - [#666] (start with a plunge cut here)
(o403 call [#104] [0.00] [#100] [180.00] many sided)
o100 endwhile
(g1 f #106 z +.250 retract )
g0 x [#205 + 0.95] y 0.00
#302 = 0
(printout the circle radius is 2.0)
(g2 i [#205 + 0.95 + 2.0] j 0)
o101 while [#302 lt #103]
#302 = [#302 + 1]
#305 = [#200]
#666 = [#302 * #105]
g1 f #106 z - #666
o403 call [#104 + 1.00] [0.00] [#100 - .60] [180.00] (nine sided star)
o404 call [#205 + 0.95] [0.00] [#100 - .60] [180.00] [5] [2.0] (many sided)
o405 call [#205 + 0.95] [0.00] [0.0] [180.00] [29] [2.0] [.40] (sided)
o406 call [#205 + 0.95] [0.00] [#100 - .60] [180.00] [29] [2.00] [.14](piecrust)
(#8 cannot be larger than 2* #7)
o407 call [#205 + 0.95] [0.00] [#100 - .60] [90.00] [4] [2.00] [1.50] [1.30](clover)
o408 call [#205 + 0.95] [0.00] [#100 - .60] [180.00] [5] [2.00] [.34] [-0.98]
o409 call [#205 + 0.95] [0.00] [#100 - .60] [180.00] [20] [2.00] [.14] [+0.48]
o101 endwhile
g1 f #106 z +.250 (retract )
g0 x0 y0
m2
%