Page 1 of 1

Remove overflow of provider chest (with Stack Inserters)

Posted: Wed Apr 06, 2022 11:36 am
by togtja
I have a setup where I use a constant combinator to request items to a provider chest.
Due to how logistic robots work, they sometimes overflow the request amount, and I want to remove that overflow.

My original idea, was to use a provider chest, to ask for the items, and transfer those item to another chest, where I read the amount of items that were there, and removed the overflow using some for each math with the constant combinator.
Looking like this:

Where the Request = ConstanCombinator-(ReadFromChest+ReadFromInserter)
And Overflow = -Request

The Overflow gets set as the filter to the Stack FIlter inserter.

Now This design works if I don't use stack inserter (or overwrite the stacksize to 1), but I want it to work with a larger stack size.
Is there any way to make it work with stack inserters (or miniloaders)

The reason is that I want to automate filling a cargo rocket ship from Space Exploration using Constant Combinator, and I want to use the limited cargo space to have perfect stacks, and a quick method to empty the cargo ship, when lowering a value in the constant combinator. Luckily the flaws of the desing was easy to recreate in vanilla factorio.
(The extra decider combinator is just to clear the signal from the content read from the cargo ship, as it has a lot of virtual signals)

Re: Remove overflow of provider chest (with Stack Inserters)

Posted: Wed Apr 06, 2022 4:03 pm
by Tertius
Why getting rid of the overflow, if you can fill in correctly in the first place?

It works like this:
The requester chest requests roughly the required amount of items ("roughly", because of bot carrying capacity and circuit network latency)
The stack filter inserter transfers exactly the required amount of items ("exactly", because it is possible).
Combinator A computes the difference between the required amount of items (from the constant combinator) and the chest+inserter hand contents. It's the current demand. Its output defines what is requested by the requester chest as well as what should be transferred by the inserter.
Combinator S1 picks one of the required items, and combinator S2 extracts the amount of the picked item. The output of S2 defines the stack size (signal S) and the output of S1 defines the filter for the inserter.

This way, the overflow stays in the requester chest. In my example, I set the amounts to 23, 45, 67 to show how any odd amount of items can be moved correctly.
Why this is correct: Combinator A produces the demand with 1 tick latency. Demand changes the moment the inserter picked up items. Since the whole swing takes more than 1 tick, the new demand is correct before the inserter finished its swing and is ready to pick up the next item, so the amount transferred is always correct and never too high.
Unbenannt.png (90.9 KiB) Viewed 397 times

ps. I didn't realize you explicitly want overflow handling, because you want to reduce the amount of items with the constant combinator. In this case, you can add the same circuitry to an additional stack filter inserter to compute filter and stack size for items to move to an overflow chest:
Screenshot 2022-04-06 184119.png
Screenshot 2022-04-06 184119.png (208.13 KiB) Viewed 387 times

Re: Remove overflow of provider chest (with Stack Inserters)

Posted: Sat Apr 09, 2022 5:34 pm
by togtja
Thanks a lot! that did exactly want I wanted! Did not know about that functionality of the "Anything" signal.

I don't know if it is possible to use multiple stack insert for it to go faster?

Re: Remove overflow of provider chest (with Stack Inserters)

Posted: Sat Apr 09, 2022 10:16 pm
by Tertius
I don't see a way to exchange items between the given 2 chests with more than 1 inserter. There is not enough space - only the 4 sides of a chest. You can add more requester chests and regular chests, all with a stack inserter between them, but that probably requires a new circuit setup if they should work together and count items as a whole.