converting GP2D02 ir reading into centimeters
Special_K
Posts: 162
Does anyone have a BS2 code that can convert the readout from the Sharp GP2D02 IR Sensor into centimeters values?
Comments
http://www.parallax.com/dl/docs/cols/nv/vol5/col/nv114.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
255 being the dection of a very close item.
http://www.barello.net/Papers/GP2D02/index.htm
I just do not know how to turn it into bs2 code
any help converting this to BS2 code would be much appreciated
http://www.seattlerobotics.org/encoder/200112/gp2d02.html
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
See if this is as helpful as I think it may be, even though it's a different Sharp I/R distance sensor, I suspect the linearization curve is the same, or nearly the same:
http://www.acroname.com/robotics/info/articles/irlinear/irlinear.html
I suppose if worse turns to worst, you can always build some tables, and use a lookup to determine the appropriate distance from the data obtained from the sensor. Not "pretty" by any means, but it should work reasonably well.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
madlabs.info/gp2d12/sharp_gp2d12.shtml
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
home.twmi.rr.com/brouillette/gp2d02/GP2D02_convert3.xls
it converts the GP2D02 output into a Centimeter form, but it uses decimals and the BS2 can not handle that. can anyone see a way to convert this into BS2 code.
also this code
www.ottawarobotics.org/articles/gp2d02/gp2d02.html
www.cs.montana.edu/harkin/courses/cs445/topics/10-ir/lectures/slideset1.pdf
Post Edited (Special_K) : 8/11/2006 9:19:07 PM GMT
got the code from this site.
www.schoeldgen.de/robot/getdist.c
Here is the code bit placed into the GP2D02 full code ( from acroname) with a dual reading from a Ping))). Let me know if you have or can tighten up the readings from the GP2D02..
Thanks to all.
instead of using the Range Vs V. which is non linear.
See the datasheet http://www.acroname.com/robotics/parts/GP2D120_SS.pdf
Given that you can use the following formulae to get the distance:
R = (m' / (V + b')) - K
(m') and (b') are values you will need to determine by trial and error, as they depend on the sensor and the ADC you are using. (K) is equal to 4 for the GPD12
I am using a 10bit ADC and my m'=5930 and b'=3
You can try this by placing an object at a known distance from the sensor (preferably between 10 and 80cm) and reading the returned value (R) from the formulae. You can then adjust your m' and b' values, according to the expected distance. This is an empirical approach, but works very well.
The range here is in inch..but it is easy to convert this in cm.
X =(((2251/(IRCNT-60))-4))
this code does the conversion into CM
IRCN is the readout from the GP2D02. it works ok but it is not spot on. still want a tighter reading.
if anyone can help tune up this equation please post.
thanks
I don't suppose you're going to like this answer, but be that as it may. The GP2D02 is now an obsolete sensor from what I understand. One of the reasons is certainly the difficulty that you're experiencing right now.
There are a number of other similar Sharp sensors, even some with digital output, which might ease this pain substantially. I've attached a Sharp Sensor Guide, although it is a few years out of date. Hope that is helpful.
Regards,
Bruce Bates