Shop OBEX P1 Docs P2 Docs Learn Events
Calibrate formula for PING — Parallax Forums

Calibrate formula for PING

BronsonBronson Posts: 44
edited 2011-12-26 19:02 in BASIC Stamp
Considering about environment affecting Ping sensor, can someone provide me a formula code for calibrating Ping?
The purpose of this is I can adjust the Ping to suit the environment.

At this moment, my formula is DISTANCE = (2260 ** TIME).

If I can calibrate, I can re-calculate the constant value (2260) according to environment.
The problem is I don't really understand how to invert ** operation.

Regards,
Bronson Alex

Comments

  • $WMc%$WMc% Posts: 1,884
    edited 2011-12-22 20:51
    What does your code look like?
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2011-12-23 10:52
    You set up the calibration reflector at a known DISTANCE and measure TIME on the Stamp. Then apply the following inversion routine. The result is the factor (like 2260) that you need to use subsequently
    in DISTANCE = factor ** TIME.

    '---------binary division loop-----------
    
    [COLOR=#ff0000]' Enter with distance < time, distance<32768, time<32768
     FOR idx=15 TO 0               ' 16 bits 
       distance = distance // time << 1    ' remainder*2 
       F.Bit0(idx) = distance/time     ' next bit 
     NEXT 
     RETURN ' F is the factor for **[/COLOR]
    
    There is an explanation at this URL.
  • BronsonBronson Posts: 44
    edited 2011-12-26 19:02
    Tracy: Thanks a lot for your code! I will try your code...
Sign In or Register to comment.