;threading o sub o call o call # = #1 # = #2 # = #3 # = #4 # = #5 # = #6 # = #7 # = #8 O100 if [# NE #<_current_tool>] (MSG,ERROR : Set tool before use macro) O100 return [-2] ; indicate failure to epilog O100 endif G8 ; Lathe radius Mode G18 ; XZ Plane G90 ; Absolute Distance # = [# / 2.0] # = [#<_x> * 2] (starting X) # = #<_z> (starting Z) G96 D2000 S# ; Constant Surface Speed Mode M4 ; Start Spindle G4 P2 ; Wait to reach speed O110 if [#] M8 O110 endif # = [0.86603 * #] # = [# * 0.125] # = [# * 0.250] # = [# -0.06] ;(DEBUG,# # # #) O200 if [#<_metric>] # = 0.2 # = 0.1 O200 else # = 0.007 # = 0.004 O200 endif ;(DEBUG,test) G95 F# ; Feed-Per-Rev Mode ;(DEBUG,Test2) ;Threading ;(DEBUG,Test3) O300 if [# GT 0.5] ;internal ;(DEBUG,interior) ;cut the minor flat diameter ;(DEBUG,INTERNAL Threading thread dia-# startZ-# finishZ-# Pitch-# Tool-#) G0 Z # G0 X [# + # - #] G1 Z # G0 X [# - #] G0 Z # G96 D600 S# ; limit RPM in threading mode G76 P# Z# i# j# k# H3 R1.5 Q29.5 E0 L0 G0 X [# - 0.5] O300 else ;external ;(DEBUG,Test2) ;(DEBUG,TEST) ; cut the major diameter (DEBUG,EXTERNAL Threading thread dia-# startZ-# finishZ-# Pitch-# Tool-# MF #) G0 Z # G0 X [# +1] ;G1 X [# - #] ;G1 Z # ;G0 X # G0 Z # ;G96 D1000 S# ; limit RPM in threading mode G97 S1000 G76 P# Z# i-1 j# k# H2 R1.5 Q29.5 E0 L0 G0 X [# + 0.5] O300 endif ;(DEBUG,Test4) G0 Z# M5 M9 o call ; restore g20/21, g90/g91, feedrate cuter-comp and other using now global _backup_var o endsub M2 %