Author Topic: Sharp IR range detector  (Read 8522 times)

0 Members and 1 Guest are viewing this topic.

Offline KohanbashTopic starter

  • Supreme Robot
  • *****
  • Posts: 430
  • Helpful? 1
Sharp IR range detector
« on: April 07, 2008, 08:27:42 AM »
Hi
Admin (or anyone else) can you say quickly what your experience is with the sharp IR's with respect to error in returned distance and how it changes with different lighting conditions.

Also do you have a recommendation for how far they should be apart from each other in order to avoid false returns (ghost returns, etc...)
Robots for Roboticists Blog - http://robotsforroboticists.com/

Offline superchiku

  • Supreme Robot
  • *****
  • Posts: 952
  • Helpful? 5
  • cooll
Re: Sharp IR range detector
« Reply #1 on: April 07, 2008, 08:48:03 AM »
wouldn't it be better if u just look at the sharp ir tutorial
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline KohanbashTopic starter

  • Supreme Robot
  • *****
  • Posts: 430
  • Helpful? 1
Re: Sharp IR range detector
« Reply #2 on: April 07, 2008, 08:56:31 AM »
wouldn't it be better if u just look at the sharp ir tutorial
Before posting I checked the tutorial and searched the forum.

The fact that there is an affect from lighting and interference between devices is mentioned, however I am asking from peoples experience what that effect really is so that I can determine whether the sensor will work for my application.
Robots for Roboticists Blog - http://robotsforroboticists.com/

Offline superchiku

  • Supreme Robot
  • *****
  • Posts: 952
  • Helpful? 5
  • cooll
Re: Sharp IR range detector
« Reply #3 on: April 07, 2008, 09:17:05 AM »
 well iam a kind of a sharp ir supporter, well yess we do get interference by light when using sharp ir's but the interference is minimum , offcourse sharp ir's wont work well in direct sunlight but normally sharp ir's are pretty powerful sensors and work well indoors, if u want i can supply u a graph which interprets different digital readings at different distances for a gp2d12 and also a general equation which will let u interpret the distance by looking at the digital reading..
« Last Edit: April 07, 2008, 09:19:00 AM by superchiku »
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline KohanbashTopic starter

  • Supreme Robot
  • *****
  • Posts: 430
  • Helpful? 1
Re: Sharp IR range detector
« Reply #4 on: April 07, 2008, 09:22:32 AM »
Do you have any plots showing reported distance vs actual distance
Robots for Roboticists Blog - http://robotsforroboticists.com/

Offline superchiku

  • Supreme Robot
  • *****
  • Posts: 952
  • Helpful? 5
  • cooll
Re: Sharp IR range detector
« Reply #5 on: April 07, 2008, 09:46:50 AM »
i told ya its the reading for distance vs digital reading ,

and the graph is not linear so u have to use the equation which i derives to know the distance for any digital reading
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline KohanbashTopic starter

  • Supreme Robot
  • *****
  • Posts: 430
  • Helpful? 1
Re: Sharp IR range detector
« Reply #6 on: April 07, 2008, 05:46:37 PM »
superchiku - Right I understand that. I am going to rephrase my questions.

How repeatable is it (whats the change in voltage between readings at the exact same distance)?
What is the change in voltage output relative to different lighting conditions (at the exact same location)?
Does anyone have experience/suggestions about how close I can put multiple sensors with out needing to worry about false returns?

Thanks,
sdk32285
Robots for Roboticists Blog - http://robotsforroboticists.com/

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Sharp IR range detector
« Reply #7 on: April 11, 2008, 07:08:15 AM »
The sharp IR is VERY noisy as a sensor.

Hook it up to an oscope and you will see. You need to put a noise filter to make it useful. I haven't had time to experiment, but I'm thinking a cap across ground and output might fix it. An averaging algorithm won't work - the nose is too high and throws the average off.

As for environment sensitivity, I'm starting to find that different models are affected differently. I wish I had an answer . . .

Most recently, I tested a GP2Y0A21YK in bright direct sunlight without problems. But I haven't done a controlled 'lab test' . . .

