I am trying to make a simple IR detector

jpanhalt

Joined Jan 18, 2008
11,087
Is there anyone you could partner with on the MCU programming? It really is not very complicated as programming goes -- just like flashing LED's but with a certain pattern.
 

AlbertHall

Joined Jun 4, 2014
12,344
Can you make and/or assemble a PCB as there will be some harware needed as well?
In comparison there is much less work involved in programming a micro than in making the board for it go on.
 

Hymie

Joined Mar 30, 2018
1,277
I would like the module to detect a train passing over a IR sensor, and set a LED to Red, then to wait 2 Seconds and then reset the LED to Green, and then wait for the next train.

The simplest way of achieving the above would be to use an IR detector that incorporates both the transmitter and detector is a single module (detecting the reflected signal from the passing train). The negative going pulse from the detector is then fed to the trigger of a 555 timer (with a mono-stable time period of 2 seconds). The red LED would be powered from the positive rail to the 555 timer output and the green LED powered from the 555 timer output and 0V.

The advantage of the above is that the IR sensor could be mounted beneath the track, detecting the train passing above – if necessary an IR reflective material could be stuck to the underside of the model train.
 

djsfantasi

Joined Apr 11, 2010
9,156
I would like the module to detect a train passing over a IR sensor, and set a LED to Red, then to wait 2 Seconds and then reset the LED to Green, and then wait for the next train.

The simplest way of achieving the above would be to use an IR detector that incorporates both the transmitter and detector is a single module (detecting the reflected signal from the passing train). The negative going pulse from the detector is then fed to the trigger of a 555 timer (with a mono-stable time period of 2 seconds). The red LED would be powered from the positive rail to the 555 timer output and the green LED powered from the 555 timer output and 0V.

The advantage of the above is that the IR sensor could be mounted beneath the track, detecting the train passing above – if necessary an IR reflective material could be stuck to the underside of the model train.
SparkFun makes one such component. Here is a LINK to it. They fit between N Scale rails. I use them on my model railroad.
 

Reloadron

Joined Jan 15, 2015
7,501
SparkFun makes one such component. Here is a LINK to it. They fit between N Scale rails. I use them on my model railroad.
I was originally going to suggest one of these or similar but all things considered at about $1.00 USD each I would run with the above suggestion. Since it begins with a sensor I would just use a reflective optical switch as suggested. Now what you do with the sensor signal is up to you and where you feel comfortable. Using discreet components there is as mentioned the 555 timer chip where the sensor triggers the timer and the timer goes from a green LED to a red LED for two seconds. You determine the time duration with a few component values. One sensor and one chip per LED pair. The same sensor could also just as easily be paired with a uC (Micro-Controller) be it an Arduino or any number of others available. Nice feature is easily programmed for what you want and a single uC could likely handle several sensors reducing your overall parts count and cost. Either method will get you what you want, just different steps involved getting there. You can buy modules pre made with 555 timer chips or uC chips so that reduces your need to fabricate from scratch. Sort of turn key solutions. :) Really comes down to what works for you?

Ron
 

Bernard

Joined Aug 7, 2008
5,784
If the transmitting IR LED were mounted under the engine or a car, then with 2 detectors between the rails there would be directional data and only one signal per passing train.
 

Thread Starter

AllisonAmg

Joined May 18, 2020
71
Can you make and/or assemble a PCB as there will be some harware needed as well?
In comparison there is much less work involved in programming a micro than in making the board for it go on.
I have veroboard
If the transmitting IR LED were mounted under the engine or a car, then with 2 detectors between the rails there would be directional data and only one signal per passing train.
Thats a great idea.... makes the detection algorythm a lot easier
 

Reloadron

Joined Jan 15, 2015
7,501
Yes, i would angle the sensor to catch the bounce off the loco
Most sensors like this for example are already angled. So rather than a single sensor you simply mount two. Depending on train direction one will trigger first then the second so it becomes easy to get direction. If Sens_A triggers before Sens_B the train is going this way and if Sens_B triggers before Sens_A the train is going the other way. :)

Again just as in a single direction this can be done using discrete components or a micro controller. Discreet component likely a quad-nand gate (SN7400 or similar). That or just about any uC and the sort of programming you would need is hardly a monumental task. Most of it could likely be cobbled together from online samples. Goes back to your choice and if you really want to know direction. Either way detecting or determing direction is not a problem or all that difficult.

Ron
 

Thread Starter

AllisonAmg

Joined May 18, 2020
71
Most sensors like this for example are already angled. So rather than a single sensor you simply mount two. Depending on train direction one will trigger first then the second so it becomes easy to get direction. If Sens_A triggers before Sens_B the train is going this way and if Sens_B triggers before Sens_A the train is going the other way. :)

Again just as in a single direction this can be done using discrete components or a micro controller. Discreet component likely a quad-nand gate (SN7400 or similar). That or just about any uC and the sort of programming you would need is hardly a monumental task. Most of it could likely be cobbled together from online samples. Goes back to your choice and if you really want to know direction. Either way detecting or determing direction is not a problem or all that difficult.

Ron
I like those.... but i cant find anyone who stocks them...... couldnt i just use a photo diode and a IR led ?
 
There is a reflective object sensor. Then there are inductive and capacitive proximity sensors. All three COULD work from the bottom. IR sensor pairs mounted in a "C-shaped" housing, I've seen about an inch apart.

If you wanted to detect a train with a beam block, ttray light must be minimized or you have to modulate the detector like the ones for remote controls made by Vishay.

You have to create the 38 kHz carrier, typically and modulate it and do missing pulse detecction.

The last method likely has the most realizm to it because it's smaller and less obtrusive.
 
Last edited:

Thread Starter

AllisonAmg

Joined May 18, 2020
71
I like those.... but i cant find anyone who stocks them...... couldnt i just use a photo diode and a IR led ?
I like those.... but i cant find anyone who stocks them...... couldnt i just use a photo diode and a IR led ?
Most sensors like this for example are already angled. So rather than a single sensor you simply mount two. Depending on train direction one will trigger first then the second so it becomes easy to get direction. If Sens_A triggers before Sens_B the train is going this way and if Sens_B triggers before Sens_A the train is going the other way. :)

Again just as in a single direction this can be done using discrete components or a micro controller. Discreet component likely a quad-nand gate (SN7400 or similar). That or just about any uC and the sort of programming you would need is hardly a monumental task. Most of it could likely be cobbled together from online samples. Goes back to your choice and if you really want to know direction. Either way detecting or determing direction is not a problem or all that difficult.

Ron
would this do instead https://uk.farnell.com/on-semicondu...OPPING-sensors-transducers-NEWSTRUCTURE-20APR
 

jpanhalt

Joined Jan 18, 2008
11,087
Hi,

Search on "IR reflective sensor" with your favorite distributor. RadioShack used to sell an ancient one. Here is a Digikey search: https://www.digikey.com/products/en/sensors-transducers/optical-sensors-reflective-logic-output/556?utm_adgroup=Sensors & Transducers&utm_source=google&utm_medium=cpc&utm_campaign=Dynamic Search&utm_term=&utm_content=Sensors & Transducers&gclid=EAIaIQobChMI6szQj9_A6QIVUr7ACh0wVgUaEAAYASAAEgJN6PD_BwE.

I show the whole one. Click on Sharp to get a more limited set. Sharp, Sony, Vishay are big names in the field.

I am reluctant to ask where you are, as it doesn't matter to me, but it might make a difference for recommending sources. Are you in the North America or Europe?
 
Top