I have generated a radio packet of data with a preamble header of 0x55555555 and crc32 for the data only. The entire packet was separated in even and odd streams for I and Q. The I and Q were oversampled by a factor of 10. The I and the Q were modulated into BPSK then then the I & Q were combined and mixed with the carrier and then transmitted. The transmission is random so I do not know when a packet starts or ends as the payload length is variable. The channel has multipath and noisy.

At the receiver I receive symbols with noise between the packets. I know there is frequency drift during transmission. I tried to frequency sync the packets, but I can not tell where the preamble starts from the collected symbols If I demodulate the received symbols and search for the preamble I can not find it, because of the frequency drift.

What is a good approach to unlock this circular problem ?



2 Answers 2


For maximum sensitivity preamble detection with time referencing, consider using a barker code, or for more choices with longer lengths a PRN (pseudo-random noise) sequence, or for even more choices when more distinction is needed (CDMA) Gold codes are a possibility. (Also not further detailed but have other advantages are Kasami codes and Zadoff-Chu codes).

All these codes offer the characteristic of having a strong autocorrelation at time offset = 0 and importantly a much smaller autocorrelation for any other time offsets. Such as that demonstrated in the graphic below for a PRN sequence using an LFSR (Linear Feedback Shift Register):

LFSR correlation properties

The codes provide some noise immunity through processing gain; under condition of white noise, the processing gain which is the improvement of SNR is given as $10Log_{10}(N)$ where N is the length of the sequence. This comes out from addition of correlated signal components results in the standard deviation of the signal component growing at rate N while the noise (if white, meaning uncorrelated from sample to sample) will have a standard deviation that grows at $\sqrt{N}$. We detect the presence of the sequences using correlation, which is a multiply and sum:

$$R_{xy}(\tau) = \Sigma x(t-\tau)y(t)$$

With the formula above representing a cross-correlation function of the received signal $x(t)$ with the sequence of interest $y(t)$, at various time offsets $\tau$.

There are several ways this is done in practice and depends on the detailed implementation approach but for shorter sequences this can be done with an FIR filter, with the coefficients of the filter as the code sequence upsampled to match the sample rate of the received signal (best to do this at the lowest rate possible of course). For longer sequences it is often more practical to create a code generator with a programmable offset (to shift the start position in time) and simply multiply the received sequence by the code and accumulate the output. A threshold detection can indicate the successful presence of the code.

Below shows the result of a sliding correlation on a GPS signal, where the code repeats every 1 ms. (I would never use an FIR filter to correlate a GPS sequence which is 1023 chips long, but this shows what a sliding correlation would look like).

sliding correlation

Other approaches involve doing the correlation in the frequency domain using this relationship:

$$R_{xy} = \text{IFFT}(\text{FFT}(x)\text{FFT}^*(y))$$

Which states that taking the inverse Fourier Transform of the complex conjugate product of the Fourier Transforms of x and y results in the circular correlation of x an y.

Further, a very important take-away is the sensitivity of any of these correlations to frequency offset, specifically that the magnitude goes down as a Sinc function with the first null at 1/T.

Please see this post directly where I detail that: GPS CA Signal Acquisition

This informs the frequency capture range based on the length of code used. If you are well inside this main lobe in frequency (I typically use 1/2 the null-null frequency range, but if the SNR is poor you may need to be more constrained). Typical acquisition approaches will either slowly ramp the frequency offset or step the frequency offset during correlation (The frequency is offset by using an IQ rotator on the received signal prior to correlation). Stepping the offset involves setting the frequency at an initial guess, correlating and if the acquisition threshold is not exceeded, stepping the frequency by 1/T (if using 1/2 the null-null frequency range) and repeating. If ramping, the ramp rate must be much less than 1/T without inducing an additional frequency offset loss.

The frequency offset is accurately estimated by comparing two successive correlations, since frequency is the change in phase versus the change in time ($d\phi/dt)$ by simply comparing the phase and time between two successive correlations, we can determine the frequency offset assuming we are in the frequency range of acquisition as detailed above (importantly these correlations are complex correlations with two real outputs I and Q such that carrier phase is determined).

Note that the frequency computation detailed at this link Obtaining phase and magnitude of 2 spectral components after ADC using the computation

$$K = I[n]Q[n-1] - I[n-1]Q[n]$$ where K is propotional to frequency offset equally applies to the successive I and Q correlation outputs, referred to as I[n], Q[n] and I[n-1]Q[n-1].

Much more practical with modern processing and shorter preamble sequences would be a one shot frequency offset and delay estimation that I have detailed here:

GPS signal acquisition

That said, a robust preamble solution could involve sending multiple copies of one code to aid initial carrier and clock acquisition (and channel estimation!) followed by a final negative of the code sequence to mark the beginning of the data. (Just invert the code and the correlation will be shifted 180°). The trade space is over-head of the preamble versus acquisition sensitivity. It is typical to require more SNR during acquisition, especially if a fast acquisition is needed, hence the significance of correlation and processing gain.


Typically the coarse and fine frequency correction is applied before demodulation. The header preamble is for frame sync on the demodulated bits. Here is a matlab guide for frequency correction for QAM: https://www.mathworks.com/help/comm/ug/correct-frequency-offset-qam-using-coarse-and-fine-synchronization.html

  • $\begingroup$ Thanks. This for 16QAM My requirements are for BPSK or QPSK. Also in the example I can not see how comm.QAMCoarseFrequencyEstimator works. Is there a simple m file for it without using tool boxes ? $\endgroup$
    – Adam
    Aug 7, 2018 at 19:58
  • $\begingroup$ It doesn't say it in the Matlab page but the coarse frequency estimation can be done using an FFT then looking for the peak. As you increase FFT bin resolution you get a better frequency offset estimate but also increase computation complexity. The FFT coarse frequency estimation should also work for BPSK/QPSK. $\endgroup$
    – JTM
    Aug 7, 2018 at 20:04
  • $\begingroup$ Thanks, I will try using FFT and see if I can get the same result. What about comm.CarrierSynchronizer and comm.PhaseFrequencyOffset how they work ? $\endgroup$
    – Adam
    Aug 7, 2018 at 20:18
  • $\begingroup$ The phase correction is done using a Phase Lock Loop (PLL). This MATLAB page shows the error equations for each modulation type. mathworks.com/help/comm/ref/… $\endgroup$
    – JTM
    Aug 7, 2018 at 20:25
  • $\begingroup$ The coarse frequency correction can be done by multiplying your input by a tone at the offset frequency then applying a low pass filter. After that the small drift/fine correction is done similar to the phase correction but you look at the rate of change for the phase error. $\endgroup$
    – JTM
    Aug 7, 2018 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.