LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extremely Accurate Phase Shift Calculation

Hello all,

 

I know this question has come up many times but there are specific accuracy requirements in my problem and I'm just wondering if there may be some unique solution that I have not explored yet and that may not have been posted on the forums. I'm trying to find the phase shift between two low frequency signals, around 27 Hz. I've tried a few methods but I've found the best method so far is the one that I have attached to this post (it's just a simple demonstration of the concept using generated waveforms). What I'm wondering is if this is the most accurate way to calculate the phase shift? And if it isn't what method would you suggest? Accuracy is key in my application because I'm using the phase shift between three receivers to triangulate the position of the source. So the smaller the error in the phase shift the better! My last question is does the sampling frequency and number of samples affect the accuracy of my method? I realise that by increasing the sampling frequency and number of samples a more accurate representation of the signal is received and so a more accurate phase shift can be calculated, but is there a threshhold frequency that, once passed, won't lead to a more accurate phase measurment? I'm new to labview, and I'm really trying to sink my teeth into understanding how and why things work, so explanations would also be greatly appreciated! Thanks in advance for anyone's help.

 

Cheers,

 

Graham 

0 Kudos
Message 1 of 10
(7,351 Views)

Graham,

 

Your approach seems reasonable. You raised several important questions.  With quantized data the accuracy is ultimately limited by the quantization error which is linked to resolution.  If one or both of your signals is noisy, the noise may limit accuracy. If your signals are stationary then more samples should provide more accuracy. If they vary during the sampe set, the data means little. The Cross Power Spectrum uses the FFT internally, so all the issues of spectral leakage may need to be considered if the sampling is not synchronous.

 

Do you have a clean reference signal?  What accuracy do you need?

 

Lynn

0 Kudos
Message 2 of 10
(7,338 Views)

Hi Lynn,

 

Thanks for the response! To tell you the truth I'm not quite sure what you mean by 'reference signal', I assume you mean a signal that is the same as the transmitted, or input, signal which can be compared to the received signals. Unfortunately, if this is what you mean, in my system there is no such reference signal because the transmitter is actually a spinning magnet. The phase differences are calculated by comparing the signals received in three receivers. The phase difference between the signals in receiver 1 and 2 leads to one angle and the phase difference between the signals in receiver 2 and 3 lead to a second angle. So, I don't beleive I have a clean reference signal. The signals themselves are not extremely noisy at the distances that I am working at right now, however as the distance increases the signals do become much noisier. Also, the transmiter remains stationary for as long the test takes. At the moment I dtermine the phase shift by averaging the phase shifts from 30 different sample sets. As for the accuracy, ideally I would like to get somewhere close to plus or minus 0.3 degrees. I realize this is a long shot, but it would be nice if that accuracy could be attained. I hope that I answered your questions and didn't frustrate you too much in the process! I just have one last question, would a phase lock loop be a plausible solution to my problem? I realize this requires a reference signal, but what if the reference signal was simply taken to be the signal from the first receiver or a generated sine wave with a frequency matching the frequency of the spinning magnet? Anywho, hope this clarifies my situation a little better! 

 

Cheers,

 

Graham

 

Graham 

0 Kudos
Message 3 of 10
(7,329 Views)

Graham,

 

Your explanation helps a lot.  

 

0.3 degrees is about 1 part in 1200. Signals will eventually be noisy. Frequency is about 27 Hz.

 

If you had a perfectly clean signal with known amplitude you could get the phase directly (within 90 degrees) via an acrsine calculation.  0.3 degrees at 27 Hz is about 31 us or a sampling rate of ~32 kHz.  You would need about 12 bits of amplitude resolution, maybe more.  That speed and resolution are not difficult with the equipment available today.  But this would give poor results with a noisy signal.

 

Here is what I would try: 1. Generate a clean reference signal.  Use a receiver mounted at a fixed distance (small) from the transmitter.  A simple pickup coil might be sufficient.

2. Amplify the received signals from the "working" receivers to the same rms amplitude as the reference signal. 3. Multiply the reference by the received signals.  4. Using the trignometric identity for the product of two sines gives two terms (a) a twice frequency term and (b) the cosine of the phase difference.  Eliminate the twice frequency term with a low pass filter.

 

The details are what is important of course: Phase shifts/delays through all signal paths must be the same to within your error tolerance or known so that they can be calibrated out. Filter bandwidths must be low enough that the second harmonic component is less than the error limit.  The noisy signals should have any DC component removed before multiplying so that the output of the multiplier does not contain a significant 27 Hz component. And the recievers must not move far enough to change the phase more than the error limit in the time it takes to make a measurement.

 

This is the way the phase detector in a phase locked loop works.

 

Lynn

Message 4 of 10
(7,315 Views)

Graham,

I had been in a similar situation some time ago. This is what I had found:

In order to accurately determine the phase shifts two things are important:

1) sampling frequency, Fs

