Files
linuxcnc/nc_files/bore.ngc
Thaddeus Hughes 9d2379205f claude init
2026-04-03 21:47:22 -05:00

36 lines
1.0 KiB
Plaintext
Executable File

; 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<bore> 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
#<r> = [#3/2-#<_td>/2] ; effective bore radius (bore radius minus tool radius)
#<z> = [#4-#6]
o101 while [#<z> GT #5] ; helical passes, one full circle per stepdown
G3 X[#1+#<r>] Y[#2] I[-#<r>] Z[#<z>] P1
#<z> = [#<z> - #6]
o101 endwhile
o102 if [#4 GT #5] ; partial final pass to reach exact zend
#<ang> = [[#<z>-#5]/#6*360] ; angle where remaining depth is consumed
G3 X[#1+COS[#<ang>]*#<r>] Y[#2+SIN[#<ang>]*#<r>] I[-#<r>] Z[#5]
G3 X[#1+COS[#<ang>]*#<r>] Y[#2+SIN[#<ang>]*#<r>] I[-COS[#<ang>]*#<r>] J[-SIN[#<ang>]*#<r>] 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<bore> endsub
M2