How can I auto-balance two or more chests?
After some experimenting I found a setup which works quite well. It is based on an idea that only those chests will be filled which have below average item count:
- New items enter the transport belt ring from the right.
- The red wires connect each chest to the two inserters which move items into it. The rightmost chest is connected to the leftmost inserter again.
- The green wires connect all chests to the input of the arithmetic combinators and then the outputs of the combinators to all inserters (except the first)
- The first combinator calculates the average fill-level of the chests. It is set to
iron plates / 6 = BLUE
. - The vertical inserters are set to
iron plates < BLUE
(except for the first inserter which isn't connected to any network at all. This is important to avoid a deadlock when all chests are perfectly balanced). This means the inserter will work when the chest they serve has below average iron plates. - The second combinator calculates average minus 1. It is set to
BLUE - 1 = GREEN
. - The horizontal inserters are set to
iron plates < GREEN
. That means they will start taking plates from the right neighbor chest when the chest they serve is more than 1 below average. The purpose of the -1 difference is to make sure that chests prefer to take items from the ring than from the neighbor. Without that there will be an infinite loop because the last chest will feed an item back into the ring the moment the first chest picks one up.
The result is that all metal plates which enter the system will be evenly distributed along the chests. When plates are manually removed from one of the chests, the inserters will rebalance by moving items from right to left to refill that chest. The last will move plates back into the ring which will then be picked up by the first chest. After a while the chests will be balanced again.
Also, the upper part of it is free (the electric poles and combinators could easily be placed further south) so a trainstop could be placed there to fill and empty the system. A method to empty the system without blocking train access would be an additional inserter right of the rightmost chest.
The only flaw in the design is that the first chest will always have slightly above average number of items. But considering that I built the design to handle large quantities of items I consider that acceptable.