The circuits are designed around the LM339 comparator chip and can use a wide assortment of matched infrared – emitter / detector pairs. The basic circuit shown below has been tested with sensor gaps as wide as 12 inches but a distance of 8 inches or less is more practical.
In the circuit, the LED will turn on when the infrared beam is broken. The value of the resistor R1 determines the sensitivity of the phototransistor Q1. In most cases a value of 1 Meg or 470K ohm with good results but every situation is different and some experimentation might be needed.
Basic Infrared Detector Schematic
Circuit Operation – When a train breaks the infrared beam the phototransistor will conduct less current. The voltage at the MINUS input of the comparator will rise above the reference voltage at the PLUS as determined by R3 and R4. The output of the comparator to turn ON and the LED will be lit.
Good alignment of the emitter and detector is important for good operation, especially if the gap is large. This can be done with a piece of string stretched between and in line with LED and phototransistor. A length of dowel or stiff wire could be used to set the alignment. Another method that can be used for longer distances is a laser pointer shone through one of the mounting holes.
The next diagram shows two methods of aligning the emitter and detector mountings. For best results the height of the “beam” should be at coupler height and at an angle across the tracks.
Visit Here for more.