1 / 6

PING))) Ultrasonic Distance Sensor

living with the lab.

hasad
Download Presentation

PING))) Ultrasonic Distance Sensor

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. living with the lab The PING))) sensor emits short bursts of sound and listens for this sound to echo off of nearby objects. The frequency of the sound is too high for humans to hear (it is ultrasonic). The PING))) sensor measures the time of flight of the sound burst. A user then computes the distance to an object using this time of flight and the speed of sound (1,126 ft/s). PING))) Ultrasonic Distance Sensor ultrasonic pressure waves from PING))) speaker sound wave reflects off object andreturns to PING))) “microphone”

  2. living with the lab Computing Distance The PING))) measures the time required for the burst of sound to travel to the target and then back to the PING))). The speed of sound is 1,126 in dry air at 68°F, which means that sound can travel 1 inch in 74 μs: Since the sound wave must travel out to the target and back again, a factor of 2 must be incorporated into distance calculations. If a variable “duration” records the time of flight of the sound wave, then the distance to the target in inches is computed as follows:

  3. living with the lab Specifications • measurement range: 0.8 in to 120 inches • supply voltage: 5V • supply current: 30mA sensing distance (feet) as a function of angle www.parallax.com/Portals/0/Downloads/docs/prod/acc/28015-PING-v1.6.pdf

  4. AREFGND1312PMW 11PMW 10PMW 987PMW 6PMW 54PMW 32 TX 1RX 0 POWER ANALOG living with the lab DIGITAL Connection to an Arduino Arduino RESET3V35VGNDGNDVin012345

  5. living with the lab Arduino Sketch • The Arduino triggers the PING))) by sending a 5µs (5 microsecond) pulse to the sensor through pin 7, which is initially configured as an Arduino OUTPUT. • Immediately after sending this pulse, pin 7 is switched to an INPUT. • When the PING))) receives the 5µs pulse from the Arduino, it sends a 40kHz (ultrasonic) burst of sound out its “speaker” and sets pin 7 to HIGH. • The PING))) then waits for the sound burst to reflect off of something and return to the “microphone” where it is detected; the PING))) then sets pin 7 to LOW. • The Arduino uses the pulseIn command to measure the time of flight of the sound wave in microseconds (the time that pin 7, when configured as an input, is HIGH). • The “time of flight” of the sound wave in µs is stored in the variable “duration.” void setup() { Serial.begin(9600); } void loop() { long duration, inches; pinMode(7, OUTPUT); // send a 5 microsecond pulse out pin 7digitalWrite(7, LOW); delayMicroseconds(2);digitalWrite(7, HIGH);delayMicroseconds(5);digitalWrite(7, LOW); pinMode(7, INPUT); // make pin 7 an inputduration = pulseIn(7, HIGH); // measure the time of flight of sound wave inches = duration / 74 / 2; // 1130 ft/s * 12in/ft * 1s/1,000,000us = 74// factor of 2 since sound travels out and back Serial.print(inches); // display distance in inchesSerial.print("in ");Serial.println();}

  6. living with the lab Example Application The picture shows how stiff wire (such as a coat hanger) can be used to mount the PING))) to an aluminum plate. An Arduino and breadboard are also mounted to the plate, and a piezospeaker is installed on the breadboard to allow the device to output an irritating noise whose frequency is proportional to the distance from the PING))) to a target. void setup() {pinMode(8, OUTPUT); } void loop() { long duration, inches, tone_freq; pinMode(7, OUTPUT); // make pin 7 an output digitalWrite(7, LOW); // send wakeup pulse delayMicroseconds(2); digitalWrite(7, HIGH); delayMicroseconds(5); digitalWrite(7, LOW); pinMode(7, INPUT); // make pin 7 an input duration = pulseIn(7, HIGH); // time of flight of wave inches = duration / 74 / 2; // compute distance in inches tone_freq = inches*100; // a freq of 100*inches is good tone(8,tone_freq); // send a tone out of pin 8 }

More Related