; Helical bore subroutine - cuts a circular hole by helical interpolation ; Params: #1=x, #2=y, #3=diameter, #4=zstart, #5=zend, #6=stepdown ; Uses #<_td> (tool diameter) to compute offset radius o sub ; x, y, d, stepdown, zstart, zend G90 G91.1 G0 X#1 Y#2 G0 Z#4 G1 X[#1+#3/2-#<_td>/2] Y[#2] ; move to bore edge, compensated for tool radius G17 # = [#3/2-#<_td>/2] ; effective bore radius (bore radius minus tool radius) # = [#4-#6] o101 while [# GT #5] ; helical passes, one full circle per stepdown G3 X[#1+#] Y[#2] I[-#] Z[#] P1 # = [# - #6] o101 endwhile o102 if [#4 GT #5] ; partial final pass to reach exact zend # = [[#-#5]/#6*360] ; angle where remaining depth is consumed G3 X[#1+COS[#]*#] Y[#2+SIN[#]*#] I[-#] Z[#5] G3 X[#1+COS[#]*#] Y[#2+SIN[#]*#] I[-COS[#]*#] J[-SIN[#]*#] Z[#5] ; cleanup pass at final depth ;G3 X#1 Y[#2+#3/2-#<_td>/2] J[-#3/2+#<_td>/2] o102 endif G0 X#1 Y#2 G0 Z0 o endsub M2