John’s been in touch with a very clever Model train IR detector:
Your website and the products you offer are great for any level of model railroading, and recently I saw a few folks missives on signals, so I thought I’d send you my updated cheap train detection article.
I’ve been trying to get some way to detect trains as they pass, and drop signals to red when they go by.
There are some good detectors out there, but I wanted to see what I could figure out on my own. I’ve been fooling around with the little sensors used in manufacturing mostly made to send a signal for something, like a light being on, or to turn on lights when dark, or objects passing by on an assembly line.
How about people sensors? Both types had some utility, well the turn on the lights did just that, but not when I wanted to run trains.
The people sensors… well OK… sensed people, not HO trains, and when I adjusted the sensitivity they detected everything but trains.
Back to research, and success!
I found little IR detectors on eBay for $2.00 each. A lot less than that from China (just ordered 20 more for a total of $10.33!) but it takes a few months mail, and customs, and red tape to get here from there.
They are called Arduino PIC AVR IR Infrared Obstacle Avoidance Sensor Module Object Detector, and eBay has a ton of vendors selling them.
Size is about 16 mm by 50mm with a plug attached. They run on 3.3 to 5 volts DC, and will detect anything directly in front of the sensor diodes.
They work by sending an InfraRed beam out of the dark diode which is supposed to bounce off the detected item back to the detector Diode, which changes state when InfraRed comes in the front of it.
Out of the package, they will detect from as little as 8 mm and, with playing with the on the board potentiometer, out to about 40 mm.
They react fast, and in a few tests actually picked up the space between the passing HO cars. Not good. So I decided I would modify the detector, but quickly determined that connecting everything with jumpers and alligator clips was tedious and confusing.
So I made a little test board. It has a place to connect my power supply, a common cathode, type “D” 2 color signal, and a relay to get the trigger from the detector and change the signal. I use a relay, also from eBay, 1 Channel Relay Module 5V Optocoupler LED for Arduino Pic ARM AVR (also on eBay) note that it has the same plug as the detectors.
These are single pole – double throw relay that work with the same voltage as the little detectors. By having several in tandem I can control all sorts of stuff, like killing track power if a switch is set in the wrong direction (called trailing a turnout, by the way) and a train is approaching the error set switch.
Obviously I can turn on road crossing signals, and by leap-frogging the relays, can have a real signal system – where operators go on green only.
As I got into the detectors, I realized that not only the range was a problem, but putting them in some kind of structure so they could “see” a train going by would also be difficult.
As we see in the pictures, the wires and little IR and Detector diodes are really small, and can easily be hidden in a trackside trash-can and maybe a tree stump on the other side of the tracks.
Since I’m planning on having a dozen or so of these detector/relay/signal sets, I also bought some 3 conductor Arduino plugs/connector sets that plug into the board and relay.
The circuit design is:
I found that the relay below is just what I needed to make a tester, but decided for the layout I’d get a bunch on one board, they come up to 16 relays on a board but I ordered a few with 8 relays.
1 Channel Relay Module 5V Optocoupler LED for Arduino Pic ARM AVR:
8 Channel Relay Module 5V Optocoupler LED for Arduino PiC ARM AVR
I wondered if I could remove the IR LED and Detector LED, and if they needed to have a specific wire lead length.
I decided to try to un-solder the IR-LED and Detector LED and extend them on longer wires, this allows for them to be hidden in most anything on the railroad, like in cars waiting at a grade
crossing, or in a little signal box next to a switch.
Some care needs to be taken as the little IR Led and Detector are unsoldered, wires extended, and shrink tubing applied.
Be careful not the lose the polarity. I added about a foot of wire, and 6” to each LED, like below.
Since they face each other now, their mode switched and they send a detect signal until the space between them is blocked, out of the box and mounted side-by-side, they look for reflected IR so they are normally not detecting.
So, how to detect the trains without blinking as the detector “sees” the spaces between the cars?
Decided to shoot the beam on an angle like below:
My signals, most from China, are LED common cathode, so the schematic shown above is how to wire them with that configuration.
If common anode, reverse the + common to the relay and connect the negative to the LED’s.
What I found is that when the IR and Detector are facing each other, the range is really increased. I easily detected a card blocking the beam from more than 6”.
When my test railcar even gets close, the detector hits it and the detector will report “track occupied” to the relay, which turns the signal red.
I’m planning on also having a parallel LED on my control board to also see where my trains are, and what tracks are occupied.
Humm, maybe a detector to see when someone opens my beer fridge would be an ancillary use?
John From Baltimore”
A huge big thanks to John for sharing his Model train IR detector.
Here’s his last post if you want to get up to speed with his layout: Model railroad quarry.
That’s all for today folks.
Please do keep ’em coming.
And if today is the day you get started on your layout, the Beginner’s Guide is here.