Understanding FFT Output

I need help understanding the output of DFT / FFT calculations.

I am an experienced software engineer and you need to interpret some indications of the smartphone’s accelerometer, for example, to find the main frequencies. Unfortunately, I overslept most of my EE college colleges fifteen years ago, but I read DFT and FFT the last few days (apparently not much good).

Please no answers from "go take the EE class". I actually plan to do this if my employer pays me. :)

So here is my problem:

I captured the signal at 32 Hz. Here is a 1 second 32-point sample that I outlined in Excel.

enter image description here

Then I got some FFT code written in Java from Columbia University (after following the sentences in the message " Reliable and Fast FFT in Java ").

The result of this program is as follows. I believe that it runs FFT in place, so it reuses the same buffer for input and output.

Before: Re: [0.887 1.645 2.005 1.069 1.069 0.69 1.046 1.847 0.808 0.617 0.792 1.384 1.782 0.925 0.751 0.858 0.915 1.006 0.985 0.97 1.075 1.183 1.408 1.575 1.556 1.282 1.06 1.061 1.283 1.701 1.101 0.702 ] Im: [0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ] After: Re: [37.054 1.774 -1.075 1.451 -0.653 -0.253 -1.686 -3.602 0.226 0.374 -0.194 -0.312 -1.432 0.429 0.709 -0.085 0.0090 -0.085 0.709 0.429 -1.432 -0.312 -0.194 0.374 0.226 -3.602 -1.686 -0.253 -0.653 1.451 -1.075 1.774 ] Im: [0.0 1.474 -0.238 -2.026 -0.22 -0.24 -5.009 -1.398 0.416 -1.251 -0.708 -0.713 0.851 1.882 0.379 0.021 0.0 -0.021 -0.379 -1.882 -0.851 0.713 0.708 1.251 -0.416 1.398 5.009 0.24 0.22 2.026 0.238 -1.474 ] 

So, at the moment, I can’t make any head or tail tails. I understand the concepts of DFT, such as the real part, which is the amplitudes of the component cosine waves, and the imaginary part - the amplitudes of the component sine waves. I can also follow this diagram from the big book " A Guide for Design Engineers and Digital Signal Processing Engineers ": enter image description here

So my specific questions are:

  • From the conclusion of the FFT, how do I find the "most common frequencies"? This is part of my analysis of accelerometer data. Should I read real (cosine) or imaginary (sine) arrays?

  • I have 32 point input in the time domain. Should the FFT output be a 16-element array for real and a 16-element array for imaginary? Why does the program give me real and imaginary outputs of arrays of size 32?

  • In connection with the previous question, how do I parse indexes in output arrays? Given my input of 32 samples taken at 32 Hz, I understand that the output from an array of 16 elements must have its own index, evenly distributed up to 1/2 of the sampling frequency (32 Hz), so I correctly understand that each element (32 Hz * 1/2) / 16 = 1 Hz?

  • Why is the FFT output negative? I thought that the values ​​are the amplitudes of the sine wave. For example, the output Real [3] = -1.075 should mean an amplitude of -1.075 for a cosine wave with a frequency of 3. Is this correct? How can the amplitude be negative?

+63
java fft audio signal-processing accelerometer
Jul 18 '11 at 23:17
source share
4 answers
  • You should not look for the real or imaginary part of a complex number (this is what your real and imaginary array is). Instead, you want to look at the magnitude of the frequency, which is defined as sqrt (real * real + imag * imag). This number will always be positive. Now all you need to find is the maximum value (ignore the first record in your array. This is your DC offset and does not carry any frequency-dependent information).

  • You get 32 ​​real and 32 imaginary outputs because you use complex complex FFT. Remember that you converted 32 samples to 64 values ​​(or 32 complex values) by extending them to the imaginary parts of zero. This leads to a balanced FFT output, where the frequency result occurs twice. Once you are ready to use it at outputs from 0 to N / 2 and once mirror at outputs N / 2 to N. In your case, it's easier to just ignore outputs N / 2 to N. You do not need them, they are just an artifact about how you calculate your FFT.

  • The frequency for the fft-bin equation is (bin_id * freq / 2) / (N / 2), where the frequency is your sampling frequency (aka 32 Hz, and N is the size of your FFT). In your case, it simplifies up to 1 Hz per garbage. Boxes N / 2 to N represent negative frequencies (strange concept, I know). For your case, they do not contain any relevant information, because they are just a mirror of the first N / 2 frequencies.

  • Your real and imaginary parts of each hopper form a complex number. This is normal if the real and imaginary parts are negative, and the frequency itself is most positive (see My answer to question 1). I suggest you read complex numbers. An explanation of how they work (and why they are useful) exceeds what can be explained in one stackoverflow question.

Note. You can also read what autocorrelation is and how it is used to determine the fundamental frequency of a signal. I have a feeling that this is what you really want.

+62
Jul 19 '11 at 1:40
source share

You already have good answers, but I’ll just add that you really need to apply the window function to the data of your temporary domain to FFT, otherwise you will get unpleasant artifacts in your spectrum.

+6
Jul 19 '11 at 6:23
source share

1) Look for indexes in a real array with the highest values ​​except the first (DC component). You will probably need a sampling frequency well above 32 Hz and a larger window size to significantly improve meaningful results.

2) The second half of both arrays is a mirror of the first half. For example, note that the last element of the real array (1.774) matches the second element (1.774), and the last element of the imaginary array (1.474) is negative for the second element.

3) The maximum frequency that you can get with a sampling frequency of 32 Hz is 16 Hz ( Nyquist limit ), so each step is 2 Hz. As noted earlier, remember that the first element is 0 Hz (i.e., DC bias).

4) Of course, a negative amplitude makes sense. It just means that the signal is "flipped" - the standard FFT is based on the cosine, which usually has value = 1 at t = 0, so a signal that had value = -1 at time = 0 would have a negative amplitude.

+4
Jul 19 2018-11-11T00:
source share

Note that the “most common frequency” can be sprayed into several FFTs, even with the window function. Therefore, you may need to use a longer window, multiple windows, or interpolation to better estimate the frequency of any spectral peaks.

+3
Jul 19 2018-11-22T00:
source share



All Articles