Shop OBEX P1 Docs P2 Docs Learn Events
Sharp IR Distance Sensor Algorithms — Parallax Forums

Sharp IR Distance Sensor Algorithms

ercoerco Posts: 20,256
I love me some Sharp IR distance sensors, even if their analog output is non-linear. I suspect most of us use these either with lookup tables or in non-precision applications where rough ranges are used. But this morning I found some hardcore equations at https://www.upgradeindustries.com/product/58/Sharp-10-80cm-Infrared-Distance-Sensor-(GP2Y0A21YK0F) and https://www.upgradeindustries.com/product/57/Sharp-20-150cm-Infrared-Distance-Sensor-(GP2Y0A02YK0F)

Depending on your ADC resolution and other factors, you might not need floating-point accuracy to 6-7 sig figs. :)

Comments

  • That's good stuff!

    Thanks for sharing. Now....Bookmarked.
  • ercoerco Posts: 20,256
    There's an older Parallax PDF along these lines, using a Sharp sensor with an ADC0831. BS2 code within did an approximate curve fit, based on ranges. Perhaps not to 6 sigfigs though.

    I bet Jim has that PDF and will post it. Or will I find it first?
  • Sorry, was sidetracked with my new DJI Phantom 3 calibration.

    Have to see what the competition is doing. :)
  • Hello,
    Does anyone have some working code in C that works with the: GP2Y0A21YK0F?

    I have attempted to access it with the example codes in the PropC libraries but nothng gives me
    anything that is useable. Have used my Simpson and my O'scope to follow the voltage changes on
    two of the sensors. The meter and the scope show correct function of the unit but the code for it
    and the other example codes to not change values correctly and show an integer of 2 and a varing floating
    point.
    Thank you in advance.
    Martin

Sign In or Register to comment.