Relays and switches have mechanical contacts which physically make or break
a circuit. Rarely will the contacts come together solidly or separate
decisively without bouncing (briefly making and breaking the circuit). This
can raise havoc with digital latching and counting circuits that might be
monitoring through the relay/switch contact. It can result in latching at the
wrong time (when the relay opens for instance) or in extra counts. Both are
An input transition is sampled on either the input turning ON or turning OFF.
When an input changes after being stable longer than the defined Debounce
delay the input transition is immediately reported and processed. This
eliminates filtering delay.
The Debounce delay timer is restarted with each input transition. When the
timer is active additional transitions are not processed. This ignores
noise from switch and relay contact bounce.
When the Debounce timer expires the state of the input is updated to reflect
its current status. In effect this accomplishes pulse stretching. A short
input pulse shorter than the defined delay will activate the input which
will remain active until the delay expires. This can be long after the pulse
Another way to capture short input pulses is Latching.
This can be
configured to accomplish pulse stretching as well. Additionally a pulse
may be captured and require a manual reset through Latching.
Debounce can also be used to achieve a stable state detecting the presence
of an AC voltage. In order to avoid counting each period of a 60Hz AC voltage
the Debounce setting needs to be at least 167 milliseconds. The default
setting of 200 milliseconds is perfect for that. The input detects the
presence of the voltage and gives a steady ON result. Note though that an
input is rated only to 30V.
HELP Topics: IO/Inputs/[DIN]/Debounce