Multiple train on a single stop?

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Ezarkal
Burner Inserter
Burner Inserter
Posts: 14
Joined: Wed Apr 24, 2019 11:55 pm
Contact:

Multiple train on a single stop?

Post by Ezarkal »

Hi!

I'm currently trying to build a train-based megabase with Bob and Angel and I'm, of course, getting to the point where my train stations are ridiculously big and convoluted.

I was wondering if there was a way to unload multiple types of wares at a single train stop with the following requirements:
-The easy one: Different wares would come from different trains.
-The tough cookie: The train stop would only call the trains whose wares it needs. Say I want to unload both coal and iron ore, I don't want one of them to saturate the station while there's a shortage of the other.

Combinator-based solution, railway-based solution or mod-based solution would suit me, so long as I don't have to build yet another station with 14 train different inputs and 8 outputs.
(...Hell, who am I kidding. It's bob and angel. It WILL happen anyway. :D )
mergele
Fast Inserter
Fast Inserter
Posts: 175
Joined: Sat Aug 20, 2016 5:45 am
Contact:

Re: Multiple train on a single stop?

Post by mergele »

You'd need a workaround. Assuming no other mods you'd have combinators to figure out what should be requested and then you lay a wire connection to the exit of where the two trains wait and open the road for them.

You'd probably want a waiting station close to the destination where the trains wait until they get the request instead of blocking the source station (Also saves wire and sanity.)
Pi-C
Smart Inserter
Smart Inserter
Posts: 1726
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Multiple train on a single stop?

Post by Pi-C »

Ezarkal wrote: Sat Jan 18, 2020 3:26 pm I was wondering if there was a way to unload multiple types of wares at a single train stop with the following requirements:
-The easy one: Different wares would come from different trains.
-The tough cookie: The train stop would only call the trains whose wares it needs. Say I want to unload both coal and iron ore, I don't want one of them to saturate the station while there's a shortage of the other.
Here's an example:
multi-unloader-station.png
multi-unloader-station.png (3.08 MiB) Viewed 8329 times
I'm using these mods, among others: Calling trains:
Next to the left warehouse, there's an arithmetic combinator summing up what already is at the station (sign "Have") and a constant combinator containing the negative amount of what must be at the station (sign "Need"). These feed into a decider that outputs everything (input value) as long as there's no train at the station (T=0). The output is fed into another decider (next to sign "Order") that converts any signal with a negative value to 1. Thus, the station will request only items it doesn't have enough of. This combinator has two outputs: the green wire leads down to the entry of the station and serves as a guidance signal to trains (if they carry anything that's needed here, there will be a match and the signal to this station will be opened). The output from the red wire is pulsed to request trains with things needed here.


Controlling inserters:
There's one decider (directly above the locomotive) that isolates the T signal from the train stop. It feeds into another decider that is also connected to the "Need" constant combinator. If T>0 (i.e. if there is a train at the station), the output (all negative values) of the constant combinator is forwarded to another decider that converts all negative values to 1 and is connected to stack filter inserters (if you don't want to use Filter Stack Inserter Plus, you should replace them with normal filter inserters). It sets the filters of the inserters, so if enough of one product has been unloaded, the signal will be removed from the filter.

Reordering:
I have a depot that releases trains whenever a station places an order for something they carry. I'm using mixed cargo trains, so if a train carrying iron and copper ore leaves the depot because iron was required, but is diverted to a station that needs copper, there is a chance the train may unload the copper and drive back to the depot without delivering the iron. Therefore, I want to reorder anything that this train carried but isn't needed at this station. This happens with the combinators below and to the left of the "Reorder" sign.

The decider on the top right gets the same input as the "Order" decider (difference between "needed" and "have"). All negative signals will be converted to 1 and passed on to the arithmetic combinator that will turn these signals to -1. The decider below that arithmetic combinator will read Train ID (T) and train contents from the station and will also get the signals from the "need" combinator. If T>0, all input signals will be converted to 1. Outputs from this decider and the arithmetic combinator are combined in the bottom decider of the left column (cancelling out the signals for everything needed at this station). Everything >0 (Train ID, virtual signals set on the train, and train contents not needed here) will be passed on with the input value. There are three arithmetic combinators above the decider, to cancel out T and the virtual signals (I use TrainsSignalSender to mark all my trains: C for cargo, F for Fluid, A for artillery, and X for express). The result is then pulsed out on the red wire and registers another order.


A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Premu
Fast Inserter
Fast Inserter
Posts: 104
Joined: Wed Nov 13, 2019 4:40 pm
Contact:

Re: Multiple train on a single stop?

Post by Premu »

For using train stations for different kind of wares the simplest way to achieve it I can think of is to use a bot based unloading system. Just load everything into active provider chests, and have active requester chests nearby specifically for the goods you need. The bots can do the sorting for you in a compact setup.

