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: 

Phase issue

Solved!
Go to solution

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

Phase Diff.PNG

Download All
0 Kudos
Message 1 of 11
(4,249 Views)

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

0 Kudos
Message 2 of 11
(4,247 Views)
Solution
Accepted by topic author SparkEE

Capture.PNG

Surprisingly there is a vi for that


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 11
(4,225 Views)

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?

0 Kudos
Message 4 of 11
(4,216 Views)

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


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 11
(4,204 Views)

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

0 Kudos
Message 6 of 11
(4,167 Views)

BS what does an average of a complex number really do?  My Google-fu cannot find a difitive answer.  


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 11
(4,136 Views)
Amplitude phase data is an interesting thing for mean and fitting.....
Depends a lot on the distribution .... Sometimes you have a round spot in the complex plane, sometimes a cycle angle shaped cloud...
Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 8 of 11
(4,115 Views)

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

0 Kudos
Message 9 of 11
(4,096 Views)

Not really.  The average of the sum of the squares is more often implemented.  But not a standard as far as I know.


"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 11
(4,072 Views)