Stations & other LTN based designs

Adds new train stops forming a highly configurable logistic network.

Moderator: Optera

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Stations & other LTN based designs

Post by Optera »

slippycheeze wrote: Wed Aug 14, 2019 8:51 pm Heh. The previous signals still remain, though, so it hasn't actually broken anything past.
While adding the any vehicle type signals the naming schema for the auto generated position signals annoyed me, it used to be "LTN-<vehicle_name>" while all other signals are "ltn-<descriptive_name>".
So with 1.10.13 that naming schema was changed to "ltn-position-<vehicle_name>".

Sadly migration scripts don't support regex for migrating auto generated signals.
The only signals still working after upgrading to 1.10.13 are for base vehicles where I knew the exact names and could write a migration script.
All position signals for modded rolling stock vanish and have to be set again, including in blueprints.
slippycheeze
Filter Inserter
Filter Inserter
Posts: 587
Joined: Sun Jun 09, 2019 10:40 pm
Contact:

Re: Stations & other LTN based designs

Post by slippycheeze »

Optera wrote: Thu Aug 15, 2019 5:07 am
slippycheeze wrote: Wed Aug 14, 2019 8:51 pm Heh. The previous signals still remain, though, so it hasn't actually broken anything past.
While adding the any vehicle type signals the naming schema for the auto generated position signals annoyed me, it used to be "LTN-<vehicle_name>" while all other signals are "ltn-<descriptive_name>".
So with 1.10.13 that naming schema was changed to "ltn-position-<vehicle_name>".

Sadly migration scripts don't support regex for migrating auto generated signals.
The only signals still working after upgrading to 1.10.13 are for base vehicles where I knew the exact names and could write a migration script.
All position signals for modded rolling stock vanish and have to be set again, including in blueprints.
Ah! Thank you, and I'm sorry if I missed that in the changelog et al. I'll file that away in my mental map of answers to deploy on discord, when people ask the same question.

Also, since this'll notify you, thank you again for LTN, and the rest of your mods. I very much appreciate what they bring to the game, for me.
csduff
Fast Inserter
Fast Inserter
Posts: 110
Joined: Thu Nov 22, 2018 3:42 pm
Contact:

Re: Stations & other LTN based designs

Post by csduff »

slippycheeze wrote: Wed Aug 14, 2019 8:51 pm Heh. The previous signals still remain, though, so it hasn't actually broken anything past.
Didn't break anything. Just been using LTN for months now, and when I finally got off my lazy ass around to making a refueling system using a dozen combinators, it's all just simplified.

Don't get me wrong, I love the mod and love the progress.
NiteAngyl
Manual Inserter
Manual Inserter
Posts: 1
Joined: Mon Aug 19, 2019 6:20 pm
Contact:

Re: Logistic Bot Provider

Post by NiteAngyl »

phi1010 wrote: Mon Jun 10, 2019 9:18 pm A provider station allowing all items from a logistic network being requested over long distances via LTN.


2019-06-10 22_44_44-Clipboard.png

Why so complicated?
* Requester chests need to be cleaned out to avoid residual items clogging the station.
* While still cleaning residuals, they must not be loaded into an arriving train.
* Disabling the station (e.g. via red signal) while cleaning residuals would reduce efficiency.
* Stack Inserters only allow one type of item as a filter, this should always be an item that is still missing in the train, and already present at the station.
* Requester chests do not allow to read their contents when setting the filter.

Mechanisms:
* 4 Active Provider Chests: Removes everything that has been requested too much or cannot be loaded efficiently at the moment.
* 12 Active Provider Chests: Removes everything that has been requested too much.
* 12 Filter Stack Inserters: Clean out everything that is present and not needed anymore.
* 12 Requester Chests: Request items via bots.
* 12 Stack Inserters: Unpack the requester chests to allow the circuit to see what's currently inside.
* 12 Belts: Return their contents, allows to decide what should be loaded right now.
* 1 Belt in the middle: Allows the belts to empty while the majority of their contents is not to be loaded into the train (residuals or oversupply) -- or when there is no train
* 12 Filter Stack Inserters: Make sure nothing unintended get's into the train.

