# Methods for aligning FFT bins with an FSK signal

Say I want to demodulate some FSK modulation. My (novice) understanding is a pretty good way to do this is by taking the FFT, with the length chosen such that the bin spacing is equal to the tone spacing. In the common case of the tones being spaced at the reciprocal of the symbol duration, this just means taking the FFT over the symbol period. Symbol detection could then be as simple as looking for the bin with the highest magnitude.

Let's assume timing issues are already solved: there's still the problem of frequency alignment. If the receiver's frequency is a little bit off then some of the tone power will bleed into adjacent bins, degrading accuracy.

What are some basic algorithms for addressing this?

Before I address your question, I'll suggest that using a frequency domain technique (FFTs) to demodulate inherently time domain data (a time series of sequential data symbols) won't be very practical. Symbol timing recovery is inherently a time domain process. ISI encountered in common modulations like GFSK/GMSK means you really have more than 2 frequencies for 2FSK symbols at the receiver.

Now on to your question of how to perform frequency alignment.

You requested algorithms for what is normally called Carrier Frequency Offset (CFO) estimation and correction.

In communications receivers, there are sometimes two stages of CFO estimation and correction: coarse and fine. For 2-FSK burst communications, a single stage of coarse CFO correction is usually all one would need for non-coherent FSK demodulation.

CFO correction is generally performed as a (cyclic) digital spectrum shift by multiplication with a time-varying complex exponential in the time domain:

$$x_c[n] = x[n]\space e^{j\pi \frac{-f_{offset}}{F_s/2}n}$$

where $$f_{offset}$$ is the estimated CFO, and $$F_s$$ is the sample rate.

Although for FSK, if one has already computed the baseband waveform from the FSK-modulated symbols (i.e. the output of an FM discriminator), a simple level shift of the basedband waveform, to have it's peaks and troughs centered about 0, is equivalent to CFO correction.

CFO estimation algorithms can be divided up into two broad classes: Open-loop feed-forward algorithms and closed-loop feedback algorithms. Closed-loop algorithms work a sample at a time, are usually used for fine frequency offset estimation, and usually involve some arrangement of PLLs. Open-loop algorithms work on a block of samples at a time and are used for coarse frequency offset estimation.

You probably just want to use an open loop instantaneous frequency estimate for computing your CFO estimate. The instantaneous frequency estimate of an FM/FSK waveform at any given sample is given by

$$y[n] = \dfrac{F_s/2}{\pi}\mathrm{arg}\left(x[n]x^*[n-1]\right)$$

Normally to generate an CFO estimate, one computes the instantaneous frequency over several symbols and looks at the average peak and trough levels to estimate how much the waveform level needs to be shifted for the waveform to be centered about 0.

In your proposed case of having all the samples for one symbol, assuming you don't have a terribly large CFO, computing the instantaneous frequency for that one symbol will tell you what 2FSK symbol you have without performing the FFT.