Crashing your probe into a workpiece can be an expensive mistake. Of course, the probing move itself (G38.2) can't harm your probe because it stops immediately on contact—assuming your probe is connected and configured, of course—but while moving the probe into position (G0 or G1) you have to be really careful about where the probe is relative to the piece to avoid crashing. And if you didn't get enough sleep, that might be iffy.
There's another way. During those positioning moves, you can detect if the probe made contact and stop. You just have to use a probe move (G38.3) which stops when contact is made and allows the program to continue when it isn't.
To demonstrate, here's a macro I wrote to probe the top-back-left of a workpiece in a mill. I use G38.2 for the probing moves, G38.3 for the positioning moves, and G0 for backing off after probing. Probe with confidence with Crash-Free Probing™!
Reminder, your probe has to be connected. This won't save you if it's not.
Code: Select all
(probe to zero at top-back-left of workpiece)
(start this code with your probe within 5mm above, behind, and to the left of the workpiece)
(user variables)
#100 = 5.08 ; probe diameter [mm]
#101 = 5 ; probing depth [mm]
#102 = 0.1 ; after-probing backoff clearance [mm]
#103 = 10 ; probing feed speed [mm/min]
#104 = 100 ; probe positioning feed speed [mm/min]
(note: if you will be probing with several different diameter tools, you can comment out the line defining #100 here and instead define it in the MDI.)
(probing code)
M70 ; save machine settings
G21 ; metric (bcuz imperial sux ofc)
G28.3 X0 Y0 Z0 ; call this zero for now
(debug, REMINDER: ENSURE YOUR PROBE IS CONNECTED AND ENABLED)
(subroutine for probe positioning moves)
o100 sub ; arguments: X move, Y move, Z move
G38.3 X[#1] Y[#2] Z[#3] F[#104]
o201 if [#5070 EQ 1]
(debug, PROBE TOUCHED DURING POSITIONING MOVE; ROUTINE CANCELLED)
M2
o201 endif
o100 endsub
G90
(debug, MOVING TO Z PROBE LOCATION)
o100 call [#101] [-#101] [0] ; move to Z probe location
(debug, PROBING TOP)
G38.2 Z[-#101] F[#103] ; probe Z
(debug, TOP FOUND)
G28.3 Z0 ; zero Z
G0 Z[#102]
(debug, MOVING TO Y PROBE LOCATION)
o100 call [#101] [0] [#102] ; move to probe the back side
o100 call [#101] [0] [-#101] ; plunge probe
(debug, PROBING BACK)
G38.2 Y[-#101] F[#103] ; probe Y
(debug, BACK FOUND)
G28.3 Y0 ; zero Y
G0 Y[#102]
(debug, MOVING TO X PROBE LOCATION)
o100 call [0] [#102] [-#101] ;
o100 call [0] [-#101] [-#101] ; move to probe the left side
(debug, PROBING LEFT)
G38.2 X5 F[#103] ; probe X
(debug, LEFT FOUND)
G28.3 X0 ; zero X
G0 X[-#102]
o100 call [-#102] [#102] [#102]
G28.3 X[-#102-#100/2] Y[#102+#100/2]
(debug, SUCCESS! ZEROED POSITION ON TOP-BACK-LEFT)
M72 ; restore machine settings
Code: Select all
#100 = 5.08
Code: Select all
#100 = 3