Long wires (50 m) connected to digital inputs can pick up a lot of noise. The amplitude of the noise can reach a few volts, which could be read as a “high” signal from the input circuit, giving all sort of problems.
If you are debugging a system a few hundred kilometres from your lab, this two circuits can save your day.
The first circuit is a simple RC filter, with 1 kOhm and 100 nF. The cut-off frequency will be:
f= 1/(2 Pi*R*C)=1,59 kHz
The second circuit adds threshold and isolation. In fact, the input voltage must exceed the threshold voltage of the two LEDs before the output phototransistor is switched on. The circuit is particularly suited to work with a 24V signal, where the output of the sensor is either hight (24V) or floating. This is typically a sensor with PNP output.