TL;DR
I did a version where I controlled the inserters, not the requester chests as the OP did. The balancing was improved. Support for multi-item added. Blueprint attached at very bottom of the post.
---
Some month ago, I wanted to solve the same problem and was satisfied with my solution of reading each chest's content. Reading of your solution really got me, thanks for that. After reading this threat and testing your setup, I have to agree with the given objections by mrvn and RocketManChronicles.
Assumptions & design concept
1. I too didn't want the requester chests to request that much Items. I would like to design the train loading station in a way that could work with not-separated roboports, even if I would prefer to at least have the option keep it separated.
2.1 It might happen, that a train entering the station to be loaded is already partly loaded.
2.2 The trains will either go to a (de-)centralized unloading station where everything will be unloaded evenly, or directly to i.e. an assembling station where maybe they would
not be unloaded evenly.
2.3 Reading train content and controlling delivering adequate demand only is not included here.
3. A train loading station of that kind would probably be installed near furnaces or mass producing assembling plants. A one-sided 4 wagon loading station with therefore 6 (maxed out) stack inserters can load around 17880 (744.5 x 6 x 4) items per minute, plus the time window for the trains entering and leaving the station. Mining drills at ore patches might not keep up with that speed.
3.1 As for ore patches, imagining that a solution here might be delivering different ores to one train, i.e. in shared ore patches, setting different items -per wagon- for the requester chests might be a choice you want to have. Though there are some other, like setting filters for the cargo wagons' slots - which I don't prefer here, as our intention here is to do a balanced loading.
3.2 Of course, you can sort the items later, but just loading what comes first will probably lead to random chest contents, which we don't want for several reasons.
3.3 Loading different items in the same train requires (here):
a) different combinator logic per item
b) a closer look at the trains leaving setting (i.e. the 2 wagons with iron ore might be full, but the 1 with coal might only be half filled)
c) for reasons of simplicity, every bot/roboport on the loading station is in range of every chest.
4. Thinking this any further, by setting the filter for each requester chest, the basis for multi-item cargo wagons is done, though this might need further train inventory control.
5. Therefore I decided to not combinator-control the requester chests, but the inserters. I chose to set the item requests per wagon manually (or with a constant combinator i.e. per wagon).
6. I ran some test with 6 provider chests (positioned centralized above the station) and 480 bots delivering to a 4 cargo wagon station and found, that for large numbers the balancing of the OP's design was doing good, but looking at small numbers the balancing was somewhat off. In the solution posted in this post, the balancing is too when running multiple items. It works very well in terms of balancing for small numbers too, assuming that there are enough items in stock to be delivered to the requester chests
and only 1 item type is delivered. At least, there is no big variation in the delivered amount per item (every chest containing iron has nearly the same amount, though the chests containing stone have different amount(s)).
---
Setup
- Overview over the station. Logic elements are pulled out a bit to offer a better view.
- overview.jpg (1.18 MiB) Viewed 12556 times
The 4 wagon station loads 4 different items.
1st wagon: 6 chests iron ore
2nd wagon: 4 chests iron ore, 2 chests stone
3rd wagon: 6 chests copper ore
4th wagon: 6 coal
Number-boxes are redwired to the corresponding chest and showing the amount of items inside. Don't get distracted by the redwires between inserter and steel chest.
wiring
- Detailed look at the wiring.
- wiring.jpg (565.72 KiB) Viewed 12556 times
The items (per chest) are set with the top constant combinators. They are only (green-)wired to the corresponding requester chests. As Wagon 1 and 2 share a resource (iron ore), there are 3 greenwire connections between them (1. requester chests, 2. inserters, 3. steel chests). The connection ends before the row with stone. I've chosen an amount of 200. The arithmetic combinator is set to input: [each] / [number of chests], output: Signal A. Its input is wired to the inserters, its output to the steel chests. The inserters are connected via greenwire and set to mode: enable/disable, enable condition: [everything] <= Signal A. Each steel chest is redwired to the corresponding inserter.
Enjoy.