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.
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.
01-23-2015 10:37 AM - edited 01-23-2015 10:38 AM
I am using LabVIEW 7.1 and windows 2000
I am trying to measure phase difference between 2 signals. The results I'm getting are 0 to 360. Below zero it reads -360.
Is there a way to get results from -180 to 180 degrees?
attached is the VI I am using along with the subVI that is running the phase part.
Any help is greatly appreciated
Thanks,
SparkEE
Solved! Go to Solution.
01-23-2015 10:40 AM
I'm trying to get results so that I can average lets say
-0.2356
-0.15646
0.21564
0.5446
getting -360.2156 with 0.21654 doesn't help me
01-23-2015 12:44 PM
Surprisingly there is a vi for that
01-23-2015 02:32 PM
Hey Jeff, I was looking more into the "Unwrap phase VI" but there seems to be a difference in the current edition which is the one you have and labview 7.1. Is there a way you could either down convert it for me or give me the VI for the one you have?
01-23-2015 03:24 PM - edited 01-23-2015 03:26 PM
Probably not. the vi is a wrapper to the lvanlys DLL calling "unWrap85" if how it works has changed you would need the new dll (likely they added a function and depreciated the other)
Peeking into the CLFN set-up shows a unWrap85 and a unWrap function. Good money on the change happening in version 8.5. So you simply need to mod 360 and subtract 180 from the remainder
01-24-2015 03:51 PM
In my (admitedly limited) experience, when one has gain and phase data, it is almost always "the wrong thing to do" to average gains and phases separately, not the least because of the "wrapping" problem you are encountering. The problem completely goes away if you do vector averaging -- take your gain/phase data, express it as a 2-D vector with X and Y components, take the average, and use the phase of the average. A few more steps (which may take a whole additional millisecond on your PC), but you'll get a more sensible result. If you don't have a known gain to associate with each phase, just pick a gain of 1. You can probably convince yourself that this makes sense by drawing a picture. Note that this "naturally" takes the signal strength into account when computing the average. For example, if I had a signal with strength 10 and phase 0, and another signal with strength 0.1 and phase 90, does it make more sense to say that the "average phase" of these two signals is 45, or that it is near 0? I'd vote for the latter, if for no other reason that accurately measuring phase on a weak signal is tricky ....
Bob Schor
01-25-2015 08:07 AM
BS what does an average of a complex number really do? My Google-fu cannot find a difitive answer.
01-25-2015 01:09 PM
01-25-2015 01:44 PM
Consider a "cloud" of points in the complex plane, where the X axis corresponds to the Real part and the Y axis corresponds to the Imaginary part.
The "complex mean" is the same operation as the "real mean", namely you add up all the numbers and divide by N, the number-of-numbers. Since adding complex numbers means "add the real parts and add the imaginary parts", it (operationally) is the same as adding the X-Y vectors. Similarly, dividing by N, a real, just means dividing the summed real and imaginary parts. What you end up with is the centroid of the cloud of points, the "point in the middle of the cloud".
Now consider two measurements, one with a S/N of 100 that gives you a phase of 0°, and one with a S/N of 0.1 that gives a phase of 90°. What phase would you like to report as your "best estimate" of the true phase? You could average the phases and get 45°, but I'm sure you'd agree that you'd want to put more "weight" on the measurement with higher S/N. One way of weighting the estimates would be to assume a fixed noise level, call it 1, and say "the first measurement corresponds to a signal, or a gain, of 100, the second to a gain of 0.1". Now you have two vectors, in X-Y terms, of (100, 0) and (0.1, 1). Their average is (50.5, 0.5) which corresponds to a phase of 0.6°, which is consistent with "trusting" the phase of 0° returned by the high S/N measurement more, and weighting it more heavily.
Does that make sense?
Bob Schor
01-25-2015 09:00 PM
Not really. The average of the sum of the squares is more often implemented. But not a standard as far as I know.