Simplest approach for rail sets automation How would you tackle the automation of a lego rails set. I am looking for a solution that can be achieved with available parts.

From the answer I will chose either to invest into lego rail sets for my son or into digital H0 sets.

What I am looking for:


start given engine and run to given destination, stop.
when approaching a rails crossing stop if segment busy.
change switches for engine to send to destination.
run multiple engines independently and concurrently.


Optionally:


if multiple routes are available sent train to free route.
if train is running low on power send to service station.


I am not interested in setting timings. I want to be able to simply run the different engines each on their own. This requires detectors which are able to return the ID of the engine entering and leaving the different segments.

I'm pretty good at programming and I would appreciate a doable solution running from a computer.
I've wanted to do something similar since I took part in a public event last year and we had trains running continuously on separate little ovals. My ambition was to have two stations, each with some switches, and run one train at a time between them and switch it to an empty track where it would stop.

Since I already had two RCXs, my solution was to place one at either station with light sensors to detect incoming and outgoing trains. I motorized the switches (using a modified version of instructions I found online - I could make some instructions if you wish), and wrote a program that allows the RCXs to communicate with each other about the state of the trains and the switches.

There were two tricky parts: one is that although you can send PF commands from an RCX, there is no feedback from the PF receiver so you'll have to resend the command several times and hope for the best. The other is that the communication between the RCXs is affected by the PF commands. When you send a PF command, the receiver in the RCX will end up in a state where the next serial byte is lost, and although there is collision detection for the communication between the RCXs, there is nothing similar for the PF commands (the sending of which requires the disabling of all interrupts on the RCX).

My solution was to design a protocol for communication between the two RCXs such that they, in effect, negotiate whose turn it is to send PF commands and stay silent when the other RCX is sending. This worked very well in my living room, where the trains would happily run and stop and be handed back and forth between the two RCXs (since you can't easily ID the trains, you have to know where they are). I then tried to set this up at an event, but unfortunately the room was anything but compatible with PF. Possibly because of the fluorescent lights, the PF IR range was severely limited and the trains would not receive the signals from the RCXs.

A solution based on NXT (or EV3) could probably be a lot more powerful and reliable, especially since you'll have much better ways of detecting the trains. Even so, I suspect they'd run into the same problems in some showrooms as my RCX solution.