Trains random stopping at and leaving stations

Engineering time: uhm, a few months?
Random stThis layout is just one big loop with three stations where trains can be stopped on side tracks. Two stations have two side tracks and one station has one side track. This is the first project that I have used signals: when a train needs to stop, the signal is put to red, when the train is started, the signal is put on green. Every station has per side track a motorized switch and a sensor. The sensor is located before the motorized switch.

The layout is controlled by one central controller, an Arduino Mega. trains are started and stopped based on a few variables like a maximum time a train can stop at a station, a maximum time a station is empty, etc. Next to that there’s a “random sauce” that makes these variables a bit random.

In case the system wants to stop a train, the system checks the sensor if there’s currently a train on the switch. If so, the switch cannot be changed since that would derail the train. In that case the system waits a few seconds, checks the sensor again and if there’s no train, the switch is put on the side track. Now the system waits until the sensor is hit by a train, which means that a train is guided to the side track. A few seconds after the train has passed the sensor, the switch is put back in the straight position and the side track is disabled which will stop the train.

In case the system wants to start a train, the sensor before the motorized switch is checked if there’s a train passing a sensor. If so, the system waits a few seconds before the train on the concerning side track is started, to make sure there’s a minimal distance between the trains which are riding on the loop. If the sensor doesn’t detect a train, the system waits until the next train passes by to make sure that a train is not started just in front of another train or while a train is on the parallel track of the side track.

This waiting for a train is a downside of this functional design: since a train takes one and a half minutes to complete the whole loop (see video below), the system had to wait for some time before a train could be started or stopped. This resulted in a somewhat boring layout: there were not many actions per minute to make it enjoyable. A version 2.0 which is in development takes really good care of this problem!

Youtube videos

Photo gallery