How to make each train go to a different (same name)station?

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
mrvn
Smart Inserter
Smart Inserter
Posts: 5710
Joined: Mon Sep 05, 2016 9:10 am
Contact:

How to make each train go to a different (same name)station?

Post by mrvn »

For example: I have 5 coal mines and 3 trains to transport coal. Each mine has a station called "Coal" without waiting bay.

Now I fear that 2 trains might decide to go to the same station. The first will enter the station and the second will block the main track.

How do I make each train pick a different station? Or at least, when reaching a station that is busy, to pick again and keep on driving?

Can I disable a station when a train has arrived to make other trains choose a different station even before getting stuck? (Yes, I know I can disable the station, but does that have the desired result?)

Aeternus
Filter Inserter
Filter Inserter
Posts: 835
Joined: Wed Mar 29, 2017 2:10 am
Contact:

Re: How to make each train go to a different (same name)station?

Post by Aeternus »

You'll need to make a bypass for the station and block the entry to the station by a circuit controlled signal (and the signal prior to that, with the station entrance and bypass on it, needs a chain signal). Flicking the signal to red by circuit should cause the second train to repath, head over the bypass and go to the other station. Bit of a kludge, but it works.

mrvn
Smart Inserter
Smart Inserter
Posts: 5710
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: How to make each train go to a different (same name)station?

Post by mrvn »

My station looks like this:

Code: Select all

        _B____Coal____D_
 ____A_/_C____________E_\_F____
A-F are possible signal places. Currently I have A as chain signal and B, D, F as normal signal.

Is that what you mean? In this setup B automatically turns red and A blue when a train enters. No circuits required.

mophydeen
Filter Inserter
Filter Inserter
Posts: 529
Joined: Sun Nov 22, 2015 5:02 pm
Contact:

Re: How to make each train go to a different (same name)station?

Post by mophydeen »

For unload stations which are next to each other this is easy. If you want to load trains at miners on opposite sides of the map it's gone be hard.

myway:
- use different names for loading at mines: Iron 01, Coal 05, Copper 06, Uranium 05, Oil 01,...
- storage/distribution station: miningtrains offload at storage, basetrains load at storage.

IF you make storage station robopowered. You make a few 'Storage Unload' stations with proper lighting. And 1 for each resource.

Check my book if you want blueprints for trains (LLCCCC)

SpeedDaemon
Fast Inserter
Fast Inserter
Posts: 124
Joined: Fri May 22, 2015 3:31 pm
Contact:

Re: How to make each train go to a different (same name)station?

Post by SpeedDaemon »

With stack inserters, you can load a train in about 5 seconds - far faster than the number of miners on a typical ore patch can supply. I find I need to uniquely name each of my mine stations to tune the number of trains coming in to the amount of ore available. I don't want a train sitting at a mine waiting to fill when it could be at another one and full in seconds.

I wish I could find a more elegant way of doing this, but haven't yet (I'm playing with expensive recipes right now, and my current iron/gear area has 16 unloading stations that need to keep 64 blue belts filled with ore, so that's a LOT of mines :P )

Aeternus
Filter Inserter
Filter Inserter
Posts: 835
Joined: Wed Mar 29, 2017 2:10 am
Contact:

Re: How to make each train go to a different (same name)station?

Post by Aeternus »

SpeedDaemon wrote:With stack inserters, you can load a train in about 5 seconds - far faster than the number of miners on a typical ore patch can supply. I find I need to uniquely name each of my mine stations to tune the number of trains coming in to the amount of ore available. I don't want a train sitting at a mine waiting to fill when it could be at another one and full in seconds.

I wish I could find a more elegant way of doing this, but haven't yet (I'm playing with expensive recipes right now, and my current iron/gear area has 16 unloading stations that need to keep 64 blue belts filled with ore, so that's a LOT of mines :P )
Put electric smelters (with efficiency modules) at the mines. Smelted iron/copper compresses into stacks of 100 instead of 50 for ore, so you've got double the resources per train. Then disable the station if the ore in the buffers for the train isn't a full cargo. Station will activate once it has a cargo ready, which calls a train to it. You need very few trains to haul the smelted ore back to base, depending on how big a mine you make you can use one or two trains per resource type for every 5 or so mines.

aaargha
Filter Inserter
Filter Inserter
Posts: 330
Joined: Wed Dec 07, 2016 8:35 am
Contact:

