Skip to main content

Create your own DCC model railway signalling scheme

Project description

model-railway-signalling

A DCC model railway signalling application written in Python, enabling automated and interlocked layout signalling schemes to be designed and configured via the UI without the need to write any code. The application is primarily intended for the Raspberry Pi, but will also run on other platforms (albeit without some of the Raspberry-Pi specific interfacing functions).

  • Enables layout schematics to be created with signals, points, track sections and block instruments.
  • Supports most types of UK colour light signals, semaphore signals, and ground signals.
  • Interfaces with the Pi-SPROG DCC command station to drive the signals and points out on the layout.
  • Uses the Raspberry Pi GPIO inputs to provide train detection in support of signalling automation.
  • Incorporates MQTT networking to allow multiple signalling applications to be linked for larger layouts.
  • Provides a Public API to support custom layout control interfaces.

Example Screenshot

Configured / pre-installed systems are now available to purchase from: https://www.model-railway-signalling.co.uk/ The website also included a number of user guides that can be downloaded (in PDF format).

My youTube channel also has a number of videos demonstrating the use of the application: https://www.youtube.com/@DCCModelRailwaySignalling

What's new for Release 4.8.0:

  • Improved object creation - when you click a button to add a new object to the schematic, the object now moves with the cursor until 'placed' on the canvas in the desired position (by left mouse click). Useful for working on layout schematics larger than the displayed window scroll area.
  • Improved copy function - The new objects now appear on the schematic as soon as you have copied them. They then track the cursor until 'placed' on the canvas in the desired position (by left mouse click). Useful for working on 'busy' layout schematics where the copied items would have overlayed other objects.
  • Other minor improvements to the schematic editor in terms of cursor styles during object moves and area selections (Edit Mode), and scrolling of the displayed canvas area via the mouse/touchscreen (Run Mode).
  • New DCC Accessory switches feature, enabling you to add and configure buttons on the schematic to control other DCC-enabled accessories on your layout (e.g. If you are still analogue for control of trains, then you can use this feature with external DCC-relay modules for operating track isolating sections).
  • Improved Route Feature - DCC switches can be added to the route configuration to operate DCC accessories needed to complete the route setup (level crossings, track isolating sections etc).
  • The font, font size, font colour (black, white or auto) and font style can now be specified for Route Buttons (these options can also be applied to text boxes and DCC Switches)
  • The canvas (background) colour and grid colour can now be changed and the grid hidden in edit mode
  • Bugfix to colour chooser - Previous colour will now be retained if cancelled (without errors)
  • Bugfix to object selection (shift-left-click) - will now no longer error if cursor is not over an object

Example Screenshot2

Bug reports and feedback is welcome and appreciated:

  • What aspects are intuitive? What aspects aren't?
  • What aspects do you particularly like?
  • What aspects particularly irritate you?
  • What new features would you like to see?

email: enquiries@model-railway-signalling.co.uk (if reporting bugs then please attach the sig file, application logs and any relevant screenshots)

Installing the application

For a first time installation use:

$ pip install model-railway-signals             <== This should work for most python installations
or
$ python -m pip install model-railway-signals   <== If the command line version of pip is not installed/enabled
or
$ python3 -m pip install model-railway-signals  <== If you have multiple major versions of python installed

When installing the application on later versions of python you may get the following error:

error: externally-managed-environment

To overcome this, add the '--break-system-packages' argument to the command - e.g.

$ pip install --break-system-packages model-railway-signals 
$ sudo mv /usr/lib/python3.11/EXTERNALLY-MANAGED /usr/lib/python3.11/EXTERNALLY-MANAGED.old

To upgrade to the latest version use:

$ pip install --upgrade model-railway-signals            <== This should work for most python installations
or
$ python -m pip install --upgrade model-railway-signals  <== If the command line version of pip is not installed/enabled
or
$ python3 -m pip install --upgrade model-railway-signals <== If you have multiple major versions of python installed

To remove the application:

$ pip uninstall model-railway-signals                    <== This should work for most python installations
or
$ python -m pip uninstall model-railway-signals          <== If the command line version of pip is not installed/enabled
or
$ python3 -m pip uninstall model-railway-signals         <== If you have multiple major versions of python installed

