How to use infrared receiver sensors for collision avoidance

**Great tutorial! **

Great tutorial! This is a easy, cheap, and useful sensor that should get more mention.

If anyone is interested they can see videos of my Boe-Bot running with Dual IR Proximity Sensors here. I have an example running a course with fixed distance and following my hand using multiple modulation frequencies. The Boe-bot text is an awesome resource, and I like that you went through it with an AVR =)

Thank you very much fro

Thank you very much for writing this. I was sub-consicously looking for that. I just want to point out that some people just love the Ping or Sharp sensor`s look. Their look is sorta cute but I agree that home-made IR rangefinders look more hardcore. Thanks again!

Great, added to [to do

Great, added to [to do list].

I will try with a 555 as emitterā€¦ Adjusting the range by changing the duty cycle or the frequency.

Thanks a lot!

Make your own!

My robot works also great with itā€™s homemade IR sensor. I really recommended to make your own instead of buying an expensive sharp one. If anyone is interested I can share my Picbasic codeā€¦

Be sure the receiver canā€™t see the IR light directly. Place a (metal/black) barrier between them or put a piece of shrink tube around the led.(also makes the IR beam narrower)

Another tip is to place the led more on the front and the receiver little more back. As the IR light also will shines through the back of the receiver.

Eureka!

My sensor is done!

The soldering is crap but it works!

It works great! Thnk you soooo much!

you just made my day :slight_smile: I

you just made my day :slight_smile: I was looking for a simple cliff detaction sensor form my new project. Sharp is good but to big and i really donā€™t need to know the distance. Well done!

Thanks! Stuff to learn aboutā€¦

Hey Thanks,Ā Ro-Bot-X

Not only a good How-To but a good Why-it-Works. Ā 

Not to get too Spamish, but you can make 5 of these for $3 with these:

http://arduino-direct.com/sunshop/index.php?l=product_detail&p=208

http://arduino-direct.com/sunshop/index.php?l=product_detail&p=210

And LMR members get 5%plus5% to the site if you sign up and send an email to me; [email protected]

Iā€™ll do some experiments with thisā€¦Ā 

Great writeup job. Ā LMR may be collaborating in WIKI stuff and this could all end up where people can find itā€¦ For now, my How-To stuff is here:Ā http://arduino-direct.com/sunshop/index.php?l=product_detail&p=210

Regards, Terry

Ā 

Wow Terry, you have good

Wow Terry, you have good prices for the IR LEDs and receivers. I need to order a pack to do some tests and come up with a little boardā€¦ I am already in the process of designing a board that can be mounted on a servo with a single sensor and another that can be used either separate or as a shield on Arduino, but tests must be done first.

Hey, I was just sketching on

Hey, I was just sketching on the ā€œservo-pointed-sensorā€ stuff. Ā I would like a simple easy-to-reproduce design that uses a small servor to rotate sensors (Ultrasonic and IR) over 360 degrees. Some cool but expensive robots use a gear system or a continuous-rotation servo with limit switches. Ā 

How about the sensor block sits atop a pencil-sized vertical shaft and the servo arms push and pull on a thin cord wrapped around the shaft and permanently attached at one pint so it doesnā€™t ā€˜creepā€™.

These sensors donā€™t have real sharp horizontal resolution and reasonable accuracy is fine.

I bet someone has done this. Pointers? Comments?

I want a design that I can show that anyone with real simple materials and a trip to the hardware store or Fa Da Te (DIY in Italian) can make.Ā 

I bet the 38 KHz IR could be made pretty sharp resolution with a simple lens and slit, though.Ā 

Ā 

Ā 

Ā 

Ā 

Receiver vs Phototransistor

I understand that because these receivers are only looking for IR light modulated at 38 KHz they are less susceptible to outside interference. I was wondering if there are also other advantages over a plain old IR Phototransistors like used in Mr Generalā€™s Compound Eye or a QRD1114 Ā 

The IR phototransistors work

The IR phototransistors work at short distances. The IR demodulators work as far as 8 feet. All you need to get such a great distance is a powerful IR LED. Since the LED is pulsated for short times, you can have a very low resistance in series or even none and the LED will survive and will give up lots of light. At close distances you can make the pulse bursts less than 10 miliseconds, but at long distances itā€™s a must. Make sure youā€™re using 5mm LEDs not 3mm for long distances. I was experimenting with both sizes and saw a big difference with the same 220 ohm resistor in series with both.

Thank you

Thank you

Great Post, Exactly What I Was Looking For, Butā€¦

Ro-Bot-X,

Ā Ā  Thanks for a great post!Ā  This is exactly what Iā€™ve been looking for.Ā  I ran out and grabbed one of these sensors from the dreaded ā€œShackā€ to try it out.Ā  I hooded my IR LED with some shrink wrap and set it forward of the sensor.Ā  I get about 8 inches for 38 kHz at 5V.Ā  I tried varying the duty cycle, but I didnā€™t see much difference in the sensitivity.Ā  Then, I tried to change the period.Ā  At 34 kHz and at 44 kHz, I get no reaction at 50% duty cycle.Ā  Is it just a matter of aligning the emitter and receiver?Ā  I was hoping to take readings at various period lengths to determine distance.Ā  Iā€™d love to have the sensor trigger at 4-5 cm and another sensor to trigger at 7-8 cm.Ā  Any help appreciated.

Thanks!

EDIT:

Ā Ā  I may have my problem.Ā  I see that your code includes a delay between write/reads:

void loop(){
Ā  IR38Write();
Ā  if (digitalRead(IRsensorPin)==LOW){
Ā  Ā  digitalWrite(D13ledPin, HIGH);
Ā  } else {
Ā  Ā  digitalWrite(D13ledPin, LOW);
Ā  }
Ā  delay(100);
}
Ā  How long is ā€œdelay(100)ā€ ?Ā 

little mistake.

In the circuit above the servoā€™s black wire is connected to + instead of -

IR Compound Eye updating??

Anyone have one of these and working on updating to 38KHz operation??

I have some coming from Dagu, but will take a while to get here from YourDuino.com to me in Italy. Ā I think they will sell for about $10 in the LMR shop. Maybe we can all figure out an easy way to upgrade these to 38KHz and longer distancesā€¦ they certainly have lots of LEDsā€¦ Ā  Ā Hereā€™s the schematic. Ā Looks like it wouldnā€™t be that hard to update it for 38KHz.Ā 

We have the receivers here:Ā http://arduino-direct.com/sunshop/index.php?l=product_detail&p=210

Wire into anything with a piece of this:Ā http://arduino-direct.com/sunshop/index.php?l=product_detail&p=185

Anybody have time to try this out??Ā 

Ā 

Regards, Terry King

...On the Mediterranean in Italy

[email protected]

Ā 

Thanks for trying out this

Thanks for trying out this sensor. I think some sensors (different manufacturers) may be less sensitive than others. The Panasonic PNA4601M sensor definitely behaves this way. I have an old TSOP4838 that also works, but there are many TSOP sensors that work at 38kHz and are not sensitive to other frequencies. To get 35.7kHz you have to set delayMicroseconds(14) in the IR38Write function, to get 41.6kHz set delayMicroseconds(12). Sensor alignment should not matter, because the LED emits a cone of light and the receiver also has a detection cone. More importantly is Ā to use a light color material as the object when testing (white paper for example).Ā 

Oh, and the delay() function in Arduino expects miliseconds as argument. 100 miliseconds is just to have a break between sensor measurements.

Ā 

I guess youā€™re right, I

I guess youā€™re right, I moved the servo a bit and the wire moved with it and I didnā€™t check back. Thanks for noticing, Iā€™ll fix it.

Does a TSOP 4838 work with the code above?

Hello Everyone!

Ā Ā  My question is regarding the code above. Has it been verified to work with a TSOP 4838 38KHz receiver? Or has any one tried it and was successful? If itā€™s verified to work with a 4838, then if anyone can please point me to the right directionā€¦ I have two IR receivers on hand; one is a 4838 and another one is a PNA4602m I salvaged from a broken toy. The 4602m works just fine with the code and circuit specified above but the 4838 doesnā€™t. I might be missing somethingā€¦ I just bought the 4838 off Ebay, Im beginning to think itā€™s defective since the 4602 works perfect. I tried different alterations on the code and the circuit like changing the half cycle delay lower and higher; or changing the supply voltage/resistance from the minimum to maximum based on the 4838ā€™s datasheet. Any opinion or comment is very welcome. Thanks in advance! : )

Ā 

It should work with

It should work with TSOP4838, Iā€™ve tested it some time ago. There are 2 things that might not let it work. First, the length of the burst pulse, in the code I used 10ms, perhaps you can shorten it to about 2-3ms. Also, the receiver may need to be shielded from reflected IR light going out from the back of the LEDs or it will switch to low regardless if there is an object in front or not. If the receiver does not switch to low at all, it may be defective.

Thanks

Thanks for the tips. It seems that it is defective or I got the wrong part. I checked the impedance accross pins 1 and 3; I should be getting 30Kohms according to the datasheet, Iā€™m reading close to 100K. I tried shortening the burst length to 2 and 3ms (int i = 0; i <= 115; i++) and (int i = 0; i <= 77; i++), still no response from the receiver (doesnā€™t go low). Iā€™ll try to get another one and give that seller a - feedback if he doesnā€™t do something about it. : )