Combinators:
* 1x (*) at bottom left: Calculates what's missing in the train
* 3x (>=) at bottom right: Decides what to load right now -- it needs to be missing in the train, and it should be one of the items that are present on the belt the most
* 1x (/), 1x (>) at left: Divides the request by the number of chests, but makes sure at least one item per chest instead of none at all are requested, to avoid inability to load small amounts.
* 2x (|), 2x (>), 1x (/), 1x (>=), 1x (*) at left top: Returns only items on the belt whose quantity is above the average quantity per item. OR-Diodes are required for timing.
* 1x (*), 2x (>) at the top: Sets a filter to all items present on the belt, that are not allowed to be loaded, to clean them out of the boxes fast and keep them away from the belt (especially while loading). May do nothing while the majority of the belt is okay, and the bad items are only residuals on the belt -- with a second above average filter we could only improve our guess of the requester chests contents, but it will still be only a guess.
* Roboport: Tells the station which items can be provided. You might want to add a constant combinator and specify a lower request size minimum, if you want to load costly items (e.g. less than a thousand roboports)

EDIT: Blueprint was cropped, should be functional now.

PS:
Video
Hello phi1010,

The blueprint you've created is exactly what I've been looking for: a way to accurately request multiple items from my mall anywhere in my factory. However... it doesn't work for me like in the video you've posted.
I've connected a single constant combinator to the stop with the right configurations. I've placed a couple of passive provider chests with twice the requested amount of items in the logistic perimeter.
I can see on the Roboport that the signal switches on when I place items in the passive provider chest, but when a train arrives to pick up its order this provider station does not load any requested items.

Is there anything I may have overlooked? Thank you in advance.
slippycheeze
Filter Inserter
Filter Inserter
Posts: 587
Joined: Sun Jun 09, 2019 10:40 pm
Contact:

Re: Logistic Bot Provider

Post by slippycheeze »

NiteAngyl wrote: Mon Aug 19, 2019 6:34 pm The blueprint you've created is exactly what I've been looking for: a way to accurately request multiple items from my mall anywhere in my factory. However... it doesn't work for me like in the video you've posted.
I've connected a single constant combinator to the stop with the right configurations. I've placed a couple of passive provider chests with twice the requested amount of items in the logistic perimeter.
I can see on the Roboport that the signal switches on when I place items in the passive provider chest, but when a train arrives to pick up its order this provider station does not load any requested items.

Is there anything I may have overlooked? Thank you in advance.
As Operta noted above, with the introduction of the unified wagon/locomotive presence signals, modded wagon/locomotive signals changed name, and could not be migrated. If the station is dependent on those signals, that might mess things up. I have not inspected it to determine if this is the case.

PS: I solved the residuals / overfetch problem by using an unfiltered inserter from requester chest to active providers, and disabling them via circuit when a train was present at the station. (I asked for the unified signals way back to simplify this, in fact.) Never found a problem with that: nothing got so much overload that I filled all the slots of the chest and blocked myself loading *something* the train wanted into it.

I finally just went with the Logistic Cargo Wagon, though, which uses scripted magic to make the wagon request and provide items like a chest based on the LTN collection / delivery status. Scripted, so not going to be the lowest UPS option, but on the other hand, only does anything during train collection or delivery, and event triggered, so ...
sadris
Inserter
Inserter
Posts: 29
Joined: Thu Oct 02, 2014 5:55 pm
Contact:

Re: Provider/Requester in one stop

Post by sadris »

Optera wrote: Thu Jul 20, 2017 7:03 am
Basic Provider & Requester
This stop can supply/request any number of items.
To prevent timing issues (stop output is some ticks faster than the yellow combinator) it's waiting until train decoding signals are available before sending unloading signals.

2017-05-23-09-44-27-3173806.jpg

Pro:
- very versatile
- fast loading/unloading

