G04P0; Pause 0s, read the current machine coordinate position correctly for subsequent procedures M5; Close the spindle (Read the current tool mechanical coordinate position) #20=#864 #21=#865 #22=#866 IF#571 EQ 0 GOTO 1; Discrimination system using a fixed position on the knife mode or the current position of the knife mode (Fixed feed mode for X, Y, Z) #1=#572-#20 #2=#573-#21 #3=#574-#22 GOTO2 N1#1=0 #2=0 #3=0 (Move to the initial position of the knife) N2 G91 G00 Z#3 G91 G00 X#1Y#2 (The first time to detect the speed of 100mm 1000mm detection signal M101 G91 G01 Z-1000 F150 M102 G04 P0; Synchronize M103 G91 G01 Z1000 F50 M102 G04 P0; Synchronize #9=#400 #12=#870 (The second test at 1000 speed under the detection of 1000mm knife signal M101 G91 G01 Z-1000 F15 M102 G04 P0; Synchronize M103 G91 G01 Z1000 F15 M102 G04 P0; Synchronize #10=#400 #13=#870 (The third test at 1000 speed under the detection of 1000mm knife signal) M101 G91 G01 Z-1000 F5 M102 G04 P0; Synchronize M103 G91 G01 Z1000 F5 M102 G04 P0; Synchronize #11=#400 #14=#870 #8=[#9+#10+#11]/3; Find the average of two pairs of knives #7=[#12+#13+#14]/3; Find the average of two pairs of knives #6=#14-#7 #402=#8; Save the Z axis zero offset of the coordinate system #403=1; Set automatic correction coordinate system logo #404=-#7; Save the tool thickness, if the previous tool thickness parameter is 0, the system will use this variable to modify the tool thickness parameter to complete the first knife #405=#7 G91 G01Z#575-#6F#578; The knife is completed, Z axis back