View on GitHub

pymrrsln2

Two-aspect signaling for model railroads using LocoNet

Download this project as a .zip file Download this project as a tar.gz file

This page describes how to build simple 2-aspect signaling on small model railroads using Digitrax LocoNet. The concept described here can be probably extended to larger layouts, but the maintenance might become more difficult and thus JMRI should be probably used instead.

Description of the system

By two aspect signaling, we understand to use just green and red aspects on the signal (with obvious meanings: red = stop, green = go). The system described here behaves very simply: when a train enters a block, the signals that guard this block turn red and when the train leaves the block, the signals go green. To guard all blocks that are in the direction of travel, we would need to know this direction. That however poses some difficulties which we are not going to deal with in this project.

In order to accomplish this, all we need to know is when a train enters a guarded block. That can be achieved by block occupancy detector which will send a message to LocoNet. We need to respond to this message by changing the aspects, i.e. a link between blocks and signal head needs to be created. Such the link is stored in a signaling file that we will describe later. This is all that is required from the user to use this system.

The hardware components needed for this system are:

Signaling file

Signaling file is a simple text file that describes the behavior of signals on the layout. It has the following format:

  NUM_ASPECTS = 4

  SIGNALS = {
    BlockID : [ SignalHeadID, SignalHeadID, ... ],
    BlockID : [ SignalHeadID, ... ],
    ...
  }

where BlockID is a number corresponding to the block occupancy detector (starting from 0), SignalHeadID is the number of signal head (starting from 0).

Obtaining BlockID

To get the BlockID number, run signals.py --debug 1 (make sure you setup the config file). Then place your locomotive on the layout into the detection block. You should see a message like:

Block 0 , state = HI

When you remove the locomotive, you should see:

Block 0 , state = LO

Obtaining SignalHeadID

To get the SignalHeadID, you need to find out which switch ID controls the signal head. On SE8c in default configuration these numbers start from 257. Use your throttle to find the switch number, then use this formula:

SignalHeadID = (SwitchID - 257) / 2

and round the number down.

With SE8c configured for 4-aspect signalling, there are 2 switch IDs corresponding to one signal head. This setup will work with this project.

Configuration file

Configuration file sets up the serial connection between the computer and LocoNet. It looks like this:

    port = {
      'device'    : '/dev/ttyACM0',
      'baud_rate' : 57600
    }

where device needs to be set to the name of the serial port (on Windows something like 'COM1').

Tips & tricks