I have developed a circuit to turn on/off tunnel lights on my HO railroad. This circuit is to replace a previous circuit that works pretty well except when train lengths are short!
In the rest or normal state, the tunnel lights are off and monitor led is green (a three wire red/green led common anode).
The idea is that when a train goes over either LDR embedded in the track at the entrances to the tunnel, the lights in the tunnel turn on, and when the entire train has exited, the lights turn off. The idea here is to use two Flip-Flops, one for each tunnel entrance, that are set when a train is detected. Once either of the flip flops is set, transistor Q1 turns off and transistor Q2 turns on. The signal for this is from the quad input NOR gates on the CD4002 (Y2) which is triggered when either or both of the Flip Flops are turned on ( triggered by 1Q and 2Q).
The set signal of the Flip Flops comes from the NAND gates that send a +5 signal when the LDR's are covered. This all works great!
The more difficult issue is the Reset. The condition for this is: Both flip flops must be on (set), which means a train has entered the tunnel AND it has also left the tunnel (triggering both Flip Flops) and both LDR's must be uncovered (last car has passed). At this point all inputs to the first NOR gate are set to 0 (2 NAND gates and the two complements of 1Q and 2Q of the flip flops). This sets 1Y to +5 and this signal goes to the two resets of the Flip Flops. Both flip flops will always be reset at the same time. This is where it gets dicey. I needed to take the signal for the resets from a voltage divider. Directly linking the two resets to the output of 1Y didn't work. Only one flip flop would reset.
Most of the time, the circuit starts up in the rest state, but I have been unable to figure out how to make sure the system is reset on power up.
I had used a CD4013 (D flip flop) but I could not get the reset to reset both flip flops. One would always go back to set again.
I don't know why I couldn't get that one to work. Sometimes it only worked if the voltage meter was connected.
I am quite the novice at this, by the way.
So, there must be a few things wrong in the circuit, but I don't know where!
In the rest or normal state, the tunnel lights are off and monitor led is green (a three wire red/green led common anode).
The idea is that when a train goes over either LDR embedded in the track at the entrances to the tunnel, the lights in the tunnel turn on, and when the entire train has exited, the lights turn off. The idea here is to use two Flip-Flops, one for each tunnel entrance, that are set when a train is detected. Once either of the flip flops is set, transistor Q1 turns off and transistor Q2 turns on. The signal for this is from the quad input NOR gates on the CD4002 (Y2) which is triggered when either or both of the Flip Flops are turned on ( triggered by 1Q and 2Q).
The set signal of the Flip Flops comes from the NAND gates that send a +5 signal when the LDR's are covered. This all works great!
The more difficult issue is the Reset. The condition for this is: Both flip flops must be on (set), which means a train has entered the tunnel AND it has also left the tunnel (triggering both Flip Flops) and both LDR's must be uncovered (last car has passed). At this point all inputs to the first NOR gate are set to 0 (2 NAND gates and the two complements of 1Q and 2Q of the flip flops). This sets 1Y to +5 and this signal goes to the two resets of the Flip Flops. Both flip flops will always be reset at the same time. This is where it gets dicey. I needed to take the signal for the resets from a voltage divider. Directly linking the two resets to the output of 1Y didn't work. Only one flip flop would reset.
Most of the time, the circuit starts up in the rest state, but I have been unable to figure out how to make sure the system is reset on power up.
I had used a CD4013 (D flip flop) but I could not get the reset to reset both flip flops. One would always go back to set again.
I don't know why I couldn't get that one to work. Sometimes it only worked if the voltage meter was connected.
I am quite the novice at this, by the way.
So, there must be a few things wrong in the circuit, but I don't know where!
Attachments
-
34.7 KB Views: 35