% (Program to mill a helical cam) (K. Lerman) o1000 sub #$CenterX$ = #1 #$CenterY$ = #2 #$ToolDia$ = #3 #$MinRadius$ = #4 #$MaxRadius$ = #5 #$NumberOfSteps$ = #6 #$FeedRate$ = #7 #$Depth$ = #8 #$tool radius$ = [#$ToolDia$/2.0] #$current step number$ = 0 #$at depth$ = 0 o1001 while [#$current step number$ LT #$NumberOfSteps$] #$current angle$ = [#$current step number$ * 360. / #$NumberOfSteps$] #$radius at current angle$ = [#$MaxRadius$ - [#$current angle$/360] * [#$MaxRadius$ - #$MinRadius$] + #$tool radius$] #$X$ = [[0 - #$radius at current angle$ * cos[#$current angle$]] + #$CenterY$] #$Y$ = [[#$radius at current angle$ * sin[#$current angle$]] + #$CenterX$] o1002 if [#$at depth$ NE 1] #$at depth$ = 1 G1 F#$FeedRate$ X#$X$ Y#$Y$ (Go to point) G1 F[#$FeedRate$/5.0] Z#$Depth$ (Plunge to depth) o1002 else G1 F#$FeedRate$ X#$X$ Y#$Y$ (Mill to point) o1002 endif #$current step number$ = [#$current step number$ + 1] o1001 endwhile G0 Z.2 (Retract) o1000 endsub ([0,0,0] is at surface in center of cam) (Start above surface with clear path to initial point) (To do multiple passes, lie about the tool diameter first pass) S1M3 o1000 call [0][0][.800][.5][1.0][6000][5.0][-2.220] o1000 call [0][0][.650][.5][1.0][6000][5.0][-2.220] o1000 call [0][0][.530][.5][1.0][6000][5.0][-2.220] o1000 call [0][0][.500][.5][1.0][6000][5.0][-2.220] M5 %