Debounce Filtering - Campbell SDM-IO16 User Manual

16 channel input/output expansion module
Table of Contents

Advertisement

B.5 Debounce Filtering
Appendix B. General Principles of Pulse and Frequency Measurements
The module is able to digitally filter input signals to prevent false counting of
pulses or inaccurate measurement of frequency for signals sources that do not
have "clean" digital signals. Such signals are often generated by mechanical
switch closures where the contacts often bounce on changeover resulting in a
signal that, for instance, goes low as the switch closes but then goes high for an
instant as the contact bounces, before finally going low again when the switch
finally closes properly.
The method of filtering switch bounce is also based on the 4096 Hz sampler. The
principle of operation is that when the debounce time parameter is non-zero an
integrator function is enabled for that port. Then when the signal is sampled, a
counter is either increased or decreased depending on whether the signal is high or
low. The counter value can range between two limits that represent the high or
low input states. Only when the counter reaches the opposite extreme limit will a
change of state be recognized. This action emulates a traditional 'RC' type of
filter, except that the integrator changes in a linear fashion. The amount by which
the counter is changed decreases with increasing size of the debounce timer
parameter; i.e. the larger the parameter the slower the integration counter will
change and the longer it will take for a change of state to be recognized.
This debounce time is the time a signal must stay in the new state before it will be
recognized as having changed state. This is the minimum time it takes the internal
counter to ramp from one limit to the other, providing the input signal switches
cleanly from one state to the other. As with a traditional 'RC' filter, if the signal
'bounces' back to its old state, the integrator will ramp in the opposite direction
during the bounce. This means that a new change of state will not be recognized
until the filter time has passed plus twice the time period that the signal 'bounces'
back to its original state.
As an example, a switch that changes state but bounces to its original state for a
total of 0.5 ms whilst changing will, with the default debounce time of 3.17 ms,
not be recognized as changing state until 4.17 ms after the initial change. Only one
pulse will be counted, though, even if the switch opened and closed several times
within that 4.17 ms period.
One consequence of this method of filtering is that the maximum frequency that
can be measured is affected by the amount of switch bounce. In the example
above, it takes 4.17 ms to detect the initial changeover. The next change back to
the original state cannot start until the end of this period otherwise the original
changeover may not be counted. Assuming the same amount of bounce for all
changeovers, the maximum frequency in this example would be 1/(0.00417*2),
which equates to 120 Hz, rather than 158 Hz if there is no bounce.
The relationship between the minimum debounce time in milliseconds (t
debounce parameter (n) is:
t
= 0.244 + n * 0.244
d
The relationship between maximum frequency (f
switch bounce time (t
) in milliseconds is:
b
f
= 1000 / (2 * (t
+ 2 * t
))
max
d
b
) and the
d
), debounce time and total
max
B-3

Advertisement

Table of Contents
loading

Table of Contents