Train Set Controller

A command-and-control system that demonstrates real-time orchestration of a complex model railway using Raspberry Pi hardware.

Overview

This project is a long term work in progress. It is Adrian's personal project and is not a commercial product.

This is a private project showcasing how Raspberry Pi (RPi) computers can be used in real time to command and control a model train set. The system controls 17 points, manages 12 powered tracks, monitors 24 position sensors, and drives 24 multicolour LED indicators.

The command-and-control device drivers are currently built in Python for rapid development, with a possible future port to Rust. The front end is a web application built with Vue.js.

Hardware Stack

Hardware interfaces are provided by Sequent Microsystems of San Jose. The platform uses three home automation cards, three power relay cards (each providing eight relays), a solid-state relay card, and a GPIO extension card. Everything runs on an RPi Model 5.

Model train set control layout

Train set command and control layout.

Raspberry Pi hardware stack

RPi hardware stack powering the control system.

Progress Updates

This feed will track the build in short articles with text and graphics as new milestones are reached.

Wiring loom

The PI is now installed

The PI has moved off my desk and under the board. It is powered up and running, and I have control from my desk. The wiring loom is now installed.
The power distribution is now installed with 12v DC and Ground supplied to both sides of the Pi. This allows for neat wiring for point motors. Next step is to
complete the track power connections and move on to testing the board with actual trains. Open questions remain on how to best connect mains power to the board.

Sequent Microsystems

It is worth mentioning Sequent Microsystems.

They have provided the interface cards I am using. They also supply both Python and C libraries for the RPi. During my development, as you would 
expect, I have come up against a number of issues. The documentation is pretty good, but there are smethings I didn't understand and one issue 
that was bugging me. 

Sequent worked through a weekend, and delivered a firmware fix on a Sunday. For me, this was a very low priority issue, but the support I 
received was excellent. Since then I have exachanged emails a number of times and had same day responses. 

I have found Sequent Microsystems to be very responsive and helpful.

Protection Software

The low level interface has been extended to include track protection software. This runs on a regular interval (currently every 750 ms).
It reads the state of the track board from the various cards, and looks for logical inconsitencies. These include

- Points set in the wrong direction
- Tracks powered in the wrong direction
- Tracks not powered when they should be
- conflicts with track segments being occupied

If a problem is detected than the track segment is powered down. If, at the next iteration, the problem is resolved, the track is enenrgised. 

The Sensor code is sticky. This means that once a train has passed over a sensor it stays active until it is cleared. This protection code clears
sensors behind the train.

This code effectively locks the train configuration, because it is replicated in Python code running on the RPi.

Train Controller Hardware

The hardware is built.

I am using a number of RPi hats to interface to the train set. I selected cards from Sequent Microsystems to provide the hardware interfaces.
The main reason for this was the very clean i2c interface that provides many more I/O channels than the Pi itself.
These are:

  • Three x Home Automation Cards
  • Three x Power Relay Cards
  • One x Solid-State Relay Card
  • One x GPIO Extension Card
Train set control layout

Train controller configuration

Initial commissioning complete with 17 points and 12 powered tracks under command.

The basic train interface is now complete. This consists of:

  • 17 points
  • 12 powered tracks
  • 24 position sensors
  • 24 multicolour LED indicators
Raspberry Pi hardware stack

New relay stack and enclosure layout

Installed the third relay card and completed a cleaned-up wiring pass. Power distribution is now isolated per block for easier fault tracing.