Page 1 of 1

Turn on for a range...

Posted: Sat May 26, 2018 8:20 pm
by Mr. Tact
I have a process creating a fluid. I want the process to start when the fluid storage goes under a constant value of X, but I don't want the process turning on and off as the amount fluctuates just over and just under the value X. So, I'd like the process to run until the amount of fluid is X + 5000. I figured out a way to do this by shuffling an item between two chests. When the storage goes under X, an inserter enables putting the item in a chest. The process run as long as the item is in the chest. Another decider and insert shuffles the item back to the other chest at X + 5000, stopping the process.

Is there a cleaner way to do this?

Re: Turn on for a range...

Posted: Sun May 27, 2018 1:15 am
by Nitrah
Look up factorio SR latches on YouTube. You can link a pump to a tank

Re: Turn on for a range...

Posted: Sun May 27, 2018 10:57 am
by Lav
You need not SR latch, but a hysteresis loop. There are a few designs available in this thread: viewtopic.php?f=8&t=32432

I personally prefer the one with decider combinator and reversed multiplication combinator:

1. Storage Tank ---> Decider combinator: IF resource >= top_limit OUTPUT S=1 ---> Producing Facility: active IF S=0.
2. Arithmetic combinator: S * diff ---> resource. It feeds from decider's output and into decider's input, possibly with a different wire color to prevent signal contamination in the original network.

If you want amount to oscillate between 10K and 13K, then your top_limit=13K and diff=3K.

It's functionality is extremely simple. Producing facility is active until resource reaches the top_limit. At this moment decider outputs S=1, which stops the production AND feeds an extra resource=diff signal into decider's input. Because of this, decider continues to output the S=1 signal until real amount of your resource drops below top_limit-diff.

The beauty of this design is that you can place simple "flickering" switches at first, simply to prevent the storage tank overflow, and then just slap another combinator on top of an already functional scheme to convert it to a hysteresis loop.

Re: Turn on for a range...

Posted: Sun May 27, 2018 1:06 pm
by Optera
I prefer using a memory cell with dedicated set and reset combinators over the promoted 2 combinator hysteresis for the following reasons:
- thresholds can be set directly and can be compares to actual values at a glance
- threshold for set and reset can be made from entirely different signals
- multiple set and reset thresholds can be easily combined

For example my oil refineries turn on when either petrol, light oil or heavy oil is < 50% and turn off either of them is > 90%

Re: Turn on for a range...

Posted: Sun May 27, 2018 2:06 pm
by Mr. Tact
Optera wrote:I prefer using a memory cell with dedicated set and reset combinators over the promoted 2 combinator hysteresis for the following reasons:
- thresholds can be set directly and can be compares to actual values at a glance
- threshold for set and reset can be made from entirely different signals
- multiple set and reset thresholds can be easily combined

For example my oil refineries turn on when either petrol, light oil or heavy oil is < 50% and turn off either of them is > 90%
A "memory cell"? I like your description, can you be more specific? Or perhaps provide an example blueprint?

Re: Turn on for a range...

Posted: Mon May 28, 2018 6:15 am
by Optera
It's what the combinator tutorial calls an RS Latch.
https://wiki.factorio.com/Tutorial:Circ ... er_version

I didn't want to use that name as some still think of the terrible unstable 2 decider latch modelled after electronic circuits shown below the good version in the tutorial.

Re: Turn on for a range...

Posted: Mon May 28, 2018 11:38 am
by Mr. Tact
Cool. Thanks for pointing me at what I was looking for.

Re: Turn on for a range...

Posted: Mon May 28, 2018 9:20 pm
by Nitrah
Lav wrote:You need not SR latch, but a hysteresis loop. There are a few designs available in this thread: viewtopic.php?f=8&t=32432

<snip>
This is an SR latch.