Train yard management - circuit conditions advice needed

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
User avatar
Trblz
Long Handed Inserter
Long Handed Inserter
Posts: 63
Joined: Thu Sep 21, 2017 1:23 am
Contact:

Train yard management - circuit conditions advice needed

Post by Trblz »

I need some advice on how to setup circuit conditions to manage a train yard.

My situation is as followed:

I have a train staging (parking) area well outside my main base. On it are 5 iron ore trains waiting.
In my main base, my iron ore unloading station has inventory level detection: set "I"=1 when iron ore = 0

My iron ore trains have a circuit condition at the yard location to wait until "I"=1

How can i prevent all iron trains to leave the train yard when they are triggered?
My Mod list: Necormant co-author

leitk
Fast Inserter
Fast Inserter
Posts: 115
Joined: Wed Jun 21, 2017 7:20 pm
Contact:

Re: Train yard management - circuit conditions advice needed

Post by leitk »

How about just a waiting bay:
Waiting Bay.PNG
Waiting Bay.PNG (205.68 KiB) Viewed 8442 times
The chain signals only allow one train through, and you could replace the regular signal with another chain or just remove it if you want it to have a big gap between the waiting area and the station.

However, I recommend using that space for on-deck trains.

DScoffers
Inserter
Inserter
Posts: 33
Joined: Fri Sep 23, 2016 1:24 pm
Contact:

Re: Train yard management - circuit conditions advice needed

Post by DScoffers »

I also use leitk’s design without the rail signal.
It works well if you have only a couple of different unloading station types. If it’s a long distance or a main line then it probably isn’t suitable.
Using this method you don’t need to use a circuit condition to tell trains to go to the unloading station as only one can enter that section at a time.

Also, using leitk’s method, if I want to keep trains in the waiting bays I set a circuit condition on the rail signal at the start of the unloading station so that I don’t have to wire all the way to the waiting bays. IF iron ore > x, then close signal.

User avatar
Trblz
Long Handed Inserter
Long Handed Inserter
Posts: 63
Joined: Thu Sep 21, 2017 1:23 am
Contact:

Re: Train yard management - circuit conditions advice needed

Post by Trblz »

Thanks Leitk/DScoffers,

That design works if the parking is next to the train station. So the output of the parking is directly linked to the multiple train stations.

The challenge in my base is that the train stations are in the center without any room for a nearby parking.

I am checking if i can use some of this logic: https://www.reddit.com/r/factorio/comme ... automated/
The last comment might work with SR latch:
loading station empty > SET (I=1)
Train dispatches from yard > RESET (I=0)

Tough i wonder if it needs to be this complicated :?:
My Mod list: Necormant co-author

User avatar
Lav
Filter Inserter
Filter Inserter
Posts: 384
Joined: Mon Mar 27, 2017 10:12 am
Contact:

Re: Train yard management - circuit conditions advice needed

Post by Lav »

If your trains at the trainyard can receive the I=1 signal, then there's a wire connection.

If there's a wire connection, then you can wire one of the train signals at the exit of the trainyard and send a message in reverse direction, telling your base that a train has been dispatched. Then you can set I to 0 again, and wait for the train to arrive and unload before checking for inventory again.

Personally I would set up a state storage in this situation, which would take the values of: "inventory full", "need cargo", "need cargo, train dispatched" and "train unloading", with separate circuits to manage the switch between conditions. That would use more combinators, but would be easier to debug and expand.

Bauer
Filter Inserter
Filter Inserter
Posts: 346
Joined: Fri May 05, 2017 12:48 pm
Contact:

Re: Train yard management - circuit conditions advice needed

Post by Bauer »

You need 2 combinators at the train yard per line/station.

There has to be a signal (pulse) "C=1" to call 1 train.
1st combinator: Input train station (T), if T>0 then T1.
2nd combinator: Input the call signal and the output of the first combinator. Output (C) = C-T.

Connect the call signal also to the station (leave condiction C>0) and pass the output of the 2nd combinator to the next station in the yard as new call signal.

If you are not sure that there always is a train somewhere in the yard, you can connect the output of the last 2nd combinator to the input of the first station. Then a "C=1" goes round until a train (T>0) arrives and is dispatched.
The problem is that you cannot predict how long it will take for a train to travel from the trainyard to the unloading station. Hence, you do not know when to call for the next train. There is also no way to identify if the stuff arriving at the unloading station is from a specific train that you called. Such a system will never be robust enough with just a few combinators.

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