2) number of samples, N

It follows that the resolution of your frequency being analyzed will be df = fs/N

So to accurately sample and determine the phase of a 10 Hz signal for example, your df should be 5 Hz or less.

Also to determine at a very accurate level, other factors are also important. These are stray pick ups.

I had been able to better my phase shift determinations to within 0.2 - 0.4 milliradians just by paying close attention to the two points I mentioned above.

Hope this helps.

 

navneet

Message 5 of 10
(7,273 Views)

Hey Guys,

 

Thanks for the responses. My first question is for Lynn. I've tried to start implementing code in labview based off of your suggestion and I understand the theory behind the solution but I have one main problem with the implementation. I can't seem to figure out how to match the rms value of the refernce signal to the rms value of the receiver signal. So, in short, I'm having trouble resizing the received wave to have the same rms value as the reference wave. Any suggestions on how to do this? Also, I find that once I filter the signal from the receiver the amplitude of the filtered wave is not as constant as I would like. The peaks seem to follow a sinusoidal path and I'm wondering how this will affect my results? My last question is for navneet. I'm just wondering what you're reffering to when you say df? Like I've mentioned before I'm fairly new to signal processing and so the terminology ios quite new to me as well! Thanks for the help guys.

 

Cheers,

 

Graham 

0 Kudos
Message 6 of 10
(7,260 Views)

If you are going to implement this with DAQ hardware. You should know that most of the  NI DAQ (and others to) board do not have simultaneous sampling. They use one analog to digital converter, and a multiplexer. So the channels are digitized (read) in a round robin way. A project with your specs need simultaneous sampling of the channels. However if you are just simulating the setup. It should be doable I think 



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
Message 7 of 10
(7,247 Views)

Hello CoqRouge,

 

That is a very good point! I did some reading after I saw your post about ways to elimante the negative effects of non simultaneous samplings and one of the solutions that came up involved using the allign and resample express vi. What are your thoughts on this? If you don't think this is a viable solution any suggestions on how I might be able to make the signals simultaneous using a software approach?

 

Cheers,

 

Graham

0 Kudos
Message 8 of 10
(7,238 Views)

Hi Graham,

If you look at the delay between the waveforms in non-simulataneous sampling and work out the inter channel phase delay, it is very small! I worked it out by feeding anolog output directly to input channels 1 and 2. The inter channel delay was less than 0.02 milliradians over a wide frequency range (I checked upto 1 kHz). this is already less than the accuracy you require I guess?

The frequency resolution, df is given by sampling frequency/number of samples. It tells you the minimum frequency that can be detected by your analysis.

Message 9 of 10
(7,220 Views)

Graham,

 

I have been away from the Forum for a while.

 

I would probably normalize both signals to amplitude = 1.0.  Calculate the rms values of each signal and then multiply each by the reciprocal of that value.

 

Be careful with your filtering.  All filters have both a transient beahvior and a phase shift.  If you need to filter to reduce the noise on the signals, also run the reference signal through an identical fitler so it has the same phase shift.

 

Lynn

0 Kudos
Message 10 of 10
(7,175 Views)