Con:
- sorting multiple items from steel chests (I'm using merging chests and loaders)
- inserters will lock up if loading more than 40 items
- requires some tuning between stack size bonus and locked slots/wagon to prevent stuck inserters.
This doesn't seem to work. There isn't any combinator signal to define that the stop is either a provider nor a requester.

What are all those large numbers in the existing combinator for?
slippycheeze
Filter Inserter
Filter Inserter
Posts: 587
Joined: Sun Jun 09, 2019 10:40 pm
Contact:

Re: Provider/Requester in one stop

Post by slippycheeze »

sadris wrote: Fri Aug 23, 2019 10:24 am What are all those large numbers in the existing combinator for?
Don't know, but they are usually either for filtering via integer rollover, or something similar. Unless they define request/provide sizes, in which case they are to make the station "not do that" if it accidentally advertises availability because, eg, transport delays or combinator math or whatever makes a value go negative when it should be positive, or vice-versa. (Also solved by a < or > filter, but *shrug*)
phi1010
Inserter
Inserter
Posts: 46
Joined: Sat Aug 20, 2016 3:31 pm
Contact:

Re: Logistic Bot Provider

Post by phi1010 »

NiteAngyl wrote: Mon Aug 19, 2019 6:34 pm
phi1010 wrote: Mon Jun 10, 2019 9:18 pm A provider station allowing all items from a logistic network being requested over long distances via LTN.
The blueprint you've created is exactly what I've been looking for: a way to accurately request multiple items from my mall anywhere in my factory. However... it doesn't work for me like in the video you've posted.

Sorry, took a while -- apparently one wire from the constant LTN stop combinator to the output of the negating arithmetic combinator right next to it got lost at some point, so it simply does nothing, because it does not notice the request. The train signals are not used at any point, it only relies on the output of actual contents from the stop and requested contents from the combinator.

Patch to apply to existing station (I will update the blueprint later):

Humpfry
Burner Inserter
Burner Inserter
Posts: 12
Joined: Wed Jul 20, 2016 12:34 pm
Contact:

LTN Train Stop combinator not showing requested cargo

Post by Humpfry »

In my playthru the constant combinator on the LTN train stop is not showing the requested item that is supposed to be delivered, leading to unwanted items being unloaded on my train stop. I am running the latest version of LTN 1.11.0 and Factorio version 0.17.69

I checked the demo map and the same situation is happening there too.
Factorio 0.17.69 2019-09-21 3_59_55 PM.png
Factorio 0.17.69 2019-09-21 3_59_55 PM.png (3.62 MiB) Viewed 11704 times
The arithmetic combinator only shows the train car setup for the input and missing the requested cargo information (the output of the LTN train stop combinator). As you can see I have not changed the arithmetic combinator, the input is the train stop combinator and the train stop itself is connected to the output of the arithmetic combinator then to the filter inserters. The end result is the output of the train contents to the filter inserters and unloading all the train contents, the requested items AND unwanted items (if there is residue from a previous dispatch) - which is why the arithmetic combinator is SUPPOSE to stop the residue being dropped off.

You might as well not use the arithmetic combinator and connect the read train stop cargo directly to the filter inserters to unload. It is useless in helping stop unwanted items being dropped off. Obviously you can stop the train at the depot (by turning off the depot signal when there is left over cargo on the train).
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: LTN Train Stop combinator not showing requested cargo

Post by Optera »

Humpfry wrote: Sat Sep 21, 2019 10:14 pm You might as well not use the arithmetic combinator and connect the read train stop cargo directly to the filter inserters to unload. It is useless in helping stop unwanted items being dropped off. Obviously you can stop the train at the depot (by turning off the depot signal when there is left over cargo on the train).
Have you even tried it before writing this?
On a requester the stop combinator outputs items that should NOT be unloaded. Together with the arithmetic combinator it will prevent filter inserters from unloading those.

[Optera] Merged into design thread
ztn
Burner Inserter
Burner Inserter
Posts: 13
Joined: Wed Aug 07, 2019 8:00 pm
Contact:

how to check why train come to station?

Post by ztn »

i want to use same stations for receive and send items - so i want to check why this train come to station. what is the easy way to do it? the only difference is Logistic Train Stop Output have additional signals if train come to take goods. but it's hard for me to filter out these signals from alongside signals about train configuration. may be i miss something and there is another easy way to understand that i need load or unload train?
xfir01
Long Handed Inserter
Long Handed Inserter
Posts: 93
Joined: Fri Feb 10, 2017 5:08 pm
Contact:

Re: how to check why train come to station?

Post by xfir01 »

Have you seen the Provider & Requester in the sample station thread?

viewtopic.php?f=214&t=51073#p297648
ztn
Burner Inserter
Burner Inserter
Posts: 13
Joined: Wed Aug 07, 2019 8:00 pm
Contact:

Re: how to check why train come to station?

Post by ztn »

yes i see it. 2nd post connected with my question but author give exactly 0 explanation of these set of combinators Image half of that combitanors use overflow shenanigans that impossible to understand if you don't know exactly why you do this and how it works. i want simple answer for my simple question - i don't need solutions how to make "provider+requester" station in "right" way.
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: how to check why train come to station?

Post by Optera »

The simple answer: Learn how provider, requester and 1 combinator binary decoder work.
This is nothing more than all of those merged together.

merged into design thread
torne
Filter Inserter
Filter Inserter
Posts: 342
Joined: Sun Jan 01, 2017 11:54 am
Contact:

Re: how to check why train come to station?

Post by torne »

ztn wrote: Tue Sep 24, 2019 5:47 pm i want to use same stations for receive and send items - so i want to check why this train come to station. what is the easy way to do it? the only difference is Logistic Train Stop Output have additional signals if train come to take goods. but it's hard for me to filter out these signals from alongside signals about train configuration. may be i miss something and there is another easy way to understand that i need load or unload train?
A couple of things that might help if you want to build your own design instead of using the one mentioned:

1) If your LTN setup makes sure that trains never leave the depot unless they are empty (which is generally a good idea), then any train which has any items on it when it arrives is to be unloaded, and any train that's empty when it arrives is to be loaded. LTN-generated routes are always intended to load an empty train at one station and then fully unload the train at another station; the same train is never used for loading and unloading at once.

