# IR detection ?



## gregc (Apr 25, 2015)

rather than hijack the thread on "computer controlled" layouts, i thought i would create a separate thread discuss IR detection

i know that reflective IR position sensors are available: CKT-IRSENSE. I'm unwilling to make such an investment.

i recently completed a signaling system using what I call "paired-detection" using two 3mm IR photo-transistor embedded between the HO ties about 5 ties apart at the block boundaries to detect a train enter/exiting a block. I know this is not sophisticated enough for some modelers.

my detector circuit is an IR photo-transistors tied to 5V thru a 470k resistor and the collector to an Arduino analog input. 

I learned that an incandescent ceiling lamp is a good source for IR while compact fluorescent and LED bulbs are not. My signaling won't work in the dark.

i was unsuccessful trying reflected IR detection by putting an IR LED between the ties as well. I realized that this is a problem with daylight flooding the room. (I probably wouldn't have had a problem if my layout was in the basement.

I also investigated IR detectors designed for TV remotes that use modulated (38 kHz) emitters. I discovered that the detectors have additional circuitry that both filters the signal for the modulated frequency as well as having an automatic gain control (AGC) to adjust to room light conditions. (My assessment is that they will work in bright sunshine but can work over longer distances at night).

modulated IR sensors are sensitive on the side of the housing, not the end like most LEDs and photo transistors, making it difficult to mount between ties. They are also a few $ each while an IR photo transistor is $0.10. (still too expensive for me)


i'd still like to figure out how to use inexpensive IR photo transistors, using software. My guess is that the CKT-IRSENSE does not use modulated IR detectors.


one advantage of using the analog input is that the detection thresholds (hysterisis) can be adaptive, presumably based on environment at time of use.

i haven't tried making measurements both with the IR emiiter off and on, using the measurement with the emitter off as a baseline/theshold and for a level above that when the emitter is on.

another thing i haven't tried is driving the emitter with a larger current. The max current of the TSAL7400 IR LEDs i have is 100 ma. I'm sure I have not come close to that value (~30 ohm resistor). And even if I did, i don't think i would want to drive them continuously at that current (1A for 10 LEDs).

So pulsing them on, just during a short period during which the ADC is measured seems appropriate and minimize average current draw


I'd appreciate hearing how others have successfully used simple IR photo-transistors and LED emitters in bright daylight conditions. I'd like to experiment with them in applications other than signaling, such as both vertical and across track position sensing.

thanks.


----------



## J.C. (Dec 24, 2016)

I do something similar with LDR's (photo cells) to either turn a LED on or off depending on the application .


----------



## wvgca (Jan 21, 2013)

just out of curiosity, what are you using for the pulse frequencey, ie: time on / off


----------



## gregc (Apr 25, 2015)

wvgca said:


> just out of curiosity, what are you using for the pulse frequencey, ie: time on / off


is it a frequency or just momentary turning on the emitter whenever a measurement is made?

measurements probably don't have to be made more often than every second. I'm not sure how long the on period is: turn on, measure, turn off.

and before/after, make a measurement w/o the emitter on to determine a threshold.


----------



## fcwilt (Sep 27, 2013)

Hi,

I had Azatrax (http://www.azatrax.com/ir-model-train-detector.html) make me some custom MRD8 units with the default timing altered to be better suited to locating the gaps between cars.

I would be glad to gift you one since I'm not using them.

Frederick


----------



## gregc (Apr 25, 2015)

fcwilt said:


> I would be glad to gift you one since I'm not using them.


Frederick,
wow
thanks you, that's very nice of you to offer.

just identifying the device helps me understand how such a circuit works. Looking over their web page and instructions I noticed that it requires 40 ma. which suggests the max current thru the emitter.

would you mind contacting me thru a private message?


----------



## Waddy (Dec 18, 2014)

I've used these with no problems. I place them about mid-level with car height and at a diagonal to each other (not directly across from each other).

https://www.ebay.com/itm/I16-2-mode...e=STRK:MEBIDX:IT&_trksid=p2055119.m1438.l2649


----------



## gregc (Apr 25, 2015)

after evaluating a commercial unit, it appears that there are at least two tricks

one is to shield (e.g. heat shrink) both the emitter and sensor (photo transistor) to minimize the sensor aperture and sensitivity to background light (day light).

a second trick is to measure the sensor input (using analog ADC input) with emitter disabled to determine a threshold for determining if the sensor is detecting IR light from the emitter.


----------



## fcwilt (Sep 27, 2013)

gregc said:


> after evaluating a commercial unit, it appears that there are at least two tricks
> 
> one is to shield (e.g. heat shrink) both the emitter and sensor (photo transistor) to minimize the sensor aperture and sensitivity to background light (day light).
> 
> a second trick is to measure the sensor input (using analog ADC input) with emitter disabled to determine a threshold for determining if the sensor is detecting IR light from the emitter.


As I mentioned my emitter/sensor pairs are mounted side-by-side in the gap between two ties, facing up, reflecting off the bottom of the locos/cars.

The room is illuminated with can lights in the ceiling (LED flood bulbs).

You can see the heatshrink applied to both.

There have been no problems with detection regardless of room light conditions.

Frederick


----------

