Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Wall Following Sensor, variable voltage to IR LED.

Status
Not open for further replies.

3v0

Coop Build Coordinator
Forum Supporter
This afternoon I have been thinking about a wall following sensor to help a robot navigate a maze. They are popular in the robot vacuum cleaners but not so much elsewhere.

For the purpose of discussion the robot wil run in a maze with paths up to 10 inches wide. I want to point a narrow beam IR LED at the wall next to the robot. If the robot is parallel to the wall the beam will come back as a uniform cone. Reflected cone size will indicate the distance from the wall. When the robot is crooked the beam will be distorted. This will be detected by a line of photo-transistors ahead of and behind the emitter.

I can get about 9 photo-transistors to an inch and more if I stagger them. It is my hope that about 10 on each side of the emitter will be enough.

The problem that is bugging me is that I need the uC to control the voltage going to the IR LED in addition to modulating it at 40KHz. Let the computer pick the intensity that works best.

The first thing that comes to mind is to PWM the high part of the 40KHz, use a capacitor to smooth out the voltage. Can this work or is it too choppy.

A digital pot could be used if one could be found that handled the current (should not be a problem) and the correct resistance range. The smallest resistance pots from microchip are about 0 to 5K.

Maybe use a digital pot with an opamp. If it was setup right once could have all the pots steps in a useful range.

Suggestions?
 
What about using two of them and comparing the distances returned? That should give both the distance and the angle, assuming the resolution is good enough.

I don't know how that compares in terms of final part count and cost, though.


Torben
 
If you PWM the high side of the 40 KHz, the peak output won't change. This might make PWM less effective than it would initialy seem. I would use a digital pot or just resistor ladder as the control element in a single-transistor current source.

When the bot is crooked, you might not get what you expect. The cones of the detectors will point in the same direction as the emitter. Draw some pictures and you'll see what I mean.
 
Unless you're using 40 KHz filtered sensors, why are you modulating the LED at 40 KHz? If it's just to save power, remember you only need to light up the LED when you want to take a reading.
 
mneary said:
Unless you're using 40 KHz filtered sensors, why are you modulating the LED at 40 KHz? If it's just to save power, remember you only need to light up the LED when you want to take a reading.

No receiver, just plane Jane photo transistors. I was planing to use the 40KHz to reject stray light. Thinking I can get by without it?

Maybe the first post was too long and is not getting read.

There is a line of photo transistors about 3 inches long with a single IR LED in the center. When the IR beam strikes the wall it bounces back and hits the photo transistors.

If the robot is not crooked the same number of detectors on each side of the LED will be illuminated.

If the robot is crooked the line of photo transistors nearest the wall will have fewer illuminated. More on the end further from the wall.

Even the short version is long.
 
40 KHz alone won't reject stray light. You'll need to do something active to subtract out the ambient. At 40 KHz this will be difficult without active filters (like in the typical 3-wire IR sensor package.) If you measure ambient of all your photo detectors and then measure again with the LED on, the comparison will tell you who is illuminated.

I'm expecting that when the bot is crooked the lower intensity on the end further from the wall might reduce the number of photo detectors that detect above their threshold.

I'm thinking that a single detector with ambient measurement and multiple LEDs would be easier to perfect.
 
Have you considered the cones of the receivers as suggested by mneary, if you think of the receiving diodes as emitters then the overlap of the cones produced will stay the same no matter what angle the wall is.

Mike.
 
Torben said:
What about using two of them and comparing the distances returned? That should give both the distance and the angle, assuming the resolution is good enough.
I don't know how that compares in terms of final part count and cost, though.
Torben

After hearing the same think from you and Bill I went back and check again. The sharp IR distance sensors do not seem to function at distances short enough to be useful.

I did find a non-analog sensor that goes active at 5 cm. Digikey has them GP2Y0D805Z0F for $3.25 each. One could use them as electronic wiskers with one on each side of the robot. If one did a slight S path so that the sensor toggled frequently it could work. It may be hard to aquire the wall to start with.
 
mneary said:
When the bot is crooked, you might not get what you expect. The cones of the detectors will point in the same direction as the emitter. Draw some pictures and you'll see what I mean.

