Shop OBEX P1 Docs P2 Docs Learn Events
Receiving ultrasonic signal w/ prop? (Audio Spectrum Analyzer? Oscilloscope?) — Parallax Forums

Receiving ultrasonic signal w/ prop? (Audio Spectrum Analyzer? Oscilloscope?)

DogPDogP Posts: 168
edited 2009-07-01 20:21 in Propeller 1
Hey,

If I want to receive an ultrasonic signal (or audio signal for that matter), how would I do that w/ a prop? I've looked at the oscilloscope demo, but I don't think that'd work because the amplitude isn't high enough to visually see it (I'd like 20-30 ft or so detection). I don't need to actually decode any data from it... just determine that it _did_ arrive. The Spectrum Analyzer seems like a possible fit, but the problem with that is that I need to know exactly _when_ it arrived (some lag is okay as long as I can determine when it actually arrived). I'm trying to create something similar to the typical ultrasonic range finder, except longer distance. I saw this at Home Depot tonight: www.sonin.com/UltrasonicRangeandStudFinder.html, which got me sorta thinking about a long(ish) distance ultrasonic ranging project I've been wanting to work on.

Any ideas? I plan on sending a tone at exactly 40.5KHz, so can I do something like sampling at exactly 4 times the frequency and look for the 11001100..... pattern? Will the prop actually switch states from such a tiny input (ultrasonic electret mic, receiver, transceiver, etc) at this distance (er... I guess... will the signal be greater than the noise)? Or could I help it by adding a really tight filter with an amp (if I could actually make a tight enough analog filter to help)? Or should I get a hardware ADC rather than using the sigma delta? I'm used to doing this kinda stuff with RF on software radios, but I think it can be done here as well. I'm just not really sure where to start with implementing it on the prop, so I'd appreciate any input.

And if there's already a module out there that outputs a digital signal when an ultrasonic signal is detected, or if that'd be an easier circuit to make, then just watch for the digital signal on the prop, that'd work great too.

Thanks,
DogP

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2009-06-28 13:23
    Hello DogP,

    if the signal is greater than the noise depends on a alot of things that we can't see from here

    how much power does your ultrasonic-sender have ?
    what's his characteristic ? small beam ? or wide spreading all over ?

    the counters of the prop can measure frequencies which might be an aproach too

    what do you want to do IN THE END ?

    in the past almost every time when the forum knows what should be done in the end
    new and often easier to realise solutions are found

    best regards

    Stefan
  • DogPDogP Posts: 168
    edited 2009-06-28 19:48
    The proposed sender is: search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=P9893-ND ... it'll take 20Vrms, and I'll drive it with whatever voltage it needs up to that. It's supposed to output 105dB SPL with a pretty wide beam (max at 0 deg, -15dB at 90 deg). The wide beam is the reason I want to use this over another.

    The receiver will either be an electret mic known to work at ultrasonic freqs: search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=P9925-ND , or ultrasonic sensor: search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=423-1086-1-ND , or ultrasonic transducer: www.sparkfun.com/commerce/product_info.php?products_id=8505 .

    What I'd like to do in the end is have 4 ultrasonic sensors in a room with an ultrasonic transmitter sending beacon pulses, then locate the transmitter's position by taking the difference in time arrival at each sensor. It's an easy concept, but the details of implementation on a prop aren't totally obvious. On a PC, I'd just take 4 mic inputs, apply a narrow digital filter, and if I needed to, do lots of small FFTs (or probably DFTs) and determine the time down to the resolution that I want. 1ms is about 1ft, which is what I'd like to do (or better), which would be about 40 cycles received. But I figure there's gotta be a much simpler way to detect "the presence of" a signal than that. Correlation on the Prop seems to me like the most obvious method to me.

    I think it should be doable, since using a tiny speaker and sending even a pretty quiet 1KHz tone can be heard anywhere in the room, and I even tested it with the voice recorder mode of my cell phone and I could hear it in the recording. Of course the ultrasonic transmitter is more directional than a speaker, but with the specs of the transmitter (-15dB at 90 degrees) I think a sensor sensitive at that frequency could "hear" it as well (I haven't tried hooking it up to my PC, since I'm not sure if my sound card supports 96KHz sampling).

    So yeah... if anyone has any ideas/input, I'd appreciate it!

    Thanks,
    DogP
  • KyeKye Posts: 2,200
    edited 2009-06-28 22:22
    Well, you would want to setup a few rountines:

    Cog 1 - Setup this processor to output a burst of tones of some kind of repeating data pattern with a easily seen start and end.
    This processor communicates with the transducer.
    This processor should save a snap shot of the system counter when it starts sending (snap1c1).
    This processor should save a snap shot of the system counter when it finishes sending (sna2pc1).

    Cog 2 - Setup this processor to input the burst of tones produces by cog 1 using the start and end when seen.
    This processor communicates with the receiver.
    This processor should save a snap shot of the system counter when it starts receveing (snap1c2).
    This processor should save a snap shot of the system counter when it finishes receveing (snap2c2).

    cog 3 -
    This processor computes (snap1c2 - snap1c1) and accounts for roll over if the value computed is negative by adding (2^32) - 1.
    This processor computes (snap2c2 - snap2c1) and accounts for roll over if the value computed is negative by adding (2^32) - 1.

    This processor then averages the two values and puts the out to (averageTime).

    ...

    And with that you can do whatever else you need.

    The average time valiable will have the time it took to travel it in. But the variable will be in system counter ticks so you will need to do a bit of math on it first.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,

    Post Edited (Kye) : 6/28/2009 10:27:16 PM GMT
  • DogPDogP Posts: 168
    edited 2009-06-29 01:30
    Kye: Thanks, but the real problem I'm trying to figure out is getting the data from the receiver into the prop (the trigger for your Cog 2 start receive and finish receive). How can I get the prop to determine that the signal is being received?

    I'm also not going to be doing the sending and receiving from the same prop... the transmitter will be completely independent, and the receiver will have 4 sensors and determine the difference in receive time, which will give the distance relative to the distance of the first sensor that received the signal. Since the sensors will be in known fixed positions, I'll be able to compute the exact location of the transmitter. It'll be like solving a word problem: X arrived at B 10ms after A, C 8ms after A, D 14ms after A, and A is at (-15,-15,10), B at (-15,15,10), C at (15,15,10), and D at (15,-15,10)... where is X? You know B is 10ft further from X than A, C is 8ft, D is 14ft. You'll get a hyperboloid solution for each, which will intersect at a single point. I believe the technical name for this method is Multilateration: en.wikipedia.org/wiki/Multilateration.

    I could also do it with 3 sensors and a coordinated transmit time (so I know the exact distances from all 3 sensors), then I need a way to instantly (or instantly enough) tell the receivers that the transmitter is starting. I like the 4 sensors method better though.

    DogP
  • Chad GeorgeChad George Posts: 138
    edited 2009-06-29 01:43
    I've been thinking about something similar for a little while now.

    I once saw a technology from one of the ivy league schools where they were sending simultaneous radio and ultrasonic transmissions (i think they called it cricket or something like that...don't remember and couldn't find it again quickly)

    This makes the "time-frame" issue is pretty much solved since the radio signal travels instantaneously enough over short distances ... at least compared to sound.

    Also this scales better when there are multiple targets that need to be located, like in the application I have in mind.

    I'm probably going to follow this approach... and I planned on using the maxbotics transducers since they're cheap and I've had good success with their ultrasonic rangers that use the same transducer.

    I've also considered using ultrasonic dog repellers and even the ultrasonic transducers in the "cool vapor" humidifiers.
  • DogPDogP Posts: 168
    edited 2009-06-29 02:43
    Yeah, 3 sensors and an RF (or light) signal to tell that it's transmitting works, but why do you say it's better for multiple targets? Unless the other targets listen for the transmission and back off until the longest propogation time has passed, they can still step on each other. For multiple targets, my plan was to use different frequencies, then you wouldn't have to worry about collisions. The 3 sensor w/ coordinated transmit time is probably easier on the math, but the 4 sensor solution is completely workable, and according to wikipedia: "Multilateration is, in general, far more accurate for locating an object than sparse approaches such as trilateration, where with planar problems just three distances are known and computed". I guess it'd just depend how accurate the measurements are and the resolution needed.

    How do you plan on detecting the exact arrival time of the ultrasonic pulse though? Are you planning on doing this w/ the prop, or something else?

    The problem I have w/ the Maxbotics is the relatively narrow beam (-18dB at 35 degrees), so I'd need 4+ transmitters aimed in multiple directions, compared to one that'll cover an entire hemisphere (that's all I need since I know the sensors will be above the transmitter). And yeah, I've also looked at the ultrasonic dog repellers, but it seems that most of those are pretty directional (and not any cheaper/better than raw transmitters).

    DogP
  • JonathanJonathan Posts: 1,023
    edited 2009-06-29 14:47
    I've been working on a similar navigation system for a while. I have all the hardware built but got stumped by the math. My system is slightly different, the RX is mounted on the 'bot. I have three "beacons" with TX transducers. I have an RF TX on the 'bot and RF RX on the beacons. The 'bot requests a ping from the beacons in turn. The 'bot uses a prop and the beacons use an SX. I use an op amp and comparator on the RX side to amplify and filter the US ping. The hardware works pretty well, but as I said the math to determine location stumped me. I'd love to talk to you off list about the math, I'll shoot you a PM.

    Oh, as to directionalty, what I did is put 3 TX transducers on each beacon, aimed 45 degrees apart. The'bot has 2 RX transducers, mounted 180 degrees apart on a tower that can be rotated by a servo. In my tests this was enough to get accurate enough readings. I found that if the beacon/bot transducers aren't fairly well in line the inaccuracy builds up quick, but as long as they are about 10-15 degrees from each other it's ok.

    Jonathan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
  • Chad GeorgeChad George Posts: 138
    edited 2009-06-29 15:24
    DogP said...
    but why do you say it's better for multiple targets? Unless the other targets listen for the transmission and back off until the longest propogation time has passed, they can still step on each other.

    I think you misunderstood what I was suggesting. The "transmitters" that need to coordinate with each other are the fixed units not the targets.

    The targets are passive with respect to the localization system, they only listen for the sonic and radio signals and they can do their own localization because the "fixed-position" of the transmitters is sent along with the radio trigger signal.

    In your system its reversed.. the units doing the transmitting are also the localization targets... whenever you add more things to locate you have to deal with additional transmitters that need to coordinate. If you want to locate more than one thing this will pretty quickly degrade the overall update rate of the system.

    For me I want to locate 8-10 robots in a relatively small 30-50 ft range at 5-10hz update rate. Basically, I want something analogous to DGPS but that will work indoors too.
    DogP said...
    How do you plan on detecting the exact arrival time of the ultrasonic pulse though?

    My initial thought here is to modulate a triangle wave pattern within the ultrasonic pulses. As long as enough of the pattern is received the exact trigger point of the radio signal can be reconstructed from the demodulated signal.

    This will give the high resolution position fix...if there wasn't enough signal received to determine the trigger point then only a low resolution fix will be recorded.
  • KyeKye Posts: 2,200
    edited 2009-06-29 15:28
    Well, for getting data into the propeller chip you want an adc attached to the receive and you would just look for a spike in the values returned by the adc.

    ... I'm sorry, but how you do that is implementation specific.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • localrogerlocalroger Posts: 3,452
    edited 2009-06-29 23:30
    DogP, I think for what you're doing your best bet is to apply the spectrum analyzer technique, where you overlay successive samples that are your target freq's period long and measure the amplitude; if your target freq is there they add up, but other frequencies will "average out." It's pretty fast and uses pretty simple math that leverages the Prop's architecture well. Depending on your sensor you might need a preamp to get the received voltage into a range where the prop ADC can see it above the noise floor; a scope (even the software prop scope using your ADC circuitry) can be useful for this. This is important because the closer to the noise floor your signal is the more periods you will need to overlay to solidly detect it, and that will reduce your distance accuracy.
  • HannoHanno Posts: 1,130
    edited 2009-06-30 00:38
    A while ago I did a simple test with a demoboard, a ping sensor, and ViewPort. I used the ping sensor to send out the ultrasonic signal and used the microphone on the demoboard to listen for the return. I used ViewPort to trigger and graph the signal. Pretty cool seeing the ~4 waves of ~20 kilohertz sound energy. If I looked carefully I could tell the difference between hard/soft surfaces.
    Hanno

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Download a free trial of ViewPort- the premier visual debugger for the Propeller
    Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!
  • DogPDogP Posts: 168
    edited 2009-06-30 06:19
    Thanks for all the input!
    Chad George said...
    I think you misunderstood what I was suggesting. The "transmitters" that need to coordinate with each other are the fixed units not the targets.
    Ah... I see what you're saying... so basically you have to assume that the bots don't move too quickly that their position has changed significantly between pulses from the individual transmitters (or do simultaneous w/ multiple frequencies)?
    localroger said...
    DogP, I think for what you're doing your best bet is to apply the spectrum analyzer technique, where you overlay successive samples that are your target freq's period long and measure the amplitude; if your target freq is there they add up, but other frequencies will "average out." It's pretty fast and uses pretty simple math that leverages the Prop's architecture well. Depending on your sensor you might need a preamp to get the received voltage into a range where the prop ADC can see it above the noise floor; a scope (even the software prop scope using your ADC circuitry) can be useful for this. This is important because the closer to the noise floor your signal is the more periods you will need to overlay to solidly detect it, and that will reduce your distance accuracy.

    Yup... I keep thinking back to the spectrum analyzer technique... my biggest problem with that is that I'm looking at the frequency components, so I'd need to break it into small chunks to determine when it occured... and 1ms resolution (~1ft) is only 40.5 cycles at 40.5KHz. 1ft resolution is okay, but I'd like to do better... maybe smaller chunks would be doable, but of course the smaller chunks I look at, the less the signal accumulates.

    From some thinking and everyone's input, I think the way for me to go may be amplify the signal to make sure the prop detects it, and filter the signal to just the frequency that I want (or use a sensor that's only sensitive at my desired frequencies). This will give me a sensor with sensitivity only at my desired frequency... then I should be able to simply watch the power of the signal to determine whether a signal is present or not. Since I wouldn't be detecting the actual frequency, this would only give me the ability to do one frequency (which is really my main application), although multiple would be possible by RF signaling to do time division.

    Does that sound like a reasonable solution?

    Thanks,
    DogP
  • Beau SchwabeBeau Schwabe Posts: 6,572
    edited 2009-06-30 07:00
    DogP,

    If you are just looking at 1 particular frequency, the spectrum analyzer technique should work just fine. You should take your measurements in quadrature though. I.E. for the period of 40kHz which is 25us you need to sample at every 90 deg or 6.25us. Since you know what the value or position of the wave is supposed to be at every 90 deg position if your input agrees with the correct value then you add to an accumulator, and if the input disagrees with the correct value you subtract form an accumulator. Each accumulator should be 180 deg appart, so you will have 2 of them. One of which is associated to the 0 and 180 deg position, and the other accociated to the 90 and 270 deg position. By squaring the value of each accumulator and then adding them together you complete Pythagorean theorom solving for the Hypotenuse or in this case the signal strength.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • DogPDogP Posts: 168
    edited 2009-07-01 06:35
    Okay... thanks, that technique makes sense.

    Sorry for what I know is a stupid question, but to do this, I don't use the sigma delta ADC, correct? I still haven't wrapped my head completely around the sigma delta ADC. It seems like what I want is to very weakly bias the input right at the switching threshold and use an analog input to cause it to switch logic (1 bit ADC), which if asked, I'd say do a voltage divider to make the voltage at the input 1/2 Vcc.

    The sigma delta achieves its usefulness by constantly outputting the opposite of the current digital state, and recording the new state, right? But if I only sample at 160KHz with a feedback pin, I don't think I could know the true analog value from just one sample. Pulling the input pin to exactly the switching threshold could tell me something about the true analog signal from just one sample at my sampling frequency though (I think the sigma delta will give a stream of bits, with the number of 1s is proportional to amplitude, but a voltage of 1.7V and 1.5V will look mostly like 1010, while a resistor divider will always be 1 @ 1.7V and 0 @ 1.5V).

    Thanks,
    DogP
  • Beau SchwabeBeau Schwabe Posts: 6,572
    edited 2009-07-01 14:55
    DogP,

    "but to do this, I don't use the sigma delta ADC, correct?" - You could use an external method to keep a voltage reference exactly at threshold, or you could configure the counter as an inverter (basically a 1-bit ADC) that has the output tied back to the input via a feedback resistor.· This method·uses the threshold of the I/O to determine the opposing output level.· With a large value for the feedback resistor (1M to 10M), the·input can be weakly biased·at the switching threshold.· This method is what the audio spectrum analyzer uses but keep in mind that it has a 12.5ns bias (or an inverter with a 12.5ns propagation delay).

    Another method would be to use an external DAC tied to the I/O pin through a large feedback resistor (1M to 10M).··You adjust the DAC until the input pin being monitored, just starts to report random 1's or 0's indicating that you are right at the pins threshold.· The reason you don't want a fixed resistor divider, is that temperature will effect the threshold, and/or the resistor divider.· A DAC can dynamically track the threshold through software and any temperature fluctuations on the I/O will drop-out.

    The second method would provide the best gain keeping you closer to the I/O's threshold voltage depending on the resolution of the DAC (cascoding multiple DAC's may be an option here to increase the perceived DAC resolution).· I know that this may seem counter intuitive, but the closer you are to the thresholds "noise floor" the more sensitive you are to any external "signal" that would be trying to influence the I/O ,·which is desirable in this circumstance.






    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 7/1/2009 3:02:35 PM GMT
  • DogPDogP Posts: 168
    edited 2009-07-01 20:21
    Excellent suggestions and explanations... what you're saying is totally clear now [noparse]:)[/noparse]. Now I just need to make it happen.

    Thanks,
    DogP
Sign In or Register to comment.