I'm looking into using Arduino to build an ABS (Automatic Block Signal) system for a live steam railroad.
The idea is that a "block" will be between 2 Arduinos. When a block is occupied, the signals facing outside display red, however the signals further away display yellow, the next ones green etc.
Basically, each board needs to both send and receive instructions to each other. If using serial, I think 4 pins per board will be needed. Also, the signal units I want to build will be portable and will need to be able to mix and match without having to reprogram each time.
What are some of the protocols that I will need to write into the program?
Forgot to mention, this is not for a layout. This is for multpile physical locations at a large-scale live steam railroad. So, a single board is impractical.
I want to be able to built portable units for a trackless train as well, so the locations of the signals will be subject to change. Basically, everything will need to be plug-n-play. Though the total cable length shouldn't exceed 500m for all signals combined.
For detection, I intend on potentially trying something called PMTC (Pulse-Modulated Track Circuit). When the train's wheels enters the block, it "shorts" the circuit causing a red signal. The advantage with PMTC is that you can tell the difference between an occupancy or a broken rail. For using PMTC, one pair of the board's I/O pins will be connected to each end of the block. This comes from the "Track Circuit Theory" which was developed in the 1870's, though back then they used a battery on one end of the track and a relay on the other end.
For those kind of distances i would use RS-485. Serial wouldnt reach that long.
Have all the arduinos connnected to this bus with RS-485 transceiver.
Have a master module which has control of the communications. So theres no packet collisions, only the master initiates communication. the master sends a message to an arduino. Waits for a response. Then it sends a message to the next arduino etc. Means you wont get arduinos all sending messages at the same time causing collisions.
It can constantly query them in sequence and send the next message in its next sequence.
Train passes through the red zone. Current zone turns orange. Next cycle it gets queried a message by the master it responds with now its orange. In turn the master can send the previous block it can now go from orange to green
You could also possibly use rfid tags in the trains. As the train passes a block/entrance it gets scanned so you know where that train is on your master. You could also use this information to track whether a block is empty or has a train.
Having this information off block full, orange, or empty all on the main microcontroller could be handy. You could do up a digitL display of yiur track, and in real time parts of the occupied track will turn orange, red, green etc
With the ability to be able to manually change them through the master display
Also having 1 master control all of them will make it easy to change track layouts
Another benefit. You could even work out average speed of trains as you know the distance between the blocks