Train Simulator Controller: Horn Control
As I build my realistic Train Simulator dashboard and controller, each foundational component I have constructed upon the way has made subsequent additions increasingly straightforward. The CAN bus controller in particular has made slotting each new control and gauge into the setup sufficiently easy that I was able to add a horn control to the setup in just a few hours, most of which were spent soldering and crimping. The horn control consists of only two items: a four-way industrial joystick, chosen to resemble the horn control on some UK passenger trains, and one of my CAN controllers, its firmware updated to know how to send horn messages over the CAN bus.
Unlike the United States, where train horns are often multiple simultaneous tones (and extremely loud) to distinguish them from car horns, UK train horns typically have two different tones that can be separately and sequentially triggered for the same purpose (as Wikipedia notes). Many trains actually have four options: two loud tones, and the same two tones at a reduced volume. As explained in the linked Wikipedia article, noise complaints triggered new rules that have both reduced when drivers sound horns at all, and generally shifted towards softer horn sounds. To support emulating as wide a range of train as possible, I elected to support those four possible horn sounds: following the example of the venerable Class 125, and compatible with the single volume supported by the Class 80x I’m trying to emulate, loud high and low tones will be up and down respectively, while soft high and low tones will be right and left respectively. However, to provide maximum flexibility, the translation from joystick direction to horn command will take place in the PC-side software.
Prototypical horn controls, from a Class 125 HST (left), Class 321, and Class 802.
The first step was to wire up my joystick’s NO (normally open) contacts to a fresh CAN bus controller. The 8+ GPIO pins broken out from the Raspberry Pi Pico that provides its brains are more than sufficient to handle the four digital inputs for the direction in which the joystick has been pushed, so no modifications to the CAN bus controller were necessary. For previous controls I have used simple 0.1" male and female headers (pins and sockets), but I have wanted to start moving towards something a little more mechanically secure - not least because my DRA button keeps getting disconnected! I elected to use JST-SM connectors, similar in pitch to those simple headers (2.5mm or just under 0.1"), supporting up to 3 amps at 250 volts, and most importantly, locking with some force needed to unlock the latch. Without further ado, I soldered and crimped wires onto the CAN bus PCB side, then onto the joystick side, sharing a common ground between each of the switches in the joystick to reduce 8 potential wires to 5.
With the hardware complete, next up was the firmware. Each CAN bus controller PCB has a set of solder pads to set its identity (visible as A1, A2, and A3 if you look closely in the above images), and associates that ID with a particular function in the firmware. Copying and slightly modifying the DRA/AWS acknowledge button board’s C++ module produced a new horn module that will periodically send the current horn state over the CAN bus, and will also send state change messages every time the horn input changes. Finally, I slightly modified the PC-side Python driver I am temporarily using to interface with Train Simulator Classic to pass this information to the Class 80x, and voila, a functioning horn! I’m pleased that adding new controls has become increasingly simple, and as I continue to iterate on the physical construction of the dashboard, I look forward to adding more controls, such as headlights/taillights, windshield wipers, and pantograph/third rail/diesel engine controls.
Playing the high and low tones of a Class 800 UK passenger train horn. 🔊 unmute to hear that classic two-tone sound.