This is a macro for gear/spline cutting with absolute toothe profiling. It steps down to a full tooth profile at each index point. This is best used on thin section large diam /ratio gears that resists warping due to detensioning from material removal . It is also the fastest method.
It has a programable front end that asks the important questions.
'M2228 Gear/Spline cutting Macro with Absolute tooth profiling
Sub Main()
'MsgBox(" In CONFIG set {ROT 360 rollover} & {Ang Short Rot on G0}")
Setvar(1,Question("Number of Teeth/Splines"))
Setvar(8,Question("Tooth/Spline DEPTH"))
Setvar(10,Question("# of steps to depth"))
Setvar(5,Question("X End of CUT"))
Setvar(7,Question(" INFEED Feedrate"))
Setvar(9,Question(" CUTTING Feedrate"))
N0:
Setvar(20,Question("Infeed AXIS?.... Y(0).... Z(1)"))
Setvar(2,(360/Getvar(1))) '(angle To turn chuck)
Setvar(3,.1) '(y clearance)
Setvar(4,-.050) '(X start of cut)
Setvar(6,0) '(starting A position)
Setvar(11,(Getvar(

/Getvar(10))) ' Step value
Setvar(12,0) 'Current depth
'**********
If Getvar(20)=0 Then GoTo n1
If Getvar(20)=1 Then GoTo n11
If Getvar(20)>1 Then MsgBox" Selection MUST be 0 or 1,,, Restart MACRO"
GoTo n0
'***Y Infeed***
Code "G0 X0"
While ISMOVING()
Wend
Code"G0 Y#12"
While ISMOVING()
Wend
Code"G0 A#6"
While ISMOVING()
Wend
'**********
N1:
Code"G0 A#6"
If Getvar(6) >= 360 Then GoTo n10
Code"G1 Y[#12]"
'**********
N2:
Do While Getvar(12) < Getvar(
CODE"G1 Y[#12+#11] F#7"
While ISMOVING()
Wend
CODE"G1 X#5 F#9"
While ISMOVING()
Wend
CODE"G1 Y0"
While ISMOVING()
Wend
CODE"G0 X0 "
While ISMOVING()
Wend
Code"#12=[#12+#11]"
GoTo n2
Exit Do
Loop
Code"#6=[#6+#2]"
Code"#12=0"
If Getvar(6) <= 360 Then GoTo n1
If Getvar(6)> 360 Then GoTo N10
'**********
Code "G0 X0"
While ISMOVING()
Wend
Code"G0 Y#12"
While ISMOVING()
Wend
Code"G0 A#6"
While ISMOVING()
Wend
'*****Z Infeed****
N11:
Code"G0 A#6"
If Getvar(6) >= 360 Then GoTo n10
Code"G1 Z[#12]"
'**********
N21:
Do While Getvar(12) < Getvar(
CODE"G1 Z[#12+#11] F#7"
While ISMOVING()
Wend
CODE"G1 X#5 F#9"
While ISMOVING()
Wend
CODE"G1 Z0"
While ISMOVING()
Wend
CODE"G0 X0 "
While ISMOVING()
Wend
Code"#12=[#12+#11]"
GoTo n21
Exit Do
Loop
Code"#6=[#6+#2]"
Code"#12=0"
'**********
If Getvar(6) <= 360 Then GoTo n11
If Getvar(6)> 360 Then GoTo N10
'**********
N10:
Code"M5 M9"
End Sub
End