Noise spikes caused by external AC switching
Add a 10nF and a 10 or 100k resistor on your sense line.







simulate this circuit &ndash; Schematic created using CircuitLab

depending of how long is your pulse signal, you might want to adjust the values.

Make sure you have common ground between what you sense and your circuit, if you use long cables, twist the pair and use shielded cables.