LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

tone detection WITH time information??????

Hello everybody,
 
I record continiously sound with my soundcard(10000 Samples at 44100Samples/s.) In this waveform data I try to find 8.5ms sends long 12kHz pulses and the time when they occur.
 
 I'm using the single tone information VI which enables me to detect the 12kHz pulses. But I need to know when the pulse exactly occurs. Unfortuanetely the VI doesn't output this information although it gets the timing information(time of the 1st sample and sample rate) of the waveform data from the sound input read VI.
 
I need to determine the time when the pulse occurs in the order of an accuracy of a couple of ms up to 20ms.
 
What can I do to make the VI to give the time information or is there a better VI(s) you can recommend?
 
Thank you very much,
Martin
 
 
additonal infos:
LABVIEW 8..2.1
notebook dell latiude d630
internal standard sound card
 

Message Edited by LabviewHans on 07-18-2007 04:53 PM

0 Kudos
Message 1 of 20
(4,360 Views)
Martin,

What else is in the signal besides the 12 kHz tone? Are there other tones or noise? At what frequencies? What is the shape of the 12 kHz pulse? How do you define knowing "when the pulse exactly occurs"? Is it when the amplitude of the first cycle of the pulse exceeds some percentage of the maximum amplitude or some other parameter? Do the pulses start synchronously with the phase of the 12 kHz signal or at a random phase?

Defining the problem is a big first step toward solving it.

Lynn
0 Kudos
Message 2 of 20
(4,340 Views)
Hi Lynne,
 
sorry for the missing information. 😕
 
Let me describe the overall goal: I try to determine the distance between an underwater device and the ship. Therefore I send a ping from the ship to the underwater device with the computer->labview->soundcard->transducer(hydrophone) and then the underwater device replies by sending aSINGLE 12kHz 8.5ms pulse. The distance is:
 
distance = {(time when I receice the reply pulse) - (time when I sent the pulse to underwater deivice)} * {(sound velocity in water) / 2}
 
The hydrophone is in the water when I sent the pulse and when I listen to the reply. Therefore I have some background noise from the ocean plus the noise created by the soundcard itself. Usually the signal noise ratio is ok. Therefore I tried the following approach:
 
I get the time with the VI 'get time in seconds' when I sent the ping. In addition I get the time when the VI 'single tone measurement" detects when an amplitude at 12kHz exceeds a certain threshold(I'm also working on the determination of an appropriate threshold).  But this is not the real time when the reply puls hits the hydrophone at the ship. I tested this at sea and it works. But the distance is very inaccurate(about 125m off) and when the distance between ship and underwater device is constant and I ping multiple times labview gives me different distances varying from 820m up to 910m at a acutal distance of 700m, which is bad.
 
So, I guess I would like to have the time when the amplitude of the first cycle exceeds the threshold unless it is just a 2ms noise tone.
 
I attached a VI which demonstrates my approach.
 
Feel free to modify it and/or illustrate your approaches.
 
Thank you so much,
Martin
 
 
 
0 Kudos
Message 3 of 20
(4,326 Views)
Martin,

I have created a subset of your VI which simulates a pulse with noise and finds the time the pulse crosses a threshold. If it finds a pulse, it checks the frequency. Try it with different Frequencies, Offsets (pulse return delay from beginning of dataset), and Reply Thresholds.

This will not be very robust with poor signal to noise ratios but may give some ideas.

Lynn
0 Kudos
Message 4 of 20
(4,318 Views)

Hi Lynn,

thank you very much for your VI and the ideas. This is definetely a good solution. :manhappy:

Unfortunately it only works when the 8.5ms 12kHz reply pulse is the signal with the strongest amplitude. This is usually true around 12kHz(8kHz to 14kHz). But I get a lot of ocean and sound card noise at low frequencies(0kHz upt to 3kHz) with amplitudes in the order of the reply pulse or even bigger. After thresholding the waveform time data 1-D array we use the index where the first value is bigger than the threshold to determine the time when the reply pulse hit the hyrdophone. Therefore we assume that the first big amplitude of the amplitude-time data is related to the 12kHz pulse, which is not necessarliy true, especially if you have strong back groundnoise at low frequencies.

Therefore it might be better to look in the frequency domain for the pulse at its arrival time. I mean that's what the single tone information VI is doing. I computed a spectrogram(frequency versus time) in the attached a VI, where you can clearly see the 12kHz pulse, but the pulse is shown over the whole time, which is not true since we only have 8.5ms 12kHz out of 226ms total time data. Do you have an idea why that is or how I can get the time information of the 12kHz pulse?

I'm also trying to modify the single tone information VI to get time information....

Thanks a lot,

Martin

Message Edited by LabviewHans on 07-20-2007 12:11 PM

Message Edited by LabviewHans on 07-20-2007 12:11 PM

0 Kudos
Message 5 of 20
(4,312 Views)
Martin,