Offline benji

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: Sharp IR range detector
« Reply #8 on: April 11, 2008, 10:30:09 AM »
Quote
but I'm thinking a cap across ground and output might fix it.
i have this sensor and i will attempt to put a cap between output and ground,but,, what capasitance value is good for this?
the value would totally depend on how fast the out changes(how fast is the noise)

have you seen this on an osci? what value do you recommend?
good ol' BeNNy

Offline superchiku

  • Supreme Robot
  • *****
  • Posts: 952
  • Helpful? 5
  • cooll
Re: Sharp IR range detector
« Reply #9 on: April 11, 2008, 10:54:03 AM »
i think the admin has already provided an ingenious solution to the problem like using the auto calibrate mode, where the sensor autmatically calibrates the threshold in the intial moments when the robot is switched on no matter what the lighting conditions may be..
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline killsto

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: Sharp IR range detector
« Reply #10 on: April 11, 2008, 08:50:53 PM »
An equation for the GP2Y0A21YK would be greatly appreciated. I can find equations for other sensors but not this one. I did find the graph though.

Offline superchiku

  • Supreme Robot
  • *****
  • Posts: 952
  • Helpful? 5
  • cooll
Re: Sharp IR range detector
« Reply #11 on: April 12, 2008, 02:05:41 AM »
try to make an eqn urself by taking the digital readings and plotting them in excel
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
    • Ro-Bot-X Designs
Re: Sharp IR range detector
« Reply #12 on: April 12, 2008, 02:14:42 AM »
try to make an eqn urself by taking the digital readings and plotting them in excel

You see, exactly how you don't understand how it's done something unless you look exactly at the code, other people may be doing the same. For you it is simple to take the readings, dump them on the PC and plott them in excel. But for others that have no ideea what you are talking about this is chinese. So, if you expect complete answers to your questions, do the same for other people, otherways it's just talk in the wind...
Check out the uBotino robot controller!

Offline superchiku

  • Supreme Robot
  • *****
  • Posts: 952
  • Helpful? 5
  • cooll
Re: Sharp IR range detector
« Reply #13 on: April 12, 2008, 03:04:11 AM »
well , its because benji asked a similar question earlier and i gave a complete reply to that question so i was hoping that the asker would know to look for it but since u say that iam not answering properly then i would answer properly now,

see how u can plot the equation and all , ull find that in the advanced sensor interpretation tutorial..

now abt the uart what u got to do is that use my code which i have written and connect ur serial port of ur computer to the serial of ur uart . just connect the analog voltage out of the sharp ir to the pin no 0 of atmega16's port a and when u switch your hyperterminal on you will be to see your digital reaings at a gap of 2 secs... if you are using any other mcu of avr series then change the appropriate mux value in the code , if  you are using any other mcu then i  guess you have to make your own code by looking at the uart tutorial of this site..

here is the code

Code: [Select]
# include<stdio.h>
# include<avr/io.h>

# include<util/delay.h>
# include<avr/interrupt.h>
# include<stdlib.h>
# include<string.h>
# include<avr/pgmspace.h>



#define USART_BAUDRATE 38400
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL)))- 1)


 char u[11]="adcvalue\r\n";
 char *d;
 char b[10];
 char *p;
 
 unsigned int a;

void adcinitialize();
void uartinitialize();
void adcgetvalue();
void transferusart();
void printvalue(char *);

 int main(void)
  {
   adcinitialize();
   uartinitialize();
   while(1)
    {
adcgetvalue();

     
p=itoa(a,b,10);

strcat_P(b,PSTR("\r\n"));

d=&u[0];

transferusart();

     
     }       
   

   return(0);
   }
 
 
 
 void adcinitialize()
  {
   
  ADCSRA|=_BV(7)|_BV(ADPS2)|_BV(ADPS1);
  ADMUX=0x60;
  ADCSRA|=(1<<ADSC);
  while(!(ADCSRA & (1<<ADIF)));
  ADCSRA|=(1<<ADIF);
  TCCR1B|=(1<<CS12);
 
  }
 
  void uartinitialize()
   {
    UCSRB= (1<<RXEN) | (1<<TXEN);
    UCSRC= (1 << URSEL) | (1 << UCSZ0) | (1 << UCSZ1);
    UBRRL=BAUD_PRESCALE;
UBRRH=(BAUD_PRESCALE>>8);
   }
