I posted this recently on another thread about train detection, but I thought it might be good to bring direct attention to it be starting a thread all on its own.
This is a very inexpensive infrared train detector which will work with the layout room lights either on or off. In its basic form it is limited in what it can do. For example, there is no delay mechanism so the detector will turn on and off as each car rolls over it. Adding delay circuitry is beyond my comprehension but perhaps someone with a better knowledge of electronics could contribute that sort of additional information. It is also only capable of powering an LED, but I'm sure a relay could be added.
I must state a couple of qualifications: First, I have only used this circuit in test mode because I don't have a layout to try it on. However, I have built three of the sensors and they all work. They will consistantly detect at about 1 1/2".
Second, I have no clue about where I got this circuit from so I cannot give proper credit to the designer.
Here is the schematic and Digi-Key parts list. I think you can use pretty much any LED you choose:
EDIT August 3, 2013. Two key items in the above diagram have become obsolete: For QSC112-ND, use 160-1030-ND or QSD123-ND. Bob Frey whom designed the circuit recommends the 160-1030-ND but either will work. For QEC113-ND, use 754-1600-ND. All parts numbers are Digi-Key.
Here is one of the test circuits, as well as the test track. The tubes in the test track holes are heat shrink tubing:
There are two sensitive bits to observe. One is that the phototransistor (LED infrared detector) must be shielded with heat shrink tubing so only the very tip of the detector is exposed. Second is that you will need a filtered 12V DC power source. When I tried the detectors on an old train set power pack they did not work reliably.
As I said in the other thread, I am an electronic dunce. The fact that I got three of these circuits to work consistently shocked the heck out of me! If I can do it, anybody can!
Now, if someone could add a delay component and perhaps a relay, we would be off to the races! And in economy class to boot!