Re: Train yard management - circuit conditions advice needed

Post by mrvn »

Personally I would try to find some space to fit at least one extra train at your unloading station, maybe have 2 unloading stations side by side if you can't fit a waiting bay before it. And then use just 2 trains. Name all the ore mines the same and disable the mine when it doesn't have enough ore buffered for a train. Make the loading / unloading as fast as possible, load / unload from both sides with 12 stack inserters (24 express stack inserters if you are using Bobs mod).

If you can't keep your ore processing busy with that then it would be better to build a new one where you have more space and then ship in plates. If you remove the smelters you should have enough space for multiple train stops so you can unload plates better.

Alternatively try the LTN (logistics train network) mod. Doing this manually with combinators is complex and error prone.

DScoffers
Inserter
Inserter
Posts: 33
Joined: Fri Sep 23, 2016 1:24 pm
Contact:

Re: Train yard management - circuit conditions advice needed

Post by DScoffers »

I’m not on Factorio to test this, but I think it would work.
Using your example, the signal I=1 would be sent when iron ore = 0.
This signal would have a timer that stops I=1 being sent after around 2-3 seconds, this would allow only 1 train to exit the waiting bays.
A second timer allows the I=1 to only be sent again starting 60 seconds later (if it applies of course).
The 60 seconds timer should be long enough for the train to get to the unloading station and start unloading.
This will depend on the distance between the waiting bays and unloading station.

Problems could arise if the mainline backs up.

User avatar
Trblz
Long Handed Inserter
Long Handed Inserter
Posts: 63
Joined: Thu Sep 21, 2017 1:23 am
Contact:

Re: Train yard management - circuit conditions advice needed

Post by Trblz »

I've tried to design a test setup with three trains in a loop setup.

clock pulses every 600 ticks, pulse triggers green signal
unloading gives green signal when empty
train released when 2 green signals received at parking.

intended behavior: train dispatched from parking when inventory is empty AND pulse received every 10 seconds

however the trains are still leaving too early.

mod used:creative mode
Attachments
A train yard test.zip
(4.17 MiB) Downloaded 120 times
My Mod list: Necormant co-author

DScoffers
Inserter
Inserter
Posts: 33
Joined: Fri Sep 23, 2016 1:24 pm
Contact:

Re: Train yard management - circuit conditions advice needed

Post by DScoffers »

The logic sounds like it should work, but it depends on your setup.
So 2 greens circuit signal are being sent too early.
Run it for a while and report back why.

User avatar
Trblz
Long Handed Inserter
Long Handed Inserter
Posts: 63
Joined: Thu Sep 21, 2017 1:23 am
Contact:

Re: Train yard management - circuit conditions advice needed

Post by Trblz »

I think i have it - see my save file

The setup is now:

The demand indicator for Iron: =1 if inventory = 0
The demand indicator for Copper: [C]=1 if inventory = 0

In RED box
A clock set to 1200 ticks (=20 secs) before reset: output [C]
A train selector [T] where T = C/400 + 1. This way train 1,2,3 is selected.

Every Iron train in Parking has two conditions:
For Iron: Enable if I=1 AND T=1 (or 2 or 3)
For Copper: Enable if C=1 AND T=1 (or 2 or 3)

In this setup:
400 = the longest amount of time for the train to reach the station - this depends on travel distance and train speed
And the 1200 = the 400 times the number of trains per unloading station (here: 3)

For DEBUG I have:
Lights indicating which train is currently selected if there is demand.
A way to remotely [R] empty the unloading stations.
Attachments
Screenshot
Screenshot
factorio.png (2.91 MiB) Viewed 8331 times
A train yard test 2.zip
Save file
(4.3 MiB) Downloaded 123 times
My Mod list: Necormant co-author

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

Re: Train yard management - circuit conditions advice needed

Post by mrvn »

