A.5 debounce filtering – Campbell Scientific SDM-IO16 16-Channel Input/Output Expansion Module User Manual

Page 37

Advertising
background image

Appendix A. General Principles of Pulse and Frequency Measurements

accurate duty cycle readings for higher frequency signals. Signals up to 4.000
kHz can be measured without error. Signals of higher frequency will also
appear to give accurate measurements. Care should be taken as signals that are
exact multiples of the sampler frequency, e.g. 4096, 8192 Hz will give
completely spurious readings.

A.5 Debounce Filtering

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.5ms whilst changing will, with the default debounce time of 3.17ms,
not be recognized as changing state until 4.17ms after the initial change. Only
one pulse will be counted, though, even if the switch opened and closed several
times within that 4.17ms 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.17ms 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 120Hz, rather than 158 Hz if there is
no bounce.

A-3

Advertising