Model Railroad Mainline/Siding Signal Lights Circuit

Introduction: Model Railroad Mainline/Siding Signal Lights Circuit

About: Started playing with electronics to add extra character to my model train layout. The hobby keeps growing.

I began this project for a model railroading friend who was having some trouble getting his signal lights for a mainline/siding to work correctly, or more exactly, in the manner that he wanted. The signal standards are visible at each end of the turnouts used to enter or exit where the siding exists on the mainline route. These are three aspect signal standards: green/yellow/red. One of the turnouts is controlled by a Tortoise switch control and the other by a simpler stall motor switch which has a microswitch installed that will open or close based on the switch position.

For the purpose of this tutorial, when both turnouts are considered closed, it is free sailing on the mainline and both signal lights will show a green signal only. The truth table PDF will highlight the switch position combinations and the on or off lighting of the signal aspects.

A couple of important notes:

  • A closed switch position always produces a green
  • An open switch position always produces a yellow
  • When the switches are NOT in the same position (open or closed) a red is added
  • Thus, a red signal is always accompanied by another colour.

Supplies

2 - 2p Screw Terminals

2- 4p Screw Terminals

7 - 2n3904 transistors

2 - 150 ohm resistors

4 - 220 ohm resistors

6 - 10k ohm resistors

3 - 20k ohm resistors

1 - CD4070 XOR Gate IC chip

Step 1: How It Works

Refer to the Siding Controls PDF file for the full schematic of the circuit.

The CD4070 IC chip provides XOR calculation on the two inputs. Basically, when both inputs are the same (in my case 0 or 5 volts) the output is 0v. When the inputs do not match (one is 0v and the other is 5v) then the output is 5 volts.

The other parts of the circuit are simple transistor switches that turn on and off with the power provided by the switch (SW1 and SW2) inputs. Please note that the switch inputs are grounded by the GND circuit on the circuit board.

How it Works:
Examining the top circuit for the LED output D1:

The Yellow LED (pin 4 of D1) turns on when the input to SW1 has a positive voltage and transistor Q1 is turned.

The Green LED (pin 3 of D1) turns on when there is 0V on Q3 which in turns causes transistor Q6 to turn on. Q6 is on when Q1 is off and vice versa.

CD4070 U2A XOR is used to control the output of the red signal light. The truth table of the XOR IC matches the requirement of a positive signal when the inputs are not in sync. The IC will output 0V when Both SW1 and SW2 are in the SAME Position (either open or closed). When switches are NOT in the same position (Open or Closed) the output is Vcc and this will turn on transistor Q5 which will then turn on both of the RED leds.

I should note that the resistor values used for current limiting on the signals are just suggestions. I believe on my actual circuit board I used larger value resistors after testing different values with individual lights. I prefer the signals not to be glaring. The circuit is also based on common anode signals which I believe are pretty standard. If your signals come with a common resistor I would suggest removing it and using individual resistors on each of the leds. Different coloured leds tend to have a different forward voltage and therefore current draw (with the same valued resistor). Experiment with this!

Also, I have tested and designed this with a 5v power supply. This circuit should also work fine with 9v or 12v if that is your power supply. If you use a higher voltage supply just increase the resistor values used for the leds. Again, test and experiment. Start at 1 or 2k for the red led and see how you like the output.

Step 2: The Circuit Board

My first working version of the circuit board was done on a breadboard. When the concept was proven to work I then hand soldered the entire circuit, which can be very time consuming. My current working circuit board, and as shown in the video, is a printed circuit board with output files generated by Kicad which is my circuit modelling software.

I have used this site for ordering the PCB's:

https://jlcpcb.com/

Here in Canada the cost for 5 boards is less than $3. Shipping tends to be the most expensive component. I will usually order 4 or 5 different circuit boards. (The second and more circuit boards are about double the price of the first 5). Typical shipping costs (by mail to Canada for various reasons) is about $20. Having the circuit board pre built so I just have to solder in the components is a great time saver!

Here is a link to the Gerber Files that you can upload to jlcpcb or any of the other PCB prototype manufacturers.

Be the First to Share

    Recommendations

    • Summer Fun: Student Design Challenge

      Summer Fun: Student Design Challenge
    • Fandom Contest

      Fandom Contest
    • Metal Contest

      Metal Contest

    3 Comments

    0
    SushilD6
    SushilD6

    3 months ago

    I am not an engineer but a hobbyist of model railroad. Project done by you is marvelous. But may I request you kindly give me an hint as to how to proceed for a similar project with the help of Arduino UNO as at this age I don't want to do assembly of electronic components, solder etc. Thanks in advance. Good day.

    0
    bobinbd
    bobinbd

    Reply 3 months ago

    Doing this with an arduino would be much simpler. I thought of that but decided to use IC's for the challenge!

    Here is some logic for doing this with the arduino. I used input_pullup for the switches because you may have a floating pin depending on how you measure the voltage on the switch machine.

    The truth table
    Switch One Switch Two Signal A Signal B
    Open Open Yellow Yellow
    Open Closed Yellow/Red Green/Red
    Closed Open Green/Red Yellow/Red
    Closed Closed Green Green

    Open always produces a Yellow
    Closed always produces a Green
    When switches are not the same, Red is added

    To achieve the same results with the Arduino you will need code something like this:
    // 3 output pins for signal 1 (red green and yellow)
    // 3 output pins for signal 2 (red green and yellow)
    // 2 input pins for the switch position. assume 5v is closed position and 0v is open position
    #define a1Red 3
    #define a1Green 4
    #define a1Yellow 5
    #define a2Red 6
    #define a2Green 7
    #define a2Yellow 8
    #define s1 9
    #define s2 10

    // Set pin modes
    pinMode(a1Red, OUTPUT);
    pinMode(a1Green, OUTPUT);
    pinMode(a1Yellow, OUTPUT);
    pinMode(a2Red, OUTPUT);
    pinMode(a2Green, OUTPUT);
    pinMode(a2Yellow, OUTPUT);
    pinMode(s1, INPUT_PULLUP);
    pinMode(s2, INPUT_PULLUP);

    // do the red lights
    // if s1 and s2 are NOT the same then the red light of both aspect signals are on
    if (digitalRead(s1) <> digitalRead(s2))
    {
    digitalWrite(a1Red, HIGH);
    digitalWrite(a2Red, HIGH);
    }
    else
    {
    digitalWrite(a1Red, LOW);
    digitalWrite(a2Red, LOW);
    }
    // do the green and yellow lights
    // when switch 1 has 0v (LOW) green is on and yellow is off
    // when switch 1 has 5v (HIGH) green is off and yellow is on
    if (digitalRead(s1) == LOW)
    {
    digitalWrite(a1Green, HIGH);
    digitalWrite(a1Yellow, LOW);
    }
    else
    {
    digitalWrite(a1Green, LOW);
    digitalWrite(a1Yellow, HIGH);
    }
    // same logic applies to aspect 2
    if (digitalRead(s2) == LOW)
    {
    digitalWrite(a2Green, HIGH);
    digitalWrite(a2Yellow, LOW);
    }
    else
    {
    digitalWrite(a2Green, LOW);
    digitalWrite(a2Yellow, HIGH);
    }

    I haven't tried this but I think it would work.

    0
    Penolopy Bulnick
    Penolopy Bulnick

    1 year ago

    This is fun and nice to do for your friend :)