2) You don't necessarily need to even decide whether you are loading or unloading the train. The most basic version of this is pretty simple and doesn't require that you actually decide whether to load or unload the train, though it isn't always good:

- The LTN output tells you what items should be on the train, plus some extra signals about the train configuration.
- The train stop itself can tell you what is currently on the train.
- So: multiply the current contents of the train by -1 with an arithmetic combinator, and then connect the LTN output to the output of that combinator to add the signals together.
- This gives you positive numbers for everything that must be loaded onto the train, and negative numbers for everything that must be removed from the train.
- Connect that wire to the filter inserters you use to load the train, then multiply it by -1 again and connect *that* to the filter inserters you use to unload the train. Filter inserters in set filter mode ignore negative amounts, so that's "enough".

The issue with doing it that way is that if the inserters have a stack size greater than one, then they can get into a state where they load slightly too many of an item, then unload too many, then load too many, then unload too many, etc. There's a number of options to prevent this (including, but not limited to, just setting the inserter stack size to 1) with different tradeoffs in combinator complexity, speed, handling multi-item stations vs single-item stations, etc, many of which have been discussed in this subforum.

This basic version just ignores the train configuration signals, which is fine if all the trains that come to any given station are the same configuration. It's generally fine even when they're not - the one exception is when the station is capable of loading something that can be used as locomotive fuel, or unloading something that's left over from burning fuel, as in those cases you have to avoid accidentally interacting with locomotive fuel slots instead of the cargo.
Zorku
Burner Inserter
Burner Inserter
Posts: 7
Joined: Sat Dec 23, 2017 6:39 pm
Contact:

Re: Stations & other LTN based designs

Post by Zorku »

Optera wrote: Sun Sep 22, 2019 6:11 am
Humpfry wrote: Sat Sep 21, 2019 10:14 pm You might as well not use the arithmetic combinator and connect the read train stop cargo directly to the filter inserters to unload. It is useless in helping stop unwanted items being dropped off. Obviously you can stop the train at the depot (by turning off the depot signal when there is left over cargo on the train).
Have you even tried it before writing this?
On a requester the stop combinator outputs items that should NOT be unloaded. Together with the arithmetic combinator it will prevent filter inserters from unloading those.

[Optera] Merged into design thread
I was quite confused about this same issue, and I'm still confused about the part where it seems to be broken on the demo map, unless that's somehow meant to be an example of how to set up a station incorrectly?

Your nasty reaction did give me the insight to try my little bug test efforts in a different way, and I have a little bit better understanding of what conditions actually cause the LTN to change what signals will output at my drop off stations. It seemed difficult to catch the bad deliveries that were gumming up my factory when I was under the assumption that it was the wires that weren't working, rather than when and where I was putting dummy items into the cargo.

With the kind of "idiot that doesn't understand how these signals work" viewpoint that I'm much more familiar with, I'm gonna try and walk through this other post.

