Let's Make Robots!

Make your own IR obstacle detection sensor

Detects objects at close range. Can be used for object tracking.
AttachmentSize
OBJECT_TRACKER_.BAS1.24 KB
OBJECT_TRACKER_V1.7.BAS1.89 KB
MPSA13.pdf154.35 KB
MPSA14.pdf43.7 KB

Now with video of the sensor being used as a Mintvelt inspired object tracker! This sensor is a short range obstacle detector with no dead zone. It has a reasonably narrow detection area which can be increased using the dual version. Range can also be increased by increasing the power to the IR LEDs or adding more IR LEDs

The photo below shows my test setup with some IR LED's (dark blue) as a light source and two phototransistors in parallel for the reciever. You could use one of each but I wanted to spread them out to cover a wider area. This setup works like a FritsLDR but with IR. It has a range of about 10-15cm (4-6 inches) with my hand as the object being detected.

I'm only running my LEDs about 20mA. My LEDs are capable of 50mA continuous and some LEDs are capable of 100mA (see "Getting the most from a LED").

I'm using this setup on Junior as a general purpose object advoidance sensor to prevent him backing into anything. I'm getting a good response with less than a volt when my hand is up close and reflecting the IR and over 4.5V with no IR.

IR_amp_closeup.jpg

To get this to work well with an A/D input it needs to have a much lower impedance (needs to let more current through). You can do this with an op-amp but most op-amps like more than 5V and are usually more expensive than my one transistor and three resistors. This is a simple one transistor amplifier that gives my ADC good resolution. Click on the schematic for a larger picture.

IR_sensor_Schematic__small_.jpg

Starting from the left you can see my two IR LEDs with a resistor and transistor in series. The transistor allows the processor to turn the LEDs on or off. This is necessary to tell the difference between the ambiant IR from daylight and indor lighting and the reflected light from the LEDs that indicates the presence of an object.

Next are my two phototransistors in parallel with a 1M resistor in series. You could use only one but I wanted to cover a wider area so my transistors will point in slightly different directions. If either one detects IR it will allow more current to flow. Since volts=current x resistance, even a small increase in current will create a reasonable increase in voltage across the 1M resistor. Unfortunately the low input impedance of many AD converters will act like a small resistor in parallel with the 1M resistor and dramatically reduce the output to the processor. This is where our BC549 transistor comes in to save the day. In conjunction with the 1K and 10K resistors it amplifies the signal so that the analog input on your processor gets a nice strong signal.  The BC549 is not too critical, just about any general purpose signal transistor should do. My transistor had a hfe of 490 when measured with a multimeter. You should probably have a hfe of at least 200-300.

IR_sensor__small_.jpg

As you can see my sensor is made from liberal amounts of hotglue. Click image for a bigger picture. This has the advantage that you can flex the leds and transistors outward to cover a larger area. This is Juniors reversing sensor to prevent him reversing into anything and as such will cover a wide area. I will make single Led/Phototransistor sensors for front left and front right. This will allow him to avoid crashing into obstacles when his rangefinder/object tracker is looking elsewhere.

Note that the phototransistors are slightly forward of the blue LEDs. This helps stop stray light from the LEDs being detected.

 

 

 

 

 

 

Below is the sensor hooked up to Juniors mainboard which has three of my amplifiers built in.

IR_Sensor___Mainboard.jpg

 Using a simple test program that turns on the IR LEDs, stores the value of the ADC, turns off the LEDs, reads the ADC again and then subtracts the stored value from the recent value I was getting readings from 6 to 940. This was with the curtains closed and the lights off. When the reading was 6, my hand was about 300mm (1ft) away. With the lights on the values ranged from about 60 to 940 with a value of 60 being with my hand only about 150mm (6inches) away. Considering the max possible resolution with a 10bit ADC is 0 to 1023, I thought 60-960 with the lights on was a very good result.

After a comment about using sleeves I repeated these test with heatshrink sleeves on the LEDs and phototransistors. The sleeves actually had a negative effect and reduced the range. After I removed the sleeves I did not get the same reduction in range with the lights on. I don't know if it is because during the first test it was daylight outside and the curtains didn't block it all or if it was the way I held the sensor but the second set of test gave an almost identical range of approximately 300mm (12 inches) reguardless of the lights being on or off. I'll have to try again tomorrow when it is daylight again. It seems my initial test was at fault, maybe the way I held the sensor?

IR_Sensor_Single__small_.jpgThis is the single version of the sensor and will cost about half. In the photo you can see the current limiting resistor for the LED. Ignore the value as I had different requirements for Junior. Use the values shown in the schematic.

I've joined the positives together so there is only three wires going back to the mainboard.

Note that the phototransistor is slightly in front of the LED to prevent stray light from the LED being detected.

 

IR_Sensor_Single_2__small_.jpgOnce again I've used hotglue and heatshrink to make it solid and well insulated.

 

 

 

 

 

 

 

 

 

 

 

This is the schematic for the single version. Click on it and the photos for larger images.

IR_single_sensor_Schematic__small_.jpg

Because this sensor only has a single phototransistor it isn't quite as sensitive. To compensate I've increased the current to the LED to almost 50mA which is the maximum continuous current allowed. Because the LED is pulsed on and off this is quite safe and could have been increased to 100mA. The problem with pushing a LED to its limits when controlled by a proccesor is that if a fault occurs in the software then the LED could be destroyed.

