; === HELICAL MILLING === ; Helix-mill a hole with pecking. ; Assumes metric, XY plane, feedrate, and tool compensation are set. O sub # = #1 ; [mm] X center # = #2 ; [mm] Y center # = #3 ; [mm] Hole radius # = #4 ; [mm] Z start position # = #5 ; [mm] Z end position G0 X[ # - # ] Y# G0 Z# # = # ; Mill out body with several full helical turns O100 while [ # GT [ # + #<_zstep> ] ] # = [ # - #<_zstep> ] G2 I# J0 Z# ; Peck G0 Z# G0 Z# O100 endwhile G2 I# J0 Z# ; Peck G0 Z# G0 Z# ; Flat out the bottom G2 I# J0 O endsub ; Make one polygonal milling turn. ; Assumes metric, XY plane, feedrate, and tool compensation are set. O sub # = #1 ; [mm] X center # = #2 ; [mm] Y center # = #3 ; [mm] Hole radius # = #4 ; [mm] Z start position # = #5 ; [mm] Z end position # = #6 ; Edge count # = [ [ # - # ] / # ] # = [ 360.0 / # ] # = # # = 120. O100 repeat [ # ] # = [ # + # ] G1 X[ # + cos[#] * # ] Y[ # + sin[#] * # ] Z# # = [ # - # ] O100 endrepeat O endsub ; Helix-mill a polygonal hole. ; Assumes metric, XY plane, feedrate, and tool compensation are set. O sub # = #1 ; [mm] X center # = #2 ; [mm] Y center # = #3 ; [mm] Hole radius # = #4 ; [mm] Z start position # = #5 ; [mm] Z end position # = #6 ; Edge count G0 X[ # - # ] Y# G0 Z# # = # # = # ; Mill out body with several full helical turns O100 while [ # GT [ # + #<_zstep> ] ] # = [ # - #<_zstep> ] O call [#] [#] [#] [#] [#] [#] # = # O100 endwhile O call [#] [#] [#] [#] [#] [#] ; Flat out the bottom O call [#] [#] [#] [#] [#] [#] O endsub ; === SCREW/NUT POCKETING === ; Mill a pocket for a nut, part #1 (nut pocket). ; Assumes metric, XY plane, feedrate, and tool diameter are set. O sub # = #1 ; [mm] X center # = #2 ; [mm] Y center # = #3 ; [mm] Nut depth # = #4 ; [mm] Nut radius # = #5 ; [mm] Screw radius ; Initial positioning G0 X# Y# ; Cutter compensation to the right. G42 ; Make a pocket for nut. # = # O100 while [ # GT # ] O call [#] [#] [#] [0.] [-#] [6] # = [ # - #5410 * 0.9 ] ; Subtract 90% tool diameter G0 Z0.0 ; Get tool up for another plunge O100 endwhile ; Cleanup. G40 G0 Z#<_zsafe> O endsub ; Mill a nut pocket, part #2 (screw body pocket). ; Assumes metric, XY plane, feedrate, and tool diameter are set. O sub # = #1 ; [mm] X center # = #2 ; [mm] Y center # = #3 ; [mm] Screw radius # = #4 ; [mm] Sheet thickness # = [ # - #5410 / 2 ] O call [#] [#] [#] [0] [-#] ; Cleanup. G0 Z#<_zsafe> O endsub ; --- BEGIN CONFIGURATION --- ; Don't forget to set up tool table. S2000 F250 #<_zsafe> = 30. ; [mm] Safe Z #<_zstep> = 3.5 ; [mm] Z step #<_thickness> = 13.5 ; [mm] Sheet thickness #<_nut_radius> = 3.95 ; [mm] Nut radius #<_nut_depth> = 7.5 ; [mm] Nut depth #<_screw_radius> = 2. ; [mm] Screw radius #<_grid_step> = 30. ; [mm] Nut grid step #<_grid_width> = 180. ; [mm] Grid width #<_grid_length> = 210. ; [mm] Grid length ; --- END CONFIGURATION --- G21 G90 G17 ; Metric, Absolute, XY plane O sub # = 0. O100 while [ # LE #<_grid_width> ] # = 0. O110 while [ # LE #<_grid_length> ] O120 if [ #1 EQ 1 ] O call [#] [#] [#<_nut_depth>] [#<_nut_radius>] [#<_screw_radius>] O120 elseif [ #1 EQ 2 ] O call [#] [#] [#<_screw_radius>] [#<_thickness>] O120 endif # = [ # + #<_grid_step> ] O110 endwhile # = [ # + #<_grid_step> ] O100 endwhile O endsub G0 Z#<_zsafe> T4 M6 G43 ; 1.5mm cylindrical M3 O call [1] G0 Z#<_zsafe> T2 M6 G43 ; 3.175mm cylindrical M3 O call [2] G0 Z#<_zsafe> M2