I have a signal which always has the same preamble (4x 0xAA - 10101010...).

I also have a signal with additive noise, and I want to find my preamble in that a noisy signal using corelation.

enter image description here

U used xcorr, but I was a little confused by that. Can you help me? It looks like that signal was too noisy so that no preamble was found?

I have just used

  • $\begingroup$ Correlation is, for uncorrelated signals, additive, and since the noise should be uncorrelated to your preamble, the signal can't be "too noisy": The correlation would always increase by the preamble's energy when you hit just the exactly right time offset index. (unless the assumption of non-correlatedness breaks down, or the noise is so powerful that the autocorrelation of the preamble doesn't stick out enough) $\endgroup$ – Marcus Müller Apr 1 '17 at 13:54

You should be able to see an peak correlation as from your plot and the length of your pattern it does not appear to be noisy enough such that you would not see a peak (unless your noise is completely in the time domain as in excessive jitter that I cannot visibly see).

I suspect that the pattern you are using is extending far beyond the length of the preamble such that your data payload is corrupting the final cross correlation result (or you are not using just the preamble pattern to correlate with your data). It goes without saying that the preamble and data need to be running at a similar rate (although you can have a significant clock offset and still correlate; correlation amplitude versus frequency offset is a Sinc function with the first null at a clock offset of 1/T where T the length of your correlation sequence; the longer the sequence the more accurate your clocks need to be). From your result if I read the numbers on the plots correctly your correlation result is close to 60 on average, and from your description you are correlating over 32 symbols (4x 0xAA). If the sequences were not correlated, and the average for your data and pattern are 1/2, then this suggests your sampling rate is approximately 8 samples per symbol if you are indeed correlating over the full 32 symbols.

You will also benefit by removing the mean from your data (such that it is bipolar in the correlation computation) as you will see in my example below. Also as shown this does not appear to be the reason you are not getting any result (as shown by my result even with the mean present).

Trying to duplicate your conditions, here is the result I got when I correlated the 4x 0xAA pattern to a random sequence of 0's and 1's for 5000 samples: (although I reversed the correlation from what you did such that the preamble correlation would appear first):

random sequence no preamble

And then with the preamble at the beginning and repeated in the middle of the random sequence (note the noise is very big in this case; as I added the random data to the preamble, just to show what you should expect to see in extremely noisy conditions:

preamble and random sequence

And by removing the mean of the signals prior to correlation the detection becomes quite easy even in the presence of the very significant noise (the noise is a random pattern of 0's and 1's at sample rate):

corr with mean removed

zoom in of correlation

Also for completion, below shows the result in the case of correlating over just a portion of your sequence (1x 0xAA) with the same preamble in the sequence (4x 0xAA); 20Log(4) less processing gain but showing that a clear detection is still possible with the amount of noise I had added (and such an approach may be done if the rest of the preamble is reserved for timing recovery; meaning by design we need to detect early in the preamble):

shorter correlation

Not directly related to why you are having issue, but a challenge also to be aware of with this pattern is that while great for timing recovery (as there is a transition at your data rate on every symbol), your preamble does not have a unique autocorrelation as you can see by the cyclical pattern in the plots above.

The same processing gain in SNR is achieved as in other patterns at the position in cross-correlation where the delay between the patterns is zero , $R_{xy}(0)$, (the gain in SNR is 20Log(N) where N is the number of samples where the noise is still uncorrelated; usually due to symbol rate filtering this is the number of symbols) and if you use a circular correlation you can also achieve that SNR advantage at every offset where the sequence aligns as described above as well. For timing critical applications where it is important to know the actual position within the sequence, Barker codes or other similar pseudo-random sequences are used that have the property that correlation is maximum at shift = 0 and close to 0 everywhere else (such as maximum length sequences). An example 11 bit Barker code is 10110111000. If you treat the 0's as -1 you will see that this sequence will add to +11 when they are added and in a circular correlation will add to +1 everywhere else. Note however the challenge for clock recovery in such a sequence given the longer runs of ones and zeros compared to 1010101010.

  • $\begingroup$ Thank you answer! Now my idea: Send the barker from first (A) device. Receive this signal on second (B) device. Then (with constant delay) send received barker back to first device. Then by using correlation and timer compute the delay between sent and recieved signal - just pulse radar. For transmit/receive use something like si4463 in RAW mode and STM32 for compute the delay. But not sure if this technology can be so accurate. Speed of light 3e8 m/s, It is about 3 m for 10 ns. But make real time correlation and measure time with resolution about 10 ns on STM32 e.g. F4 ? $\endgroup$ – WITC Apr 5 '17 at 12:44
  • $\begingroup$ Yes I have implemented such exact systems for active ranging using spread spectrum (so with PN codes instead of barker codes). Note your clock rate will ultimately limit RMS range accuracy using rms range = T/sqrt(12) since the signal has a uniform probability of arrival anywhere between two clock edges $\endgroup$ – Dan Boschen Apr 5 '17 at 13:06

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.