LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Phase angle and other power measurements using zero crossing?

Hi,
I would like to measure the phase angle between two analog inputs. One signal will be AC voltage, either 230VAC or 120VAC, scaled down with a transducer to some readable value such as +/- 5V. The other signal will be AC current, also scaled down and transformed into a voltage using another transducer. Basically these will be two 5V signals.
I wish to measure the phase angle between these two. I would like to take small "chunks" of samples, lets say about 32 ms, sampled at 10KHZ. I'll be using a cRIO. This sample time can be adjusted if necessary.
The signal is a 60 Hertz line frequency so I will get about 320 samples to cover about 2 cycles (16.6 ms each). I would like to display the phase angle between these two signals, updating each time I grab another set of samples.
At the same time I will be calculating an RMS value for each of these (scaled back up to their respective real values of amps or VAC).
 
The goal is basically to create a Labview "power analyzer" using the cRIO and a few analog inputs. This would constantly display a phase angle, rms values, possibly peak values, so I can calculate power factor and real/reactive power, etc..
 
I have successfully used someones example from this forum that checks for peaks and reports the index of the array where the peak was found. The problem is, if I only check for peaks, this is ok until I get a signal that is not so "clean".  Rather, I would like to detect zero crossing in order to measure the time difference and thus phase angle.
Is there a function available that does this already (on a small sample of data)?
Anyone have any suggestions?

Thanks
 
Jeffrey Scharpf
Senior Engineering Technician
Milwaukee Electric Tool Corp.
0 Kudos
Message 1 of 40
(10,687 Views)
I found a zero crossing vi buried somewhere in the functions, but it outputs a true false.
Anyone know how to measure phase angle (or just measure the time) between two analog inputs?
 
Thanks
Jeff
0 Kudos
Message 2 of 40
(10,622 Views)
Take the two signals and multiply them together.  Then use the AC/DC measure function to get the DC value.  The value will be the sine of the phase angle between the two.  The only drawback is it is not a full 4 quadrant measure.  This one is only good from 0 to 180.
Randall Pursley
0 Kudos
Message 3 of 40
(10,617 Views)
Randall:  Could you please attach a sample vi?  I am not getting good results using your method.
- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 40
(10,611 Views)

Thanks for the response! I'm going to try that.

I'm not sure what you're referring to regarding the full quadrant measurement.

The signals I'll be measuring will be sine waves from an analog input sampled as fast as I can.

One is measuring ac voltage (reduced down to +/-5V), the other is measuring ac current (also reduced and converted to a voltage). These will be measuring the amps and volts from a power tool in use. In some cases there might be some noise (an SCR will be switching one or both of the signals on and off so you get a "jagged" looking sine wave).  I'm wondering if what you're referring to will be affected by this.

I will try your suggestion.

 

Regards,

 

Jeff

0 Kudos
Message 5 of 40
(10,600 Views)
I was in a hurry yesterday and didn't get everything in the response.  Attached is a program for a simple phase measurement.

1.  Both waveforms must be normalized to a peak magnitude of 1
2.  Multiply the waveforms together.
3.  Multiply the result by two
4.  Take the ArcCos
5.  Convert to degrees if needed

Since I am taking the arccos, this approach will only give you the correct result if your phase is between 0 and 180 degrees.

If you need to determine phase for a full range (-180 to 180), then you will have to use a Hilbert transform as part of the algorithm.  To get the best results with the Hilbert transform function, your sampled waveform should be a whole number of cycles.  The reason for this is a whole number of cycles will have a zero DC level which will minimize the distortions of the Hilbert transform results.  I have attached another jpg of this program.


Randall Pursley
Download All
Message 6 of 40
(10,587 Views)

Ok I found a solution that I can understand and use fairly easy. I use the zero crossing function (in one of the math sections I think). It sets a true every time it finds a zero crossing. I then just keep resetting it, until the array of data is done. I store these positions in an array and take the average difference which ends up being my time delay since I sampled simultaneously using a cRIO.

I have the code if anyone is interested.

Thanks again for all the help!

Jeff

0 Kudos
Message 7 of 40
(10,569 Views)
Although I like Randall's method, and I mostly understand it (Hilbert transform is still a mystery), I would like to see your approach Jeff.  It sounds interesting.  Please post your code.
- tbob

Inventor of the WORM Global
0 Kudos
Message 8 of 40
(10,556 Views)
   
Jeff's approach will work just fine as long as you know ahead of time what the frequency is, since you have to convert the time delay to a phase delay, and if the signal isn't too noisy.  My approach is more robust for noisy signal because you are essentially averaging across the sampled signals to get a single value representing the phase difference between the two signals (hence, the longer the acquisition time, the more accurate your mesurement).

Essentially a Hilbert transform in the frequency domain is performed by changing the sign of the negative frequency components.  All cosines become sines and all sines become cosines.  I use this to convert one of the sine signal to a cosine signal and then use the trig identities to get the result in the for cos (w) +jsin(w) where w=the phase difference between the two signals.



~~~ Currently mass compiling to version 8.0.1, hour 3

Message Edited by rpursley8 on 03-08-2006 01:12 PM

Randall Pursley
0 Kudos
Message 9 of 40
(10,554 Views)
I can see already that I have inherent issues. The first is the zero crossing vi. Once and a while, I'm guessing, if the first data point in an array is at or near zero, everything gets shifted, so with good data coming in, for example, I see it jump from 41 degrees to -317 degrees. The cosine still seems to work ok but it changes the power factor by about .04.
 
I definitely want to try Randalls method as I'm concerned about noisy data. We will be measuring volts and amps from a power tool. This has speed control so the signal could be choppy.
I just am not that good with the more sofisticated functions so it will take me a while to implement.
 
 
 
Jeff
0 Kudos
Message 10 of 40
(10,543 Views)