LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Measuring lag between input and output sine waves...

Hi,

 

I am using a Labview VI to control an array of servo motors, each receiving a sine wave input (with different phase offsets for each servo). I'm using a NI USB-6229 DAQ system to monitor their movement via a wire that I've soldered onto each servo's potentiometer. I've written another VI that recieves both the initial sent signal and the returned DAQ signal and plots both on a waveform chart. Both signals show up on the plot as expected, with an obvious phase shift between them. I'm having problems accurately measuring the phase shift, and I'd rather have an automatic method that gives accurate numerical values instead of a more qualitative visual method.

 

So far I've tried to use triggers and peak to peak comparisons, but I've been having problems getting results in real time. My incoming signals are time stamped, if that helps. Is there a quick and easy method to extract phase shift data from two sine waves on a waveform chart?

 

Thanks for the help...

0 Kudos
Message 1 of 3
(3,104 Views)

This might do the trick.  Especially if you know the frequency.

 

Do an FFT of both signals and get the phase values at the frequency of interest.  Subtract them.

 

It may get a bit tricky above 180 degrees, but that's easy to take care of.  IIRC, you can unwrap the phase on some of the FFT fns, but I may be confusing it with MatLab.  Come to think of it, I'm sure you can unwrap the phase in LabVIEW and that probably is the best way to go.

 

If you don't know the frequency, use the FFT to find the max magnitude and figure out the frequency from that.

 

How's that sound?

-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




Message 2 of 3
(3,099 Views)
Since I work with lock-in amplifiers I came up with this. I guess it will work in your case. This method has some limitations. It will work up to 180 degree. It also measure absolute phase lag. You can not say if the signal is leading or lagging. But in your case it will always be lagging. I posted a VI showing the method in another discussion. Here is the link. http://forums.ni.com/ni/attachments/ni/170/409516/1/demo_v2.vi. Since your DAQ unit do not have simultaneous sampling you will get a small phase error due to inter-channel delay. This is also true if you use the FFT method. What is your signal frequency and which samplerate do you use?


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