For only ordering stuff you actually need it heavily depends on how your overall railway concept looks like. Do you use trains with only one good, or do they carry different goods? Shall trains deliver their goods to different stations, or do you just have direct deliveries between two stations?

An rather uncomplicated solution can be found for using only trains with one good driving between two specific stations. You need a global data-bus (not to be mixed up with a belt bus ;) ) along your railway lines connecting all your stations. Each train could drive from a loading station to a fixed position in a close-by depot where it can wait. From where it continues to the delivery station. A signal in the depot will be set to red if no active request is needed, blocking the specific train.

Oh - and you will most likely need far more than 36 bus-signals for such a setup, so 0-9 plus A-Z will most likely not be enough to cover all connections. So don't be shy to use signals like 'Fish' or 'Wooden Crates' to request trains. ;)

Note that this solution should work with vanilla alone, so no additional mods are required.
Ezarkal
Burner Inserter
Burner Inserter
Posts: 14
Joined: Wed Apr 24, 2019 11:55 pm
Contact:

Re: Multiple train on a single stop?

Post by Ezarkal »

Thank you for your answers! I think I have enough clues to design something workable now.

So for my current setup:
-My entire train network is linked via a "data bus".
-My train stops are all named according to the ware supply or receive from the train (conveniently named "load" and "drop")
-I'm mostly using the loaders from the "loader redux" mod to unload my train, as it's pretty fast and convenient. So while I can still filter wares, I can not turn them on/off via combinator.
-I did experiment a bit with depot stations, but I was not satisfied with the results so I kind of gave up on that for now. I may come back to it later. If you gents have good setup to suggest, I'm all ears.

So I think I'll try and go with a hybrid of Premu's idea and what I already have. I'm thinking about creating hybrid stations to receive both wares, and link them to the train network so they can send a signal specific to the train they will need. Now at the "load" stations, I'll link the rail signal to the bus so it only let a train pass when there's a request somewhere on the system for that train. I'll combine that with a few combinators that send train backs if they get send by mistake.
While not a perfect solution, it should be workable.

Pi-C, your solution looks great, but I'm still a neophite when it comes to complex combinators setups. I'll give it a hard look and try to wrap my head around it, though. :D
User avatar
Impatient
Filter Inserter
Filter Inserter
Posts: 883
Joined: Sun Mar 20, 2016 2:51 am
Contact:

Re: Multiple train on a single stop?

Post by Impatient »

Oh, that one is easy.

Both for the simple and complex requirements:

Example:
Factory that requires 3 goods A, B and C. A is delivered by a train type wiht only good A in it. For B and C there is a "mixed" train type, that delivers B and C. One unloading station. Stacker on the input side of the station.

Build the stacker so that each type of train has to pass through one single routing station for that train type. In this example that would be one routing station for train type A and another one for train type BC. In the train schedule this station has no conditions and the trains will pass through it without stopping if the tracks are clear. In front of that station is a simple rail signal - the release rail signal - that is connected to the factories buffer or buffers of the goods in that train type. So the release signal for train type A is hooked to the buffer of good A and the release signal for train type BC is hooked to two deciders which are hooked to one of the buffers of goods B and C exclusively. The enabled condition is a simple (good x)<(value). If the buffer runs dry, the signal switches to green and a train with that type of good or types of goods is released into the station (in front of that release rail signal there obviously has to be the normal "stacker to station" rail chain signal, so trains of different types dont crash if both their goods are requested).

For unloading I would use slow filter inserters. Up to 5 filters can be set and I think only the refinery and the reactor have 5 ingredients. But there may be modded items with more of course. With slow filter inserters you can hook them to a decider that is directly hooked to the buffer of the good. Makes one decider per ingredient. By unloading with filter inserters you have the advantege to be able to unload only one good from a mixed train type. Say only good B from a BC train.

The inserters unload onto belts, which are filtered by prio splitters.

All in all for N ingredients and M types of trains you need N x 1 buffer, N x 1 decider, M x 1 routing station, M x 1 cabeling to the release rail signal and a lot of filter inserters and prio splitters.

Thats it. No inter factory cabeling or mods are required.

The same can be done with the output station. Though more complicated. For mixed train types it needs one decider per ingredient more, that makes an AND check if all the items are available in sufficient ammounts in the output buffers. And the very complicated part is that trains have to come in the specific squence the output station released them to do the correct loading. It can not just release every train type for which items are available. But that is beyond the scope of this post.
Ezarkal
Burner Inserter
Burner Inserter
Posts: 14
Joined: Wed Apr 24, 2019 11:55 pm
Contact:

Re: Multiple train on a single stop?

Post by Ezarkal »

Hello again,

I'm back with another question

So my current system is working. As discussed previously, the way I implemented it is to "unlock" the desired supply train at the source station when the ware it carries is needed somewhere. While it's working pretty well, I do have one last logistical deadlock that can happen (and already has while the system was booting). Here's a simplified schematic version of the issue. Behold my paint skills:
logistical deadlock.png
logistical deadlock.png (11.09 KiB) Viewed 8128 times
So in this setup, both "red catalyst" station need iron and copper ore*. A and B is just to differentiate them here in this post. They both have the same name and I'd like to keep it this way, since I have more than just two of these in the game. My iron ore train is also supplying other specific stations with different names.

