For those who don't know, a hysteresis loop is used to switch something on and off based on an input signal, while avoiding very quick on-off switching. For example, you might want to turn on iron smelting when there are fewer than 40k iron plates, and leave it on until there are more than 60k plates.
Here's the hysteresis loop. The signal (in this case iron) comes in from the left, and the power switch on the right turns on when the input level goes below the lower threshold, then stays on until the input level goes above the upper threshold:
When iron drops below 40, the power turns on and stays on until iron is above 60, then it turns off.
Edit: I realized there's a flaw with this, since if the input signal goes very briefly above the upper threshold and then falls back below (which is probably not at all uncommon in a typical setup), the alien artifact can get stuck on the upper left belt. Luckily there's a simple fix: put three artifacts (or whatever you use) on the belt, all on the inside lane, like this:
This ensures that power can't get switched off until the first artifact has cleared the top-left belt, and is available to re-trigger the sensor when needed.
My attempt at proving it is reliable (I'm new to this so it's very possible that I'm making some bad assumptions):
- It cannot get stuck with the output on and the input signal over the high threshold, because in that case only the lower-right belt is stopped, and any artifacts on the sensor belt (top-right) must move off.
- It cannot get stuck with output off and input below the low threshold, because in that case only the top-left belt is stopped. Since all three artifacts can't fit on the stopped belt, at least one must circulate around to the sensor belt, and remain there (since the input signal is high).
- If the input is between low and high, then both top-left and bottom-right belts are stopped, so no artifacts can move onto or off of the sensor belt, which means the output state can't change.