ztn wrote: Tue Sep 24, 2019 6:54 pm yes i see it. 2nd post connected with my question but author give exactly 0 explanation of these set of combinators Image half of that combitanors use overflow shenanigans that impossible to understand if you don't know exactly why you do this and how it works. i want simple answer for my simple question - i don't need solutions how to make "provider+requester" station in "right" way.
This is doing a few things that I bet you can follow, but for some reason when I try to paste in the blueprint string it's missing wires and even a few combinators. Dunno why that happens, but I fixed it by referencing the pic of Logistic Provider & Requester for LTN 1.10.13, since it has the same 5 combinators and those draft images are way more crisp than old school screen shops.

So, the first thing that's throwing you for a loop is exactly what you think it is. The 'any length depot' blueprint shows this thing simply enough. You've got a decider combinator that waits until the train is empty and then tells the station it's a depot, and then our two offending combinators are the constant combinator with all our encoding numbers and the arithmetic combinator that multiplies them all by the encoded position of (engines/wagons.) If you want your station to know which segments are engines/wagons then use this. If you only use one size of train then ditch this.

So, on to the blueprint you were actually looking at: The constant combinator on the left side of the power pole and the first arithmetic combinator are "overflow shenanigans" and that all runs through 2 more combinators now. Instead of sending that signal right to the inserters, it goes into a decider that passes each signal along as 1, if it was less that zero. So, negative numbers on those symbol-numbers are all 1s now. Since the output sometimes contains signals like "Load 7000 green circuits into me" it's best if we not multiply those by encoded numbers and then pass them to the inserters. I guess this was the most elegant way to deal with that.

Our 2nd decider combinator checks if anything is more than 0 to pass ALL values through, and accepts those encoded position numbers as well as the contents of the train. Since we already filtered out all of the regular things that come out of LTN output with that less than zero check, this should just trigger off of those overflow values where we've actually got wagons, so I guess this is a safeguard against trains that don't contain cargo wagons.

As far as you're concerned, so far this is a great deal of sound and fury, signifying nothing, but it used to be that if you rolled up in a short train you'd take all the fuel out of some of your engines, and then maybe the train would be stuck...

Now, finally, we're getting to those other two arithmetic combinators. The one closer to the LTN station accepts LTN output and multiplies it by -2. -2!? But everything was -1 so far! Why would it be different now!? Well, this is why I walked through all that encoded position stuff. It passed all the LTN outputs through, so if we added everything*1 to everything*-1 it would all be zero. We just want that -1 value so that we can stop the inserters from moving items they aren't supposed to, and we have to multiply by -2 in order to get it. As the basic blueprint notes, the combinator delays the signal a bit, so inserters don't filter out the crap if you hook them up directly; you need to slow down the train contents signal by also running it through a combinator. Could be anything, but in this case it's a check to make sure there are wagons.

And then the far arithmetic combinator. We dealt with requests, so this is our provider logic. We've got the familiar *-1 behavior here, where the LTN output tells your stop how many items were requested, and our *-1 reduces that signal to 0 when the train actually has that many items on board. Technically you could add another combinator to slow down the LTN output signal, but why would your train arrive with all the cargo it requested on the first tick?

And that's all of the pieces. I'm missing a tiny sliver of why it's done like this, but if you care about the requester and provider behavior then Requester v2 for LTN 1.10.13 and Provider show you what those three combinators do, and the little string of 5 combinators cuts out the redundant check for "is anything a cargo wagon?" because you get the same boolean "yup" when you're doing overflow positions.

And just in case that was hard to follow:
so i want to check why this train come to station. what is the easy way to do it?
The LTN output and the contents of the train are the two pieces of data that you put together to figure out what the train is doing at this station. LTN output always gives those encoded position values, but as for the items, it says what is in the cargo condition for the stop it is at, as well as what was already on the train (other than what was requested.)

If you subtract the LTN output signal from the station signal then unexpected items will be 0, and the requested items will give you a positive number until the train is empty.
If you subtract the station signal from the LTN output signal then items meant for pickup will be positive until the train contains this many items.

So positive or negative numbers tell you if the train arrived for a request or provide order, based on which way you connect the wires to the arithmetic combinator. If your station is configured for both provide and request orders then you could also check based on which arithmetic combinator provides positive values.

Do you need to know why the train is arriving for purposes other than controlling which set of inserters activates?

