Shop OBEX P1 Docs P2 Docs Learn Events
hey guys, help with Ping))) — Parallax Forums

hey guys, help with Ping)))

zeiczeic Posts: 1
edited 2014-02-25 08:50 in Accessories
I need to help me how to interface a microcontroller PIC 16F877A with your ping sensor

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2014-02-25 06:33
    zeic,

    Welcome to the Forums!!

    First off you will need to start by making the Pin that you select on your 16F877A a logic "LOW" and an output.
    Then you will need to make that same pin a logic "HIGH" for about 10us (micro seconds) and then to a logic "LOW"
    Immediately following that you will need to make the pin an input and time how long it takes for the pin to go "HIGH" again. <-- This HIGH will be the echo, and the time returned will be an arbitrary value that won't have any "weight" unless you know the precise unit of time (instruction clock speed) of your 16F877A. Keep in mind that this returned time will be the time of flight "there and back". If the pin does not go HIGH, then you will need to make previsions in code for the PING to timeout. This condition simply means that the PING sensor is aiming at something too far away to receive a valid echo response.
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2014-02-25 08:42
    A small modification to what Beau said. After the 10µs trigger pulse, turn the pin into an input, and look for the low to high transition, which will occur at about 180µs after the trigger pulse. Then start your timer, and stop it when the pin goes low again. Use the duration high, times the speed of sound, to calculate the distance there and back.

    The PING))) itself times out after 20 milliseconds.

    I've just been looking at this in another thread. Here are a couple of 'scope shots. Voltage on the pin is the yellow trace #1, and the trigger pulse is enhanced with orange and also shown time-expanded as trace #A. First shot shows a return echo of about 1ms. In the second shot, the PING))) times out at about 20ms, from pointing off into open space. The other thread had to do with how to make it time out sooner, for faster response.

    echo1ms.png
    echo20ms.png
    640 x 480 - 7K
    640 x 480 - 7K
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2014-02-25 08:50
    Zeic, Also, welcome to the forum. I edited your thread title. You'll have better luck with responses when the title is descriptive, more than just "hey guys"!
Sign In or Register to comment.