Author Topic: GP2Y0A2YK0F Sharp Distance Sensor  (Read 64130 times)

0 Members and 2 Guests are viewing this topic.

Offline stt585Topic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
GP2Y0A2YK0F Sharp Distance Sensor
« on: December 29, 2007, 04:22:17 PM »
Hi everyone, I am working with the GP2Y0A2YK0F Sharp distance sensor and am having significant noise problems with it.

Does anyone have experience using this sensor?  I see noise spikes occuring at 1kHz.  There are also lower frequency noise components as well because the output signal from the sensor is very "fuzzy."  I have thought about adding capacitors between the output pin and ground to filter out some of the noise, but the problem with this is that it decreases the response time of the sensor (ie. if you very suddenly remove the object in from of the sensor, the voltage should drop, but because of the capacitor, the output voltage drops very slowly until it finally reaches its steady state value approximately 2 s later. . .

If anyone has any expertise with this sensor, please let me know because I am starting to run out of ideas.  The output signal from the sensor is just way too fuzzy to be A/D'd with any decent accuracy.

Offline Rebelgium

  • Supreme Robot
  • *****
  • Posts: 637
  • Helpful? 0
  • It's called the future ... We like it here
    • orgcrime.net
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #1 on: December 29, 2007, 04:28:10 PM »
Just an idea: Place a smaller capacitor ( 22pF or something), this will cause the sensor to react much faster.
To relax after some hard work on robotics: A very fun free online text based MMORPG
orgcrime.net

Offline robonoob

  • Robot Overlord
  • ****
  • Posts: 149
  • Helpful? 0
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #2 on: December 29, 2007, 05:29:45 PM »
hi
sorry maybe im being impolite posting here but not helping you...but i was wondering if u could give me a link to that sensor cuz i-m doing a wallbot(wall avoiding robot) and maybe i could use one of those...
thank you

Offline stt585Topic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
Re: [b]GP2Y0A02YK0F[/b] Sharp Distance Sensor
« Reply #3 on: December 29, 2007, 05:39:08 PM »
Hi, I made a mistake in the part number.
GP2Y0A02YK0F is the correct one.
http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail?name=425-2062-ND

Offline stt585Topic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #4 on: December 29, 2007, 05:40:17 PM »
Just an idea: Place a smaller capacitor ( 22pF or something), this will cause the sensor to react much faster.


Yes, that is true, but it doesn't eliminate the fuzziness of the output signal, which is the bigger problem.

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
    • dunk's robot
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #5 on: December 29, 2007, 06:21:50 PM »
hey stt585,
you have probably tried this already but
have you tried testing your setup with a voltage divider in place of your sensor to test all the other components in your circuit?
there are a lot of places noise can creep in and it's worth ruling them out before you blame the sensor.

making sure i'm leaving enough time for my microcontrolers ADC to stabilise before taking a reading has caused me problems in the past.
shielding (or shortening) sensor wires is worth trying as well.

dunk.

Offline Rebelgium

  • Supreme Robot
  • *****
  • Posts: 637
  • Helpful? 0
  • It's called the future ... We like it here
    • orgcrime.net
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #6 on: December 29, 2007, 06:34:34 PM »
you can also use the sensor stand alone for a quick test setup, and then see if the spikes are still present. If they aren't, the problem isn't your sensor.
To relax after some hard work on robotics: A very fun free online text based MMORPG
orgcrime.net

Offline stt585Topic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #7 on: December 29, 2007, 07:11:45 PM »
hey stt585,
you have probably tried this already but
have you tried testing your setup with a voltage divider in place of your sensor to test all the other components in your circuit?
there are a lot of places noise can creep in and it's worth ruling them out before you blame the sensor.

making sure i'm leaving enough time for my microcontrolers ADC to stabilise before taking a reading has caused me problems in the past.
shielding (or shortening) sensor wires is worth trying as well.

dunk.

Yep, I've got a 25k Pot that I was using before I replaced it with the sensor.  I was scoping the power rail just now and noticed that it became much much more noisier when i plugged in the sensor.  The noise on the power rail is the same frequency as the noise on the output of the sensor so I think that at least some of it is coming from the sensor itself.

I also noticed that the power rail was much noisier when a microcontroller was connected in the breadboard, but is pretty insignificant compared to the sensor noise.

No, I haven't tried fiddling around with the ADC setup and acquisition time yet.  That's a good idea, thanks!

Offline stt585Topic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #8 on: December 29, 2007, 07:14:08 PM »
you can also use the sensor stand alone for a quick test setup, and then see if the spikes are still present. If they aren't, the problem isn't your sensor.

Ya, even when I just hook up +5V and GND to my sensor and read the output, it's noisy as hell.  I've even started eliminating ambient IR noise sources but haven't been able to isolate it yet.  Have you used this sensor before?

Offline frank26080115

  • Supreme Robot
  • *****
  • Posts: 322
  • Helpful? 2
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #9 on: December 31, 2007, 11:22:23 AM »
http://www.robotroom.com/DistanceSensor3.html

David Cook made a lot of tests with different capacitors, also
Quote
a microcontroller could simply take multiple readings and discard the highest value to eliminate spikes.

Maybe you can take an average if it's too noisy to eliminate just one spike.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #10 on: December 31, 2007, 12:57:11 PM »
I carefully looked at my readings with the analog GP2Y0A21YK just now.

No servos are running, nothing is blocking the sensor, and I have a 3300uF cap connected to the battery, with five .1uF caps right after my 5V regulator.

This is what I typically get in hyperterminal:
0 5 7 9 0 0 0 0 0 1 2 0 0 0 0

I never noticed this noise before . . . so I just investigated . . .

The above readings were done with this ADC setting:
a2dSetPrescaler(ADC_PRESCALE_DIV16); // configure ADC scaling

So I changed it to:
a2dSetPrescaler(ADC_PRESCALE_DIV128); // configure ADC scaling

Where higher DIV numbers increase accuracy but also increase read time (effectively finding an average over more time).

Now I got these typical values:
0 0 0 0 4 0 0 0 0 0 1 0 1 0 1

So this led me to believe that there are short lived spikes going on. So oscoping it, I got the attached image. I took this reading right from the sensor output bypassing the wires. Those spikes happened no matter what was in front of the sensor. My oscope autoset couldn't find a pattern in the spikes.

Odd . . .

edit: corrected a typo
« Last Edit: December 31, 2007, 02:01:08 PM by Admin »

Offline stt585Topic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #11 on: December 31, 2007, 02:36:20 PM »
So this led me to believe that there are short lived spikes going on. So oscoping it, I got the attached image. I took this reading right from the sensor output bypassing the wires. Those spikes happened no matter what was in front of the sensor. My oscope autoset couldn't find a pattern in the spikes.

Odd . . .

http://document.sharpsma.com/files/GP2Y0A21YK-DATA-SHEET.PDF  (page 2)
I don't know how to explain those larger sporadic spikes . . . maybe ambient IR noise?  But those smaller ones closer to the signal--do they occur at intervals of approximately 40 ms?  I hypothesize that the "fuzzy" noise is the transition time between sample outputs.  Right now I think that I need to perform my A/D at a specific time, but even if I DO perform my A/D between those transition times, the signal is too "thick" to properly take a reading.

I will try to change my acquisition time settings on my microcontroller.  Is that what DIV does, or does it change the A/D conversion clockÉ

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #12 on: December 31, 2007, 03:03:34 PM »
Quote
I don't know how to explain those larger sporadic spikes . . . maybe ambient IR noise?
well . . . i wasn't using a darkroom . . .

Quote
But those smaller ones closer to the signal--do they occur at intervals of approximately 40 ms?
looking closely at the signal, there are groupings of tiny spikes that occur for a duration of 30.44ms. and spaced by 8.86ms. I guess thats a total of 39.3ms, which is really close . . . you can see this in the image i attached.

The big spikes just seem to have no pattern . . .

Quote
Is that what DIV does, or does it change the A/D conversion clockÉ
this is what AVRlib says:
Quote
// A2D clock prescaler select
//      *selects how much the CPU clock frequency is divided
//      to create the A2D clock frequency
//      *lower division ratios make conversion go faster
//      *higher division ratios make conversions more accurate
#define ADC_PRESCALE_DIV2       0x00   ///< 0x01,0x00 -> CPU clk/2
#define ADC_PRESCALE_DIV4        0x02   ///< 0x02 -> CPU clk/4
#define ADC_PRESCALE_DIV8        0x03   ///< 0x03 -> CPU clk/8
#define ADC_PRESCALE_DIV16      0x04   ///< 0x04 -> CPU clk/16
#define ADC_PRESCALE_DIV32      0x05   ///< 0x05 -> CPU clk/32
#define ADC_PRESCALE_DIV64      0x06   ///< 0x06 -> CPU clk/64
#define ADC_PRESCALE_DIV128      0x07   ///< 0x07 -> CPU clk/128

Offline stt585Topic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #13 on: December 31, 2007, 03:37:30 PM »
Awesome, thanks for all the thoughts, tips, advice and links everyone.  I will give this another try today!

Offline benji

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #14 on: January 07, 2008, 04:20:02 PM »
i have ordered this same ir for my mapping project,, is it a good one? what about noise?
how much resolution does it provide?
good ol' BeNNy

Offline brijesh

  • Full Member
  • ***
  • Posts: 55
  • Helpful? 0
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #15 on: January 07, 2008, 05:23:59 PM »
There was similar thread sometime back. I am using sharp IR sensors too and felt it was too noisy. So dug around and came across this page.

http://www.gorobotics.net/Articles/Sensors/Effectively-Using-the-Sharp-GP2D12-Rangefinder/

I have written come code and tested it. Have not yet integrated it into the robots control loop so as to say anything about its performance. After filtering the max variation in the ADC output was limited to less then 10.

Other things to watch out for:
1) The reference voltage used by the ADC. On my board (Baby Orangutan AVR board) the reference voltage is 5V. But the max signal  range is from 0v to 2.45V, so top 2 bits are wasted.
2) Atmega data sheet says the accuracy of ADC is +/- 2LSB bits at 100KHz sampling rate.
3) Bandwidth of ADC is only around 35 KHz.
4) All the numbers above are from what I remember, don't have data sheets in front of me. Cross check them before using.

