|
|
|
How to make a thread with cnc macro program?
O1999;
G90G94G17G40;
G0X#24Y#25; Quickly locate the X and Y coordinates of the thread center
M3S#19; The spindle rotates forward at the set speed
#31=#2*0.5+#3; Calculate the tool offset
#32=#18-#1; When the tool moves along the spiral line, the first position of the cut
#33=#24-#31; Calculate the position where the tool moves to the starting point of the thread
G0Z#18; Quickly locate the tool to point R
G1X#33F#9; The tool linearly interpolates to the starting point of the spiral line, and the starting point is located in the negative direction of X
N20 G02Z-#32I#31; Use the offset as the radius and the pitch as the Z-down distance of the helix (absolute coordinate)
IF[#32LE#26]GOTO30; Jump when the current Z-direction position is greater than or equal to the set Z-direction bottom position
#32=#32-#1; The next helix depth target position in the Z direction (absolute coordinate)
GOTO20;
N30;
IF[#3GT0]THEN #6=#33-#1; For external threads, when retracting, the tool retracts one pitch in the negative X direction
IF[#3LT0]]THEN #6=#24; Internal thread, the tool moves to the center of the thread when retracting
G0X#6
G90G0Z#18; Lift the tool to a safe height
M99;
O001;
G90G54G69;
G43H01Z50.M03S2000;
G00X0.Y0.M08; (The meaning of each #):
#1=0; (Initial value of rotation angle)
N11G68X0.Y0.R[#1];
#2=105.; (Radius of the center circle of the hole)
#3=18.; (Half of the major diameter of the thread)
#4=10.; (Tool radius)
#5=3.; (Thread pitch)
#6=50.; (Thread depth)
#7=1.; (Initial value in Z direction)
#8=8; (Equal thread hole number)
X[#2+#3-#4]Y0.;
Z1.
N12G02I[#4-#3]Z[#7]F200
#7=#7-#5;
IF[#7GE[-#5-#6]]GOTO12
G00X#2Y0.;
Z1.
#1=#1+360/#8;
IF[#1LT360.]GOTO11
G00Z50.;
X0.Y0.
G53G28Y0.Z0.;
M30; |
|
|
|