Range-finding ultrasonic / infrared

What's the best (cheapest, quickest, easiest) way to detect obstacles for a small robot? The book I have starts with infrared, and later replaces them with ultrasonic. Infrared is way cheaper, but I don't full understand how it works..

I've got some phototransistors here, that seem to work exaclty like LDRs, they just change the resistance with the light - except they also work with infrared (as well as normal light). I've seen infrared LEDs, and infrared phototransistors - am I right in thinking these are simple filtered to only detect IR, instead of normal light?

Would these be accurate enough to be able to get a range, or would it simple be a yes/no if something's there? Ideally, I want to be able to detect a) if there's anything within, say, 6 inches, and also if there's anything within, say, 3 inches. That way, as things get near, I'll start turning my robot, but if it doesn't turn quick enough, it'll increase the turn when it gets closer.

Thanks,

--
Danny
Reply to
Danny T
Loading thread data ...

You can buy units that are designed as IR distance sensors. They give you either a voltage (which you can read with the comparator or a/d) or a binary output. The Sharp GP2D120 comes to mind. Here is a datasheet:

formatting link

You can get them at the various robotics webstores. However, they are cheaper at Arrow electronics. Make sure you get some JST connectors, because they are a bit difficult to run without them. Acroname sells them with the connectors and wires for $12.50 plus shipping:

formatting link

I've built robots with these before, and they work pretty well. One issue they have is that they are *really* directional. This is an issue when you are trying to detect obstacles, and mounting becomes critical. That is one thing to say for ultrasonics.

You can also just use a bump sensor, like the roomba.

formatting link

--
Regards,
   Robert Monsen

"Your Highness, I have no need of this hypothesis."
     - Pierre Laplace (1749-1827), to Napoleon,
        on why his works on celestial mechanics make no mention of God.
Reply to
Robert Monsen

Sounds good, but Acroname don't have visible shipping costs for the UK! Cheapest I've found here is:

formatting link

But I'll have a look around. I'll probably need 2 or 3, but looks like they'll do the job! :)

There's something more elegant about a robot that moves around without hitting things... Imagine seeing people walking around an office by bumping off walls ;-)

--
Danny
Reply to
Danny T

Unfortunately, it would be like trying to navigate with tunnel vision. All you can tell is the distance to something, nothing else. That makes it difficult to build mental models of what's out there. Robots without vision processing are somewhat like flatlanders, living in a 2d world of walls. They tend to crash into walls, chair legs, and feet even with the IR sensors. Thus, bump sensors are fairly important for keeping the robot from getting stuck.

One thing that is often done is to to measure the current through the motors. That way, you can use a sudden increase as a signal that you've hit something, and the motor has stalled. I was watching a roomba a few days ago, and it appears to use that strategy. It was trying to climb onto a persian rug that was too high for it, but which was lower than it's bump sensor. It got a bit onto it, but then got stuck, noticed this, and backed off. Not too bad. It also has wheels that can bob up and down, which helps with this kind of thing.

You can notice increasing current by using a small (like a 1 ohm) resistor, in series with the motor, and by watching the voltage across it. By smoothing out the voltage spikes with a filter, you can keep track of the general trend of current. If it goes beyond a certain point, you are pretty sure that the motor is stalling.

Unfortunately, with your driver circuit, you don't have the ability to back up. For that, you need a way to reverse the current through the motor. That is often done with an H-Bridge (or a 1/2 H). There are dedicated chips to handle this kind of thing (see the texas instruments SN754410, for example). You can also control the speed using PWM, which just means turning it on and off, and adjusting the amount of time it's on to control the speed of the motor. 'PWM' stands for Pulse Width Modulation. Some new PIC 16F chips have PWM built in, but only a single channel, which means you need two processors, working in tandem, to use this feature (which is pretty much useless). However, doing PWM in an interrupt routine is almost trivial, if the frequency is low.

--
Regards,
   Robert Monsen

"Your Highness, I have no need of this hypothesis."
     - Pierre Laplace (1749-1827), to Napoleon,
        on why his works on celestial mechanics make no mention of God.
Reply to
Robert Monsen

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.