Brijesh


Offline benji

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #16 on: January 08, 2008, 07:12:53 AM »
Quote
1) The reference voltage used by the ADC. On my board (Baby Orangutan AVR board) the reference voltage is 5V. But the max signal  range is from 0v to 2.45V, so top 2 bits are wasted.
how about having the output of the sharp IR into an op amp with gain of 2 and then to the AVR?? anyone tried this?
i guess that would increase the resolution 2 times
good ol' BeNNy

paulstreats

  • Guest
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #17 on: January 08, 2008, 09:00:37 AM »
I use the GP2D12 sharp distance sensor. This has a lot of similar type noise but doesnt seem quite as bad as yours (it works well enough for me - it generally gives a correct range).

I generally take 5 readings and then divide the result by 5 in software to get an average value. I know its not perfect but it seems to work. but make things slow.

I looked at the difference between the GP2D12 and the GP2Y0A2YK0F and it seems the main difference that the beam width on the GP2Y0A2YK0F is almost twice as big as the GP2D12, Maybe this is causing some additional problems by having a wider detection range, greater scattering etc... Maybe there is a problem with reflections

Offline brijesh

  • Full Member
  • ***
  • Posts: 55
  • Helpful? 0
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #18 on: January 08, 2008, 01:57:18 PM »

how about having the output of the sharp IR into an op amp with gain of 2 and then to the AVR?? anyone tried this?
i guess that would increase the resolution 2 times
[/quote]

