I have a technical problem to solve. A sensor is sensing a value for "locked" and "neutral" to prevent fast switching of states because of tolerance and signal noise, a hysteresis must be used.
For example the value "512" must report "locked" but until the value of 499 the state will stay locked. Now because of different models and application, these values are not fixed and can change, so the value of hysteresis must be calculated by the formula.
I've collected the following examples:
First number represents lowest value before rise, second number is level for reporting "locked" and third value is the lower threshold for reporting "neutral" again
- 506 - 555 - 543 (9.91% rise from base, 2.1% fall from high to low)
- 506 - 627 - 583 (20.26% rise from base, 7.54% fall from high to low)
- 506 - 722 - 614 (30.75% rise from base, 17.59% fall from high to low)
- 506 - 840 - 666 (40.48% rise from base, 26.12% fall from high to low)
- 506 - 976 - 696 (48.77% rise from base, 40.23% fall from high to low)
The lowest acceptable value from locked would be 550, the highest is 1000.
I'm looking for a mathematical formula to calculate the actual number from the rise level that can be measures, for example i would need to calculate the following
$$506 - y - x$$
Where $y$ is any given value between 550 and 100, and $x$ becomes a value matching the pattern of above example
Can someone help me with this? I'm not very familiar with math.