This post describes software hysteresis.
Hysteresis in software is a method of judgment to prevent chattering due to small fluctuations in input values and to stabilize the state. Judgment is made dependent on the previous state and works as follows.
Hysteresis judgment
- If the previous judgment value Hys is 0, set Hys to 1 when x[n] ≥ High.
- If the previous judgment value Hys is 1, set Hys to 0 when x[n] ≤ Low.
By using different thresholds for rising and falling edges, the output can be controlled to avoid frequent switching even when the input value fluctuates near the threshold.
