06-15-2012 07:31 AM
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.
06-15-2012 07:52 AM - edited 06-15-2012 07:53 AM
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...
06-15-2012 08:22 AM
@_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.
06-15-2012 08:35 AM
That's what I thought. Thanks.
And what about the shift??
06-15-2012 08:43 AM
Actually I did not understand your shift question - are you asking what the phase between sin ( ft ), sin ( 2ft ), and sin ( 3ft ) ... is?
06-15-2012 09:06 AM
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.
06-15-2012 10:06 AM
...so maybe have a look at 'Discrete Fourier Transform (DFT)'
06-15-2012 10:22 AM
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..
08-23-2012 01:20 PM - edited 08-23-2012 01:20 PM
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);
08-23-2012 01:28 PM
I think AmpPhaseSpectrum might answer your question as well. Just turn "Unwrap" off (since you don't want to allow higher order phasing).