Sunday, April 4, 2010

Arduino Using Ping ))) (tm)

Here is your latest snippet.

The Class


Ping)))™

What is Ping? “Ping” is a networking term used to troubleshoot network issues. It sends out a request and times how long before the response. It is analogous to a sonar ping used in submarines where a sound (audible or inaudible) is sent out and the response is timed to determine the distance of objects in water.

This demonstration uses a product from Parallax.com that is also called “ping”. Ping ))) ™ to be exact.

From the Parallax website: The Ping sensor measures distance using sonar; an ultrasonic (well above human hearing) pulse is transmitted from the unit and distance-to-target is determined by measuring the time required for the echo return. Output from the PING))) sensor is a variable-width pulse that corresponds to the distance to the target.

Read the Wikipedia entry: http://en.wikipedia.org/wiki/Sonar

Using Sonar

The Arduino chip is used to measure the distance as sound travels at a generally predictable rate through air at given densities (generally associated with altitude). The variances aren’t beyond usable in hobby robots.

Arduino supplies some code with the development platform code that handles the Ping )))™ (heretofore called just “Ping”) does return distance based on time of signal return. For this demonstration, functionality was added:

a) Delta distance

b) Indicating delta distance

c) Indicating direction

Sonar may be made more useful if other data points are included. Because the distance is measured with sound, it is not precise. The more measurements that are taken, then generally, the better the data on distance. However, there has to be a stopping point somewhere. This demonstration code takes the average (mean) of 4 distance samples. A better determination might be made taking the modal values and discarding the rest. This will be left as an exercise.

Once an acceptable distance is measured, the value is kept until the next measurement is averaged. The two distances are compared and the Delta (finite forward difference) of the distance is taken. From the Delta, direction may be determined- if the distance is smaller, then the gap between Ping and the sensed object is closing. If the distance is greater, then the gap is increasing.

Since the time between samples is known, then the rate of Delta may also be determined. At this point the following items are known:

Two distances

The Delta of those two distances

The rate of Delta for those two distances

Once the above information is in-hand...

==============

I know, this is such a tease- remember that the document is still in draft status right now.
Enjoy!