LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculate Phase from Noisy Sine Input

Hello,

 

I have a sine wave being read in real time into my VI and I'd like to calculate how out of phase it is with a simulated sine wave. I followed the example on http://digital.ni.com/public.nsf/allkb/F4BB644ECCA595D886256FFE00722E29 and the phase is still all over the place and I'm assuming it's not being estimated correctly. The simulated sine I'm comparing it to is from Sine Waveform.vi with a constant phase.

 

These calculations worked when I had two simulated sine waves for testing. Any insight on what I should do is much appreciated.

 

0 Kudos
Message 1 of 9
(3,537 Views)

It is difficult to tell without having the actual data. Please run your VI until you have collected some typical data. Make the data default and save. Then post that VI.

 

The Extract Single Tone Information.vi uses Fourier transform techniques internally to find the frequency and phase. Those methods sometimes do not work well with samples sets containing a fraction of a cycle or only a few cycles, especially if the data segment does not contain an integer number of cycles.

 

It looks like the image you posted of your data is from a chart, so it is not clear how much data you feed to the analysis VIs on each call.

 

Lynn

0 Kudos
Message 2 of 9
(3,517 Views)

The image you posted only has one signal, and talking about "phase" with respect to one signal does not make much sense.   Do you perhaps mean frequency?

 

If you do mean frequency, you still may be running in to some randomness due to the fact that you aren't actually looking at a sine wave.  If you measure from max point to max point, that will vary slightly.  That having been said, perhaps some digital filters would help you.

0 Kudos
Message 3 of 9
(3,508 Views)

Here's my VI with the default set. I'm using the Extract Single Tone Information.vi for now, but my FFT from Spectral Measurements appears to be getting some relevant info in its graph.

 

EDIT: I realize that the phases on the compass graph are mixed up from their labels at the moment, but that's the general idea on how I'm getting those.

0 Kudos
Message 4 of 9
(3,501 Views)

What about a curve fit of a sine with phase as a parameter?  Maybe frequency and amplitude as well.  That should get past the partial cycle issue.

0 Kudos
Message 5 of 9
(3,488 Views)

@Zwired1 wrote:

What about a curve fit of a sine with phase as a parameter?  Maybe frequency and amplitude as well.  That should get past the partial cycle issue.


Could you explain more on that? I'm not sure if I'm getting a correct phase to begin with and the posts I see on sin fits are way over my head.

0 Kudos
Message 6 of 9
(3,477 Views)

I cleaned up the vi a bit so it's easier to run without it bugging the user for a file. The phases are correct to the labels as well.

0 Kudos
Message 7 of 9
(3,456 Views)

First you need to define what you want to do.

1. There is no meaningful definition of a phase relationship between two signals of different frequencies.

2. The way you create subsets of the signal data makes it almost certain that the phase returned by Extract Single Tone Information.vi will differ on each iteration.

 

The graph image shows the first part of the signal passed to Extract Single Tone Information.vi on two successive iterations of the for loop.  Whilethe difference is not large, it is clear that the initial phase of the two signals has changed. The array image shows the outputs of Extract Single Tone Information.vi for the 60 Hz signal and for the distorted signal. Note that the frequency of the signal is not 60 Hz and that it varies slightly from iteration to iteration. The phase shows approximately a 22 degree progression with each iteration with some variabillity probably due to the changing frequency.

 

Lynn

 

Phase change.png

 

 

Freq and phase.png

0 Kudos
Message 8 of 9
(3,425 Views)

In music, when two tones are close to, but not exactly the same frequency, you get a third wave, a "beat" that you can hear.  Is this kind of what you are getting at, at least as an analogy?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 9
(3,410 Views)