#
#	MACRO threadmill
#	
#	This macro mills a thread using helical interpolation.
#	
#
ASSIGN: Canned_cyc= 0;
MACRO: safe_start     Repeats= (Do_safe= 1)*(Tool_ch= 1);
ASSIGN: Finish_depth= Hole_depth;
ROTARY_POS: B= Bstart;
#ASSIGN: Helix_up= 1;
ASSIGN: Zfinish= Finish_depth;
ASSIGN: Cutter_offset= Tool_dia/2;
ASSIGN: Clear_dist= Diameter/2-Cutter_offset;
ASSIGN: Clearance= 0.0;
ASSIGN: Rap_level= Zstart;
ASSIGN: Xtemp= Xstart; Ytemp= Ystart;
ASSIGN: X= Xstart; Y= Ystart; 
ASSIGN: Threadmillstartpt
ASSIGN: R1= .5*Diameter+ (Cutter_offset+Clear_dist)*Inout;
ASSIGN: X1= R1*Xvector;  Y1= R1*Yvector;
RAPID:  X= Xtemp+ X1; Y= Ytemp+ Y1;
ASSIGN: Xret= X; Yret= Y;
SELECT: Helix_up
CASE: 0
RAPID:  Z= Rap_level+ Tool_clearance;
ASSIGN: Codes= Coolant;
FEED:  Z= Rap_level;
CASE: 1
RAPID:  Z= Rap_level+ Tool_clearance;
ASSIGN: Codes= Coolant;
FEED:  Z= Rap_level-Finish_depth;
ASSIGN: Finish_depth= -Finish_depth;
END SELECT:
ASSIGN: X_hole= Xstart; Y_hole= Ystart;
ASSIGN: Feed= Tfeed;
DCOMP_ON: P6= Comp_dir; X= Xstart; Y= Ystart;
THREADMILL: X= Xtemp; Y= Ytemp;
DCOMP_OFF: P6= Comp_cancel; X= Xret; Y= Yret;
ASSIGN: Finish_depth= Zfinish;
ASSIGN: Clearance= Clear_dist;
RAPID: Z= Initial_z-Zorgshift; Codes= Coolant_off;