The spectrogram is a good idea. I think you had the time steps and window length paramters set too long. I brought them out as controls to seek out suitable values. Using the output of the spectrogram, you could check the bins at the target frequency for values above threshold and then scan along the time axis to locate the pulse timing. The columns around 139 peak when the frequency is 12000 and the rows from 64 to 87 have most of the pulse energy when the offset is 1000. By looking only at bins in the pulse frequency range you will miss your low frequency noise.

The "H"pattern you see, especially in linear mode, is due to the sharp edges of the pulse having energy in other part of the spectrum than just the pulse frequency. Window type selection and length can help reduce that, but may affect the frequncy or timing resolution.

Lynn
0 Kudos
Message 6 of 20
(4,297 Views)
Hello Lynn,

thank you very much for your ideas and you VI. :manhappy: I modified your VI and now I'm able to locate the pulse timing and therefore the distance. It works great.

That's why I tried to implement that into the actual VI where I get my data from the sound input VI. Unfortunately I ran into a couple of other problems, which I couldn't solve yet.

As you can see at my first VI I posted('Ranging.vi'), the sound input vi runs continiously(each run=10000 samples) in a while loop. Before I send a ping I stop the VI and then I send the ping and then I start the sound input vi right afterwards to receive the reply ping from the instrument.

One of my problems is that I don't know at which time or which index in the 10000sample waveform data is related to the first sample after the ping. So I  had to change the ranging.vi slightly. for that reason I clear the sound input task before I send a ping and create a new sound input task every time after sending a ping. Now the first value in my spectrogram array is related to the first sample after sending the ping. But now I have another problem. I'm sending a ping to the instrument and than I receive a reply ping after 12ms(=4.4m / 343m/s). But the index of the beginning of the pulse in my spectrogram array varies, so that the calculated distance is between 0m and 3m (in most cases 0m or 1m). I think this is related to the performance of the software/hardware. usually the vi is to slow to start immediately after sending a pulse and then I miss some samples before the beginning of the pulse which results into too small distances like 0m or 1m.

1)What can I do to figure out the time difference between the end of interrogate pulse generated by labview and the time of the first value of the spectogram, which is probably the time which labview needs to create a new sound input task and so on?

2) I also tried to get the timewhen I send a ping(get time vi) and to substract that from the timestamp of the of the sound input waveform data. But this timestamp is always wrong. According to the timestamp of the waveform data of the sound input vi I have to miss the reply pulse, but I never do.

3) do you have any  other ideas how to determine the time difference between  sending  an  interrogate ping and receiving a reply pulse as exact as possible?

Thank you so much for your help,
Martin

Message Edited by LabviewHans on 07-25-2007 03:53 PM

0 Kudos
Message 7 of 20
(4,269 Views)
Martin,

The problem with the approach you are using is that software timing is notoriously jittery unless you are using a real time OS. The time between sending the ping and getting the sound input started is variable because OS calls are involved and you cannot control how much time may elapse between the events.

The usual solution in such cases is to start the input acquisition before sending the output pulse. You may need a longer acqusistion or continuous acquisition. Hopefully the output signal can be attenuated at the input so that the input device is not overloaded. Then you capture both the outgoing ping and the return pulse in the input data stream. You measure the time between pulses rather than trying to control or calculate it.

Lynn
0 Kudos
Message 8 of 20
(4,257 Views)
Hi Lynn,

unfortunately I cannot record output and input signal due to the given hardware.

But I found out that there stopping the sound input vi for sending a ping and starting the sound input vi right afterwards should be ok in terms of hardly missing milliseconds. But I still don't know how can I determine the index of the first amplitude after sending a ping. (If you use Sound input stop VI the data aquisition is stopped immediately, for example at the 3432nd sample out of 10000 samples, and after starting the data aquistion the 3433rd sample would be the first sample after the sending the ping. The problem is that I have no clue how to determine the index(in the example 3433) of the first amplitude value after sending the ping.)

I tried a couple of things to realize that. Here are the two most promising trys:

I checked the sound input vi and I found something like nCumulativeSamplesRead, which sounds very promising, but just shows a value which is a multiple of the number of samples(10000, 20000, 30000 and so on. (reminder:sound input configure is configured for 10000samples at 44100Hz)

Another solution could be the following one: I click at the Send Ping button and I give the sound input vi as much time as it needs to get all 10000 samples. When the VI got its 10000samples the while loop would go into the next interation to get the next 10000samples. But exactly at that point I want to stop the sound input vi. Then I would send the ping. Right afterwards I would start the sound input vi and I would miss hardly milliseconds AND the first value in my array corresponds to the (almost) first amplitude value after sending the ping. This would enable me to determine the distance with an accuracy of a few m, which is sufficient.

But I really need your help at that point because I tried a lot to force the sound input VI to get 10000samples before stopping it, but nothing worked. 😞 Do you know how to realize that in Labview?

I created a little test VI...



Thank very much,
Martin

Message Edited by LabviewHans on 07-26-2007 02:38 PM

0 Kudos
Message 9 of 20
(4,245 Views)
Are you trying to detect when your array or waveform has 10000 samples?

-Bob
0 Kudos
Message 10 of 20
(4,236 Views)