When tested, The readings from the ADC of the picaxe ranged from about 100 - 910 reguardless of background lighting. Despite the slightly reduced resolution due to a single phototransistor the range was about 400mm (16inches). This increased range was due to the increased power to the LED.

Make certain your LED and phototransister are parallel to each other for good range.

It was asked how wide is the detection area. Using my hand as the object at a distance of aproximately 300mm (12 inches) from the single sensor the detection area was about 150mm (6 inches) wide. The double sensor can detect a wider area if the phototransistors are spread out at different angles.

Using my hand sideon to the single sensor the detection area was only about 60-70mm (2-3 inches). This is reasonably narrow due to the lenses in the LEDs and the phototransistors.

It should be noted that this is not a linear sensor because the intensity of light from the LEDs is 1 divided by distance squared. In other words, when the object is twice the distance away, the IR from the LEDs is 1/4. As a result, the closer the object, the better the resolution.

This would be a useful sensor to fill in for the dead zone of other IR sensors such as the SHARP GP2D12. To prevent interferance, one should be disabled when using the other.

 


 

As mentioned at the start, I've also experimented with using two of these sensors for a simple object tracker inspired by Mintvelt's "four eyes". This version can't tell the size or distance of an object but can track an object well enough for a robot to recognise a moving object and give chase. Wish I still had a cat, imagine a robot with a waterpistol chasing a cat around the house :

I've attached the code used in the video as well as an improved version (V1.7) that eliminated the servo jitter.

 Object_tracker2__small_.jpg

 

 Good luck and enjoy :)

 


Sunday 4-1-2009

 

This is the latest version of my object tracker as used in SplatBot. I've used 20 IR leds to increase the range. They are limited to 50mA at the moment so that they can't be damaged by faulty code. If I was to push them to their limit then the range could be increased further but they could then be damaged by something like an interupt routine occuring when the LEDs are on.

IR_sensor_array__small_.jpg

This is the schematic.

IR_sensor_array_Schematic__small_.jpg

Click on it for a larger picture. I found with all The LEDs on that the sensors were swamped by reflected IR from my hand even at a distance of about 400mm. The circuit works fine and I definitely get a lot more range but I'm going to have to remove the sensors from the board and mount them seperately so that I can adjust their distance relative to each other to optimise tracking and so I can better shield them from ambiant IR.

This is a work in progress.

 


Updated: 19-1-2009

I've experimented with improving and simplifying the detection circuit. This will give you better range.

IR_obstacle_detector_3_Schematic.jpg

The MPSA13 is a high gain darlington transistor with a hfe of over 5000. If you get the MPSA14 it has about twice the gain. By adjusting the 500 ohm trimpot you should get much better range than the old circuit.

 

 

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Maybe for white objects like your fridge you could try with a second LED but with a color (like bright blue)? Either both at the same time, or one after the other?

(that's just a guess, maybe it won't work at all!)

I grew up with LEGO too, mainly Technic and electric... But I'm still new to robotics. The emitters are turned on during the reading of the left and the right photodiodes or them are drived by a pulse?

Ok, I think your a bit confused by a circuit I drew to help someone with photodiodes. Google "photodiode" for an indepth explanation but basically they need to be reverse bias to work. (put in back the front).

A phototransistor is basically a photodiode and a transistor combined. The advantage is that the transistor amplifies the output of the photodiode. Once again Google is your friend. The subject is too complicated for me to explain here.

When I first put the LEDs and phototransistors side by side, I did experiment with heatshrink around the IR LEDs and phototransistors but found it was unnecessary. The design of both the LEDs and the phototransistors ensure that IR does not go sideways from the LED to the phototransistor.

 

It is important that you read and understand the datasheets for the components you are using. If unsure, plug some components in a breadboard and experiment first as I did.

 

Hey Oddbot,

Did you ever get around to trying your set-up with an opamp? I just grabbed a LM324 out of curiosity and to play with. Just wondering if you have done any tests or have come up with any circuits? I did a little data sheet reading and there is about 400 different circuits you can build with this thing, many of which seem would work for this -do any stick out at you as working better than others? 

Cwignell has given you the answer in your forum.
Yes you can use an op-amp. No fancy circuitry needed. I'll post a circuit this afternoon when I get back from work. I just used the transistors because they were cheaper.

So much to read here. Firstly I am amazed at your laser finder. That is no mean feat to build one.

In regards to Ir detectors. I am wondering at your choice of phototransistor. Have you used the device mintvelt pictures in one of his posts.

The 3 terminal device in black casing with bubble lens(don't know correct name sorry)

Was it price that decided what you used? They are a little rich at $6-50 from jaycar or dick smiths.

That's all I've experimented with so far but it's been "fun" working out the intracacies of using them.

I can't say the range is that good with them, up to about 40cm. Maybe I'm doing something wrong.

Not that I need anymore range than that.
I did not know about the IR range finders when I was experimenting with my laser range finder. I haven't given up on it as it should have better accuracy but I have had trouble getting enough precision with the mechanical and optical setup. I'll try again one day.

i have one of these.......   could it used for the emitter?

thats a pretty good deal of current that those draw. usaually about 50mA x # of LED's.  so about 2.25 amps, even if they run at 25mA its still over an amp. You will need a deep cycle marine battery to use it.

But YES it will work!