following is a acme threading cycle for external/external threading, usung a squre sided grooving tool.
if not used with the "conversational cycles" i use, you will have to add a tool number input and drop the tool change code.
HAVE FUN!
(info: ACME threading with sq tool)
o<acme> sub
; some random notes
#<ToolNumber> = #1 (= 25 Tool Num)
#<Speed> = #2 (= 300 Rpm)
#<Thd_Dia> = #3 (= 25.0 Final Dia)
#<Drv_Dia> = #4 (= 30.0 Start Dia)
#<Pitch> = #5 (= 6.35 Pitch)
#<Thd_Angle> = #6 (= 29.0 Inc Angle)
#<Cut_Depth> = #7 (= 0.1 Cut Depth)
#<Tool_Width> = #8 (= 1.6 Tool Width)
#<z_start> = #9 (= 5.0 Z Start)
#<z_end> = #10 (= -15.0 Z End)
#<Coolant> = #11 (= 8 9 is off)
(LOGOPEN,AcmeLog)
; internal/external calc
O120 if [#<Thd_Dia> LT #<Drv_Dia>] ; External thread
#<Thd_Type> = 1
#<Thd_Height> =
#<Drv_Dia> / 2] - [#<Thd_Dia> / 2 ; height of thd
#<Cut_Dia> = [#<Drv_Dia> - [#<Cut_Depth> * 2]]
#<Drv_Dia> = [#<Drv_Dia> + 0.2]
O120 else ; Internal Thread
#<Thd_Height> =
#<Thd_Dia> / 2] - [#<Drv_Dia> / 2 ; height of thd
#<Thd_Type> = 0
#<Cut_Dia> = [#<Drv_Dia> + [#<Cut_Depth> * 2]]
#<Drv_Dia> = [#<Drv_Dia> - 0.2]
O120 endif
; do tool width error calc and depth ratio
#<Ratio_calc_1> = [#<Thd_Angle> / 2] ; half of thread included angle
#<Ratio> = tan[#<Ratio_calc_1>] ; tan value
(log,TanRatio = #<Ratio>)
#<Ratio_calc_2> = [#<Ratio> * #<Thd_Height>] ; width of 1 side relative to total depth.
#<Bottom_width> = [#<Pitch> - [#<Ratio_calc_2> * 2]/2]
O121 if [#<Tool_Width> GT #<Bottom_width>] ; tool is too wide
(MSG,Tool is too #<Tool_Width>Wide!)
(log,ToolWidth = #<Tool_Width>)
(log,BottomWidth = #<Bottom_width>)
M30
O121 else ; All is well!
O121 endif
; Tool change
O122 if [#<_Tool:Number> NE #<ToolNumber>]
; Change Tool
M09 ; coolant off
O123 if [#<_Tool:Number> LT 20] ; front turret
G00 Z#<_Frontchange:Z>
G00 X#<_Frontchange:X>
O123 else ; Rear turret
G00 Z#<_Rearchange:Z>
G00 X#<_Rearchange:X>
O123 endif
G49 ; cancel toolength offset
T#<ToolNumber> M06
G43 G7 G97 S#<Speed>
M03
M#<Coolant>
#<_Tool:Number> = #<ToolNumber>
O122 else ; No tool change -continue.
G43 G7 G97 S#<Speed>
M03
M#<Coolant>
O122 endif
; Toolpath stuff below here
O127 if [#<Thd_Type> EQ 1] ; Thread is external
o101 while [#<Cut_Dia> GT #<Thd_Dia>]
#<mod_Z_start> = [[#<Cut_Dia> - #<Thd_Dia>]/2]
#<mod_Z_start> = [#<mod_Z_start> - #<Thd_Height>]
#<mod_Z_start> = [#<mod_Z_start> * #<Ratio>]
G00 X#<Cut_Dia>
#<Mod_Z_point> = [#<z_start> + #<mod_Z_start>] ;modZstart is negative
Z#<Mod_Z_point>
(log,Zpoint #<mod_Z_point>)
G33 Z#<z_end> K#<Pitch>
G00 X#<Drv_Dia>
G00 Z#<z_start>
(log,Zstart #<mod_Z_start>)
#<Current_Width> =
#<Pitch> + [#<mod_Z_start> * 2/2]
(log,CurrentWidth = #<Current_Width>)
G00 X#<Cut_Dia>
#<Z_fin> = [[#<z_start> - #<Current_Width>] + #<Tool_Width>]
G01 Z#<Z_fin> F0.3
(log,Zfin #<Z_fin>)
G33 Z#<z_end> K#<Pitch>
G00 X#<Drv_Dia>
G00 Z#<z_start>
#<Cut_Dia> = [#<Cut_Dia> - [#<Cut_Depth> * 2]]
O125 if [#<Cut_Dia> LT #<Thd_Dia>] ; maximum cut
#<Cut_Dia> = #<Thd_Dia>
O125 else
O125 endif
o101 endwhile
O127 else ; Thread is internal
o102 while [#<Cut_Dia> lt #<Thd_Dia>]
#<mod_Z_start> = [[#<Cut_Dia> - #<Thd_Dia>]/2]
#<mod_Z_start> = [#<mod_Z_start> - #<Thd_Height>]
#<mod_Z_start> = [#<mod_Z_start> * #<Ratio>]
G00 X#<Cut_Dia>
#<Mod_Z_point> = [#<z_start> + #<mod_Z_start>] ;modZstart is negative
Z#<Mod_Z_point>
(log,Zpoint #<mod_Z_point>)
G33 Z#<z_end> K#<Pitch>
G00 X#<Drv_Dia>
G00 Z#<z_start>
(log,Zstart #<mod_Z_start>)
#<Current_Width> =
#<Pitch> + [#<mod_Z_start> * 2/2]
(log,CurrentWidth = #<Current_Width>)
G00 X#<Cut_Dia>
#<Z_fin> = [[#<z_start> - #<Current_Width>] + #<Tool_Width>]
G01 Z#<Z_fin> F0.3
(log,Zfin #<Z_fin>)
G33 Z#<z_end> K#<Pitch>
G00 X#<Drv_Dia>
G00 Z#<z_start>
#<Cut_Dia> = [#<Cut_Dia> - [#<Cut_Depth> * 2]]
O125 if [#<Cut_Dia> LT #<Thd_Dia>] ; maximum cut
#<Cut_Dia> = #<Thd_Dia>
O125 else
O125 endif
(log,CutDia = #<Cut_Dia>)
o102 endwhile
O127 endif
M09
(LOGCLOSE)
o<acme> endsub