Shop OBEX P1 Docs P2 Docs Learn Events
Programmable Acoustic Distance Sensor (PADS): I think I'm doing something wrong — Parallax Forums

Programmable Acoustic Distance Sensor (PADS): I think I'm doing something wrong

varnonvarnon Posts: 184
edited 2012-09-11 05:15 in Accessories
So I have a pair of pings, which I love. I thought it would be fun to get a PADS to see if I could make use of the extended range and other features. Unfortunately, I don't seem to know what I am doing with the PADS. For those of you who haven't seen it (or didn't create it) the documents for PADS are here: http://www.gadgetgangster.com/find-a-project/56.html?projectnum=138

The first issue:
The description of use sounds like the same code can be used to get a us reading from the the ping or the PADS.

"To trigger a reading: apply a 5usec pulse of 3.3V to 5V, to pin 3 the Signal pin. After an approximately 750 usec delay from your input pulse end the P.A.D.S will pull the pin high. The time from this pin high to when it goes low is the travel time for the acoustic pulse to the target."

The official ping code seems like it should work for either sensor.
PUB Ticks(Pin) : Microseconds | cnt1, cnt2
''Return Ping)))'s one-way ultrasonic travel time in microseconds
                                                                                 
  outa[Pin]~                                                                    ' Clear I/O Pin
  dira[Pin]~~                                                                   ' Make Pin Output
  outa[Pin]~~                                                                   ' Set I/O Pin
  outa[Pin]~                                                                    ' Clear I/O Pin (> 2 µs pulse)
  dira[Pin]~                                                                    ' Make I/O Pin Input
  waitpne(0, |< Pin, 0)                                                         ' Wait For Pin To Go HIGH
  cnt1 := cnt                                                                   ' Store Current Counter Value
  waitpeq(0, |< Pin, 0)                                                         ' Wait For Pin To Go LOW 
  cnt2 := cnt                                                                   ' Store New Counter Value
  Microseconds := (||(cnt1 - cnt2) / (clkfreq / 1_000_000)) >> 1                ' Return Time in µs

However, using this code I get notably different measurements. I have both the ping and the PADS running in alteration with a delay of 1 second. (The large delay is just to rule out interaction. I've had both pings running in alteration at 10 times a second with no problem.) Both are powered with 5 volts and have a 3.3k ohm on the sensor pin.

When measuring from my table where the device sits to a chair about 15 inches away, the ping is reports around 1030us (14 inches) while the PADS reports around 1180us (8.1 inches). With the chair 24 inches away, the ping reports around 1770us (24 inches) while the PADS reports around 760us (5.1 inches). With a cardboard box about 5 inches away from the sensors the ping reports around 470us while the PADS reports 727us (4.8 in) to 937us (6.2 in). For this test it jumps between these two values for some reason.

In any test, if I swap out my PADS for a second ping, both pings return the same measurements.This should indicate that the slight difference in position of the sensors is not an issue.

I am using the formula "distance (m) = 171.71(m/sec)* t (sec)" to find the distance with the PADS. (I used a calculator, it is not part of the program at the moment.)

I don't know what to make of this discrepancy. It seems like the ping object should return the correct number of us. I have even tried controlling the pulse length by adding waitcnt(clkfreq/1_000_000 * 5 + cnt) after the output pin is turned on. No change. I'm not really sure where to look next.



Issue 2:

I don't understand many aspects of the I2C protocol. I think most of this is because I have no experience studying acoustics.

If I trigger a reading with writing 1 to register 0, then read the data in register 1, this appears to be the correct us delay. It converts to the correct distance. I don't really understand why it is called "peak" distance, nor do I understand why there are 10 of them. Additionally, I have no idea what "peak value" means.

What does "Detect changes versus baseline echo" mean? Does this mean you can get greater precision by taking a baseline measurement? It looks like this is done on when the PADS starts up, but I'm not sure.

So far with the I2C method, the ping appears to be more accurate (I have only tested up to about 80 inches). I'm really surprised by this and I can only think that there must be some features of the PADS that I am not using correctly. I really would like to use this device more, but at the moment I'm stumped. I'd be happy to hear the thoughts of anyone who has used. I would be especially happy to hear from the creator (Ed T).

If it helps, for my purposes I will have two ultrasonic sensors mounted in a fixed position in a chamber. The ranges of the sensors overlap so they will take measurements in alteration. I would like to take 10 measures per second. (This hasn't been a problem with 2 pings.) I am measuring the movement of animals. They are detected really well with the ping within 2.5 feet. I'm really playing with the PADS to see if that range can be expanded a bit. There are reasons I'm using ultrasonic sensors instead of IR beams. My colleagues wouldn't like it if I was more specific than that.

Thanks in advance for any thoughts

Comments

  • Ed TEd T Posts: 50
    edited 2012-09-11 05:15
    Hi Varnon,
    Thanks for trying the P.A.D.S! Hopefully I can answer some of your questions.
    On your first issue I suspect that because of the higher sensitivity of the PADS you are sensing something other than your targets that is closer than your targets. The Ping and the PADS (in Ping mode) do not look for the biggest reflection, they just look for the first one that exceeds a threshold. Look around your test area for anything at the 6-8" range that could be reflecting sound back to the sensor. The ones that most often give me trouble are right angle corners and rounded objects. The right angle corners act as a retroreflector and a round object always has some part of it pointing back at the sensor.

    Issue 2:
    If you can trigger a measurement and read back the results I would say you are doing fine with I2C. Your questions have to do with the commands and operation that are particular to the PADS.

    Below, for reference, is a picture (from Appendix VI in the manual) of the echo signal (blue) seen by the PADS on my test bench. Also shown is the threshold level (red). The peaks in the echo signal are reflections from various test objects.
    In Ping mode the first echo peak (left most) is the one that is measured. In I2C mode the time and magnitude of up to 10 echo peaks are measured and can be read back via the I2C connection. Peaks are only included if they exceed the threshold level.
    So "peak distance" = the time/distance to the one of the echo peaks.

    Regarding the "baseline echo", you are correct that the sensor takes a baseline reading when it starts up. The first 2 msec of this baseline are subtracted from subsequent measurements. Most of this is crosstalk from the ultrasound transmitter.

    The nice thing with I2C mode is that many of the operational parameters can be changed. For example you can raise the threshold level to make the sensor less sensitive. If you want to subtract the baseline for more than 2 msec you can change that.

    If you want to have the PADS take measurements continuously there is an auto-trigger mode. You can then just read the results via I2C as needed.

    Also with the PADS you can take 10 measurements per second with one sensor. This might be true of the PING also.

    Hope this helps.
    --Ed

    attachment.php?attachmentid=95484
    882 x 449 - 35K
Sign In or Register to comment.