Model Train-related Notes (a.k.a. “blog”) -- these are personal notes and musings on the subject of model train control, automation, electronics, or whatever I find interesting.

2016-12-01 - IR Sensors

Category Train

To detect trains on the branchline, I experimented with using IR reflective sensors instead of block detectors. These have the advantage that they are inexpensive and can be connected directly to an NCE AIU01 board.

The original idea was to embed the sensors in the track bed. The sensors are fairly small and fit nicely between ties. The one chosen have a detection range of 2-15 mm, which would be ideal to detect when an engine truck passes over the sensor.

The IR reflective sensor used are TCRT5000. The Vishay spec can be found here.

This model is nothing more than 2 separate "LEDs" stuck together in a flimsy small plastic shell. They can be easily removed from the plastic shell and mounted in the track flush with the ties, pointing upwards (technically one LED is an emitter and the other is a receiver so calling it a LED is abusing the term, although it may look like one).

The photodetector on the TCRT5000 varies its current based on the amount of light received. No light, no current; lots of light, more current. The amount of light that bounces and the collector current depends on the distance between the detector and the object. The nominal distance is 2 millimeters and experimentation showed that I could get away with much more.

One of the LED is an emitter and needs to be powered by 5 V and a resistor (to limit and adjust the current). The other side is a phototransistor, NPN type.

How is the IR sensor going to connect to the NCE AIU?

This is how I use the IR sensors with an Arduino using the internal pull-up and next to it is the AIU input circuitry:

 

There's a good match here: connecting the IR receiver collector to the 5V/pull-up side of the AIU should do exactly what we want with the AIU input driven low when an IR reflection occurs.

We need a 5 V source and there again the NCE AIU is a perfect match. It has a 7805 voltage regulator on board that generates 5 V from the cab bus, which we can directly tap into. There is no pin output with that 5 V but it's easy to solder one from the 5 V bus anywhere on the output side of the 7805.

Pros:

  • As planned, they are easily hidden between ties.
  • Current usage is reasonable enough to tap it from the NCE AIU01's 5V supply.
  • Data sheet indicates that in reflective mode, distance is ideally up to 2-15 mm. That does not seem to be a problem when the reflective surface is a truck or tank, assuming the surface is reflective to IR.

This works with the given issues:

  • Bottom black plastic on engines is not reflective enough.
  • Some gray plastic work, others seem to not be too efficient.
  • One workaround is placing some kind of reflective tape or paint under the engines. Good success using ducting metallic tape under the engine's tank.
  • However they don't trigger long enough. E.g. a strip of 2 inches will trigger for about 1 second as the engine moves, which might not be enough to be detected in time. Too much potential for NCE or JMRI to miss it depending on their own scan timing.
  • The length will depend on the shape of the engine's under body.

Other solutions to try:

  • 2- Run it in "face to face" instead of bouncing mode. Experimental test show that distance can be around up to 7 cm that way. Sideways, distance was about 2 cm max.
    • Idea is to have a relay box on the side modified with the emitter pointing to the track. Initial tests show that the receiver would have to be mounted slanted towards the emitter, not straight up and proper alignment is going to be tricky.
    • The sensor will work in "reverse", being on when not occupied and off when occupied.

  • 3- Use multiple emitters mounted between ties to get a more powerful illumination.
    • Will ruin the "stealth" mode, may look bulky.
  • 4- Use another IR sensor with a more powerful emitter.
  • 5- Find an IR flood lamp matching the receiver's bandwidth and place it on top of the layout, pointing down.
    • According to the Vishay specs, "Emitter wavelength: 950 nm" with a daylight blocker on the receiver.
  • 6- Make the signal turn on “longer” for the NCE AIU, either by using some kind of RC circuit or a 555 in single shot mode or some Arduino contraption.


 Generated on 2019-11-03 by Rig4j 0.1-Exp-febf662