From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Zero Crossing issue for calculating ITDs from two Microphones

Hello All,

 

Basically I'm trying to determine the location of a sound source using ITDs (Interaural TIme Difference)

I'm trying to calculate ITDs in the analog data recieved from the two microphones, so I decided to the find out the time at which the both signals crossed the x-axis (zero crossing) using the time difference between the two signals I should be able to the calcutate the ITD (the difference between the two time values would be the ITD).

 

- I'm using the NI USB 6211 to get my analog data from the microphones (@ 200samples / 2k Rate(Hz)

- Then I detect for a zero crossing in the two signals when a zero crossing occurs then I measure the time of the crossing then using the time value of the both the inputs I try to calculate the ITD

-  I'm calculating the Mean DC offset of the two signals so I subtract that from my signal so the signal actually crosses the x-axis since both of the signals start at a DC offset of about 0.26V. The subtracted signal is fed into the zero crossing vi  

- Then everytime a crossing occurs I view the time so I can use that to compare with the zero crossing of the other signal 

 

 

Issues:

- I'm not able to store the time value of when the zero-crossing occurs so I want to be able to store the time value when a zero crossing occurs in an array so I can view the last zero crossing (at present the time just 'pauses' everytime a zero crossing occurs) but it's not stored anywhere

- Also I only want to subtract the time values everytime a crossing occurs but since the case structure outputs a zero when a crossing doesn't occur most of my ITDs are zero

is there a way the subtracting only occurs when the time values are greater than 0, I try to do this using the 'greater than 0' but I want it to output the value everytime it is greater than 0.

- I'm sure this isn't is the best way to calculate ITD so I would appreciate it if someone could help me improve my method

 

 

I've attached my attempt at this so any help/suggestions would be great. 

 

Kevin

 

Download All
0 Kudos
Message 1 of 4
(2,428 Views)

Do you need to do your calculations on the fly or can you do everything in post processing? Why are you converting your binary output to a number string that represents the binary output? 

 

You are using a point-by-point VI on an array of data. You should index the data and then use the point-by-point VI or your own code (see forum below) to determine if you want to take a time stamp.

 

This other forum post might be able to offer some more insight on finding zero cross points: http://forums.ni.com/t5/LabVIEW/looking-for-zero-crossing-point/td-p/688282

 

Also the time stamp you are for your subtraction is software timed rather than hardware. You will most likely want to extract the timestamp from the dynamic data coming from the DAQ Assistant and use that timestamp instead of the software timestamp as it will be more accurate representation of when the zero crossing occurred.

 

 

Noah | Applications Engineer | National Instruments
0 Kudos
Message 2 of 4
(2,383 Views)

Hi,

 

I need to calculate the ITDs on the fly as in real-time. If you are referring to why I convert Crossing Time Bottom to a string, its because I get just want the seconds part of the timestamp and then I convert back to the DBL so I can then perform the subrataction between the two values. If there is a better way to do this step I would appreciate your help for that.

 

I'm not too sure how to go about indexing the data before hand and then using the point-by-point VI. I've read the forum below and others relating to my project but I'm still struggling with getting the just the time in (seconds) every time a zero crossing occurs. I know I want to take a time stamp but then using the time stamps from both the input signals to find the difference is where my problem arises as I'm not sure how to store the timestamps for each zero crossing in an array so I can then find the difference between each of the zero crossing.

 

Also I'm not sure how to get the hardware timestamp because from my testing I did realize the zero crossing times weren't really accurate but I wasn't sure how to fix that issue. I will try to the extract the time stamp from the DAQ assistant, so should i be getting the timestamp from the dynamic data (blue line) coming out of the DAQ assistant or after I conver it into waveform data type (orange line) ? 

 

Thanks for the help

 

Kevin 

0 Kudos
Message 3 of 4
(2,367 Views)

You can just subtract time stamps and you will see the difference in seconds.

 

Using the Dynamic Data Type to Waveform Data type is the best approach if you have to use the DAQ assistant. From the waveform you can see what the start of the acquisition is (in time) and then you can see what the dt (or the amount of time between each sample) is. For example, if you know you are 10 samples from your first sample you can take the t0 and add 10*dt to get the time for that sample. Just use the Boolean output of the zero crossing to trigger whether or not you record the time.

Noah | Applications Engineer | National Instruments
0 Kudos
Message 4 of 4
(2,334 Views)