The issue is factorio's train logic will supply the closest station first if both stations have the same name. So if both stations request both iron and copper at the same time, the iron train will always go to A and the copper train will always go to B. Never the other way around. Overfilling is easily to prevent, but as long as A requests copper at the same time as B request iron, trains will go the wrong way and I'm in a deadlock.

Since both have a low throughput in the mod, it should be a pretty rare scenario, but it's still something I want to address.

My current idea is to either
1- Allow only one "Red Cat" station to be open at the time.
2- Send only one of the two trains at the same time on the network.
These stations need low amounts of both wares so both would be viable solutions at the current scale of my base.
Option 1 looks the best to me for now, but I would still prefer better options, as issues are bound to arise when I scale up.

Any suggestions?


*In this mod, red catalyst is used into many chemical process, such as the synthesis of ammonia for further uses such as fertilizer or rocket fuel synthesis. Now here's a bit of trivia, because I'm a chemist: The iron catalyzed synthesis of ammonia from nitrogen and hydrogen is an actual industrial chemical process called the Haber-Bosch process. It's used in large scale to generate fertilizers on massive scale among other thing. Nowadays, nearly half of the nitrogen atoms in the human body is believed to come from this process, and it's one of the reasons the earth can support nearly 8 billion persons with the current amount of cultivable lands...
And it's in the mod...
I can't stress how cool this is. Hat's off to Arch666Angel to include this.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1726
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Multiple train on a single stop?

Post by Pi-C »

Ezarkal wrote: Sat Feb 15, 2020 1:54 pm So in this setup, both "red catalyst" station need iron and copper ore*. A and B is just to differentiate them here in this post. They both have the same name and I'd like to keep it this way, since I have more than just two of these in the game. My iron ore train is also supplying other specific stations with different names.

The issue is factorio's train logic will supply the closest station first if both stations have the same name. So if both stations request both iron and copper at the same time, the iron train will always go to A and the copper train will always go to B. Never the other way around. Overfilling is easily to prevent, but as long as A requests copper at the same time as B request iron, trains will go the wrong way and I'm in a deadlock.
Not sure if you want this: You could use the circuit network to count the trains that leave the iron/copper stations and send the train to A on odd counts (1, 3, 5, …) and to B on even counts (2, 4, 6, …). With just two different destinations, this could be simplified by setting the counter to 1 if it was 0, and to 0 if it was 1.

Pro: Trains will always go to both A and B, so none of those would starve for input.
Con: Trains will always go to both A and B, even if their cargo isn't requested there at the moment.

This could be made more complex to take into account whether both A and B request something simultaneously (use the counter setting only in this case) or whether just one station needs something (always send trains to that station then). But this could become quite … complex. :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Ezarkal
Burner Inserter
Burner Inserter
Posts: 14
Joined: Wed Apr 24, 2019 11:55 pm
Contact:

Re: Multiple train on a single stop?

Post by Ezarkal »

Thanks for the answer.

It's not a bad idea. The main issue though is if I add more stations. I currently have 4 stations, so I could set them up with the dividers 0, 1, 2, 3. But if I add a 5th one, I'll have to change the combinators setup to include the 5th station and so on. It can be done, but yeah... complex.

A simple solution popped into my mind yesterday.
Load both trains with ½ of each wares, and send them to every stations and just limit what they unload.
I get half the amount per train, but twice the frequency. Throughput should be relatively the same, and I can just add trains as the station gets bigger.

I'll play around with the various ideas, but I think I just found my winner.
To quote GLaDOS, "The best solution to a problem is usually the easiest one."
Greybeard_LXI
Fast Inserter
Fast Inserter
Posts: 123
Joined: Sun Feb 26, 2017 10:48 pm
Contact:

Re: Multiple train on a single stop?

Post by Greybeard_LXI »

You could also increase the "send more ..." level to account for the possibility that both would be requested at the same time. The earlier request would allow the train going to A to unload iron while the train going to B unloads the copper and leave enough time for the Iron train to get to B before running out.

Sounds simple when talking about just two trains and destinations, but probably a lot more complex when there are a bunch of destinations.
SLB
Inserter
Inserter
Posts: 36
Joined: Mon Sep 25, 2017 10:47 am
Contact:

Re: Multiple train on a single stop?

Post by SLB »

Here is a hybrid unloading design
https://drive.google.com/file/d/1uP7QCf ... sp=sharing

Although there is a small problem, look specifically here
viewtopic.php?f=18&t=80911
However, if you do not pursue the use of no belt at all, this problem can be easily solved.

Sorry because I do n’t speak English well, so I ca n’t explain this design clearly here
Post Reply

Return to “Gameplay Help”