void adcgetvalue()
 {
 
   ADMUX=0x61;
   ADCSRA|=(1<<ADSC);
  while(!(ADCSRA & (1<<ADIF)));
  ADCSRA|=(1<<ADIF);
  a=ADCH;
 }
 
void transferusart()
 {
   
   while (*d != '\0')
    {

     while ((UCSRA & (1 << UDRE)) == 0) {}; // Do nothing until UDR is ready for more data to be written to it
      UDR =*d ; // Echo back the received byte back to the computer
      d++;
}
TCNT1=0;
while(TCNT1<=60000){};
TCNT1=0;
 printvalue(p);
 }
 
 void printvalue(char *l)
  {
   
   while (*l != 0x00)
    {
 

  while ((UCSRA & (1 << UDRE)) == 0) {}; // Do nothing until UDR is ready for more data to be written to it
      UDR =*l ; // send out each bit of charcter to your computer
     
     
     l++;
    }
TCNT1=0;
while(TCNT1<=60000){};
TCNT1=0;
  }
 

   

oh yes i configured my atmega16 for the 8mhz internal oscillator and used a baud rate of 38400 , u can do the same or change as per ur requirement.
« Last Edit: April 12, 2008, 03:05:42 AM by superchiku »
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

paulstreats

  • Guest
Re: Sharp IR range detector
« Reply #14 on: April 12, 2008, 05:08:49 AM »
Quote
but I'm thinking a cap across ground and output might fix it. An averaging algorithm won't work - the nose is too high and throws the average off.
I may try this at some point, it should leave less work to do in software.

I have noticed though that when i increase the adc aquisition time, I get barely no spikes whatsoever. It just takes longer to take a reading. I think that the internal adc capacitor smooths the noise and the spikes itself if you give it a chance to. (I only did this last night while trying to find the best setting for my ir emitter/detector pairs using hyperterminal to view the changeing values, my ouput print function samples all sensors and outputs them to hyperterminal, and i was surprised to see the sharp ir not producing any spikes)

Offline killsto

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: Sharp IR range detector
« Reply #15 on: April 12, 2008, 07:46:08 AM »
try to make an eqn urself by taking the digital readings and plotting them in excel

I don't have excel.

Offline superchiku

  • Supreme Robot
  • *****
  • Posts: 952
  • Helpful? 5
  • cooll
Re: Sharp IR range detector
« Reply #16 on: April 12, 2008, 08:32:26 AM »
well in order to get the eqn u need to have ms excel coz i dont know of any other software which can help ...
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline AndrewM

  • Robot Overlord
  • ****
  • Posts: 254
  • Helpful? 0
    • I Am.  When?
Re: Sharp IR range detector
« Reply #17 on: April 12, 2008, 09:19:18 AM »
The sharp IR is VERY noisy as a sensor.

Hook it up to an oscope and you will see. You need to put a noise filter to make it useful. I haven't had time to experiment, but I'm thinking a cap across ground and output might fix it. An averaging algorithm won't work - the nose is too high and throws the average off.

Do you think a 0.1 uF capacitor would be enough (or too much) to smooth out the noise from what you saw on the oscope? 
blog: www.iamwhen.com
Saving the world from humanity one robot at a time.

Offline superchiku

  • Supreme Robot
  • *****
  • Posts: 952
  • Helpful? 5
  • cooll
Re: Sharp IR range detector
« Reply #18 on: April 12, 2008, 12:16:35 PM »
may be may be not but i guess it will be, if it doesnt work just use a higher value
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline benji

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: Sharp IR range detector
« Reply #19 on: April 12, 2008, 03:26:34 PM »
Quote
I don't have excel.
  use MATLAB, the function is called polyfit

Quote
Do you think a 0.1 uF capacitor would be enough (or too much) to smooth out the noise from what you saw on the oscope? 
its all a matter of how fast the output changes ,,you have to check it with an osci then evaluate best cap value as you have 1/(2(pi).f.c) as the impedance .
good ol' BeNNy

Offline AndrewM

  • Robot Overlord
  • ****
  • Posts: 254
  • Helpful? 0
    • I Am.  When?