Pommie said:
Have you considered the cones of the receivers as suggested by mneary, if you think of the receiving diodes as emitters then the overlap of the cones produced will stay the same no matter what angle the wall is.
Mike.

Not to say that I am right. But I did some sketches to convince myself that it could work. The IR LED is non diffused. There is bound to be some scatter and reflections but I think the majority of the light should follow the lines of the cone.

I am thinking of this like a very low resolution digital camera. Each photo-transistor can only sense light that strikes it, It can see everything it its cone/field.

The graphic shows what I mean. The light from the LED hits the edge of the right (green) photo-transistors cone but does not hit the transistor itself.
 

Attachments

  • wallsensor.jpg
    wallsensor.jpg
    8.4 KB · Views: 406
3v0, interesting idea, but, big issue is fighting the ambient light. if you use modulated signal and IR receiver then you will solve the ambient light problem (mostly) but then you cannot measure the intensity of light on each receiver (as all those I saw have digital output). with receivers stacked close to each other, I do not see how you will achieve resolution you need. I still think that sonar approach would be better. The ultrasound transducers are not expensive, the sound is quite slow so you can have pretty good resolution even with 4MHz uC. If you mount send/receive capsules on a motor and swing them around (180 degrees should suffice) you can get pretty good idea on what is the exact position of the wall related to the bot. I'm working on the exactly the same idea at the moment and have it all "work" in theory, but had no time to drive to the shop and get the us capsules so I can actually try the idea out.
 
one addition to the previous post. I tried out the 6 receivers 2 transmitter circuit. Basic theory is
Code:
while(1){
  both led's off
  catch "sense" from all 6 receivers
  led1 on, led2 off
  catch "sense" from all 6 receivers
  led1 on, led2 on
  catch "sense" from all 6 receivers
  led1 off, led2 on
  catch "sense" from all 6 receivers
  compare state of all 6 receivers in all 4 stages (00/01/10/11)
  output decision
}
and I was not satisfied with results. Then I tried something completely different, one IR LED, and one IR Receiver, 1K resistor in series with the LED and variable resistor 0-100K also in series with LED. Reading values from the Receiver with different "positions" of the variable resistor determines the "distance"... It works (I was manually changing the resistor value, as I only wanted a proof of concept) nice, but without enough resolution and with different behavior on different surfaces, so, if you try to keep 10cm from white wall, it will go 3-5cm near black wooden sofa. After all this I decided to try out the ultra sound .. it is pretty much the same as with IR .. the transducers I can get here are 40KHz, so the same freq as IR Receivers I have, the only addition is that I need to make a small 40KHz signal demodulator and amplifier but I believe I can google that one out (no way I can design it myself, toooooo much analog for my taste/knowledge)
 
arhi,

Why do you prefer US or IR? I have never used the US.

I have not settled on a single approach. I need to teach students how to do this next year and intend to present several methods that work. When class starts I will need several of robots equipped with maze capable sensors so keeping the cost down is an issue.

My original idea was to use little SMD PTs (photo-transistors) to form a strip of sensors. They are only about 1/10th inch wide so they can be packed together. The PT's could be mounted in the bottom of a flat black U with the open side facing the wall to reject much of the stray light. I like the idea that this sensor provides an angle but it is starting to look too complex for what it does. Just the same it is interesting. Some of the dsPIC33's have 24 and 32 analog inputs. That and the massive processing power could be fun.

--------------Slightly different IR sensor project. -----------------------
I built a PCB with a single IR receiver and 6 IR LEDs. It was not intended for wall following. The idea is to use overlapping IR LEDs to detect objects in an arc ahead of the robot. Each LED overlaps it neighbor by 1/3 so that you end up with about an 120 degree arc with 11 detectable zones. The beam width and placement of the LEDs need tuning but the diagram shows the idea. The arc needs to correspond to the Sharp sensors sensitivity area.

I need to do the variable resistor bit you were playing with but have not yet made any provisions for it on the board. I figured I would get the basic detection working first and then experiment to see if I could get the variable power to the IR LED working for range detection.

This sensor was not intended for use in a maze but it might work if the power level range detection thing works close in.

