FFT- based frequency offset estimation algorithm

I am trying to understand and implement FFT based recovery algorithm suggested me in the post and it was also discussed here

Let assume rx_signal -signal at the receiver'input with frequency offset. according to the posts i do the following steps in matlab:

% fft

fft_rx = fft(rx_signal)

% [peak p] = max(abs(fft_rx))


I don't understand what my next step is?

• You should also consider looking at multiple adjacent bins (around 8 bins) to avoid fluctuations. You can further mitigate fluctuations by averaging multiple FFTs. – Moses Browne Mwakyanjala May 14 at 0:42

Given the links in the question, the OP is interested in more details on implementing a squaring algorithm for carrier recovery. A squaring algorithm is a popular analog option for the recovery of BPSK and QPSK modulations based on its simplicity and is completely applicable to digital implementations as well, but it is not the only algorithm nor most efficient. Specific to squaring algorithm for carrier recovery, the following will help understand how this approach works and its limitations.

If the modulation is BPSK, then the symbols each have a carrier phase of either 0 or 180 degrees relative to the unmodulated carrier (which the OP is trying to recovery). A squaring loop strips the modulation by using the property:

$$\cos(\alpha)cos(\beta) = \frac{1}{2}cos(\alpha - \beta) + \frac{1}{2}cos(\alpha + \beta)$$

From above observe what happens if we square a BPSK signal given as $$f(t) = \cos(2\pi f t+\phi[m])$$

Where $$\phi[m] = 0, \pi$$ for each symbol $$m$$

$$f^2(t) = \frac{1}{2}\cos(0) +\frac{1}{2}cos(4 \pi ft + 2\phi[m])$$

The first term is a DC offset value and is ignored or filtered out. Notice what happens in the second term from which we can now derive a constant carrier signal: The frequency has doubled (so squaring a tone in general will double its frequency, and frequency doublers are implemented by doing this) AND importantly the modulation has been completely removed, since doubling a signal's frequency will also double its phase. Since the phase was going between $$0$$ and $$\pi$$ (180 degrees) before being doubled, it will go between $$0$$ and $$2\pi = 0$$ after being doubled. This is a common analog recovery scheme due to the simplicity of implementing a frequency doubler (using a mixer, or even an XOR gate), and a frequency divider (with a flip-flop) to divide the recovered tone without the modulation by 2 to recover the coherent BPSK carrier. Pulse shaping will introduce other spectral artifacts, but they will all be sufficiently lower than the strong recovered carrier such that a PLL can be used to clean-up and provide a clean recovered coherent carrier for demodulation.

The same approach can be used for QPSK, but in this case we have four phase states, so the doubling needs to occur twice (resulting in $$f^4(t)$$). Doubling once will reduce the QPSK signal to a BPSK signal at double the carrier frequency, and doubling that will then strip the remaining BPSK modulation for a recovered carrier at four times the original frequency. (We also see that for any four quadrature phase states, if we raise it to the fourth power it will reduce to one phase state, meaning the modulation will be stripped: for example, for all phases $$(0, \pi/2, \pi, 3\pi/2)$$, any of these phases multiplied by 4 will be modulo $$2\pi$$ which is a phase equal to 0.

This approach could be done using an FFT such as first multiplying the QPSK signal by four and then use the FFT to find the strongest carrier that is at approximately four times the original carrier frequency, but that is highly inefficient and an approach I would not recommend following (this is basically breaking fred harris' rule "Don't copy the analog!" given we have so much more ability to provide direct optimized solutions with high efficiency with more direct DSP approaches targeting the core problem, where analog implementations are often much more constrained by the physical components themselves). Further it immediately requires a sampling rate 4 times higher to handle the 4x carrier increase (even for any given carrier offset). Further once the strongest FFT bin is found, the actual frequency will inevitably be at an smaller offset between the bins, so further resolution will be required to maintain actual coherence. I suggest alternate carrier recovery approaches at the links below, but if it is necessary to pursue a squaring approach, this would typically be done in a loop such that a PLL is used to clean-up the strongest single tone signal (at double the actual carrier for BPSK or four times the actual carrier for QPSK).

For a suggested carrier recovery approach please also see these other links:

High modulation index PSK - carrier recovery

BPSK and QPSK demodulation computational complexity

Demodulation of 4-QAM

• for BPSK i dont need FFT step? – Jang Lee Apr 13 at 11:22
• for BPSK after squaring you will have already created a strong single tone at twice the actual carrier frequency- so what you need to do at that point is remove all other spectral content (filter it) and this is typically done with a PLL that works as a highly selective and auto-tunable bandpass filter. After than you divide the carrier by two (this can be done as follows: dsp.stackexchange.com/questions/51895/…), or more directly with a normalized complex carrier using a square-root function, which is done by dividing the argument by 2. – Dan Boschen Apr 13 at 13:35
• Will it work for any cases? limits for $\Delta f$ or $\Delta \phi$? – Jang Lee Apr 14 at 14:38
• @JangLee I am sorry you’ll need to be clearer as to your question; I don’t mention delta phi anywhere so I am not really sure what you are referring to. That said squaring will remove the modulation independent of phase or frequency, you just need to having a sampling rate that obeys Nyquist for the multiplied frequency result. – Dan Boschen Apr 14 at 15:00
• squaring algorithm removes modulation of the signal, I have read.Why is it important for frequency estimation? – Jang Lee Apr 22 at 5:57

The other answer is great. I only wanted to add this in case the OP is interested in clicking the link below for more details and there is some very simple MATLAB code there which could be helpful given that they also included code in the question.

Here are the basic steps that you need to do for a $$M-$$PSK signal:

1. Raise the signal to the $$M^{th}$$ power.
2. Take the FFT of the result.
3. Find the frequency where the peak occurs. That frequency will be $$M$$ times the true frequency offset estimate, $$f=M\Delta f$$.
4. Coarse estimate is then $$\Delta f=\frac{f}{M}$$.

I recommend you reading my previous answer here for more details: https://dsp.stackexchange.com/a/67221/31316.

• Will it work for any cases? limits for Δf or Δϕ? – Jang Lee Apr 14 at 14:38
• @JangLee You need $|\Delta \omega|<\frac{\pi}{M}$, that is the normalized frequency. I think the other answer eluded to this by noting this means that you need a high enough sample rate for this to work. – Engineer Apr 14 at 14:51
• Should I do decimation step after or before phase/frequency correction? – Jang Lee Apr 15 at 14:45
• @JangLee what are you talking about? – Engineer Apr 15 at 21:07
• decimation ( downsampling + FIR filter) – Jang Lee Apr 16 at 5:56