Shop OBEX P1 Docs P2 Docs Learn Events
Eddie Robot - Getting Distance in cm from PING Sensors — Parallax Forums

Eddie Robot - Getting Distance in cm from PING Sensors

cch80cch80 Posts: 1
edited 2013-03-11 20:20 in General Discussion
Hi,

Let say when I issued a PING command, I got a hex value of 133.
How do I convert this value to distance in centimeters (cm)?

I'm using PING Ultrasonic Distance Sensor (#28015) on my Eddie Robot Platform.

Thanks!

Regards,
Roland.

Comments

  • FranklinFranklin Posts: 4,747
    edited 2013-03-11 17:59
    Take a look at the sample code on the ping page in the store there are examples and references there.
  • dgatelydgately Posts: 1,630
    edited 2013-03-11 20:20
    cch80 wrote: »
    Hi,

    Let say when I issued a PING command, I got a hex value of 133.
    How do I convert this value to distance in centimeters (cm)?

    The description of each function of the "Ping))) Object V1.2 " @: http://obex.parallax.com/objects/114/ is noted below. The basic returned value is microsecond "ticks". Inches, Millimeters and Centimeters are returned as just conversions from the ticks value...

    Here are the function descriptions for the Ping.spin object. Just use the "Millimeters(Pin)" method/function:
    PUB Ticks(Pin) : Microseconds | cnt1, cnt2
    ''Return Ping)))'s one-way ultrasonic travel time in microseconds
    
    
    PUB Inches(Pin) : Distance
    ''Measure object distance in inches
                                                                                 
    PUB Centimeters(Pin) : Distance                                                  
    ''Measure object distance in centimeters
                                                                           
    PUB Millimeters(Pin) : Distance                                                  
    ''Measure object distance in millimeters
    

    dgately
Sign In or Register to comment.