Interfacing a IR sensor to HC11 micro

Status
Not open for further replies.
J

jjimenez101

Guest
Hi everyone,
Im working on a project for school, this project consists of interfacing a GP2D120 IR sensor to the 69HC11 controller. I have never used IR sensors before and want some helpful hints and suggestions on how to use them with controllers.

I need to know the EXACT or as close to the exact distance of a particular object. Now do i use an ADC to convert the output signal from the IR sensor into a digital format and determine from there? Do I use a comparator connected to the IR sensor and some kind of reference voltage?

And how do i go about programming this job in assembly language?

Answers to any or all of these questions would be Awesome

Thank you,
George
 
OK, you apply a voltage to Vcc and GND. The output Vo is an output voltage with a non-linear transfer function that can measure distance from about 3 cm to about 30 cm with the output changing by 1.8 to 1.9 Volts.

It is much more sensitive at one end of the range than the other. What does this mean? A small change in voltage at 30 cm corresponds to a large change in position. A large change in voltage at 3 cm corresponds to a small change in position.

The A/D converter on a 68HC11 is 8 bits with a 5V reference. So 5V/256 = 19.53 mV/LSB So that 19.53 mV over the 1.85 V is about 95 steps or an effective resolution of about 6.5 bits.

In practice this will result in considerable uncertainty in position at 30 cm and much lower uncertainty in position at 3 cm.

To make use of this device I would create a lookup table of approximately 100 values and the corresponding distance. Then I would use the value from the A/D conversion to lookup the distance and feed the distance to the code that uses it to make a decision about what to do next.
 
Last edited:
I've used the GP2D12, which is similar. Basically, it gives a voltage out based on proximity. So, you can use an ADC for general distance measuring or you can use a comparator to trigger on a fixed distance. I used an ADC.

Some points from experience:
- this sensor injects a lot noise on the power line - probably due to pulsing the IR LED. I used a 33 uF electrolytic as a bypass since the noise is pretty low frequency. a 100n cap wouldn't hurt either
- make sure the case is grounded. yes, the case is plastic but it is conductive.
- keep the sensor positioned as high as possible. I had mine mounted low and got a lot of ground scatter which translated into A LOT (5-6 LSBs) of noise. Once I raised it up, I got around 2.5 LSBs of noise. Bypassing helped somewhat. I've talked to others using this device and they got similar results.
- use good layout techniques for analog signals.
- internally, the device has a fairly slow update cycle, don't bother sampling it very fast - it's a waste of time.

Don't expect extreme accuracy. I spent a fair amount trying to get a decent mapping of ADC value to distance and found that the farther the distance, the less the accuracy. coupled with noise and at about 2/3 of max range the GP2D12 seemed almost useless as a distance measuring device. If you can nail the noise problem, accuracy could be improved. ground scatter is probably an issue at extreme range.
 
Last edited:

this what i did but be aware that noise can make this difficult. you can average or use some form of IIR but it reduces responsiveness, remember the slow internal cycle of this beast.

edit: I just wanted to be clear, I like this device. If you can use it within the boundaries that PB and I pointed out, it can be pretty effective. I gave up trying to use it to plot robot paths but rather used it for position feedback. for that, it worked quite well.
 
Last edited:
One more thing

Thanks alot, you guys have been great. Love the information. But one more thing, if the GP2D120 is not as reliable as some of you have mentioned. What other device can I use to determing position of objects more accurately and with less annoiances?? Preferebly to be used on a robot rover to analyze its surroundings?

-George
 
I'm sorry but I'm a bit weak on distance measurement alternatives. I just didn't want you to think I was ignoring you.
 

depends on what you are trying to do. If you are mapping out a maze, then it's probably ok. If you are locating radioactive objects in an isolation chamber, don't.

don't forget, your platform will have motion even if stopped - it will probably not be 100% stable while you are ranging so you basically can't get super accuracy. I would design a program to take that into account. Like use successive readings. You might want to use fuzzy techniques like assiging a quality value to ranging results (father away - lower quality). Update when you have higher quality data, for example.

you might look into an ultrasonic ranger mounted on a servo to scan an area. they can't handle really close ranges but don't suffer from the compression of readings at farther distances. I'd guess they are a little more accurate than the IR devices.
 

According to a report here: **broken link removed**

As long as you don’t put objects closer than 4cm to the sensor, you will get reliable readings.

The above mentioned webpage also contains other information which could be useful to your choice of design.
 
Thanks for all the help

I appreciate the help, and will have further questions as my project progresses.

_george
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…