Computer controlled 3 aspect signalsfor model railways
by Ken Stone
Controlling signals on a model railway is no easy task - this is something I've found out the hard way. Solutions range from the simple - direct switching, to the complex - computer control.
What I am presenting here is a partial solution, the driver module for connecting three aspect colored lamp signals to the parallel printer port of a PC through the parallel port adapter, or to any other computer with appropriate ports. Other projects will be presented as they are developed, for control of points (switches to our friends in USA), train sensing and speed control.
Each output is capable of driving both a grain-of-wheat lamp and an LED. On the prototype board, I installed the LEDs directly on the PCB to facilitate testing, but these LEDs could be mounted on monitor board, or be retrofitted to the signal heads themselves. If you do this, make sure you wire them us as common anode!
While the schematic and board specify the lamp supply as being 12 volts, other voltages could be used to accommodate different voltage lamps. The limits as shown would be 3 volts to 20 volts. Increasing the voltage of the electrolytic capacitor to 35 volts would allow the use of 24 volts (I'm being very cautious here - voltages specified on model railway transformers can be quite inaccurate). The BC547 transistors are however limited to 100ma, so make sure you do not overload them by using too large a lamp. If greater current handling is required, use BC338 transistors instead. These are rated at 800ma, though I would not recommend pushing them that hard as dissipation must also be considered.
How It Works
The schematic of the PC controlled 3 aspect signals.
The 3-aspect signal module contains a latch, and four identical signal driver circuits. For the moment we will consider this to be connected to a computer under the control of appropriate software. Data for four sets of signals is loaded into the latch at once by presenting the data on the data bus, then sending the Strobe signal LOW then HIGH again. This data is then held, and presented to the four drivers. The NOR gate is used as a simple binary decoder, allowing us to control three lamps from two data lines.
Consider the decoder and driver circuitry around IC2A. If both O0 and O1 are LOW, the driver transistors for both the yellow and green lamps will be off. At the same time, as both inputs to the NOR gate are LOW, its output will be HIGH, thus turning on the red lamp.
If O0 is HIGH and 01 is LOW, the amber driver transistor will be switched on, but the red lamp will be off, as the NOR gate, having a HIGH on one input, will have its output LOW.
If O0 is LOW and 01 is HIGH, the green driver transistor will be switched on, but the red lamp will be off, again as the NOR gate, having a HIGH on one input, will have its output LOW.
This gives us the three valid states required by the signals. In order to keep the parts count low, I did not address the situation of both O0 and O1 being HIGH. If this occurs, both the amber and green lamps will be lit. If your model railway follows prototype practice, this would be considered a fault condition, requiring the engine driver to stop, and phone for the correct signal status.
The PCB overlay of the PC controlled 3 aspect signals.
The 3 aspect signal controller is built on a single sided PCB measuring about 8.5 cm by 6.5 cm.
Before you start assembly, check the board for etching faults. Look for any shorts between tracks, or open circuits due to over etching. Take this opportunity to sand the edges of the board, removing any splinters or rough edges.
When you are happy with the printed circuit board, construction can proceed as normal, starting with the resistors that are flat on the PCB first, followed by the IC socket, then moving onto the taller components. The LED resistors have been stood on end on this board.
Take particular care with the orientation of the polarized components, the LEDs, ICs, electrolytic and the transistors.
When inserting the ICs in their sockets, take care not to accidentally bend any of the pins under the chip. Also, make sure the notch on the chip is aligned with the notch marked on the PCB overlay.
As mentioned above, you may not wish to put the LEDs the directly on the PCB. The exception would the the power LED, which is provided to give quick visual indication that the 12 volt rail is active.
Two methods of connection to the data bus are provided, a single-in-line connector where the data bits are in order (best for hand wiring) or a dual-in-line connector suitable for IDC connectors. The strobe lead can be a flying lead or a single pin connector. The power connections use the same spacing and configuration as PC hard drives, so you can use that type of connector, or just wire to the PCB directly.
Different latch chips with the same pin configuration can be used in the circuit. The 74LS374 or 74LS377 can be used if A is linked to C. The obsolete 74LS273 can be used if A is linked to B. Check your data books.
In order to simplify construction, and limit the size (and cost) of the board, the LEDs are not in the order one would expect. Each group of red, amber and green corresponds to a single signal head, though the groups are not arranged sequentially. With the board placed so that the connections to the lamps are up the left side, the following applies:
The bit order per group is always the same, so the truth table for selecting the color is:
See the parallel port adapter article for more help on the programming needed to drive the board. I will make no attempt to provide the general software required to control the signals with respect to movement of trains, points etc. here, because no two model railways will have the same requirements.
If anyone is interested in buying one of these boards, please check the PCBs for Sale page to see if I have any in stock.
Article, art & circuit design copyright 1999 by Ken Stone. This project may built for personal use only.