Re: How to make each train go to a different (same name)station?

Post by aaargha »

It should be simple with disabling stops. Your load station signalling seems fine so you just need to wire the train stop to a nearby power pole and then set it to read train contents, and enable/disable with enabled condition "everything = 0". By doing that the station disables itself as soon as any item has been loaded into the train and enables itself once the train leaves. You could use a combinator to read the levels of the buffer to ensure that the station only enables itself once there is a full train load ready.

The important thing to make sure is that there is always a path for the train to take, either to another load station or back to the unload/waiting yard, else it may just stop where it is.

SpeedDaemon
Fast Inserter
Fast Inserter
Posts: 124
Joined: Fri May 22, 2015 3:31 pm
Contact:

Re: How to make each train go to a different (same name)station?

Post by SpeedDaemon »

aaargha wrote:It should be simple with disabling stops. Your load station signalling seems fine so you just need to wire the train stop to a nearby power pole and then set it to read train contents, and enable/disable with enabled condition "everything = 0". By doing that the station disables itself as soon as any item has been loaded into the train and enables itself once the train leaves. You could use a combinator to read the levels of the buffer to ensure that the station only enables itself once there is a full train load ready.

The important thing to make sure is that there is always a path for the train to take, either to another load station or back to the unload/waiting yard, else it may just stop where it is.
The problem with this approach (and most of them that I've come up with) is the delay between when a station is enabled, and the first train gets there. During that time, every other train from a waiting area will start towards that same station. That's fine (well, not "fine," but at least not too bad) if things are clustered together, but not if there are mines thousands of tiles apart all over.

What does a train do if the station it's currently heading for is disabled? If it still goes there and waits for its normal conditions, you could put a pulse generator on the exit of the waiting area with a latch at the mine to disable the station once a train leaves, but that only works for one mine, since you have no way of knowing which mine a departing train is heading for.

Currently, my design has 16 stops, each with the unloading stop and a dedicated waiting area for two additional trains. Each stop has three trains assigned that will empty, then go to their assigned mine and wait till full. The trains are only traveling when they need to be, and aren't in the way when stopped, so it works fairly well. The problem is that the further out the mines get, the more trains per unloading stop I need, and I can't have more trains than I have waiting areas at each stop (unless I do some serious long-distance wiring to have the extras wait at the mines).

aaargha
Filter Inserter
Filter Inserter
Posts: 330
Joined: Wed Dec 07, 2016 8:35 am
Contact:

Re: How to make each train go to a different (same name)station?

Post by aaargha »

If the stop a train is heading toward is disabled it immediately changes path to another stop with the same name. If no such stop is available it continues to the next one in the schedule. If there is no path to the stop it's trying to reach it'll just stop.

If you want to limit how many trains you send out you'll need some circuitry for that. As far as I know there is no way to ensure that they go to different stop at the start though, unless you give them unique names.

SpeedDaemon
Fast Inserter
Fast Inserter
Posts: 124
Joined: Fri May 22, 2015 3:31 pm
Contact:

Re: How to make each train go to a different (same name)station?

Post by SpeedDaemon »

aaargha wrote:If the stop a train is heading toward is disabled it immediately changes path to another stop with the same name. If no such stop is available it continues to the next one in the schedule. If there is no path to the stop it's trying to reach it'll just stop.

If you want to limit how many trains you send out you'll need some circuitry for that. As far as I know there is no way to ensure that they go to different stop at the start though, unless you give them unique names.
...which kind of takes us right back to having dedicated trains for certain mines... :D

I suppose if the base is big enough, you could divide it into zones, and give each mine in the general area the same name, so that trains could distribute themselves on the long drive out there. Of course, then you run into the problem of having more trains "in flight" than you have mines, at which point, some will turn around empty and go back to the unloading area to glom that up.

What about this, though: Divide things up into zones as above, but provide stackers at each mine. Hook up the buffer to the circuit network, as well as the belts feeding it to measure throughput. Use the incoming ore rate to weight the inventory in the buffer, and use the result to enable exactly one stop in that group all the time. Provide a turn-out in the middle of the stackers somewhere, so that trains further back the stack can leave if more than 3 or so turn up and another station enables. There would also have to be some mechanism to temporarily enable a stop when a train leaves if there is a train waiting behind it for that station. Disadvantage would be unnecessary back-and forth traffic between mines, but it should be way the heck out in the boondocks by the time you get to this point, and unlikely to bother anything.

Aeternus
Filter Inserter
Filter Inserter
Posts: 835
Joined: Wed Mar 29, 2017 2:10 am
Contact:

Re: How to make each train go to a different (same name)station?

Post by Aeternus »

Either that or ensure that only one train is heading for a station of a particular name at any given point. A token ring kind of routing, can be done with circuit signals and deactivating stations on train arrival. Only the train with the "movement" token is finding a station. Limits throughput however, if you do this, you have to make sure the cargo's being picked up are large so that the trains are infrequent. Sequence of events would be:
* Circuit network signaling: One or more stations have cargo ready. Signalled by the station not being disabled.
* Train leaves the transfer area. Movement token is set. Circuit holds other trains while the movement token is active.
* Train finds a station. Station deactivates once the train starts loading and signals the circuit of the trains arrival. Movement token is cleared.
* The next train is allowed on the grid. It leaves once any station activates - has a cargo ready.

Only one -empty- train will ever be on the grid this way, but multiple full trains can freely leave the grid. Added advantage: Significant traffic reduction on the rail grid. Disadvantage: Requires a very wide area circuit network... and those are sensitive to biter interference.

mrvn
Smart Inserter
Smart Inserter
Posts: 5710
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: How to make each train go to a different (same name)station?

Post by mrvn »

You are all missing the initial question.

I already have the mines and the stations and the trains. The trains are waiting in a large train yard. When a mine has enough coal to fill a train and sends a signal. Suddenly all trains leave the yard and race to the mine. Now here comes the problem: The first train to arrive takes the station, the second train then has to be forced to go somewhere else before it takes the turn into the station and gets stuck.

The question is how to prevent trains from getting stuck?

Here is what I have figured out for a simple station:
At the station read the train contents and enable the station if "Anything = 0" and set the signals like this:

Code: Select all

        _C____Coal____S_
 ____C_/_C______________\_S____

S - Signal
C - Chain Signal
Here is how it works:
The first train enters the station blocking the chain signals. The second train as to stop at the first chain signal, still on the main track, waiting for the first train to leave the station. Meanwhile the first train start loading and that disables the station. The second train then picks a new station. Since it is still on the main track it can bypass the bocked station and drive on.

This works fine when you don't mind waiting between trains. It always takes a while for a new train to arrive because there is no waiting bay. I'm still playing around with that.

mophydeen
Filter Inserter
Filter Inserter
Posts: 529
Joined: Sun Nov 22, 2015 5:02 pm
Contact:

Re: How to make each train go to a different (same name)station?

Post by mophydeen »

mrvn wrote:You are all missing the initial question.

I already have the mines and the stations and the trains. The trains are waiting in a large train yard. When a mine has enough coal to fill a train and sends a signal. Suddenly all trains leave the yard and race to the mine. Now here comes the problem: The first train to arrive takes the station, the second train then has to be forced to go somewhere else before it takes the turn into the station and gets stuck.

The question is how to prevent trains from getting stuck?

Here is what I have figured out for a simple station:
At the station read the train contents and enable the station if "Anything = 0" and set the signals like this:

Code: Select all

        _C____Coal____S_
 ____C_/_C______________\_S____

S - Signal
C - Chain Signal
Here is how it works:
The first train enters the station blocking the chain signals. The second train as to stop at the first chain signal, still on the main track, waiting for the first train to leave the station. Meanwhile the first train start loading and that disables the station. The second train then picks a new station. Since it is still on the main track it can bypass the bocked station and drive on.

This works fine when you don't mind waiting between trains. It always takes a while for a new train to arrive because there is no waiting bay. I'm still playing around with that.

don't let all your train go to that station ...

mrvn
Smart Inserter
Smart Inserter
Posts: 5710
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: How to make each train go to a different (same name)station?

Post by mrvn »

mophydeen wrote:don't let all your train go to that station ...
That is not under my control. The path finding can't be driven by circuits.

mophydeen
Filter Inserter
Filter Inserter
Posts: 529
Joined: Sun Nov 22, 2015 5:02 pm
Contact:

Re: How to make each train go to a different (same name)station?

Post by mophydeen »

mrvn wrote:
mophydeen wrote:don't let all your train go to that station ...
That is not under my control. The path finding can't be driven by circuits.
It is under your control. You are the one naming all the stations the same ...

User avatar
AileTheAlien
Fast Inserter
Fast Inserter
Posts: 222
Joined: Sat Mar 11, 2017 4:30 pm
Contact:

Re: How to make each train go to a different (same name)station?

Post by AileTheAlien »

mrvn wrote:For example: I have 5 coal mines and 3 trains to transport coal. Each mine has a station called "Coal" without waiting bay.

Now I fear that 2 trains might decide to go to the same station. The first will enter the station and the second will block the main track.

How do I make each train pick a different station? Or at least, when reaching a station that is busy, to pick again and keep on driving?
Just have a single train for each of the coal mines. Then if you've got waiting bays to unload the coal at your central depot, those trains don't need anything complicated. Just signals at the mines telling the trains to wait until full(-ish) before heading to dump the coal. That will use more trains than a well-balanced, complexly-signalled set of trains, but it's very simple. Even in your example, you've got five mines and three trains. Is saving two trains worth of resources worth the extra hassle? Keep in mind, that if these trains are sitting at the coal mines waiting to be filled, they're not burning fuel - the fuel cost scales with the number of trains in transit, not the total number of trains.

Aeternus
Filter Inserter
Filter Inserter
Posts: 835
Joined: Wed Mar 29, 2017 2:10 am
Contact:

Re: How to make each train go to a different (same name)station?

Post by Aeternus »

mrvn wrote:
mophydeen wrote:don't let all your train go to that station ...
That is not under my control. The path finding can't be driven by circuits.
Partially correct. Pathfinding can be -reset- by circuits. Simplest fix would be to use circuit networking to let only one train leave the yard, and hold other trains. Then clear the "resourcex train is on the network" signal once the train arrives at the station, and deactivate the station. If there's still stations with cargo, send out the next train. This however only works for low volume traffic - long trains to mines.
A kludgefix would be to have a track parallel to the station that bypasses it. Use circuit signals to, once a train passes it set a signal -before- the bypass track switch red, and once the train actually stops at the station, deactivat ehte station and use circuit signals to set the signal leading to the station red, then clear the signal leading to both the station and bypass. The circuit based switching forces the extra train to recalculate it's destination, and since the station in use is now disabled, it'll try to find another destination.

mrvn
Smart Inserter
Smart Inserter
Posts: 5710
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: How to make each train go to a different (same name)station?

Post by mrvn »

Aeternus wrote:
mrvn wrote:
mophydeen wrote:don't let all your train go to that station ...
That is not under my control. The path finding can't be driven by circuits.
Partially correct. Pathfinding can be -reset- by circuits. Simplest fix would be to use circuit networking to let only one train leave the yard, and hold other trains. Then clear the "resourcex train is on the network" signal once the train arrives at the station, and deactivate the station. If there's still stations with cargo, send out the next train. This however only works for low volume traffic - long trains to mines.
A kludgefix would be to have a track parallel to the station that bypasses it. Use circuit signals to, once a train passes it set a signal -before- the bypass track switch red, and once the train actually stops at the station, deactivat ehte station and use circuit signals to set the signal leading to the station red, then clear the signal leading to both the station and bypass. The circuit based switching forces the extra train to recalculate it's destination, and since the station in use is now disabled, it'll try to find another destination.
Having only one train driving at a time, even if it is per item type, is a no go. The question wasn't about how to make each train pick a different station at the start but how to make them keep trying till they get it right. And for that:

No need to switch signals. A chain signal does this naturally. The important part is to have a chain signal before the branch to the station to make other trains stop where they can still go past the station. And a chain signal after the branch so other trains can actually pass while a train is at the station. No real signal on the branch before the station or a second train can enter the branch.

Aeternus
Filter Inserter
Filter Inserter
Posts: 835
Joined: Wed Mar 29, 2017 2:10 am
Contact:

Re: How to make each train go to a different (same name)station?

Post by Aeternus »

A chain signal going red by a train blocking the adjacent block will not cause a train to repath. A circuit switched signal, even if it's a loop back "read signal, set read signal" will do that.
See viewtopic.php?f=49&t=46623 for similar issues.

nuhll
Filter Inserter
Filter Inserter
Posts: 923
Joined: Mon Apr 04, 2016 9:48 pm
Contact:

Re: How to make each train go to a different (same name)station?

Post by nuhll »

Just use logistic train network, and you dont even need multiple stations (but you can do it)

Post Reply

Return to “Gameplay Help”