[13.9+] Cheap no-power hysteresis in 4x4 space using belts

Power Plants, Energy Storage and Reliable Energy Supply. All about efficient energy production. Turning parts of your factory off. Reliable and self-repairing energy.
Tinyboss
Filter Inserter
Filter Inserter
Posts: 461
Joined: Sun Nov 16, 2014 12:11 pm
Contact:

[13.9+] Cheap no-power hysteresis in 4x4 space using belts

Post by Tinyboss »

Now that 13.9 fixed the problem with disabled belts not stopping items properly, we can use wired belts to make a very simple, cheap, and reliable hysteresis loop that is compact and requires no power.

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:

Image

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:

Image

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.
Last edited by Tinyboss on Thu Apr 27, 2017 2:49 pm, edited 1 time in total.
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: [13.9+] Cheap no-power hysteresis in 4x4 space using belts

Post by siggboy »

This is beautiful. I'm surprised that nobody has answered yet (probably all on vacation).

What you've built is the equivalent of a Schmitt Trigger, without combinators. Goes to 1 above threshold, goes to 0 below threshold, retains value in between -- exactly like a Schmitt Trigger.

It can also be used as a toggle/latch, even if one does not need the feedback behaviour. It can even simply be changed to pulse the toggle event instead of holding it.

It's so good for controlling power supplies with accumulators, because it doesn't use power itself, so one does not need to worry about that aspect.
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.
I've tested with single tick inputs, and they're definitely too short to allow the item to move. So the trigger signal needs to be longer than that. XKnight could probably say right away what the necessary tick length is, because he's probably already tested this aspect :).

Edit: OK, so I've tested it. If you use Express Belts for the contraption, and put three items into it (as advised), then the trigger signal needs to be at least 4 ticks long for it to reliably switch states. With 3 ticks it sometimes works, with 2 ticks it always fails. If you use slower belts you need even longer signals.

So using express (blue) belt is necessary for best performance.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
MatthewGP
Inserter
Inserter
Posts: 26
Joined: Thu Mar 24, 2016 10:11 pm
Contact:

Re: [13.9+] Cheap no-power hysteresis in 4x4 space using belts

Post by MatthewGP »

I just wanted to say thank you. This is an awesome little thing that got rid of a bunch of pain in the butt stuff. Cheers!
vanatteveldt
Filter Inserter
Filter Inserter
Posts: 947
Joined: Wed Nov 25, 2015 11:44 am
Contact:

Re: [13.9+] Cheap no-power hysteresis in 4x4 space using belts

Post by vanatteveldt »

Nice idea to do this with belts since it doesn't consume power.

I did something similar in 12.x with two inserters to/from a chest connected via an underground belt, reading the chest content as trigger and inserting out if signal > MAX, and inserting into the chest if signal < MIN:

viewtopic.php?f=8&t=24938
screenshot
Mendel
Filter Inserter
Filter Inserter
Posts: 267
Joined: Mon Aug 17, 2015 1:51 pm
Contact:

Re: [13.9+] Cheap no-power hysteresis in 4x4 space using belts

Post by Mendel »

Thanks! This works great for controlling steam engines
Cazadore
Burner Inserter
Burner Inserter
Posts: 19
Joined: Sat Dec 13, 2014 1:52 am
Contact:

Re: [13.9+] Cheap no-power hysteresis in 4x4 space using belts

Post by Cazadore »

i just want to chip in that the picture links are broken/defunct.

if anybody has a mirror or screenshots that would be much appreciated. i need those to build the latch system.
Tinyboss
Filter Inserter
Filter Inserter
Posts: 461
Joined: Sun Nov 16, 2014 12:11 pm
Contact:

Re: [13.9+] Cheap no-power hysteresis in 4x4 space using belts

Post by Tinyboss »

Hey Cazadore, thanks for the heads up. Dropbox made it so free users can no longer host images. I moved them to imgur.

But now that alien artifacts are gone in versin 0.15, my design is no longer viable. ;-)
Cazadore
Burner Inserter
Burner Inserter
Posts: 19
Joined: Sat Dec 13, 2014 1:52 am
Contact:

Re: [13.9+] Cheap no-power hysteresis in 4x4 space using belts

Post by Cazadore »

well, i just use bricks as sentilens then.

but anyway, thank you very much for the new links. much appreciated.
User avatar
Qilili
Inserter
Inserter
Posts: 24
Joined: Wed Mar 01, 2023 2:47 pm
Contact:

Re: [13.9+] Cheap no-power hysteresis in 4x4 space using belts

Post by Qilili »

siggboy wrote: Sun Jul 24, 2016 2:25 am If you use Express Belts for the contraption, and put three items into it (as advised), then the trigger signal needs to be at least 4 ticks long for it to reliably switch states. With 3 ticks it sometimes works, with 2 ticks it always fails. If you use slower belts you need even longer signals.
So using express (blue) belt is necessary for best performance.

Necroposting it for simple fix for this from your reddit post:

https://www.reddit.com/r/factorio/comme ... &context=3
Instead of putting three items on the belt, could you not just set the top left (>60 one) to also read belt contents. Then if production momentarily goes above 60 and the item stops on that belt the machine will still be enabled
Post Reply

Return to “Energy Production”