Train crashes are bad things.
So the railroads, early on, introduced systems for deconflicting trains. This started with putting the whole railroad in a critical region (one train in steam) and progressed through an increasingly sophisticated system that depended on dividing the railroad into blocks and allocating each block to only one train at a time.
It’s a fascinating subject, but not the one I want to tell here. I want to talk about the other part, what happens when the trains came to a junction or station with more-or-less complex track.
Trains switch track on switches. If the switch isn’t set correctly, the train can run the ‘wrong way through the switch.
Here’s a switch. Trains go to the right because the ‘points’ (the sharp, pointy rails pointing at us – the moving parts) are over to the left. Move the points to the right (they’re tied together with the small bar in foreground) and the trains go left.
But, what about a train coming at us from the left track? It will derail.
So it’s important that the switches are set properly.
And if you have something like this, it’s also important that the direction the switches are set doesn’t run the train onto a track where it can crash into another train.
Finally, you can only run trains through tracks at certain speeds.
(image courtesy Blair Kooistra)
Here’s a switch where the curve on the left side has to be travelled a lot slower than the mainline right side.
But wait – there are also signals – we need to control entry of trains onto sections of track, we use signals.
And having a car roll onto the main line from a siding can cause a bad wreck.
So, wherever this can happen we add a ‘derail’, a steel casting that clamps over the rail and derails anything going over it. Swing it away to permit passage. Those need controlled too.
The original control scheme involved a “signalman” (many were women, often running a rural station was a couple job) pulling levers that pulled on lengths of pipe running on rollers on the ground.
(courtesy Wm. K. Walthers)
Here’s a model of a typical signal tower. The signalman was upstairs and had good visibility down the track. In fron of the station is some of the bell crank and pipe apparatus.
This worked, but depended on the variable skill and thoughtfulness of someone doing a boring job. The consequences of mistakes could be terrible. So the railroads began implementing logic they called ‘interlocking’.
Here’s the inside, with the levers. Notice that the levers have a small grip on the side. To move the big lever, you squeeze the small lever, that unlocks the big one.
At the base, there’s a mechanism that locks the other small levers when one is squeezed. So only one large lever can be moved at a time. Critical region.
If you look back at the model picture, in front of the switch tower is a flat black box. Inside is the interlocking frame, a mechanical logic circuit with bars that slide, a layer of vertical sliding bars, and a layer of horizontal sliding bars under them.
The vertical bars connect to the levers. Notice the notches in bars and ‘bumps’
The bumps are attached to the horizontal bar underneath. Moving a vertical bar A causes the horizontal bar to slide as the bump moves out of the notch.
But if another bump on the same bar is against a vertical bar B whose notch is out of position, the horizontal bar can’t move, so vertical A is locked.
(diagram courtesy Clive Feather)
On the left the upper horizontal is forced left by vertical 3. This locks vertical 1. The lower horizontal is free to slide. 2 and 3 are free to move.
Now we move 3. This unlocks the upper horizontal, and locks the lower one. We can no longer move 2, but can now move 1.
So we have a strange logic, where we we establish an allowed initial state, and then prohibit transitions to states we don’t want.
And this works, but maintaining all the moving pipes and frames and such is a nightmare. The mechanical frames are eventually replaced by relays.
But the engineers are very conservative. They want to retain the one good quality of the frame system – that it acts not as intelligence, but as ‘don’t do that stupid’. So they retain the signalman and the levers, but replace the frame itself with these relays.
Eventually, this tech also becomes obsolete. In the 1980’s we still had the same expensive employee, the crazy Frankenstein movie relays, and people were saying “replace it with a microcontroller”.
Still being conservative, the engineers replaced, not the relays, but the levers. The microcontroller throws levers just like a human, and in turn it’s logic is checked by the relay circuit.
And to this day that’s how interlocking’s done on the railroad. With two layers – one to implement the business logic, and another to protect the system from business logic errors.
Incidentally, found this great dissertation while researching this post.