Shop OBEX P1 Docs P2 Docs Learn Events
Ping as a receiver — Parallax Forums

Ping as a receiver

Lee HarkerLee Harker Posts: 104
edited 2008-01-18 01:28 in BASIC Stamp
I've been using the Ping sensor recently and have gotten good results. I was wondering if anyone knows what it will do if you hit it with a ping that comes from another module? We will be using these with some robots for a class project and I thought there could be some rudimentary communication from one bot to the other. Maybe one bot could test for distance and when another bot·received the ping and it was not their own it would know another bot was in the area. I'm guessing that the receiver is only activated after the ping command has been sent but maybe not. Has anybody investigated this idea?
·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-01-17 17:29
    The PING's receiver is indeed activated only as part of the transmit / receive cycle used for distance sensing. The receiver can be triggered by an ultrasonic pulse from another PING if it comes in while the PING is waiting for its own pulse to be received. There is a timeout involved and the PING shuts down if it doesn't receive a pulse back within a period of time. You can see this if you have two PINGs attached to the same Stamp and you trigger them at the same time or closely together. Sometimes a reflection from one PING will reach the other and give a false distance reading since the PING won't hear its own reflected pulse if it comes after the one from the other unit.
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-01-18 00:51
    Yes, if two 'bots 'ping' at times close to one another, the first 'bot will recieve an echo "too soon" and get a wrong value.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-01-18 01:28
    One way to mitigate the problem would be to ping several times at random intervals. Then use the largest delay that you measure as your reading.

    The reason for randomizing the ping interval is so you won't inadvertently be synchronized to another bot that's using the same technique. With randomizing, each bot is more likely to find a time slot when the other isn't pinging. Just be sure that each interval of silence, or "holdoff time" is several times the longest expected echo delay.

    This "random holdoff" technique is often used in networking for dealing with collisions, when two network hosts try to transmit at the same time. Upon detecting a collision, each waits for a random length of time, then retries if the other hasn't already begun transmitting.

    -Phil
Sign In or Register to comment.