;threading o sub o call # = #1 #= #2 #= #3 #= #4 #= #5 #= #6 #= #9 #= #10 #= #11 #= #12 # = # # = # 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 D# S# ; Constant Surface Speed Mode M3 ; Start Spindle G4 P1 ; Wait to reach speed o110 if [#] M8 o110 endif # = [0.86603 * #] # = [# * 0.125] # = [# * 0.250] # = [# * 0.625] ;(DEBUG,# # # #) o200 if [#<_metric>] # = 0.2 # = 0.1 o200 else # = 0.007 # = 0.004 o200 endif G95 F# ; Feed-Per-Rev Mode ;Threading o300 if [#GT 0.5] ;internal ;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 D# 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 ; cut the major diameter ;(DEBUG,EXTERNAL Threading thread dia-# startZ-# finishZ-# Pitch-# Tool-# MF #) G0 Z # G0 X # G1 X [# - #] G1 Z # G0 X # G0 Z # G96 D# S# ; limit RPM in threading mode G76 P# Z# i[-#] j# k# H3 R1.5 Q29.5 E0 L0 G0 X [# + 0.5] o300 endif G0 Z# M5 M9 o call ; restore g20/21, g90/g91, feedrate cuter-comp and other using now global _backup_var o endsub M2 %