Then I tried something completely different, one IR LED, and one IR Receiver, 1K resistor in series with the LED and variable resistor 0-100K also in series with LED. Reading values from the Receiver with different "positions" of the variable resistor determines the "distance"... It works
What sensitivity/(distance resolution) did you get? What is the shortest distance you could measure?

EDIT: Lost attachment. I am not a big fan of the pivoting motor mounted sensor.
 

Attachments

  • 11zone.jpg
    11zone.jpg
    55.2 KB · Views: 467
Last edited:
3v0 said:
Why do you prefer US or IR? I have never used the US.
Light is too fast. ~300Mm/s so if we say that you will use cheep dedicated pic for the sensor, those usually run on 4MHz hence 1 instruction takes 1us .. and in 1us light will travel 30000m .. so any measurement of length using light is impossible without high speed mcu.

With sound, it is much easier, at typical speed of ~300m/s the same calculation show that one instruction is 3cm.

Now, yes, you should think about round trip, not one way trip, so sound will actually bounce from object 1.5cm away during one instruction, and that is something you can work with, if you look at the light, it is still 15Km distance for one instruction ... huge resolution difference :)

All this in consideration, you have to use different approach for sound and light, for sound, you can actually measure time between your "ping" and the echoed pong and get usefull results. If you integrate some more complex calculation using the temperature sensor to change the speed of sound to "correct value" you can get it really precise, and sound bounces from "most" objects the same way. When light is involved, you have to measure intensity and not "round trip time" as light is too fast. The problem here is that you cannot get any precision as light will bounce differently from different objects, the experiment I made showed that difference between white wall, polished black wood and black cotton is too huge to get any value out of that detector. Now, you can use "audible sound" instead of "ultra sound" for the same purpose, but, using 40KHz modulated sound gives few benefits:
- you do not hear the beeps
- the receiving transducer is already calibrated to some freq (the ones I use are 40KHz) and it ignores "most" of other sounds so you do not have to worry about background noise.

3v0 said:
I need to do the variable resistor bit you were playing with but have not yet made any provisions for it on the board. I figured I would get the basic detection working first and then experiment to see if I could get the variable power to the IR LED working for range detection.
It can work, the biggest problem is "different reflective index of surrounding objects". An generale, you can test yourself, just build a simple detection circuit and manually change the resistor value .. as I already wrote .. the major PITA with light is
- ambient noise
- reflective index of surrounding objects
It might work with maze, as you can "predefine" the material maze will be made of, but for some "general" use, you cannot count on any resolution with light. Pay attention that placing IR led in alu tube (1-2cm in length) will increase the "focus" of the beam from the led.

3v0 said:
What sensitivity/(distance resolution) did you get? What is the shortest distance you could measure?

With sound, no test yet, as I still do not have time to go and get those transducers, with light - with the setting I have at the moment (the best one I could come up with, fixed resistor) module that detect highly reflective object (mirror) 1m away, white paper 30cm away, and black matte sponge from 2cm away ... now .. as you can see .. *same* setup detect different objects on different distances (mirror 1m, sponge 2cm).

The tests with variable resistor, I was able to get resolution of ~3cm using white paper as "wall" with 500R static + 100K variable resistor in series with the IR LED. IR LED was enclosed in aluminum tube 4cm in length
 
about the "pivoting motor mounted sensor" .. I do not need it :) but the whole idea of my work is to have fun :) and to pack as much as possible gadgets into a single product, so controlling stepper motor, servo motor and simple dc motor in same project, as much as it sounds stupid is exactly what I'm doing attm :) .. all bunch of different sensors (I'm attm making "shake" sensor using piezo soundspeaker from "singing card" that I will mount there also :) )
 
3v0 said:
After hearing the same think from you and Bill I went back and check again. The sharp IR distance sensors do not seem to function at distances short enough to be useful.

I did find a non-analog sensor that goes active at 5 cm. Digikey has them GP2Y0D805Z0F for $3.25 each. One could use them as electronic wiskers with one on each side of the robot. If one did a slight S path so that the sensor toggled frequently it could work. It may be hard to aquire the wall to start with.

Hi 3v0,

