1
votes

I have been developing a small software in .NET that takes a signal from a sensor in real time and takes the FFT of that signal which is also shown in real time.

I have used the alglib library for the FFT function. Now my purpose is to observe the intensity of some particular frequency in time.

In order to check the software, I provided a sine wave to its input having a frequency of 1 Hz. The following image shows the screen shot from the software. The upper graph shows the frequency spectrum showing the peak at 1 Hz. However, when this peak is observed in time, as shown in lower graph, the intensity behaves like a sine wave.

enter image description here

My sampling frequency is 30kHz. What I do not understand is how am I getting this sine signal and why is the magnitude of frequency behaving like this?

1
Is it possible that as the signal is 1Hz and I'm sampling at 30kHz with FFT for each set of 30000 data points, therefore this frequency sis too low for this setup to be measured correctly?Xichan
The inverse FFT of a single peak spectrum should always be a sine. What did you expect to see?Junuxx
@Junuxx I'm not saying anything about the inverse FFT. I'm just curious about the magnitude that is varying in time like a sine wave.Xichan
The magnitude of a sine wave behaves like a sine wave in the time domain, pretty much by definition of what a sine wave is. The time domain is also usually the inverse FT of the frequency domain, also usually by definition.hotpaw2
@hotpaw2 Thanks but I know that obviously. The focus here is the magnitude of the FFT at 1Hz in time domain, not the input sine wave magnitude.Xichan

1 Answers

4
votes

This is an example of the effects of Windowing. It derives from the fact that the FFT is not a precise operation except for when dealing with perfectly periodic signals. When you window your signal, you turn it into a smaller chunk that may not repeat perfectly. The FFT algorithm calculates the spectrum of this chunk of audio, repeated infinitely. Since it is not a perfect sine wave, you don't get an exact value for the result. Furthermore, we can see that if your window doesn't line up perfectly with a multiple of your signal frequency, then it will phase shift with respect to your signal, the window capturing a slightly different chunk of your signal, and the FFT calculating the spectrum of a different infinitely repeated signal. If you think about it, this phase difference will naturally be periodic as well, as the window catches up with the next period of your signal.

However, this would only explain smaller variations in the intensity. Assuming you used correct labels on the axes of the bottom graph (something you should double-check), something else is wrong. You're window might be too small (although I expect not, because then you would see more spectral bleeding). Another possibility that just occurred to me is that you might just be plotting the real part of the FFT, not the magnitude. As the phase changes, the real and complex parts might vary, but you'd expect the magnitude to stay roughly the same.