1
$\begingroup$

In order to calculate amplitude of sinusoidal signal at a frequency around 60 Hz (but may be not 60 Hz), window function is adopted while using DFT. enter image description here

hk is the coefficient of window function and Kdc is the sum of these coefficients. Np is the number of sample in one period when frequency is 60 Hz. (XL1, XL2, XL3 are time series sample of three phase electrical quantities. Sqrt(2) is due to some electrical reason.)

As far as I know, window function is helpful to reduce discontinuity when frequency deviates a little bit. However, I am really confused why this could help to get a more accurate sinusoidal signal amplitude.

I tried to derive, but after getting the steps below, I don't know how to prove V1 is closer to A than V2.

h1 and h2 are two types of window function. h1 corresponds to rectangular window and h2 represents triangle window.

enter image description here

$\endgroup$
0
$\begingroup$

I don't think window functions are very useful. The reason you are seeing a drop in magnitude is that some you your "Height" is losing "leakage" when your frequency frequency goes off bin. Window functions try to "minimize" leakage so that may be the effect you are seeing.

Instead, have a look at my answer here: FFT Phase interpretation of input signal with non-integer number of cycles in FFT window

Particularly point #3 "The magnitude adjustment for being off bin."

If this is an insufficient start for you, let me know in a comment and I can post some further reading for you.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thx for your reply. I also believe reducing spectrum leakage could be helpful, but what made me confused is window function will also change original sinusoidal signal, which means it could also cause some side-effect while reducing leakage. The interesting thing is after several times trial, I found this concern never become true. Is there any theoretical explanation for this? $\endgroup$ – Jacksonlee19910408 Jul 30 at 23:53
  • $\begingroup$ @Jacksonlee19910408 Like I said, I am not a big fan of windows. In the stuff I do, they just obscure the parameters without adding any information. The seminal paper on windows is "On the Use of Windows for Harmonic Analysis with the Discrete Fourier Transform. FREDRIC J. HARRIS" You can find it on the web in several places with various levels of print quality. I do commend you on playing around with it first to get a behavior understanding. That way when you get theoretical the math should make more sense. $\endgroup$ – Cedron Dawg Jul 31 at 0:11
  • $\begingroup$ In addition there is the more modern en.wikipedia.org/wiki/Window_function $\endgroup$ – Cedron Dawg Jul 31 at 0:15
  • $\begingroup$ @ Cedron Dawg.Thx very much, Cedron. I appreciate your great help. $\endgroup$ – Jacksonlee19910408 Jul 31 at 15:12
  • 1
    $\begingroup$ @ Cedron Dawg. Haha, cool. Sounds a great fun! :-) $\endgroup$ – Jacksonlee19910408 Jul 31 at 21:47
1
$\begingroup$

As promised, here is a little derivation to give some insight into the effects of windows on DFT values done in reverse.

Suppose that I have a DFT from some signal.

\begin{equation} \begin{aligned} X[k] &= \sum\limits_{n=0}^{N-1} x[n] e^{-i\frac{2\pi}{N}kn} \end{aligned} \end{equation}

I look at it, decide it needs a little "smoothing", so I decide to average neighboring DFT values to make a new DFT bin. Let's call it $Y$. The weights I'm going to use are just a "twist" of the (rescaled) VonHann values. If you plug in $\omega=0$ this becomes clear.

Plug and chug.

\begin{equation} \begin{aligned} Y[k] &= ( -e^{i\omega}, e^{i\omega}+ e^{-i\omega},-e^{-i\omega} ) \cdot (X[k-1],X[k],X[k+1]) \\ &= -e^{i\omega} X[k-1] + ( e^{i\omega}+ e^{-i\omega} ) X[k] -e^{-i\omega} X[k+1] \\ &= \sum\limits_{n=0}^{N-1} \left[ -e^{i\omega} e^{i\frac{2\pi}{N}n} + e^{i\omega}+ e^{-i\omega} -e^{-i\omega} e^{-i\frac{2\pi}{N}n} \right] x[n] e^{-i\frac{2\pi}{N}kn} \\ &= \sum\limits_{n=0}^{N-1} 2 \left[ \cos ( \omega) - \cos \left( \frac{2\pi}{N}n + \omega \right) \right] x[n] e^{-i\frac{2\pi}{N}kn} \\ \end{aligned} \end{equation}

Now, my weighted average has all the sudden become a window function. Again plug in $\omega=0$ and you can see it is the VonHann.

Time for one of those trig identities.

\begin{equation} \begin{aligned} \cos(A) - \cos(B) &= \cos\left( \frac{A+B}{2} + \frac{A-B}{2} \right) - \cos\left( \frac{A+B}{2} - \frac{A-B}{2} \right) \\ &= -2 \sin\left( \frac{A+B}{2} \right) \sin\left( \frac{A-B}{2} \right) \\ \end{aligned} \end{equation}

Substitute it in:

\begin{equation} \begin{aligned} Y[k] &= \sum\limits_{n=0}^{N-1} 4 \sin \left( \frac{n}{N}\pi \right) \sin \left( \frac{n}{N}\pi + \frac{\omega}{2} \right) x[n] e^{-i\frac{2\pi}{N}kn} \\ Y[k] &= \sum\limits_{n=0}^{N-1} w_{\omega}[n] x[n] e^{-i\frac{2\pi}{N}kn} \\ \end{aligned} \end{equation}

When you plug in $\omega=0$ you see why the VonHann is also called the sine squared window.

So, here is a family of window functions whose base member is the VonHann.

\begin{equation} w_{\omega}[n] = 4 \sin \left( \frac{n}{N}\pi \right) \sin \left( \frac{n}{N}\pi + \frac{\omega}{2} \right) \end{equation}

Like I said, I'm not a window expert as I don't care for them much, but I don't think you'll find these on the list in the references. Trig equations are slippery though, it could be one of those in different form.

Still it is interesting.

Hope this helps.


For those who say it might be worthless, I say not so fast.

Let $\omega = \frac{2\pi}{N}$

\begin{equation} w[n] = 4 \sin \left( \frac{n}{N}\pi \right) \sin \left( \frac{n+1}{N}\pi \right) \end{equation}

Which means is it zeroes out the last sample as well as the first and shifts the center of the window to $(N-1)/2$, the center of the sample set, vs $N/2$ which is the center of the repeat frame.


Extra credit:

Which value of $\omega$ cancels the "The twisting caused by being off bin." which is point #2 in the reference in my first answer.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.