mmmPI wrote: Tue Apr 08, 2025 10:21 pm
GluAp wrote: Tue Apr 08, 2025 10:02 pm
Honestly - I don't know what this does.... I guess this could be a feedback loop. My programming days are long gone and I hope you can follow my notation.
I am not sure i can follow the notation, but i wanted to be sure i didn't make a mistake, because i realize it's not exactly working as a schmitt trigger, which aims at controlling that the input signals reaches the "upper bound" before flopping. I may have spoken too soon when "confirming". When i tried again the posted blueprint, i realize it wouldn't work when the value reaches the upper bound when you set it to the quantity of the fluid tank, but if you need to set it above then the blueprint just picks the maximum signal even if it's not at the specified limit. It look a lot like a schmitt trigger but isn't one.
Well .. the example with my 'special' notation has no connection with the thread opener nor the circuit I posted. It just decribed something I was wishing to be be implemented/added as it is (imo) not doable with circuits.
As far as I would say, it behaves as a Schmitt Trigger with a variable upper bound? So yes - it does not care how big the input signal is but picks the max(input), as far it surpasses the lower threshold value. If you replace the selector combinator with a decider that filters for signals above a upper bound, it should work like a Schmitt Trigger. But atm I'm a little bit lazy to test it .
Note:
The "upper limit input value" has to be higher than the highest input value that is expected to be used with the circuit. Contrary to it's naming it does not behave as the upper bound you'd find in a Schmitt Trigger. I'm not good with words I guess
So when using vanilla tanks and connecting 1 Tank to green wire, it should be bigger than 25.000. But you could make it 25.000.000 as long as there is no integer overflow when doubling that number.
When connecting 4 tanks it should be >100.000.
Then i tried to understand how the posted blueprint could serve the mentionned purpose in the OP , the usecase, but i don't think it can.
The wiring (i think plz correct me this is hypothesis) should account for 2 differents sets of inputs i thought, 1) for the fluid that could serve as fuel to know their quantity and 2) the quantity of fluid in the buffer tank, to know when to switch.
As such i am not sure i understand the usecase of the machine
Sorry, I don't understand what your idea with the two input sets is supposed to be. On the green wire are the CURRENT buffer/tank values. The red wire will only have 1 of those input signals and works as a filter. It carries the real value with a little offset regarding circuit delay.
Is this what you're missing?
Well - here is a possible use case (may not strictly be very useful for vanilla fluids^^)
You have 3 buffers with different levels of differnt fluid types. Those are on the green wire. Because Light Oil is the maximum, the circuit has choosen Light Oil and so it is on the red wire. The three buffers a connected to a 4th buffer in the middle via pumps. Those pumps are enabled but have a filter set which is set via red wire. You can see, that all pumps are filtered for Light Oil. This of cause means, only 1 pump will ever work here.

- Factorio_FluidSelector_Demo0.png (1.44 MiB) Viewed 504 times
As you can see the Light Oil level has dropped beneath the other fluids. But because it is still higher than the lower treshold (I think I set it to 2.000) it is locking in Light Oil.

- Factorio_FluidSelector_Demo1.png (1.75 MiB) Viewed 504 times
Now Light Oil has fallen below the threshold. And I notice that by circuit delay that threshold is overshot quiet a bit. For my usecase this does not matter much.
As you can see, there is no filter set for the pumps. And there is still Light Oil inside the buffer tank in the middle.

- Factorio_FluidSelector_Demo2.png (1.56 MiB) Viewed 504 times
Now the next highest fluid - Heavy Oil - is selected and the filter is set. And the process repeats.

- Factorio_FluidSelector_Demo3.png (1.54 MiB) Viewed 504 times
Here comes Petroleum ...

- Factorio_FluidSelector_Demo4.png (1.47 MiB) Viewed 504 times
Now let's look at the behaviour in more detail. Let's assume that while Petroleum being pumped to the 4the tank but not beeing used, Light Oil and Heavy Oil have filled to the max. The circuit will still hold Petroleum until it reaches the lower threshold. And that's the point where I realized that it wouldn't be useful for me in the context I was using it for.

- Factorio_FluidSelector_Demo5.png (1.37 MiB) Viewed 504 times
Let's have a look at another state: let's say Petroleum has emptied, but Heavy Oil and Light Oil are low, too. But still over the threshold.
Now the circuit will choose Heavy Oil next, even while it only reaches around 2.7k. And that's the point where it does not work like the classical Schmitt Trigger.
I'm not too happy about this. But as I said - just exchange the selector combinator with a decider with a signal filter for some upper threshold you would like to use.

- Factorio_FluidSelector_Demo6.png (1.38 MiB) Viewed 504 times
If you want to save on two ticks circuit delay you can remove the 2 arithmetic combinators and the end. The red wire will now give you the signal type that is used for filtering the pumps. Here it really does not matter what the value is set to. Btw - this value is the term (upper input limit value - buffer tank value).

- Factorio_FluidSelector_Demo7.png (1.34 MiB) Viewed 504 times
I really hope this showcases what the circuit will and can do. I would use it for fluids only atm.
I guess it's usefulness is limited, especially in vanilla. For Pyanodons it works well, because you have plenty of different fluids and several tank sizes with some of them with up to 8 connections.
You can place it down and circuit size and complexity don't increase with the amount of fluids you want to handle. It doesn't care what kind of fluid you use so there's no need to adjust values/types when placing it down.
This circuit is to be used when you have high buffer size and need/want comparativly less switching. Provided you achieve enough fill rate for you buffers and you can work with emptying out you fluids in a selective but uneven matter.
If you care for even fluid usage you may want to use a clocked setup. This may come with throughput limitations or a switching rate that's not high or low enough.
@Nidan
I have to read (understand) and reply to your message tomorrow. As my brain seems to fried for today
