LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

ReFFT and shift

Hello,

 

I would like to know if the ReFFT function (or another one maybe?) can return the shift between the ith harmonic and the foundamental. Actually, i need to realize a digital feedback correcting magnitude and shift of each harmonic of the periodic signal.

 

 

0 Kudos
Message 1 of 10
(3,508 Views)

I was'nt enough precised in my previous post. Let me explaine a bit more:

I'm working on Labwindows/CVI (2010) and I get the flux density of a transformer and the code computes the FFT of this signal using the ReFFT. First, I don't really understand the function, does it give two tabs one of real part and imaginary part? In this case, i want to know how to get back,from this, the shift as I said in the previous message. Does a specific function exists?

 

Nonetheless, I'm sceptical about the use of ReFFT. I saw AmpPhaseSpectrum function in the Help browser of Labwindows. Is this more suitable to solve my problem??

 

 

 

PS: i'm a french students working in a lab and i've never used labwindows before...

0 Kudos
Message 2 of 10
(3,504 Views)

@_trent_ wrote:

First, I don't really understand the function...


CVI comes with three examples involving the use of ReFFT, analysis\2dfft.cws, analysis\convolve.cws, and analysis\iirfiltr.cws. Maybe these can be useful to analyze. 

 

There is also some help available using F1.

 

In general, performing an FFT on a real array yields a complex result, accordingly ReFFT consists of two arrays, for the real and the imaginary part.

 

Also note that there is a successor function, FFTEx.

 

0 Kudos
Message 3 of 10
(3,501 Views)

That's what I thought. Thanks.

And what about the shift??

0 Kudos
Message 4 of 10
(3,499 Views)

Actually I did not understand your shift question - are you asking what the phase between sin ( ft ), sin ( 2ft ), and sin ( 3ft ) ... is? 

0 Kudos
Message 5 of 10
(3,496 Views)

Absolutly!

 

The signal is periodical so the FT is computable : f(t) = ∑ A[n]*cos(2π*n*f*t+Φ[n])

What i want is to extract Φ[n] from the FFT, where Φ[n] could be seen as the shift between foundamental and harmonics.

0 Kudos
Message 6 of 10
(3,491 Views)

...so maybe have a look at 'Discrete Fourier Transform (DFT)'

0 Kudos
Message 7 of 10
(3,485 Views)

FFT and DFT are the same things, aren"t they? Just two different ways to compute FT. The DFT function returns more information than the FFT one?? Or just Im and Re part in tabs?

But i need the phase of each harmonics not the phase of the whole FT. In the help of Labwindows it is said the phase is the arctan of the ratio of Im part and Re part but it only gives the phase of the 3rd (or 4th or 5th...) sample of the FT. Where is the information about phase of harmonics of the original signal??? nowhere in this phase or too complicated to extract i guess.

It seems there is no direct function to do that..

 

 

0 Kudos
Message 8 of 10
(3,483 Views)

The problem is that the FFT function can not assume that there is a single fundamental signal. In your problem, this may be the case.

 

In order to calculate the first order phase shift (if there is only one sine wave, there are no higher order phase shifts), add phase until the real spectrum at your given frequency "becomes" a pure absorbance peak shape. At the same time the imaginary spectrum at your frequency will "become" a pure dispersion peak shape.

 

The real trick is determining when each real world absorbance and dispersion peak (and their included noise) has shifted to the ideal peak shape.

 

The following equations should cover the math for a zero order phase shift.

 

real_spectrum[i] = real_array[i] * cos (phase) - imag_array[i] * sin (phase);

 

In the case, that the phase shift is zero sin(phase) = 0 and cos (phase) = 1

 

and the equation reduces to

 

real_spectrum[i] = real_array[i];

 

The the case where phase difference is not equal to zero (or mixed mode) then you can adjust the phase so that the appropriate percentage of real_array and imag_array are present to recover the pure absorbance (and dispersion peak shapes).

 

In practice you can iterate phase from 0 to 2 * pi, in whatever increments you wish and then plot the data. The peak shapes will be apparent when you get close, but it may be hard to get the optimum answer depending on noise in the system. (The area under the peak shape should bemaximum for pure absorbance and zero for dispersion mode for Lorentzian and Guassian peak shapes - I believe).

 

Just for reference, the corresponding imaginary equation becomes

 

imag_spectrum[i] = real_array[i] * sin(phase) + imag_array[i] * cos(phase);

 

 

0 Kudos
Message 9 of 10
(3,446 Views)

I think AmpPhaseSpectrum might answer your question as well. Just turn "Unwrap" off (since you don't want to allow higher order phasing).

 

0 Kudos
Message 10 of 10
(3,444 Views)