To install a specific version of the application the application:

$ pip install model-railway-signals==4.5.0               <== This should work for most python installations
or
$ python -m pip install model-railway-signals==4.5.0     <== If the command line version of pip is not installed/enabled
or
$ python3 -m pip install model-railway-signals==4.5.0    <== If you have multiple major versions of python installed

The application has minimum external dependencies (over and above the 'standard' python installation), 'pyserial' and 'paho-mqtt', both of which should automatically get installed with the application. If for some reason this doesn't happen (I've been made aware of one instance on a Windows platform) then these packages can be installed seperately (prior to installing the model-railway-signals package):

$ pip install paho-mqtt
$ pip install pyserial

If you want to use Block Instruments with full sound enabled (bell rings and telegraph key sounds) then you will also need to install the 'simpleaudio' package. If 'simpleaudio' is not installed then the application will still function correctly (just without sound).

$ pip install simpleaudio

If you are running on a later version of Python you may need to install libasound2 before the simpleaudio pip install will work.

$ sudo apt-get install libasound2-dev

Note that for Windows, the 'simpleaudio' it has a dependency on Microsoft Visual C++ 14.0 or greater (so you will need to ensure Visual Studio 2015 is installed first).

Running the application

The python package should be run as a module (note underscores):

$ python -m model_railway_signals  <== This should work for most python installations
or
$ python3 -m model_railway_signals <== If you have multiple major versions of python installed

If required, a layout schematic can be loaded at startup:

$ python -m model_railway_signals -f layout_file.sig

If required, the logging level can be specified at startup (ERROR, WARNING, INFO or DEBUG)

$ python -m model_railway_signals -f layout_file.sig -l DEBUG

Application documentation, can be found in the 'user_guide' folder: https://github.com/johnrm174/model-railway-signalling/tree/main/user_guide

Some example layout configuration files can be found in the 'configuration_examples' folder: https://github.com/johnrm174/model-railway-signalling/tree/main/configuration_examples

My youTube channel also has a number of videos demonstrating the use of the application: https://www.youtube.com/@DCCModelRailwaySignalling

And finally, a top tip for running the application on the latest Debian Bookworm release which uses Wayland as the GUI backend rather than X11 (which was the backend for previous Debian releases). I found that with Wayland, the Tkinter GUI performance was terrible for some reason (not just my application - python/Tkinter performance in general) - and that was running on a Raspberry Pi 5 which I would have expected to improve overall performance. Anyway, I found that the fix is to switch the GUI backend of the Raspberry Pi back to X11 - performance of the user interface is now lightning quick!

To change the backend - Run "sudo raspi-config", select 'Advanced Options' then 'Wayland' and select X11.

An additional benifit was that some of the other applications I use (such as the kazam video capture software) will now work as normal on the Raspberry Pi 5.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

model_railway_signals-4.8.0.tar.gz (21.5 MB view details)

Uploaded Source

Built Distribution

model_railway_signals-4.8.0-py3-none-any.whl (642.6 kB view details)

Uploaded Python 3

File details

Details for the file model_railway_signals-4.8.0.tar.gz.

File metadata

  • Download URL: model_railway_signals-4.8.0.tar.gz
  • Upload date:
  • Size: 21.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.2

File hashes

Hashes for model_railway_signals-4.8.0.tar.gz
Algorithm Hash digest
SHA256 1f4027b181072ff0310e936faa0b36fc71ff6a569350544f80f51154c84e1b5f
MD5 6b1108227eb6d52a15025952039eabad
BLAKE2b-256 14c06f7a35a650be8bdd470932bbd84c73142de9cad616ea181c1f0e688047de

See more details on using hashes here.

File details

Details for the file model_railway_signals-4.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for model_railway_signals-4.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05df9f9d912d91e5f60c28b99d985fbb7a7999ce6fdb2a87411381dcba71d86b
MD5 84dd5fb2c9ecf5495d029ba20d0a4479
BLAKE2b-256 2351da7e79c39e9c8fa4fcbf18ea7b38c9654bcc13f00895f38f2c6444e778cf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page