Shop OBEX P1 Docs P2 Docs Learn Events
Formula to calculate IR distance measurement from Eddie robot ADC response. — Parallax Forums

Formula to calculate IR distance measurement from Eddie robot ADC response.

u.asifu.asif Posts: 21
edited 2012-09-18 19:10 in Robotics
Hi,

I am sending "ADC" cmmand to eddie control board using Parallax Serial Terminal and trying to determine IR distance measurements from the obtained12-bit hex values. Forexample, I receive "0BF" on channel (2) which is equivalent to 191 in decimal. What is the correct formula to determine distance measurement from this reading.

I have used the following formula but it doesnt give the correct results:

volts = sensorReading * (5/4095);
Distance_in_cm = 60.495 * pow(volts, -1.2)

This formula gives a value of 344.90 however the actual distance is around 19-20 cm.

Any suggestions?

Thanks

Comments

  • ercoerco Posts: 20,255
    edited 2012-09-18 09:28
    Are you using a Sharp IR sensor? Those have a very nonlinear output. What's that pow function ?
  • u.asifu.asif Posts: 21
    edited 2012-09-18 19:10
    erco wrote: »
    Are you using a Sharp IR sensor? Those have a very nonlinear output. What's that pow function ?

    Its Sharp 2Y0A21YK0F IR sensor. Actually I am using the following formula:

    ADC range = 0 to FFF (which corresponds to 0.00v to 5.00v)

    volts = sensorReading * (5/4095); //sensorReading is the decimal equivalent of 12-bit hex value returned by ADC

    Finally,

    Distance_in_cm = 60.495 * pow(volts, -1.2); // pow is a math power function to take the power of "volts"

    I am using Parallax serial terminal to send "ADC" command to eddie control board. Anyone from parallax support would give a few suggestions please.

    Thanks.
Sign In or Register to comment.