Let's Make Robots!

IR v. Sonar

I've been making plan for an obstacle-avoiding robot, and was originally planning to use a Sharp IR range finder for it (10 - 80cm), but after seeing other sonar range finders, and other people's projects (the majority of the ones I see seem to use sonar), I was wondering:

Which is better: IR or sonar?

'Cos IR recievers can be affected by ambient IR light, and the best i;ve seen goes up to 150cm, whereas I;ve seen sonar ones up to 7.4m, roundabout, and they can't be affected by ambient sound (I think).

So, which would be better? Is that mainly just determined by budget and distance?


Also, do they work the same, in that a greater distance returns a lower analog value, and a lesser distance returns a greater analog value (or something along those lines)?

Comment viewing options

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

What exactly do you mean by cone shapes? Is that referring to the beam width?

'Cos when I was looking up sonar sensors earilier, and when I looked up IR ones, I cam across charts like this (comparison chart of sonar sensors): http://www.pololu.com/picture/view/0J1969

What do these charts mean? I've never really understood them

And thanks for answers so far

Those are the cones for different models in the first 2 columns. It tells you how wide the detection area is at different distances. The 3rd column is showing you how many false readings you get.

Getting a cheap sensor and hooking it up to an Arduino (or other uC) and having it spit out readings to a serial port will teach you far more about them than i can tell you in a forum. The "ping" sample for Arduino works great with the ultrasound and I found an IR one in a forum post at arduino.cc.


Ok, thanks for that. So for example at distance x, the beam has a width of y, and would reflect back (in theory) from an object in that width.

I will test a couple of sensors with that, I just wanted a bit of advice as I do not actually have a sonar sensor or an analog sensor yet.


For most practical uses, light has a bean width that is fixed for the whole range while ultrasound spreads out as it gets further away, causing a cone shape instead of a beam. I am not sure I have this right, but I think they narrow the ultrasound cone by putting the receptor in a fixture that has to be hit almost dead on to receive. I am testing narrow beam ones with a decent range (HC-SR04) and I am still concerned about avoiding things that aren't in the way but are in the cone.

I will offer some up anyway.

IR seems to be preferred at small distances while the sweet spot for ultrasound is a little further out.

Ultrasound has various cone shapes available (wide versus narrow) and IR pretty much needs to be a beam to be practical in a low power system.

I am sitting here playing with both, just by chance, and the next statement may be more about what I specifically have - ultrasound seems to have more wrong but reasonable readings that IR. What I mean is that they both occasionally give a reading that is wrong, but the IR usually seems to get it right or so far wrong you know to ignore it. the ultrasound will give some wrong readings that are within its normal range. It will not be too hard to filter them out.

Both have a hard time with fabric, but I think IR has an edge. Neither is failing totally on my blue cotton shirt, but I am getting a lot of false readings from both.

I just tested a couple of digital Sharp range finders ( http://www.littlebirdelectronics.com/products/Sharp-GP2Y0D805Z0F-Digital-Distance-Sensor-5cm.html ) and while in the site description it says they will return a logical 0 if an object is from 5cm to 0.5cm away, and if not return a logical 1.

I have noticed a few slight issues these things have:

1. They only work if the object is perfectly parallel to the diode face, and thus perpendicular to the beam

2. With shiny, reflective objects (eg. a CD) they work well (assuming issue 1 is satisfied), returning a 0 if object is in specified range

However, 3. if the object is not that shiny (eg. a book) it will only return a 0 if the object is at exactly  5cm away, and no other distance. Or it just simply won't work at all.

Can I assume analog ones work better than this?

BTW, I hate that they call those "range finders". I think they are proximity (is something nearby) sensors, as opposed to distance (how far away) sensors. And to pick a nit, there are some digital distance sensors, though I suspect all they are doing is reading the analog signal and transmitting the value on a serial line.


That link isn't the exact page I remember seeing, but, it will suffice and show you something you may not have known otherwise.

Yes. I would look at these:


what I am testing is a knock off of the middle one.