# Find Syncword (pattern) in signal, using Correlation

I have a signal which always has the same syncword ([93 0b 51 de] in hexa).

I also have a signal with additive noise(attacing it, and I want to find my syncword in that a noisy signal using corelation(actually using xcross corelation), I attach the plot of my signal with additive noise(actually the demodulated signal that I de modulated it), my syncword is hidden here with noised signal and other data(like crc ..but doesn't matter for me and Im just looking for my syncword) those data Im getting from transmitter that's transmiting on frequency 868MHZ , Im implicitly the receiver and sampling in frequency 868MHz , those IQ samples data has packets and Im seeing them on my matlab those IQ samples data(sampling them on 20480000) I demodulated them by two matched filters and the data the I got is ranges between 1 , -1 . -1 means 0 in binary and 1 means 1 in binary.. (the plot of my demodulated data see the first photo that I attached above..

code in matlab:

>>fs=204800;
>>dk=loadFile('fm.dat'); %Im loading the IQ samples that I sampled them by my hardware sampler , once I do plot(real(dk)) I see the packets in matlab

>> t20=[-40000:40000]*(1/fs);
>> mf1200 = 100*exp(i*2*pi*t20*100000);
>> mf2200 = 100*exp(i*2*pi*t20*-100000);
>> d12 = conv(dk,mf1200,'same');
>> d22 = conv(dk,mf2200,'same');
>> ddif=((abs(d12)-abs(d22))./(abs(d12)+abs(d22)));
>> xCorrResult=xcorr(ddif',random);


Then I 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 syncword was found in my demodulated data that ranges between (-1 1) ? the packet that I transmit is in frequency 868MHZ, 50KHZ symbol rate , deviation 100KHZ , and my syncword/data are attached in the photo below: the file can be opened on matlab by this matlab code (plot(real(y) will give you plot of packets like nullPacketDatanullPacketDatanullPacketData):

function y = loadFile(filename)
%

% reads  complex samples from the rtlsdr file
%

fid = fopen(filename,'rb');

y = y-127.5;
y = y(1:2:end) + i*y(2:2:end);

• It looks like you are clearly seeing something-- those big spikes in the correlation suggest that is where the syncwords are located. Jun 16 '20 at 16:06
• @DanBoschen not but those big spikes isn't properly .. because In my photo Im displaying just one packet .. and it should be just one big spike but here in the plot found 2+ big spikes .. so the result/the plot isn't good
– Ryan
Jun 16 '20 at 16:08
• @DanBoschen would be really appreciated if you could help me to do my xcross corelation to be more readable and more clear .. I guess the problem in my demodulator(two exponent-the two matched filter..)
– Ryan
Jun 16 '20 at 16:09
• @DanBoschen Im transmit the packet in frequency 868MHZ , deviation 100khz , symbol rate 50Kbaud , so the sampler (my dongle) is sampling on that frequency .. and I get IQ samples raw data , I put my two matched filter on frequency 100000 in my exp because the receiver will get the packet data on +-100khz and on 868khz will be zero ..
– Ryan
Jun 16 '20 at 16:12
• for your wish I explain here: I send RF packets in frequency 868MHZ and symbol rate 50KHZ (symbol rate=bit rate) , deviation is 100kHZ , so once I transmit by cc1350 hardware of texas instrument, and Im sampling those IQ SAMPLES DATA (raw data) by a sampler called SDR dongle. –
– Ryan
Jun 16 '20 at 16:13