Using LocoIO to make a traffic signal                                                   6/9/2003

I recently decided to build a computer controlled traffic light for a layout using LocoIO to control the LEDís.  Many programs can be written (or configured) to run the traffic light but my documentation will show you how to do it with RRCntl.  Since one traffic light uses 5 outputs on a LocoIO, you could drive 3 differently sequenced traffic lights on one LocoIO.  If you want them to be in the same sequence then you could drive a lot more from one LocoIO.

Building the hardware

Building the hardware is quite easy.  I have included a schematic to show how I did it.  It required the following parts:

My first one used 5mm LEDís (because thatís what I had laying around).  This may be the right size for a G scale light.  If you want to build a HO scale light, you might be able to use 1.8mm LEDS.  For N scale you may have to go to SMT (surface mounted components) to get it small enough.  For Z scale you would have to use fiber optic cables.

Green and Yellow require 2 ports each because at some point in time they are both off.  Red only requires one port because at no time are all 4 reds off.

Configuring the LocoIO SVís

I used the first 5 ports on a LocoIO but you could use any ports.  All my examples will assume the first 5 ports with the following addressing (you can use any numbers you want).

Since I wanted to be able to use a switch command to turn the LEDís I used SV configuration bytes as follows: (all values are hex)

SV3 - 5      80 01 10

SV6 - 8      80 02 10

SV9 Ė 11   80 03 10

SV12 Ė 13 80 04 10

SV14 Ė 16 80 05 10

This allows a B00110cc to turn E/W Green off and B00130 to turn E/W Green on.  Note: From a DTxx throttle you would add 1 to the number (ie.  Throw switch 2).

Script language

My first attempt used the scripting functionality of RRCntl to control the traffic signal.  This didnít require any modifications to RRCntl.  It had the disadvantage of a small noticeable delay in the changing of the LEDís.  It have included the script.  One reason for the small delay is that the scripting function only executes 4 lines of the script each second (by design).

Multi port write commands

LocoIO also supports OPC_PEER_XFER messages with a code of 03 and 04 for multi port writes and reads.  The LocoIO documentation goes into more detail on this.  If you wrote a program to send the following sequences out to the Loconet, the traffic signal would function.

The multi port sequence is:

Low Mask            Low Data

248 (0xF8)           120 (0x78)           N/S Red on, E/W Green on, All Yellow off

Wait 60 seconds

248 (0xF8)           216 (0xD8)          N/S Red on, E/W Green off, E/W Yellow on

Wait 5 seconds

 248 (0xF8)          176 (0xB0)          E/W Red on, N/S Green on, All Yellow off

Wait 60 seconds

 248 (0xF8)          224 (0xE0)          E/W Red on, N/S Green off, N/S Yellow on

Wait 5 seconds

Do it over and over