Author Topic: GP2D12 strage plot  (Read 3234 times)

0 Members and 1 Guest are viewing this topic.

Offline GeirTopic starter

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
GP2D12 strage plot
« on: January 22, 2009, 09:11:51 AM »
I connected my GP2D12 distance sensor to an ATmega168. The software just waits for a measurement scales it down to 8 bit. And then sends it to the computer in a loop. I placed the sensor 15cm from a black coffi cup. Then i took 10000 samples and did a plot in matlab. The plot came out like this http://gp2d12.russemotto.com.
Is the GP2D12 this bad?
« Last Edit: January 22, 2009, 09:14:31 AM by Geir »
$50 Robot schematic http://elektro.russemotto.com

Offline HDL_CinC_Dragon

  • Supreme Robot
  • *****
  • Posts: 1,261
  • Helpful? 5
Re: GP2D12 strage plot
« Reply #1 on: January 22, 2009, 02:53:24 PM »
Make sure the surface your looking at isnt shiny at all and also make sure there are no unexpected sources of infrared light in the area such as a tv remote or a window with the sun pouring in.
United States Marine Corps
Infantry
Returns to society: 2014JAN11

Offline GeirTopic starter

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
Re: GP2D12 strage plot
« Reply #2 on: January 22, 2009, 03:18:05 PM »
there should not be and thing disturbing it. And the variation is really big
$50 Robot schematic http://elektro.russemotto.com

Offline HDL_CinC_Dragon

  • Supreme Robot
  • *****
  • Posts: 1,261
  • Helpful? 5
Re: GP2D12 strage plot
« Reply #3 on: January 22, 2009, 03:52:38 PM »
try going into a room that doesnt have any natural light and slowly move an object forwards and backwards in front of it and see if the readings go all over the place or if the distance curve follows your motion
United States Marine Corps
Infantry
Returns to society: 2014JAN11

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: GP2D12 strage plot
« Reply #4 on: January 22, 2009, 04:26:43 PM »
Hi,

What's your sample speed?
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,208
  • Helpful? 15
  • 1.6L Peugeot 307 tuner
Re: GP2D12 strage plot
« Reply #5 on: January 22, 2009, 04:38:15 PM »
Ha, that question here is very critical... If you are using lamps for lighting... what type???
These long tube lamps generate a generous amount of IR light, frenzying your equipment...
For whom the interrupts toll...


P.S. I've been inactive for almost a year... Don't give promises but I'll try to complete my tutorials. I'll let you know when..

Cheers!

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,702
  • Helpful? 173
    • Society of Robots
Re: GP2D12 strage plot
« Reply #6 on: January 23, 2009, 05:47:38 AM »
The GP2D12 should be fairly immune to light. The sensors themselves however are fairly noisy, and at 8 bit a +/- 8 fluctuation would be normal. The noise we see in your graph is 2-3x bigger than normal . . .

I make this mistake sometimes, but are you positive you are reading the same ADC port that it's plugged into? ADC ports can leave voltage onto nearby ports, making it sorta work but not quite.

Offline GeirTopic starter

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
Re: GP2D12 strage plot
« Reply #7 on: January 23, 2009, 10:34:06 AM »
There is very little light where I'm doing my experiments, so this should not be it. I checkt my connection it's on the right pin :) And i did the experiment one more time today. For some reasone it got better, there is still some noise but not as bad. I uploaded the image, so you can see what you think. I did the experiment like 10 times yesterday and every plot was really bad, strange.

I don't know the sample rate. The prosessor is running at 8MHz. And the code is like this:

a2dInit();
a2dSetPrescaler(ADC_PRESCALE_DIV32);
a2dSetReference(ADC_REFERENCE_AVCC);
     
while(1)
{
    val=a2dConvert8bit(5);
    uart_putint(val);
}

Im not really used to avr so if you see a problem yell it out:) Thanks for the help so far ;D
$50 Robot schematic http://elektro.russemotto.com

Offline brijesh

  • Full Member
  • ***
  • Posts: 55
  • Helpful? 0
Re: GP2D12 strage plot
« Reply #8 on: January 23, 2009, 01:26:47 PM »

With ADC_PRESCALE_DIV32 the clock to ADC is abouot 8Mhz/32 = 250K which is higher than max specified in datasheet for 10bit precision.

"By default, the successive approximation circuitry requires an input clock frequency between 50 kHz and 200 kHz to get maximum resolution. If a lower resolution than 10 bits is needed, the input clock frequency to the ADC can be higher than 200 kHz to get a higher sample rate."

Your second picture is more are less what is expected. The sharp sensors are noisy. It will help if you put 10uF capacitor as close to Sharp sensor power pins as possible. I solder a SMD 0602 capacitor right between the connector power pins. I am talking about pins on the PCB of the sensor.

Offline GeirTopic starter

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
Re: GP2D12 strage plot
« Reply #9 on: January 25, 2009, 06:08:46 AM »
I changed the prescale to 64 not mutch change. But if the second on is what you expect i guess the sensor is OK
$50 Robot schematic http://elektro.russemotto.com

Offline paulstreats

  • Supreme Robot
  • *****
  • Posts: 1,381
  • Helpful? 21
Re: GP2D12 strage plot
« Reply #10 on: January 25, 2009, 03:53:55 PM »
Try to hook a multimeter up to the output, you should the voltage moving when you move objects closer to it. (it will verify that the sensor is working properly). Once it is then its just a noise problem....

Offline GeirTopic starter

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
Re: GP2D12 strage plot
« Reply #11 on: January 25, 2009, 04:04:00 PM »
The AD reads the voltage so i know the sensor is working. The question is, if the noise is normal?
$50 Robot schematic http://elektro.russemotto.com

Offline Kirk

  • Jr. Member
  • **
  • Posts: 44
  • Helpful? 2
Re: GP2D12 strage plot
« Reply #12 on: January 25, 2009, 07:47:08 PM »
Take the suggestion of Brijesh and be sure to have a cap on the power line for the sensor.  When I did this on my sensor it made a BIG difference.  Also try various targets.  It seems that some targets are read better and some not so well.
Kirk

Offline brijesh

  • Full Member
  • ***
  • Posts: 55
  • Helpful? 0
Re: GP2D12 strage plot
« Reply #13 on: January 26, 2009, 12:06:03 AM »
I did not save any oscilloscope screen shots of sensor output or power supply lines. But here is someone who did do it.

http://www.robotroom.com/DistanceSensor3.html#SIGNAL

To get good range and power output from the transmitter, they probably send a large current through the transmitter LED for short period of time. This large spike in current causes spikes on the power supply lines. These spikes manifest themselves on the signal line and affect ADC in the AVR.

In the above link the author talks about 10uF cap and 0.1uF ceramic cap. If you are using electrolytic caps for 10uf then ceramic cap is needed. If you are using a surface mount cap then single ceramic cap in 10uF range is sufficient. The closer to sensor PCB power pins the better it is.

Offline GeirTopic starter

  • Jr. Member
  • **
  • Posts: 27
  • Helpful? 0
Re: GP2D12 strage plot
« Reply #14 on: January 28, 2009, 05:23:45 AM »
ok thank I'll try the cap and check it whit the scope.
$50 Robot schematic http://elektro.russemotto.com

 


Get Your Ad Here

data_list