How does the leaky bucket work?
A Leaky Bucket is simply an up-down counter for debouncing an input or a fault condition.
Leaky Bucket in OpenECU
The OpenECU blockset contains a standalone Fault check block that can be used for debouncing faults or discrete inputs. The same leaky bucket algorithm is also used in Processed Analog Input block for built-in fault detection on analog inputs. This block uses the leaky bucket to detect out of range faults and slew rate faults on the input signal.
Tips for using this block:
- The leaky bucket does not just increment the counter by "rise rate" or "fall rate". The fall rate value is always added to the counter value:
- If input is true: counter = counter + rise rate - fall rate
- If input is false: counter = counter - fall rate
- The rise rate must be greater than the fall rate, or the output will never set.
If the hysteresis >= 1, the output will clear as soon as the input clears.
If the hysteresis <= 0, the output will stay latched until the ECU is reset.
For a description of the leaky bucket analogy, see Wikipedia's Leaky Bucket Article.