sábado, 12 de septiembre de 2015

Parabolic frequency estimator.

Parabolic frequency estimator.

This is an interesting problem. Say that you have a DSP (Digital Signal Processing) system implemented, for instance in an FPGA, say that you have a tone in a particular frequency and you want to know exactly what is the frequency of your tone.

So, what do you do? Well, you just find the maximum in your spectrum and then see what is the frequency bin where your tone is located (suppose you have a clean spectrum). If you are using the typical FFT Xilinx core you will have two very useful outputs of the core that you can easily use to implement implement the "search for the maximum" algorithm with some extra effort. So far so good, right?

But there is something you should take into account: The spectral accuracy you have there. That bin, where your maximum is located (by the way, think about what is going to happen if your tone falls just in the middle between two different bins. And if you are thinking that you are designing your system to avoid this problem, then think about doppler frequency shifts if you are working with a moving receiver or transmitter (eg: a spacecraft)... you will have to implement a low pass filter in your maximum bin finder).

That maximum bin you found will not provide you with the exact frequency, say you calculated your FFT with a 1024 points accuracy. You already know our frequency resolution will be fs/N, where N is the number of points you used to calculate your FFT.

Is it a problem? Absolutely and, as we are going to see in the next few minutes, results can vary significantly due to this problem (how significantly will depend on the system and its importance will depend on exactly the same thing: your system design and application). In order to check whether that is true or not we will use a Python program that will extract maximum directly from the bin finder and will also use a frequency estimator, particularly a parabolic estimator.
All the blog entry and the program is based on this paper:


There is cool mathematical explanation in this paper which is interesting to read. If you have a clean spectrum then, after calculating your spectrum and finding the maximum bin, then you calculate:


Where:


This will help us to find the real maximum value. In DSP system where knowing the exact frequency is very important this could be very useful.

You can extract a simple (very simple) code that demonstrates the parabolic estimator, here:

https://github.com/fgallardo/sandbox/blob/master/freq_estimator.py

Let's take for instance a frequency value of 1KHz and we want to estimate it with a 1024 points FFT.

##########################################
This is the frequency estimated with this method:
1000.09993501 Hz
This is the real frequency the sinusoid have
1000 Hz
This would be the value we would have with a spectral resolution of 1024 points:
996 HZ
#########################################





Therefore by using our FFT with 1024 points we would end up by estimating that our frequency was 996Hz and it turned out it wasn't. We had a 0.4% of error, by estimating a frequency 4Hz under the real value.

This is an interesting point to take into account while working on our DSP systems.

Take care!

No hay comentarios:

Publicar un comentario