Re: Sharp IR range detector
« Reply #20 on: April 12, 2008, 06:56:37 PM »
If I had an oscope or even a sharp IR sensor I suppose I could hook it up and see.  I have 4 sensors on order and when they get here I was hoping for a ballpark based on someone elses observations so I could avoid hours of trial and error (once again, still no oscope).
blog: www.iamwhen.com
Saving the world from humanity one robot at a time.

Offline benji

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: Sharp IR range detector
« Reply #21 on: April 13, 2008, 10:20:58 AM »
Quote
I could avoid hours of trial and error

these are the stuff that builds ya  ;)
good ol' BeNNy

Offline superchiku

  • Supreme Robot
  • *****
  • Posts: 952
  • Helpful? 5
  • cooll
Re: Sharp IR range detector
« Reply #22 on: April 13, 2008, 01:52:36 PM »
a scope is very costly , i dont know if other people have but i atleast dont have it...

besides a certain degree of error can be dealt with , its not wise to spend $$$ on a scope for just minor error detection
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline benji

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: Sharp IR range detector
« Reply #23 on: April 13, 2008, 02:10:17 PM »
i would never buy a scope, i go to the college to try my stuff ;D
good ol' BeNNy

Offline AndrewM

  • Robot Overlord
  • ****
  • Posts: 254
  • Helpful? 0
    • I Am.  When?
Re: Sharp IR range detector
« Reply #24 on: April 13, 2008, 04:39:09 PM »
i would never buy a scope, i go to the college to try my stuff ;D

Show off  :P

But if you happen to have a sharp ir with you next trip to the electronics lab, please let me know what freq and voltage you see any noise at.  Or even the rate of change for normal detection.  I know all the sharp irs are going to be different,e specially between models, but a good ball park to base my guessing off would be helpful.
blog: www.iamwhen.com
Saving the world from humanity one robot at a time.

Offline benji

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: Sharp IR range detector
« Reply #25 on: April 14, 2008, 03:49:50 AM »
Quote
But if you happen to have a sharp ir with you next trip to the electronics lab, please let me know what freq and voltage you see any noise at.  Or even the rate of change for normal detection.  I know all the sharp irs are going to be different,e specially between models, but a good ball park to base my guessing off would be helpful.

dont worry , i will
good ol' BeNNy

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Sharp IR range detector
« Reply #26 on: April 20, 2008, 03:33:25 PM »
Quote
I have noticed though that when i increase the adc aquisition time, I get barely no spikes whatsoever. It just takes longer to take a reading.
Yea I do that too, but its still not enough. This is just a hardware averager, like my capacitor idea.

Ideally, you need a filter that passes low spikes but completely ignores large spikes.

To determine what capacitor to use, get several and look at how the output changes. I'm guessing like a 1uF range would do it.

Quote
I don't have excel.
You just need graphing software. OpenOffice, although buggy, could probably do it.

If you guys haven't read this post already, please do:
http://www.societyofrobots.com/robotforum/index.php?topic=2712.0
It includes my oscope reading of a sharp IR.

Offline benji

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: Sharp IR range detector
« Reply #27 on: April 21, 2008, 11:33:27 AM »
about the GP2Y0A02YK,,,,,
i did try to get readings by a micro controller atmega32 sending readings to hyperterminal
when im reaching ranges about 100 cm and above the thing is totally giving weird outs
i dont have a clue now about it
its gives acceptable outs before reachin 100 cm ranges
im using single converstion mode in the adc
,,what could be wrong ???
good ol' BeNNy

Offline superchiku

  • Supreme Robot
  • *****
  • Posts: 952
  • Helpful? 5
  • cooll
Re: Sharp IR range detector
« Reply #28 on: April 21, 2008, 11:49:27 AM »
my sharp ir has a range of 10 to 80 cm dont you think that signifiess anything if the distance is under 10 cm then the analog reaing will be gibberish , same can be applied to your sensor, just look at the graph it may explain something
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,431
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
    • Nerdcore - Programming, Electronics, Mechanics
Re: Sharp IR range detector
« Reply #29 on: April 21, 2008, 12:02:42 PM »
try to make an eqn urself by taking the digital readings and plotting them in excel

I don't have excel.

try http://www.openoffice.org

 


Get Your Ad Here