e: Seems I wasn't even right about some of it. Oh well, the new design is much easier to walk through anyway.
Last edited by Zorku on Wed Sep 25, 2019 1:03 pm, edited 1 time in total.
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Stations & other LTN based designs

Post by Optera »

Updated Basic Provider and Requester blueprint viewtopic.php?f=214&t=51073&p=297648#p297648
Removed unused position decoding and overload trickery required for for logistics version.

Updated Demo Map to use more recent designs.
mrvn
Smart Inserter
Smart Inserter
Posts: 5851
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: how to check why train come to station?

Post by mrvn »

ztn wrote: Tue Sep 24, 2019 5:47 pm i want to use same stations for receive and send items - so i want to check why this train come to station. what is the easy way to do it? the only difference is Logistic Train Stop Output have additional signals if train come to take goods. but it's hard for me to filter out these signals from alongside signals about train configuration. may be i miss something and there is another easy way to understand that i need load or unload train?
The yellow constant combinator shows two things:

1) the train configuration
2) the items that should be on the train

For a provider stations that means items you have to load. For a requester stations that means items not to unload.

So program your inserters to load missing items and unload excess items and make it count perfect or you end up with 6 items loaded over the count and then 12 items added /removed in a ping-pong.
Cadde
Fast Inserter
Fast Inserter
Posts: 149
Joined: Tue Oct 02, 2018 5:44 pm
Contact:

Re: Stations & other LTN based designs

Post by Cadde »

I've been doodling a bit with a "perfect" provider that would NEVER overfill a cargo wagon and thus eliminate the "stuck inserter" issue once and for all.

Before you go "uuhh locked slots per wagon" there's a number of problems with that.

1. I am using bob's inserters and i am "cheating" with them picking up like this:
Image
This means they load wagons really fast.
2. With bobs inserters i can have 24 inserters per cargo wagon. This gives me around 288 items in 12 ticks (and that's 12 ticks because of my synchronizing design) which means 1440 item's per second transferred from chest to wagon.
3. Stack size matters... For the sake of argument, let's say my train wants 1100 items of coal AND 1200 items of stone. There's 40 slots in a wagon, one cycle of the inserters loads 288 items so 4 cycles will load 1152 items of coal... 52 too many.
And then it will load 1440 items of stone, 240 too many! Overall, i would have to have 6 locked slots per wagon which is 15% loss in capacity. I would be better off nerfing my loading routine.

At which point you may go "so don't use so many inserters / set their stack size to 1-2"

4. I am looking for maximum throughput in a single station that is to be served by several trains of different lengths. With different stack sizes of cargo and with mixed cargo possibly being loaded onto the train. In other words, i will NOT nerf anything in any way or even accept "locked slots per wagon".
5. Because it's mixed cargo, most "simple" designs simply doesn't work. That or i simply can't imagine a way to do it simply. Circuit network madness ahoy!

---------------------------------------------------

SO!

Image

Imagine for a moment that the merged chests in the center is the train wagon. This is after all my 4th or 5th attempt at getting this one right. At this point i went "/editor" and checked the circuits in tick step to ensure everything was working as i expected it to. So it's not actually a station yet.
I am merely showing off the crazy stuff one has to go through to meet the above demands.

Along the "dirt" path on the left side at the far bottom is two constants and a medium pole. That is the "LTN train stop", Thus i can change the values in it easier than changing a trains orders.

The combinators that snake about above that is dedicated to ensuring the "wagon" isn't loaded with more items than requested.
One part clock sending a pulse every 12 ticks. One part inversion X * -1 to count down the loaded items from the requested. One part wagon balancing which means if you request 500 items of something using a train that has 2 wagons, each wagon will get 250 items of that request.

NOTE: All of this is of course assuming the inputs (warehouses or logistics requester chests which is what i intend to use either side the loading platform) have enough items, otherwise other platforms will load whatever is missing into whatever wagons they can.

On the right side of the dirt sits another set of combinators which filters signals (removes position of loco/wagons signals etc), counts the number of cargo wagons (for balanced wagon loading) and filters the remaining request signals so only ONE is active at any given time.
The latter part is the part i am not so happy about at the moment. Perhaps i should just refire my old "Signal splitter combinator" mod which would simplify matters something immense.
Either way, it's a bunch of circuit network voodoo that took me quite a lot of thinking to come up with.

The way it works is i multiply each "possible" cargo with a constant value like so...

steel * <0> = <Info>
iron gear * <1> = <Info>
iron pipe * <2> = <Info>
firearms magazine * <3> = <Info>
etc etc

And the signals 0-9A-V are assigned 2^N values such as 1, 2, 4, 8, 16, 32 etc... Thus the <Info> signal is a binary encoded selector value that the next column of arithmetic combinators deals with by doing...

<Info> AND 1 = <Info>
<Info> AND 3 = <Info>
<Info> AND 5 = <Info>
<Info> AND 7 = <Info>
<Info> AND 15 = <Info>
<Info> AND 31 = <Info>
<Info> AND 63 = <Info>
etc etc

So say the train requests steel and magazines. Info would equal 1 + 8 = 9.
The next column of decider combinators then picks a unique cargo by doing...

<Info> == 1 = steel
<Info> == 2 = iron gear
<Info> == 4 = iron pipe
<Info> == 8 = firearms magazine
<Info> == 16 = ...
<Info> == 32 = ...
etc etc

On the output of that column is ONLY ONE of the possible cargoes. And that feeds into the combinators on the left of the track.
The final column of combinators just transform the cargo into an <S> signal which i use to limit stack size on the inserters, which i will explain next.

So, we are requesting 451 units of steel plate. How do we ensure that it loads only that many?
Well... All the inserters are wired up to the circuit network on their own "channels" from the arithmetic combinators on the sides of the platform.
Each and every one of these take...

EACH - <number> = EACH

So the inserters get the cargo (steel) and the virtual signal <S> (as well as some garbage like <C> and <W> because i couldn't be arsed to filter those) which set their filter and stack size respectively.

The numbers i used in the combinators, which i alternated from left to right, are...

0 <left side>
12 <right side>
24 <left side>
36 <right side>
48 ...
60 ...
72
84
etc etc

Obviously i've maxed the inserter capacity research so each inserter can move 12 items tops.
What this means is, if the request is for say 23 items then an inserter on the left side will pick up 12 items and another inserter on the right side will pick 11 items. Request satisfied.
Or if the request is for 1100 items...

1) All 24 inserters will move 12 items each for a total of 288 items... 812 items remain to move.
2) All 24 inserters will move 12 items each for a total of 288 items... 524 items remain to move.
3) All 24 inserters will move 12 items each for a total of 288 items... 236 items remain to move.
4) 19 inserters will move 12 items each. And ONE inserter will move 8 items for a total of 236 items this round.
...
5) PROFIT!


