PING) ) ) ™ Ultrasonic Distance Sensor (#28015) : Features Key Specifications
PING) ) ) ™ Ultrasonic Distance Sensor (#28015) : Features Key Specifications
com
Forums: forums.parallax.com
Sales: [email protected]
Technical: [email protected]
Features
y
y
y
y
y
y
Key Specifications
y
y
y
y
y
y
y
Pin Definitions
GND
5V
SIG
Ground (Vss)
5 VDC (Vdd)
Signal (I/O pin)
Dimensions
Communication Protocol
The PING))) sensor detects objects by emitting a short ultrasonic burst and then "listening" for the echo.
Under control of a host microcontroller (trigger pulse), the sensor emits a short 40 kHz (ultrasonic) burst.
This burst travels through the air, hits an object and then bounces back to the sensor. The PING)))
sensor provides an output pulse to the host that will terminate when the echo is detected, hence the
width of this pulse corresponds to the distance to the target.
Host Device
PING)))
Sensor
tOUT
2 s (min), 5 s typical
Echo Holdoff
tHOLDOFF
750 s
Burst Frequency
tBURST
200 s @ 40 kHz
tIN-MIN
115 s
tIN-MAX
18.5 ms
200 s
b.
c.
Air Temperature
Temperature has an effect on the speed of sound in air that is measurable by the PING))) sensor. If the
temperature (C) is known, the formula is:
Cair = 331.5 + (0.6 TC ) m/s
The percent error over the sensors operating range of 0 to 70 C is significant, in the magnitude of 11
to 12 percent. The use of conversion constants to account for air temperature may be incorporated into
your program (as is the case in the example BS2 program given in the Example Programs section below).
Percent error and conversion constant calculations are introduced in Chapter 2 of Smart Sensors and
Applications, a Stamps in Class text available for download from the 28029 product page at
www.parallax.com.
Test Data
The test data on the following pages is based on the PING))) sensor, tested in the Parallax lab, while
connected to a BASIC Stamp microcontroller module. The test surface was a linoleum floor, so the
sensor was elevated to minimize floor reflections in the data. All tests were conducted at room
temperature, indoors, in a protected environment. The target was always centered at the same elevation
as the PING))) sensor.
Test 1
Sensor Elevation:
Target:
Test 2
Sensor Elevation:
Target:
VAR
VAR
VAR
Word
Word
Word
DO
PULSOUT 15, 5
PULSIN 15, 1, time
cmDistance = cmConstant ** time
inDistance = inConstant ** time
DEBUG HOME, DEC3 cmDistance, " cm"
DEBUG CR, DEC3 inDistance, " in"
PAUSE 100
LOOP
Propeller Microcontroller
{{
***************************************
*
Ping))) Object V1.1
*
*
(C) 2006 Parallax, Inc.
*
* Author: Chris Savage & Jeff Martin *
* Started: 05-08-2006
*
***************************************
Interface to Ping))) sensor and measure its ultrasonic travel time. Measurements can be in
units of time or distance. Each method requires one parameter, Pin, that is the I/O pin that
is connected to the Ping)))'s signal line.
PING)))
1K
Pin
Connection To Propeller
Remember PING))) Requires
+5V Power Supply
' Inches
' Centimeters
The ping.spin object is used in an example project with the Parallax 4 x 20 Serial LCD (#27979) to
display distance measurements. The complete Project Archive can be downloaded from the Propeller
Object Exchange at http://obex.parallax.com.
Project : "ping_demo"
Archived : Tuesday, December 18, 2007 at 3:29:46 PM
Tool : Propeller Tool version 1.05.8
ping_demo.spin
Debug_Lcd.spin
Serial_Lcd.spin
Simple_Serial.spin
Simple_Numbers.spin
ping.spin
/**
* This class provides an interface to the Parallax PING))) ultrasonic
* range finder module.
* <p>
* <i>Usage:</i><br>
* <code>
*
Ping range = new Ping(CPU.pin0);
// trigger and echo on P0
* </code>
* <p>
* Detailed documentation for the PING))) Sensor can be found at: <br>
* http://www.parallax.com/detail.asp?product_id=28015
* <p>
*
* @version 1.0 03 FEB 2005
*/
public final class Ping {
private int ioPin;
/**
* Creates PING))) range finder object
*
* @param ioPin PING))) trigger and echo return pin
*/
public Ping (int ioPin) {
this.ioPin = ioPin;
}
/**
* Returns raw distance value from the PING))) sensor.
*
* @return Raw distance value from PING)))
*/
public int getRaw() {
int echoRaw = 0;
CPU.writePin(ioPin, false);
// setup for high-going pulse
CPU.pulseOut(1, ioPin);
// send trigger pulse
echoRaw = CPU.pulseIn(2171, ioPin, true); // measure echo return
// return echo pulse if in range; zero if out-of-range
return (echoRaw < 2131) ? echoRaw : 0;
}
/*
*
*
*
*
*
The PING))) returns a pulse width of 73.746 uS per inch. Since the
Javelin pulseIn() round-trip echo time is in 8.68 uS units, this is the
same as a one-way trip in 4.34 uS units. Dividing 73.746 by 4.34 we
get a time-per-inch conversion factor of 16.9922 (x 0.058851).
/**
* @return PING))) distance value in tenths of inches
*/
public int getIn10() {
return (getRaw() * 3 / 5);
// raw / 1.6667
}
/*
* The PING))) returns a pulse width of 29.033 uS per centimeter. As the
* Javelin pulseIn() round-trip echo time is in 8.68 uS units, this is the
* same as a one-way trip in 4.34 uS units. Dividing 29.033 by 4.34 we
* get a time-per-centimeter conversion factor of 6.6896.
*
* Values to derive conversion factors are selected to prevent roll-over
* past the 15-bit positive values of Javelin Stamp integers.
*/
/**
* @return PING))) distance value in centimeters
*/
public int getCm() {
return (getRaw() * 3 / 20);
// raw / 6.6667
}
/**
* @return PING))) distance value in millimeters
*/
public int getMm() {
return (getRaw() * 3 / 2);
// raw / 0.6667
}
}
This simple demo illustrates the use of the PING))) ultrasonic range finder class with
the Javelin Stamp:
import stamp.core.*;
import stamp.peripheral.sensor.Ping;
while (true) {
// measure distance to target in inches
distance = range.getIn();
// create and display measurement message
msg.clear();
msg.append(HOME);
msg.append(distance);
msg.append(" \"
\n");
System.out.print(msg.toString());
// wait 0.5 seconds between readings
CPU.delay(5000);
}
}
}