Model railway - Hardware
Intellibox
Between the control computer and the railway is Uhlenbrock's Intellibox (German site). Its RS232 interface supports Märklin's P50 protocol, plus extensions called P50X. The extensions include an event system for acquiring information about changes in the railway state. The most important use for this is reading track sensors, but it can also be used to keep the program in sync with other control devices.
Sensors
To implement traffic control, the system needs to be kept informed of the positions of the trains at all times. The method I'm using for this is track circuits. Märklin has their own special circuit tracks, but they are rather expensive and only available in one form. Fortunately, it's easy to modify any C-track piece to be used as part of a track circuit by cutting the metal conductor conneting the rails at both ends of the track (see pictures below). The modification is completely invisible from the topside of the track and does not prevent using the track for other purposes.
The principle of track circuits is to isolate the rails from each other and adjacent tracks so that only one is connected to ground. The other is connected to a sensor box, such as Märklin's s88. When a train enters the sensor track, its axles connect the isolated rail to ground, completing the circuit with the sensor box. Multiple modified tracks can be chained together to form a single large sensor block. This improves reliability, since some wagons are not terribly heavy and may occasionally not make contact with one axle. Longer wagons could also have a wheelbase long enough to fit a single-track sensor between axles. Thus the sensor block must be able to hold enough axles that at least one of them has good contact.
Turnout control
All of Märklin's C-track turnouts can be retrofitted with electric turnout mechanisms, which are hidden under the track base. Most can also be retrofitted with similarly hidden digital turnout decoders. However, the three-way turnout has no room for the twin decoders that would be needed. Thus, I'm using Uhlenbrock's "magnetartikeldecoder" to control that one. It fits between two adjacent tracks and does not look too terrible.
![[Image]](images/uhlenbrock-md2.jpg)
Custom hardware
I'm starting to make and use some custom hardware components based on the Arduino microcontroller boards. The first one is a wireless s88 transmitter/receiver pair using an XBee radio module. This allows me to get rid of long sensor wires and it has potential to be cheaper than Märklin's (horribly overpriced) s88 modules.
The firmware source code for both the transmitter and receiver can be found from SVN. Schematic for the transmitter is below; the receiver can be connected directly to the S88 bus (see the source file for pinout).
SVG version of the schematic