DScoffers wrote:I’m not on Factorio to test this, but I think it would work.
Using your example, the signal I=1 would be sent when iron ore = 0.
This signal would have a timer that stops I=1 being sent after around 2-3 seconds, this would allow only 1 train to exit the waiting bays.
A second timer allows the I=1 to only be sent again starting 60 seconds later (if it applies of course).
The 60 seconds timer should be long enough for the train to get to the unloading station and start unloading.
This will depend on the distance between the waiting bays and unloading station.

Problems could arise if the mainline backs up.
I don't think that works. All trains would get the signal and leave the station. Then all but one is blocked at the signal. But when it has left the signal turns green and the next train can leave. They don't return to the station.

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

Re: Train yard management - circuit conditions advice needed

Post by mrvn »

Trblz wrote:I think i have it - see my save file

The setup is now:

The demand indicator for Iron: =1 if inventory = 0
The demand indicator for Copper: [C]=1 if inventory = 0

In RED box
A clock set to 1200 ticks (=20 secs) before reset: output [C]
A train selector [T] where T = C/400 + 1. This way train 1,2,3 is selected.

Every Iron train in Parking has two conditions:
For Iron: Enable if I=1 AND T=1 (or 2 or 3)
For Copper: Enable if C=1 AND T=1 (or 2 or 3)

In this setup:
400 = the longest amount of time for the train to reach the station - this depends on travel distance and train speed
And the 1200 = the 400 times the number of trains per unloading station (here: 3)

For DEBUG I have:
Lights indicating which train is currently selected if there is demand.
A way to remotely [R] empty the unloading stations.


If you use just one station for iron and one for copper and have a stacker berfore them then you don't need to select a train. Prevents the delay when the selected train station is empty and you need to wait an extra 400 ticks for the next train to be selected.

DScoffers
Inserter
Inserter
Posts: 33
Joined: Fri Sep 23, 2016 1:24 pm
Contact:

Re: Train yard management - circuit conditions advice needed

Post by DScoffers »

mrvn wrote: I don't think that works. All trains would get the signal and leave the station. Then all but one is blocked at the signal. But when it has left the signal turns green and the next train can leave. They don't return to the station.
You’re right, it wouldn’t work with a stacker using train stations. I was thinking of using a stacker with chain signals, so the timed signal I=1 is sent to rail signals straight after the chain signals on each bay to only allow one train through.
I still think it would work, but not in Trblz example with a stacker on the main line.

User avatar
Trblz
Long Handed Inserter
Long Handed Inserter
Posts: 63
Joined: Thu Sep 21, 2017 1:23 am
Contact:

Re: Train yard management - circuit conditions advice needed

Post by Trblz »

mrvn wrote:
Trblz wrote:...
If you use just one station for iron and one for copper and have a stacker berfore them then you don't need to select a train. Prevents the delay when the selected train station is empty and you need to wait an extra 400 ticks for the next train to be selected.
In any other world setup i would totally agree, however i am working with space restrictions. It's a city-block world based on octagons with the plan to use more short trains too.
Right now there is a stacker on the left - i plan to replace it with a bunch of unloading stations.
Attachments
map.png
map.png (360.97 KiB) Viewed 8266 times
My Mod list: Necormant co-author

DScoffers
Inserter
Inserter
Posts: 33
Joined: Fri Sep 23, 2016 1:24 pm
Contact:

Re: Train yard management - circuit conditions advice needed

Post by DScoffers »

Nice map.
It looks cool, but I don’t quite understand it. Why have you gone for this design?

1) It looks like only the raw resources are delivered by train. So why have all of the city block rails?
2) If you’re going to add in loading and unloading stations on the existing city blocks, won’t deadlock be fairly easy?
3) it’s hard to tell from the map view but it looks like trains have to take a zigzag path round blocks rather than travelling between columns or rows in a fairly straight line.

User avatar
Trblz
Long Handed Inserter
Long Handed Inserter
Posts: 63
Joined: Thu Sep 21, 2017 1:23 am
Contact:

Re: Train yard management - circuit conditions advice needed

Post by Trblz »

This map is not for optimal input/output.

More about learning logic to optimze trains planning in an unnecessary complicated way ;)
No fluid bus but short trains
No train parking near unloading stations

If i want to scale it up, i will have to side load circuits - more trains.

Zigzagging is indeed a problem, especially for me getting killed as trains are coming from everywhere :(
My Mod list: Necormant co-author

Post Reply

Return to “Gameplay Help”