CurrentFeed = GetOemDRO(818) 'Save the current feed settings DoSpinStop() 'Spindle stopped Cur = GetDro(0) 'Reading x coordinate Move = Cur-20.0 'Maximum detection depth 20.0 Offset = Abs(GetOEMDRO(1000))/(2) 'Radius edge finder to compensate out Sal = Offset + 2.0 'After the completion of the knife, leaving the workpiece 2.0 If GetOemLed (825)=0 Then 'To judge the edge finder whether there is contact with the workpiece? Only in the beginning there is no contact with the workpiece, can run to search edge Code "G4 P2.5" 'Pause 2.5 seconds Code "G31 X"& Move & "F25" 'x-axis to find the edge as the feed rate of 25 While IsMoving() 'Wait stop searching edge detector Sleep(200) Wend Probepos = GetDro(0) ' Call SetDro(0, Offset) 'Set the new x-origin Code "G4 P1" 'Pause Code "G0 X" & Sal 'Fall back Code "(X zeroed)" 'Prompt Message Code "F" &CurrentFeed 'Restore the original feed settings Else Code "(Check Ground Probe)" 'Edge finder (probe) is shorted to ground the (contact with the workpiece), abort the operation End If Exit Sub