03-29-2009 11:51 PM
Hi,
I'm measuring 2 analog signals simultaneously from the 9233 DAQ module.
Whenever there is a trigger, my DAQ will collect an X number of samples from the analog module and perform a cross correlation analysis on the data.
My question is how can i get the maximum cross correlation coefficient between the two signals (e.g. North is my reference, how many samples do i need to shift my South to get the maximum correlation coefficient)?
My purpose for this?
This is so that i can get the delay between the two samples (e.g.sampling at 50kHz, if i need to shift the sample 300 times, then i know my delay is 300*1/50000 = 6ms)
Thank you.
Attached a picture of my waveforms
North = My reference signal
South = My 2nd signal
Bottom = Corss correlation betwen the two signals
Solved! Go to Solution.
03-30-2009 07:44 AM
03-31-2009 01:33 AM
Hi Randall,
Appreciated your input but i think you misunderstood my question a little bit. I wasn't trying to look for the peak in the cross correlation graph which I think you thought I was. Actually what i'm looking for is the maximum correlation coefficient between the 2 signals.
I have simulated an example to better put my question across. As illustrated in my attachment, i have 2 signals, the 1st is always delayed by 50s while the delay of the second signal varies from 110s to 50s.
When the delay of both signals are at 50s, we have the maximum correlation coefficient of 1.000 as both signals are now in sync.
So what i am trying to do now is to reverse this process so that i can find the delay between my two signals by finding out how many shifts do i need to make on my 2nd signal to get the maximum correlation (note: does not have to be 1.000, just as long as it is the highest possible value between these 2 sets of data).
Anyone who has a good idea on how to do this please feel free to post.
Thanks alot!
03-31-2009 08:40 AM - edited 03-31-2009 08:41 AM
I'm pretty sure the maximum value of the cross correlation function will correspond to the location of the highest correlation coefficient. Use your own example to verify this.
Find the index of this value. Subtract the size of the reference signal (in the X input) from the index of the peak value. The resulting value should be the number of points that equates to the shift. Divide this value by your sampling rate (50,000 in your case) and you should have your answer.
03-31-2009 11:32 AM
Really? Okay I will try that once I get the chance to.
You've been a great help Randall. Thanks!
04-01-2009 08:20 AM
Is this the solution you proposed Randall?
If i was taking 200 samples for my reference, i substract it from the max index and multiply the resultant value with my sample time (1/50kHz) to get the delay?
04-02-2009 08:23 AM
04-02-2009 11:24 PM
It does work to some extend if the signals are matching but once in awhile the value does go astray due to the second signal's waveform discrepancies when compared to the refence waveform. But when i applied it to two generated signals which were alike, the method does hold.
Thanks again Randall.
04-03-2009 07:52 AM
04-27-2009 03:46 AM
Hello everyone!!
I am new to Labview!!!
I have a situation where I have an array with each row representing a code (see picture attached). I have to find the correlation between each of these codes (rows of the array). Could anyone please suggest any ideas how I could do this in labview.
Any help would be greatly appreciated:)