Jump to content

Infrared Distance Detection


Recommended Posts

Infrared (IR) position detection has been around for yonks but I was wondering if it might be possible to use it slow a train as it approaches a stop signal based on the distance the train is from the signal. I've run some experiments using cheap IR transmitter/receivers and it looks like it might work. I know there have been some experiments using IR position detectors where the detector bounces IR light back to a detector but this is a bit different.

 

I put an IR "beacon" on the front of the train. Nothing fancy, just a 3mm IR LED fed with constant direct current. The train beacon points straight ahead. There is a trackside IR receiver positioned at the same height as the train beacon offset one inch from the center-line of the track and pointing parallel to the track. The receiver diode is powered from 5 volts and feeds a 10k resistor.

 

The train beacon saturates the receiver at a distance of 7 inches. (Any closer than that actually reduces the light intensity due to the one inch offset.)  I recorded the receiver voltages for one inch increments between 7 inches and 29 inches. It is not "straight-line" linear (it's probably inverse cube) and well within the bounds of computation for a basic micro-controller so I think it should be possible to slow any train fairly realistically as it approaches a signal at danger. I will probably do that by controlling the track voltage on a DC system but if that works it would not be too difficult to do it the other way around and make the train respond to a signal by controlling an on-board throttle either with DCC or radio-control systems.

 

As usual, there are snags. Artificial light from various sources can include some infrared although based on my limited testing that does not seem to be too much of a problem, but it could be a big problem outside in daylight. There are lot's of other possible problems too  :)

Link to post
Share on other sites

Turns out the light intensity at the receiver does just what science says it should. The intensity, represented in this case by the current flowing through a resistor, obeys an inverse square law.  That is to say the intensity is inversely proportional to the square of the distance. Remarkably my measurements actually agree with that :)

 

That makes it fairly simple to compute the rate of change of distance between the train beacon and the signal, in other words the almost instantaneous speed of the train. It's just like having a radar gun pointed at your train (or in your train) except you just need a couple of cheap IR devices instead of an expensive radar gun. Obviously if you can keep determining the speed it's not difficult to slow it down from any speed so that it decelerates smoothly and stops precisely at a signal.

 

The speed detection and control has to work in real time which probably means it is either controlling the section voltage locally or it's controlling the throttle (DCC?) in the train itself.

Link to post
Share on other sites

If you dont mind a transmitter on the front of the loco, there is no reason why this shouldnt work. I daresay the receiver can be mounted further away from the centreline of the transmitter than you did for a test. I think you are saying that as the system is saturated at 7" distance that at that point you lose control of location, so can the system be adjusted so that 100% is never reached? Could be then that you can't detect the loco early enough for a reasonable deceleration.

Link to post
Share on other sites

I think positioning and orientation of the transmitter and receiver will be critical and need to be well controlled across the fleet and around the layout. You allude to this in the drop-off at 7" due to the offset.

Link to post
Share on other sites
15 hours ago, RobinofLoxley said:

If you dont mind a transmitter on the front of the loco, there is no reason why this shouldnt work. I daresay the receiver can be mounted further away from the centreline of the transmitter than you did for a test. I think you are saying that as the system is saturated at 7" distance that at that point you lose control of location, so can the system be adjusted so that 100% is never reached? Could be then that you can't detect the loco early enough for a reasonable deceleration.

 

Strictly speaking you don't completely lose control because the intensity drops off again as the TX passes the RX so I suppose you could take that into account. Personally I wouldn't bother. I'd just assume that saturation was where the train was supposed to come to a dead-stop and position any cosmetic signals and rail breaks accordingly.

 

You probably could offset the TX and RX more but what I'm using seems about right for OO. More offset might introduce more deviation from the 1/s squared relationship but I imagine that would depend on the lenses on the TX and RX. I didn't get the impression that the offset was too critical but I don't have data for other values.

 

The experiment was quite entertaining. For some reason I had got it into my head that the relationship was inverse cube. But when I loaded the values into a spreadsheet it came out looking as if they were inverse square. I thought for a minute I had discovered something new until I did a little more research. Doh!

Link to post
Share on other sites
5 hours ago, Crosland said:

I think positioning and orientation of the transmitter and receiver will be critical and need to be well controlled across the fleet and around the layout. You allude to this in the drop-off at 7" due to the offset.

 

Yes, they would have to be consistent as would the intensity of the beacons and the sensitivity of the receivers. The receivers could be calibrated in software. I was thinking of a basic constant current source for the beacons calibrated for a preset intensity.

 

The offset and orientation do need to be pretty consistent but I got the impression there was a fair bit of leeway and I wasn't expecting millimeter precision. I'd be happy if it was good for plus/minus an inch or so.

Link to post
Share on other sites

Have you looked at the various Heathcote Electronics products, which could possibly be adapted to what you’re after? (No connection except etc ....)

I have their simple IRDOT1, which I use to indicate occupancy on hidden loops. It works well, but better when facing a black background.

Link to post
Share on other sites
On 22/11/2020 at 00:08, ITG said:

Have you looked at the various Heathcote Electronics products, which could possibly be adapted to what you’re after? (No connection except etc ....)

I have their simple IRDOT1, which I use to indicate occupancy on hidden loops. It works well, but better when facing a black background.

 

Thanks, yes I have. Unfortunately I don't think that lets me determine the distance from an approaching train. I would like to be able to slow a train as it approaches a stop signal regardless of the train's speed.

 

 

Link to post
Share on other sites
6 hours ago, Theakerr said:

How do you intend to control the train speed (voltage)?  I have something similar to your proposal for a station stop module I have built but after doing much research I had to use an electro-mechanical system.

 

A microcontroller will be associated with each IR receiver and it will control the track voltage at that section. It will calculate the acceleration required to stop at the signal and continuously adjust the voltage to maintain the required (negative) acceleration.

 

I'll use an ATTiny44A micro and use a PWM output to control a voltage regulator.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.