I need to detect a single tone signal in real-time. The amplitude and the phase of the single tone signal are changing in time. I want to detect both the amplitude and the phase of the signal. I do not want to do FFT since I only need to see a single frequency bin and also FFT is not suited well for real-time applications. I see that there are sliding Goertzel and sliding single bin DFT methods. These methods seem easy to apply and both need very fewer computations compared to DFT. However, they seem like have stability issues. Some damping factors are used to solve the stability problems. However, I still have doubts on the sliding DFT method. Is there any point that I need to pay attention while applying single bin sliding DFT? Can you give examples of real world applications that are using single bin sliding DFT?
-
$\begingroup$ "can you give an example" feels like we're supposed to do your homework (I won't do that, as I believe that won't help you at all in the greater scheme of things). At the very least, explain what you'd need an example for, what you've researched so far, and if you have any ideas of your own. $\endgroup$– Marcus MüllerMay 23, 2017 at 13:30
-
$\begingroup$ @MarcusMüller, I am not a student. So it is not my homework. So I don't understand why you post such prejudiced comments. I am just curious on the sliding DFT method which seems to be a very good approach for real-time applications which need sparse spectra analysis. So, will you give an answer to my question now? $\endgroup$– OzcanMay 23, 2017 at 14:08
-
$\begingroup$ Thanks, this reads much more answerable now, and it changes the focus of the question significantly, so I'm happy I commented. $\endgroup$– Marcus MüllerMay 23, 2017 at 14:24
2 Answers
I do not want to do FFT since I only need to see a single frequency bin and also FFT is not suited well for real-time applications. I see that there are sliding Goertzel and sliding single bin DFT methods
FFT is just an implementation of the DFT. So, for the same reasons you don't want the FFT you wouldn't want any other DFT.
Goertzel is basically a way of getting the same result any DFT would have given you, but only for a single bin, exactly. Goertzel's latency, when implemented in parallel hardware, is the same as the overall DFT's, just with less ressource usage. In software, you'd use a bunch of operations.
To detect a single tone, my recommendation here would simply be a correlator (which happens to be the same as a matched filter) with the tone of interest. Basically, take the tone you're interested in, and use it as filter taps (apply windowing to taste). You can easily shift in single samples into such a filter. If you don't window (==rectangular window) and convolve a complex sinusoid with a whole number of samples as period, you get what you'd get as a single bin DFT: it's the same formula.
The whole truth, though, is that you don't really get a useful estimate for the presence of a periodic signal with every new sample – no matter how you twist and turn this, it's always a rate-reducing operation ($n$ samples go in, 1 goes out).
So, you might want to consider your definition of "real-time detection". How could one sample change the fact that there's a let's say 200-samples-long periodicity in the signal?
Depending on what you implement this on (an FPGA? ASIC? DSP? MCU? PC-style computer?), you'd want to pick a different implementation, and you'd be getting samples in buffers, anyway – so, I'll go out on a limb here and claim that if you are writing software, you can probably get away with a simple narrowband FIR (and you'd tune that bandwidth and transition width to make your detector robust to slight deviations in frequency), and it's often most efficient to implement that using fast convolution based on the FFT.
Stability problems of running moving averages, sliding Goertzel and sliding 1-bin DFT methods can be introduced due to rounding and quantization noise in the computation and/or state storage (due to subtracting small magnitudes from large magnitudes, and etc.). This problem can be reduced by either clamping the output state, using a gain of slightly less than 1.0, or periodically restarting the filter with sufficient overlap.
Goertzel and 1-bin DFT computations are useful in any situation where one needs significantly less than log(N) of the results from an FFT, which is just a fast way of computing a full DFT.