Shop OBEX P1 Docs P2 Docs Learn Events
Increase PING resolution to 0.5 cm — Parallax Forums

Increase PING resolution to 0.5 cm

BronsonBronson Posts: 44
edited 2011-12-18 18:59 in BASIC Stamp
Hi,

Is it possible for PING))) sensor to detect distance with 0.5 cm precision/resolution?
I did it successfully with 1 cm precision.

Regards,
Bronson

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-12-12 22:16
    The sample code for the BS2 is written to display the distance to the nearest centimeter or inch, but the actual measurement is in units of 2us. The Propeller sample program computes the distance in millimeters and you could modify the BS2 program to work in units of 0.5cm. Remember that the speed of sound and thus the true accuracy of the PING's measurements is temperature dependent. It's also affected by air currents disturbing the path of the beam from the PING))). You can certainly detect distance with high precision, but the results may be meaningless if you can't control for some of these factors.
  • BronsonBronson Posts: 44
    edited 2011-12-14 19:31
    Mike,

    Thanks for your input. Now I understand why there is no resolution information on the spec sheet for Ping))).

    Regards,
    Bronson Alex
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-12-14 20:07
    Bronson,

    I imagine the total distance you want to measure is also important. Do you have a distance range where you want this type of accuracy.

    I have some example code I use with my Ping connected to a QuickStart board. It displays the Pings readings (in mm) on a little four digit 7-segment display. I'll test its accuracy if you'd like. What range would you like me to test.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-12-14 20:19
    One way to increase accuracy is to have a target at a known distance that you can move into the field of view on demand. By measuring the sonar distance to the target, you will obtain a standard from which a ratiometric distance to your unknown targets can be determined. An RC servo is an ideal means for moving a calibration target in and out of "view." This will help to cancel any variances due to temperature and humidity.

    -Phil
  • BronsonBronson Posts: 44
    edited 2011-12-15 19:47
    Considering Mike's explanation about environment affecting Ping, 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.

    Duagne: The distance range is 80 cm only. I really appreciate if you can do some testing with your board. Thanks a million!

    Regards,
    Bronson Alex
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-12-16 19:42
    Bronson,

    I just did some testing with my Ping and a QuickStart board. Man, those Pings are impressive. I set the Ping on the table and had it measure the distance to the ceiling. The Ping measured the ceiling as 1681mm away (it would sometimes flucuate to 1681mm). I got out my tape measure and sure enough the ceiling was 1680mm from the front of the Ping sensor.

    I moved the Ping sensor on top of my battery pack and it then read 1662. You guessed it, my battery pack is 18mm thick.

    I measured several other distances (including some about 800mm) with both the Ping and my measuring tape. The two measurements always agreed within 2mm. I'm not sure if the 2mm difference if from the Ping or my ability accurately measure distance with my tape measure.

    All these tests were done with nice flat surfaces such as the ceiling and the floor.

    I also measured distances to my hand and a soda can. At a little over a meter away the ping didn't always sense the presence of the can (unless the bottom of the can faced the Ping).

    My assumption is, if the Ping can sense an object, it can measure its distance precisely.

    Blowing across the front of the sensor didn't seem to affect it. I got out my heat gun and blew hot air across the front of it (it fluctuated a couple of mm) (only a few inches of the air in front of the Ping was heated). I haven't tested the Ping in air of different temperature but the affect of heat on the speed of sound is pretty well understood (more on this later).

    I just read up about the speed of sound on Wikipedia. The speed of sound in dry air at 25C is 346.45 m/s. The Basic Stamp's 2us resolution in time should translate to 0.69mm resolution in distance. The best precision that can be expected when using a Ping sensor with a Propeller is about 0.004mm. Of course this assumes you've very accurately measured the temperature. A 5C change in temperature would throw off your reading by about 1%. Humidity can influence the reading by up to 0.6%.

    My gut feeling is the 0.5 cm resolution shouldn't be too hard to achieve with a Ping. If the temperature and humidity are likely to vary a lot then Phil's suggestion of a quick calibration should help the microcontroller compensate for the difference in the Ping's output. If the Ping is always going to be in the same location, you could use the floor or the ceiling as calibration references.

    Edit: I just looked at the Ping object for the Propeller. Its resolution is 1us which gives a distance resolution of about 0.35mm. The Propeller would need a different Ping object to get 0.004mm (12.5ns) resolution. With all the other unknowns, I doubt it would be worth the trouble to increase the Ping object's current resolution.
  • BronsonBronson Posts: 44
    edited 2011-12-18 18:59
    Duagne,

    OMG!!! You have done a lot to help me. Can't thank you enough.
    Thanks for your valuable information.

    Regards,
    Bronson Alex

    Duane Degn wrote: »
    Bronson,

    I just did some testing with my Ping and a QuickStart board. Man, those Pings are impressive. I set the Ping on the table and had it measure the distance to the ceiling. The Ping measured the ceiling as 1681mm away (it would sometimes flucuate to 1681mm). I got out my tape measure and sure enough the ceiling was 1680mm from the front of the Ping sensor.

    I moved the Ping sensor on top of my battery pack and it then read 1662. You guessed it, my battery pack is 18mm thick.

    I measured several other distances (including some about 800mm) with both the Ping and my measuring tape. The two measurements always agreed within 2mm. I'm not sure if the 2mm difference if from the Ping or my ability accurately measure distance with my tape measure.

    All these tests were done with nice flat surfaces such as the ceiling and the floor.

    I also measured distances to my hand and a soda can. At a little over a meter away the ping didn't always sense the presence of the can (unless the bottom of the can faced the Ping).

    My assumption is, if the Ping can sense an object, it can measure its distance precisely.

    Blowing across the front of the sensor didn't seem to affect it. I got out my heat gun and blew hot air across the front of it (it fluctuated a couple of mm) (only a few inches of the air in front of the Ping was heated). I haven't tested the Ping in air of different temperature but the affect of heat on the speed of sound is pretty well understood (more on this later).

    I just read up about the speed of sound on Wikipedia. The speed of sound in dry air at 25C is 346.45 m/s. The Basic Stamp's 2us resolution in time should translate to 0.69mm resolution in distance. The best precision that can be expected when using a Ping sensor with a Propeller is about 0.004mm. Of course this assumes you've very accurately measured the temperature. A 5C change in temperature would throw off your reading by about 1%. Humidity can influence the reading by up to 0.6%.

    My gut feeling is the 0.5 cm resolution shouldn't be too hard to achieve with a Ping. If the temperature and humidity are likely to vary a lot then Phil's suggestion of a quick calibration should help the microcontroller compensate for the difference in the Ping's output. If the Ping is always going to be in the same location, you could use the floor or the ceiling as calibration references.

    Edit: I just looked at the Ping object for the Propeller. Its resolution is 1us which gives a distance resolution of about 0.35mm. The Propeller would need a different Ping object to get 0.004mm (12.5ns) resolution. With all the other unknowns, I doubt it would be worth the trouble to increase the Ping object's current resolution.
Sign In or Register to comment.