# Preamble detection using cross-correlation

I am generating a preamble with a sequence of [1 -1 1 -1 1 -1....] and spread with a barker-11 sequence. Now, the transmitted signal becomes [B(Barker), -B(Inverse of Barker), B, -B,....]. In channel, there is a random phase added to signal. In order to estimate the phase, First, I am doing the cross-correlation received signal with known barker sequence. When the peak value, I know it is barker sequence, I removed the symbol phases according to the barker sequence, now only random phase will present on the symbols.

However, I am also getting the peak value when it is correlated with '-B', then it inherently introducing 180 degree phase offset. How to avoid this problem??

Cross correlation I am doing by following:

if barker sequence [1 0 1 1 0 1 1 1 ....], and received symbols are complex,[r1 r2 r3 r4 r5 ....].

Corr_Real = real(r1) - real(r2) + real(r3) + real(r4) - real(r5) +......

Corr_Imag = imag(r1) - imag(r2) + imag(r3) + imag(r4) - imag(r5) +......

Correlation Index = Corr_Real^2 + Corr_Imag^2.

Please tell me if any other way to do.

• It's not clear what you're asking. You're right, if you correlate against your Barker sequence with any arbitrary phase shift applied (not just 180 degrees), then you will still get a peak value with large magnitude. Your solution seems to be: don't do that. You know what the "correct" polarity of the sequence is, given that you designed it. Correlate against the expected correct value, and then any remaining phase shift is due to the channel, as you said. – Jason R Feb 7 at 13:10
• I am sorry if my question is not clear. Assume, I am transmitting [B, -B, B, -B]. At, receiver, I received same sequence with some random phase, hence it is complex signal. Now, if do cross-correlation with [ B ], I will get +ve peak when it is correlated with [B], -ve peak when it correlated with [-B]. since cross correlation is done on the complex signal, to get index I am taking absolute value of index. That's the reason I unable to detect whether, [ B ] is correlated or [-B] is correlated. How to accurately say exact [B] is correlated ? – Rakesh Samala Feb 8 at 5:24
• You can't. If there's a random phase applied, there is no way for you to tell without additional information whether B or -B was transmitted. Carrier phase synchronization schemes still often have ambiguities like this: you might get the actual transmitted data out, or an inverted version. You need some other information to use in order to resolve the ambiguity, like a fixed sync pattern that is transmitted at a known position. – Jason R Feb 8 at 14:26