Yes it will increase the resolution by 2 times.

Offline benji

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #19 on: January 09, 2008, 07:26:25 AM »
well i think ill do this 2 times gain before goin to the avr , but about average values.. should somone get average values during the first 50 useconds or after the sensor is setteled?
how much timesteps between these five readings?
how much noise(mv) does this sensor give?anyone has a powerfull algo to get rid of this noise?
good ol' BeNNy

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #20 on: January 09, 2008, 10:19:55 AM »
I think taking an average is bad for this type of noise. You don't want noise changing your average value.

To get rid of that noise in your algorithm, take 6 or so readings in ~5ms, and store each value. Compare each value, and if you see a value thats significantly different from the others, throw it out.

For example:

10, 12, 11, 12, 35, 11

Delete the 35, as its obviously noise. You will need a 'this is noise' threshold value. Using hyperterminal you can quickly figure out a good threshold.

10, 12, 11, 12, 11

Then you can average the remaining numbers: 11 (deleting noise) vs. 15 (average with noise)

Offline benji

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #21 on: January 09, 2008, 01:32:52 PM »
yea admin, that rocks, but what about this 5usecs? is it after the 50usecs of setteling or before the things settels? is this noise u guys are talking about before or after the sensor is settled,,,,,,?

thanks admin,,nice shot
good ol' BeNNy

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #22 on: January 09, 2008, 01:38:13 PM »
Quote
what about this 5usecs? is it after the 50usecs of setteling or before the things settels?

