I have the same tool length sensor that was linked earlier in this thread. I haven't had any problems with it triggering during cutting, but I did have an issue with the probe triggering after retraction, if I had the spindle spinning during probing. For larger diameter tools I get more accurate touch results if I spin the spindle slowly while touching off the tool, so I wanted to retain this feature.
Here is my HAL, which also ands two inputs, one for the tool setter and one for the touch probe.
net M64-and-in motion.digital-out-00 and2.13.in0
net tool-sensor-and-in hm2_5i25.0.7i77.0.0.input-16 and2.13.in1
net tool-sensor and2.13.out or2.1.in0
net probe-sensor hm2_5i25.0.7i77.0.0.input-00 or2.1.in1
net probe-or-tool-sensor or2.1.out
net probe-or-tool-sensor motion.probe-input
I wrapped any G38 moves in the tool touch off subroutine with:
M64 P00
(G38)
M65 P00
The default state of motion.digital-out-00 is 0, so this code will also prevent the tool touch probe from triggering outside of a tool touch routine.