If you wanna fiddle with it yourself then here you go!
Mods: bobinserters_0.17.10, WideChests_2.2.2, LogisticTrainNetwork_1.11.6, OpteraLib_0.1.8


NOTE: I haven't tested the design LIVE yet. I am certain it will work though.
Except for one little thing... Certain requests on 2, 3, 4 or more wagons MIGHT load more than requested still. This because of not being able to divide items evenly and thus inserters that are further up the chain can overload by one or two or three items etc.

Let's put it this way... If you clone the platforms without changing anything, you are guaranteed to have overloaded items and possibly stuck inserters.
Remember the "per inserter" combinators?

0 <left side>
12 <right side>
24 <left side>
36 <right side>
48 ...
60 ...
72
84
etc etc

Well, for each platform you add, you'd do well to change the 0 (zero) to 1, 2, 3, 4 etc so as to not overload the train.
This will mean the wagons further back will have less items than the ones in front (space allowing) but i see no other way of solving this.

BTW, i didn't mention one little combinator. This one:
Image
This ensures the division over several wagons doesn't get the whole platform stuck at 122 out of 123 items requested over two wagons.
123 divided by two is 61 leaving one rest units. This is what that combinator deals with.
So keep that in mind as well if you just clone platforms.

... (dot dot dot)

And yes, i know. If you wanna use this you would have to actually build your own station through it and re-connect wires. I am not here to hold your hands but i might return with a fully live blueprint if requested.
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Stations & other LTN based designs

Post by Optera »

I like it.
That's one hell of an over engineered solution if I ever saw one.

To be fair though having one stop per item and using a dumber loading system might be smaller and easier to troubleshoot. ;)
Post Reply

Return to “Logistic Train Network”