Do something like this:

Code: [Select]
loop ~6 times:
take_reading
delay(1 ms)
store value

compare values
delete spike value(s)
average remaining values

Now to know how many readings you should take, and the delay time, print out your data in hyperterminal to see what you get.

Offline benji

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #23 on: January 09, 2008, 04:33:53 PM »
you are taking a reading each 1 micro secs,,,, i suppose the sensor is moved, how much time would you wait before goin into the loop you have introduced? thats my q

by the way ,,if i connect my micro to the serial port, would hyper terminal show data directly when its recieved to the pc?
good ol' BeNNy

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #24 on: January 09, 2008, 06:08:15 PM »
Again, you must use hyperterminal (yeap, using serial port to your PC) to determine the best sampling rate for your design. This is how I'd do it.

Quote
i suppose the sensor is moved
Sensor movement doesn't matter at 1ms. ;)

Offline benji

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #25 on: January 21, 2008, 08:59:24 AM »
sorry to get backon this a little late but i would like to say that this sensor (according to the datasheet) refreshes its output each 40 m seconds,so how do you folks aquiure its output at 1 khz???? anyone can explain?
i think we should wait 40 m each time we are goin to read a new out, or were you considering a steady state? if so im cool,but if there is a change in range that should be taken care of..
good ol' BeNNy

Offline DomoArigato

  • Full Member
  • ***
  • Posts: 54
  • Helpful? 1
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #26 on: January 21, 2008, 11:30:40 AM »
Benji, I'm pretty sure your right, the fastest you can accurately sample that sendor is around 30ms - 40ms.  Did the guy who posted this have his microcontroller plugged into the wall?  I couldn't get accuarte readings when I did.

Offline Commanderbob

  • Robot Overlord
  • ****
  • Posts: 146
  • Helpful? 2
  • Embeddedmicro.com
    • Embedded Micro
Re: Fixing the problem
« Reply #27 on: May 24, 2008, 04:12:14 PM »
I know this is an old topic but I had a problem with it a while back and now have a solution.

Here is the data with just the sensor:
Rise time ~65ns
Fall time ~1.65us
Peak to peak voltage ~2v

Sensor with 10nf ceramic capacitor on data line:
Rise time ~4us
Fall time ~340us
Peak to peak voltage ~0.1V

Sensor with 10uf ceramic capacitor and 530 ohm resistor parallel to the capacitor:
Rise time ~7us
Fall time ~6us
Peak to peak voltage ~0.11V

Conclusion, I would recommend adding a 10uf capacitor and a 530 ohm resistor to the data line on the IR sensor. The increased rise and fall times are nothing compared to the 1.9V difference in peak to peak value. There is a lot less noise with this configuration. Admin, I recommend putting this on the IR sensor page.

This was all tested/measured with a 2Y0A02 Sharp IR sensor and my 100MHz Tektronix Digital Oscilloscope.

Hopes this helps someone. ;D
Justin

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #28 on: May 25, 2008, 03:31:56 PM »
Quote
Admin, I recommend putting this on the IR sensor page.
done. ill try it out myself when i get time.

Offline SixRingz

  • Full Member
  • ***
  • Posts: 76
  • Helpful? 0
  • Bit's and pc's = Robot.
    • ManMachineSystem
Re: GP2Y0A2YK0F Sharp Distance Sensor
« Reply #29 on: May 25, 2008, 05:33:26 PM »
Well, it's been a while since I took my electronics classes but I recall a lab excercise we did which was picking up alot of noise from the tube lights in the lab. (Do you call it tube lights? The long glass cylinders which are common in schools, hospitals etc) One of the excercises was to build an IR sensor, but I can't recall if this was the one suffering from that noise or if it was some other lab... Worth taking a look at anyhow. I ordered some Sharp sensors myself on friday, so I'm as eager as you guys to get to the bottom of this. I don't want to suffer from noisy readings!! >:(
Grounding things properly means burying them in the backyard...

 


Get Your Ad Here

data_list