Consecutive Sample Debounce Filter
Simulate a digital debounce filter that changes state only after a caller-selected number of consecutive differing samples.
Description
Debouncing suppresses short changes in sampled digital state.
Debouncing suppresses short changes in sampled digital state. A transition is accepted only after the specified number of consecutive samples differ from the current stable state.1
Simulate a digital debounce filter that changes state only after a caller-selected number of consecutive differing samples.
When to use Consecutive Sample Debounce Filter
Use this tool to simulate a digital debounce filter that changes state only after a caller-selected number of consecutive differing samples.
Prepare the single firmware record, sampled digital states or effective timing/register parameters requested. Confirm byte order, bit numbering, units and device-specific limits before interpreting the calculation.
How to use Consecutive Sample Debounce Filter and understand its results
- Prepare the single firmware record, sampled digital states or effective timing/register parameters requested. Confirm byte order, bit numbering, units and device-specific limits before interpreting the calculation.
- Enter samples, initial, requiredSamples using the field table and calculation rules, then run the tool.
- Read states. The explanation below defines the units, signs, ordering and any flags or placeholder values.
- If the tool reports an input issue, correct the values and run it again. Apply the stated assumptions when interpreting a successfully returned result.
| Input field | Meaning | Value type; see rules below | Requirement |
|---|---|---|---|
| samples | Chronological digital samples. | list of boolean; minimum entries: 0; maximum entries: 100000 | Required |
| initial | Initial debounced state. | boolean | Required |
| requiredSamples | Consecutive samples required for a state change. | integer; minimum: 1; maximum: 100000 | Required |
Enter chronological boolean samples, initial state and positive integer required count. Reset the candidate count when a sample matches the stable state; change state at the threshold and return one debounced state per sample. Empty samples return an empty list.
change state when consecutive differing samples≥requiredSamples Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.
| Output field | Meaning | Value type |
|---|---|---|
| states | Debounced state after each sample. | list of boolean; minimum entries: 0; maximum entries: 100000 |
{
"input": {
"samples": [
true,
false,
true,
true,
true,
false,
false,
false
],
"initial": false,
"requiredSamples": 3
},
"output": {
"states": [
false,
false,
false,
false,
true,
true,
true,
false
]
}
} Limitations and assumptions
The filter uses sample counts rather than elapsed time and does not read GPIO. Sampling interval, switch characteristics and latency must be supplied externally.
Numeric inputs must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Missing required fields, extra fields, wrong value types and violations of the calculation rules are input errors.
Alternative or Complementary methods
Use Integer Clock Divider Finder: Find the bounded positive integer divisor minimizing absolute frequency error, selecting the smaller divisor on a tie. For a complementary task, use EEPROM Round Robin Slot Offset: Map a zero-based write index to a fixed-size EEPROM slot using round-robin placement while leaving an incomplete trailing slot unused.
References
-
Consecutive Sample Debounce Filter — tool.io
Similar or alternative tools
- Integer Clock Divider Finder
Find the bounded positive integer divisor minimizing absolute frequency error, selecting the smaller divisor on a tie.
- EEPROM Round Robin Slot Offset
Map a zero-based write index to a fixed-size EEPROM slot using round-robin placement while leaving an incomplete trailing slot unused.