I may be reading the datasheets wrong but to me it looks like the digital IR sensor only toggles if something is detected between 1cm and 5 cm from the sensor, while the analog output one from the Sparkfun site gives a nice voltage curve from about 6cm up to 80cm. I don't really know what all of your constraints are in construction and cost etc but I wonder if you couldn't take care of the minimum range problem with the analog sensors by setting them not at the outside edge of the robot, but in about 2.5-3.5cm from the edge, pointing out. If you could mount them like that without getting spurious early reflections from other features on the 'bot you could simply ignore the "recessed" ~3cm and wind up with a minimum distance reading from the edge of the 'bot of ~3cm. Dunno if this is still too far for you. It just seems that with the digital one you would have to a) be close to the wall to sense it, and b) do something like the "wiggle-toggle" you mentioned to be sure you were ~5cm from the wall--and depending on the width of the 'bot (you said the maze walls are 10" apart?) having the extra range might be useful.

Again, I don't know enough about what you're doing to say any more than "this is what it seems like to me". :) Oh yes--the analog Sharp sensors are a couple of bucks cheaper from Digikey, at least in Canada. It's still over 40 clams to mount two per side though; could be too pricey.

As to the ultrasound idea, well, I *have* played quite a bit with ultrasound and I while I've managed to build an ultrasonic rangefinder which works down to a few cm, I think you'll find the same issues with near objects (i.e. it will only be reliable down to a few cm) depending on what sacrifices are made in the design and below that threshold, you'll only be able to tell that there is something there, but not how far away it is. On one I've built the range is down to about 5cm but i.e. on the LV MaxSonar modules it's about 6".

Anyway, just some random thoughts. I'm interested to know what solution you do end up using and how well it works out. Have fun with the project!


Torben
 
Currently I am more into exploring the technology then one specific application. There is no one robot I am building so my mind tends to wander a bit. But as I see it the most difficult task here is the close in reading.

Arhi,
Thanks for updating me on you work with IR. I agree with everything you said. I just added a digital pot socket to my prototype. Still need to wire it up and write the soft SPI code. Mostly just library calls. I am using C18 on a 18F1330. This chip can use its PLL with the internal 8MHz osc to run at 32 MHz. I only have the 10K digital pots on hand. These things are so useful that I plan on ordering the other values.

I am interested in what you are doing with US although I will be working with IR for a while yet.

Toben,
I have a sharp distance sensor (fairly sure it is GP2D12J0000F) that measures from 10 to 80cm. The voltage goes up as you close to 10cm and then drops for distances less then 10cm so it is fairly useless in close. I have it mounted on the front of a robot. So far I have only successfully used it to avoid walls and objects.

If one used a maze with tall walls one could (as suggested mount the IR sensors facing across the top of the robot. I am not sure I want tall maze walls. I have a few chunks of 2x4 that I arrange to build quick and dirty mazes. Do not want to go to 2x6. Maybe place them ahead of the robot body and have them look past each other.

The GP2Y0A21YK0F is a better sensor in that it works as close as 6cm. Mouser has them on back order for 3 months. I can not be sure but they may list soon-to-be-stocked items at a discounted price to get a few sales prior to getting the shipment. The GP2D12J0000F was cheap and back ordered, when they became a stocked item the price went from $8 to $10. It will be interesting to see if it happens again.

I seen an article on the web where a guy took the PCB off the sharp sensor and added a spacer to change the focal length. Shortened the range. I can find it if anyone is interested.
 
with maze, I believe that IR will do the proper job (with variable resistor) and give pretty good resolution as all your wall's will be made of same material. If you add one simple light probe at the top of the bot to compensate for ambient light, i believe you can achieve steady and accurate resolution. The thing that I spent too much time on is "focus" .. I took data sheet too literal so assumed that 40 or 60 degree angle of IR radiation from IR LED is "absolute" .. it is not :( so I had whole bunch of interference in the early stages. After trying to "focus" the light using different materials (cardboard, plastic ...) that I believed not to be transparent, I finally ended up using aluminum tubes. Longer the tube, better the results. I also placed IR Receiver at the end of one (bit larger) tube to focus the receive side too. The "focus" might not be the right word here (yup, English is my 3rd language :( ) but I bet you understand what I mean.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top