go_away

Author Topic: interfacing a sharp IR  (Read 3408 times)

0 Members and 1 Guest are viewing this topic.

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
interfacing a sharp IR
« on: December 16, 2007, 04:11:54 PM »
hey folks, im workin on to interface a sharp ir which has a max range of 150cm.
problem is the voltage-range response , its not linier, my adc atmega adc can provide a resouloution of 10 bits.

if i just make the voltage range between 0 and 5 volts of 20 cm up to 150 cm im not gonna have linier response cuz changin from 20 cm to 30 cm would take for example 100 readings
while from 130 to 140 cm would take only 20 readings,, help folks
good ol' BeNNy

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: interfacing a sharp IR
« Reply #1 on: December 16, 2007, 04:15:57 PM »
the output voltage decreases rapidly from 20 cm to 80 then the decreasing starts to slow down
good ol' BeNNy

Offline airman00

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
Re: interfacing a sharp IR
« Reply #2 on: December 16, 2007, 04:45:10 PM »
look at the datasheet of the IR sensor to see the voltage-range response

If its not too late I would switch to sonar ( if its for obstacle avoidance)
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline Steel_monkey

  • Full Member
  • ***
  • Posts: 85
  • Helpful? 0
Re: interfacing a sharp IR
« Reply #3 on: December 16, 2007, 05:13:01 PM »
Here is some info: http://www.societyofrobots.com/sensors_sharpirrange.shtml (I also want to try sharp IR, but it is a little costly). The only one question is : what data type shall we use for computations. 16 bit unsigned should be enough. You need to separate graph into straight lines (nearly 6-7) and use 'case' to determine, which line should be used. Also polinomial interpolation is a good thing, it requeres floating point, thus unacceptable. But it is impossibe to deterine, what is distance: 20 or 80 cm is they give same values from sensor. I think, it is possible to move towards the signal a little (I assume You also use odometry), and computate difference in signal. If it decreases bot is closer then maximum point. And visa versa.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,696
  • Helpful? 173
    • Society of Robots
Re: interfacing a sharp IR
« Reply #4 on: December 17, 2007, 08:23:28 AM »
Quote
I also want to try sharp IR, but it is a little costly
$12 is too costly?! ???

Anyway, the most accurate method is a lookup table . . . albeit a very very large one if its 10 bit . . . otherwise, just linearize it in an equation and don't worry about the error.

Offline Steel_monkey

  • Full Member
  • ***
  • Posts: 85
  • Helpful? 0
Re: interfacing a sharp IR
« Reply #5 on: December 17, 2007, 01:37:43 PM »
When it come here (Russia), its price is at least doubled. Also I haven`t got Visa yet (at least 10$ in virtuon implementation). And at least two IR s are requered for project ( or IR +servo, same price). So, at least 50 bucks-a little costly  ;D
10 bit table requeres 10 bit distance representaton and will take 1280 bits. The easiest way will be to hold them in growing order, each 10 bits in two bytes one by one. So, really table will take 2 Kb. From math point of view, it will be easier than linearisation.  At least, everything can be done in Mathcad (perhaps even in *lab) or Maple: interpolate, quantitise, round, form matrix 2*1024 and sort by values in one row.
« Last Edit: December 17, 2007, 02:38:01 PM by Steel_monkey »

Offline airman00

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
Re: interfacing a sharp IR
« Reply #6 on: December 17, 2007, 01:54:48 PM »
wat distance do you want with the IR sensor?


you could always make your own IR sensor  - or maybe make a sonar sensor
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: interfacing a sharp IR
« Reply #7 on: December 17, 2007, 05:48:09 PM »
Quote
look at the datasheet of the IR sensor to see the voltage-range response
i did, thats why im posing this question ,,cuz the response is not linear....

Quote
just linearize it in an equation and don't worry about the error.
what do u exactly mean to linearize the response? how?
good ol' BeNNy

Offline brijesh

  • Full Member
  • ***
  • Posts: 55
  • Helpful? 0
Re: interfacing a sharp IR
« Reply #8 on: December 17, 2007, 05:53:52 PM »

Check out the link below it shows a method to linearize the data.

http://www.acroname.com/robotics/info/articles/irlinear/irlinear.html

Offline JonHylands

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 562
  • Helpful? 3
  • Robot Builder/ Software Developer
Re: interfacing a sharp IR
« Reply #9 on: December 17, 2007, 07:02:32 PM »
A few years ago, I took the formula from that web site, put it in Excel, and computed the numbers for an 8-bit A/D value (0-255).

The sensors return values between 0 and 2.5 volts, so you really only need 7 bits in your lookup table (128 bytes)...

Code: [Select]
byte const rangeTable [128] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 80, 76, 72, 68, 65, 62, 59, 57, 54, 52, 50, 48, 47,
45, 44, 42, 41, 40, 38, 37, 36, 35, 34, 33, 33, 32, 31, 30, 30,
29, 28, 28, 27, 26, 26, 25, 25, 24, 24, 23, 23, 23, 22, 22, 21,
21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17, 17,
16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14,
13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10};

And the code to read from it:

Code: [Select]
voltage = read_adc ();
if (voltage > 127)
return (10);
return (rangeTable [voltage]);

The code returns a value in cm of the distance to the target.

- Jon

Offline DomoArigato

  • Full Member
  • ***
  • Posts: 54
  • Helpful? 1
Re: interfacing a sharp IR
« Reply #10 on: December 17, 2007, 08:06:15 PM »
On this website I have code to do the convertion if you look at the ADC interrupt routing (gotta download Pete.zip).  You can also take a look at the data I gathered and linearized on the excel spread sheet (The IR calibrating data not the scan data). http://domoarigatoq.googlepages.com/
« Last Edit: December 17, 2007, 08:06:51 PM by DomoArigato »

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: interfacing a sharp IR
« Reply #11 on: December 28, 2007, 02:38:51 PM »
Quote
Check out the link below it shows a method to linearize the data.

http://www.acroname.com/robotics/info/articles/irlinear/irlinear.html
i kind of checked it but didnt quite get it,, can anyone provide a little explanation? thankyall
good ol' BeNNy

Offline stt585

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
Re: interfacing a sharp IR
« Reply #12 on: December 28, 2007, 06:04:01 PM »
Hi Benji, I suspect I am using the same sensor that you are:
GP2Y0A2YK0F

I have worked with Sharp IR sensors before and would just suggest that you sit down and make a lookup table for what you are doing.  If you don't know what linearization is, your best bet would probably be just a lookup table.  (To make one, sit down with the sensor and get the ADC results for a range of distances and then record it.  Then in the future, when you perform an A/D on the sensor, you will know the distance because you've measured it before.)

Also I pose this question to the experts in the crowd:  I am using the GP2Y0A2YK0F (150 cm analog proximity sensor) and am having quite a few problems with this-the output voltage is brutally noisy.  I have eliminated all stray sources of IR light in the area btw.  There appears to be a voltage spike in the output that occurs at a frequency of around 1kHz.  This was mostly eliminated by introducing a capacitor of ~0.1uF.  However, the voltage spike is not the only issue!

The output signal from the sensor is extremely "fuzzy."  It has a width of around 300 mV (meaning that the output signal for a constant distance can vary up to 0.15V in either direction from the desired signal)!!  Has anyone worked with this sensor before and encountered this?  How did you solve it?  Right now I am considering a low pass filter, but am unsure as to whether this will solve the issue or not.  Any advice would be appreciated!

 


Get Your Ad Here