template bit pattern for the 13 baud Barker code *). (* build the coding filter -*) step1 = Flatten[Riffle[barker13base, {zeropad}]]; barker13h = Join[zeropad, step1, ...
������������������������������������������������ ��� �������������������������������������������� ©���������������������������������������� ��������������������������������������������������������������������������
���������������������������������������������������������������������������������������� ������������������������������������������������������������������ ����������������������������������������������������������������������������������������� ������������������������������ �������� ����������������������������������������������������������������������������� �������������������������������������������������������������������������� �������������������������������������������������������������������������� ����������������������������������������������������������������⨯��� ����������������������������������������������������������������������� ���������������������������������������������������������������������� ����������������������������������������������������������������������������� ��������������������������������������������� ���������������������������������������������������������������������������������������� ��������������������������� ��������������������������������������� ���������������������������������������������������������������������������������������� ��������������������������� ������������������������������������������������������������������������������� ����������������� ����������� ���������������������������������������������������������������������������� �������������������������������������������������������������������������� ��������������������������������������������������������������������� ����������������������������������������������������� ������������������������������ �������������������������������������������������������������������������� ������������������������������������������������������������������������� ����������������������������������������������������������� ���������������������������������������������������������������������� ������������������������������������������������������������������������� ����������������������������������������������� ���������������������������������� ������������������������������������������������������������������������� ���������������������������������������������������� ����������
Clear"Global`*"
�����������������������������������������������������������
2 ���
Barker_Codes_v3.2_13-169baud.nb
����������������������� ����������������������������������������������������������������������� ���������������������������������� ����������
Rotate1D[array_] := Module{len = Length[array]}, IfEvenQ[len], RotateRightarray, len 2, RotateRightarray, len - 1 2; (* function needed below *)
__________________________ **Some basic definitions ����������
(* Note: sampleinterval = deltatime - units are μsec *) nsamples = 182; (*182, 202*) nsamplesbaud = 3; (* we use bauds of integer sample length *) zeropad = Table[0, nsamplesbaud - 1]; padding = {1, 1}; codelength = 13; plotxvalues = Range- nsamples 2, nsamples 2 - 1; (* Needed for plotting below *)
____________________________ **A single sampled 1 baud “code”. ����������
pulsebaud = Table[1, nsamplesbaud]; (* our representation of single baud of the code it must be nsamplesbaud long *) plotpulsebaud = PadRight[pulsebaud, codelength + 3]; ListPlot[plotpulsebaud, PlotRange → {{0, codelength}, {- 1.2, 1.2}}, Filling → Axis, PlotLabel → "������� ������ ����"] ������� ������ ���� 1.0
0.5
����������
2
4
6
8
-0.5
-1.0
�������������������������������������
10
12
Barker_Codes_v3.2_13-169baud.nb
______________________________________ **Get the impulse response of the coding filter. ����������
barker13base = {1, 1, 1, 1, 1, - 1, - 1, 1, 1, - 1, 1, - 1, 1}; (* template bit pattern for the 13 baud Barker code *) (* build the coding filter -*) step1 = Flatten[Riffle[barker13base, {zeropad}]]; barker13h = Join[zeropad, step1, zeropad]; (* impulse response of coding filter - eqn 3 in �������� �� ��� *) ListPlot[barker13h, PlotRange → {{0, nsamplesbaud * codelength + 1}, {- 1.2, 1.2}}, Filling → Axis, PlotLabel → "������� �������� ������ ����� ������� ��������"] (* hc (n) - eqn 3, �������� �� ��� *) ������� �������� ������ ����� ������� �������� 1.0
0.5
����������
10
20
30
40
-0.5
-1.0
������������������������������������������������������ ������������������������������������������������ �������������������������������������������������������
���
3
4 ���
Barker_Codes_v3.2_13-169baud.nb
______________________________________ **Get the sampled Barker code. ����������
barker13 = ListConvolve[pulsebaud, barker13h]; (* sampled code *) ListPlot[barker13, PlotRange → {{0, nsamplesbaud * codelength + 1}, {- 1.2, 1.2}}, Filling → Axis, PlotLabel → "������� �� ���� ������ ���� "] ������� �� ���� ������ ���� 1.0
0.5
����������
10
20
30
40
-0.5
-1.0
������������������������������������������������������� ���������������������������������������������������������� �����������
Barker_Codes_v3.2_13-169baud.nb
���
______________________________________ **Decode the sampled Barker code. ����������
samplecount = nsamplesbaud + 1 * codelength; (*barker13p=PadLeftbarker13,nsamples2;*) barker13p = PadRight[barker13, nsamples]; (* *) barker13plot = Rotate1D[ListCorrelate[barker13, Conjugate[barker13p], {1, 1}]]; ListPlot[Transpose[{plotxvalues, barker13plot}], Joined → True, Mesh → All, PlotRange → {{- 50, 50}, {0, 40}}, PlotLabel → "������� ����� �������� �� ������� �� ���� ������ ����"] ������� ����� �������� �� ������� �� ���� ������ ���� 40
30
����������
20
10
-40
-20
0
20
40
���������������������������������������������������� ������������������������������������������������������������ ���������������������������������������������������������� �������������������������������������������������
5
6 ���
Barker_Codes_v3.2_13-169baud.nb
����������������������������������������������������������� ����������������������� ������������������������������������������������������������������������� ���������������������������������������������������������������������������� ������� ���������������������������������������������������������������������������������� ������������������������������ ������������������������������ ��������������������������������������� ����������
totalsamples = nsamples; (* Note: we repeat some of the above for simplicity. *) sampledBaudTD = PadRight[pulsebaud, totalsamples]; (* Establish the single baud "code" with nsamples length *) sampledBaudFD = Fourier[sampledBaudTD]; (* frequency domain version of single baud code: Q(ω) - eqn (15) in Lehtinen et al. *) pwrspecBaud = Sqrt[Abs[sampledBaudFD * Conjugate[sampledBaudFD]]]; (* Get the amplitude spectrum *) ListPlot[Rotate1D[pwrspecBaud], PlotLabel → "sampledBaudFD: Shown is Sqrt[power spectrum] of single baud code"] barker13TD = PadRight[barker13h, totalsamples]; (* impulse response hc (n) of the Barker 13 coding filter *) ListPlot[barker13TD]; (* Enable plotting barker13TD by removing ";" *) barker13FD = Fourier[barker13TD]; (* Hc (ω) - eqns (14) & 16 in Reference *) pwrspecB13Hc = Sqrt[Abs[barker13FD * Conjugate[barker13FD]]]; ListPlot[Rotate1D[pwrspecB13Hc], PlotRange → All, Joined → True, PlotLabel → "barker13FD: Shown is Sqrt[power spectrum] of 13 baud code"] sampledBaudFD: Shown is Sqrt[power spectrum] of single baud code
0.20
0.15 ����������
0.10
0.05
50
100
150
Barker_Codes_v3.2_13-169baud.nb
barker13FD: Shown is Sqrt[power spectrum] of 13 baud code
0.35
����������
0.30
0.25
50
100
150
���������������������������������������������������������� ����������������������������������������������������������� �������������������������������������������������������� ��������������������������������������������������������� ��������������������������������������������������������� ����������������������������������������������������������� ���������������������������������������������������������� ������������������������ ����������
gamma = barker13FD sampledBaudFD; (*decodeFilter=InverseFouriersampledBaudFDbarker13FD; eqn 14 Lehtinen et al. *) decodeFilter = InverseFourier[1 / gamma]; decodeFilter = RotateRightdecodeFilter, totalsamples 2; ListPlot[Re[decodeFilter], PlotRange → All, Joined → True, PlotLabel → "Truncated zero-sidelobe compression filter"] (* see middle-right panel, Figure 3 of Lehtinen et al. *) decodeFilterTD = InverseFourier[gamma]; (* time domain*) Truncated zero-sidelobe compression filter 1.0
0.5
����������
50 -0.5
-1.0
-1.5
100
150
���
7
8 ���
Barker_Codes_v3.2_13-169baud.nb
���������������������������������������������������� ��������������������������������������������������� ����������
(* Equation-17, Lehtinen et al *) MisMatchFilterOut = Rotate1DInverseFourierFourier[PadRight[barker13, totalsamples]] Fourier[decodeFilterTD] Sqrt[Dimensions[decodeFilterTD][[1]]]; ListLinePlotTransposeplotxvalues, Abs[MisMatchFilterOut] nsamplesbaud, PlotRange → All, PlotLabel → "Mis-matched compression filter decoding of sampled 13 baud Barker code" ListLinePlot Transposeplotxvalues, Log10Abs[MisMatchFilterOut] nsamplesbaud, PlotRange → All, PlotLabel → "Log10 of the mis-matched compression filter decoding of sampled 13 baud Barker code" (*Matched filter*) MatchFilterOut = Rotate1D[ ListCorrelate[Conjugate[barker13], PadRight[barker13, totalsamples], {1, 1}]]; ListLinePlotTransposeplotxvalues, MatchFilterOut nsamplesbaud, PlotRange → All, PlotLabel → "Matched filter decoding of sampled 13 baud Barker code" Mis-matched compression filter decoding of sampled 13 baud Barker code 14 12 10 8
����������
6 4 2
-50
50
Barker_Codes_v3.2_13-169baud.nb
���
Log10 of the mis-matched compression filter decoding of sampled 13 baud Barker code
50
-50
-5 ����������
-10
-15
Matched filter decoding of sampled 13 baud Barker code 12 10 8 ����������
6 4 2
-50
50
�����������������������������-���������������������������������(���)��������������������������� �������������(������)������������������������������������������������������������������������������������ ����(����������)���������������������������������������������������������������������������������������� �����(=�������)�
_________________________________________________________ 2. 169 Bit Barker decoding using mis-matched, sidelobe-free filtering... This directly follows the solution path outlined above. Based on Kesaraju et al. (2017). ����������
(*sampleinterval=1; (* the same as above with possibility of changing it - units are μsec *)*) nsamples169 = 28 589; (* Magnitude of mismatch filter depends on this*) nsamplesbaud169 = 10; (* we use bauds of integer sample length *) codelength169 = 169;
9
10 ���
Barker_Codes_v3.2_13-169baud.nb
����������
plotxvalues1 = Range[0, codelength169 + 2]; plotxvalues169 = Range- nsamples169 2, nsamples169 2 - 1; (* Needed for plotting below *) pulsebaud169 = ConstantArray[1, nsamplesbaud169]; (* our representation of single, sampled baud of the code nsamplesbaud169 long *) (*pulsebaud=PadRight[pulsebaud,nsamples]; *) barker13base = {1, 1, 1, 1, 1, - 1, - 1, 1, 1, - 1, 1, - 1, 1}; (* template bit pattern for 13 baud Barker code - same as above for clarity *) barker169base = Flatten[KroneckerProduct[Reverse[barker13base], Reverse[barker13base]]]; (* template bit pattern for 169-baud Barker code *)
����������
(* fill in necessary 0's between current elements *) barker169 = Partition[barker169base, 1]; (* an elligant alternative to what we did above! *) barker169 = Flatten[ Table[PadRight[barker169[[i]], nsamplesbaud169, 0], {i, 1, codelength169}]]; barker169h = barker169; (* impulse response of coding filter eqn 3 in reference *) barker169 = PadLeftbarker169, nsamplesbaud169 * codelength169 + 1 - 1; (* add 0's on left *) barker169 = ListCorrelate[pulsebaud169, barker169]; (* impulse response of the coding filter hc (n)which is zero for ncodelength-1; n is an integer *)
����������
plotpulsebaud169 = PadRight[pulsebaud169, codelength169 + 3]; ListPlot[Transpose[{plotxvalues1, plotpulsebaud169}], PlotRange → {{0, codelength169}, {- 1.2, 1.2}}, Filling → Axis, PlotLabel → "Sampled single baud"] Sampled single baud 1.0
0.5
����������
50
-0.5
-1.0
100
150
Barker_Codes_v3.2_13-169baud.nb
����������������������������������������������������� ����������������� ����������
ListPlot[barker169h, PlotRange → {{0, nsamplesbaud169 * codelength169 + 1}, {- 1.2, 1.2}}, Filling → Axis, PlotLabel → "Sampled Barker169 coding filter impulse response"] (* hc (n) - reference eqn 3 *) Sampled Barker169 coding filter impulse response 1.0
0.5
����������
500
1000
1500
-0.5
-1.0
��������������������������������������� ����������
ListPlot[barker169, PlotRange → {{0, nsamplesbaud169 * codelength169 + 1}, {- 1.2, 1.2}}, Filling → Axis, PlotLabel → "Sampled 169-baud Barker code "] Sampled 169-baud Barker code 1.0
0.5
����������
500
1000
1500
-0.5
-1.0
����������������������������������������������������� ���������������������������������
���
11
12 ���
Barker_Codes_v3.2_13-169baud.nb
����������
sampledBaud169TD = PadRight[pulsebaud169, nsamples169]; (* pulse baud- baud length with 1's*) sampledBaud169FD = Fourier[sampledBaud169TD]; (* Q(ω) - eqn (15) in Reference *) pwrspecBaud169 = Sqrt[Abs[sampledBaud169FD * Conjugate[sampledBaud169FD]]]; ListLinePlot[Rotate1D[pwrspecBaud169], PlotRange → All, PlotLabel → "sampledbaud169FD: Shown is Sqrt[power spectrum] of the sampled single baud code"] barker169hTD = PadRight[barker169h, nsamples169]; (* barker 169h with zero weight*) (* impulse response hc (n) of the Barker 169 coding filter *) barker169FD = Fourier[barker169hTD]; (* Hc (ω) - eqns (14) & 16 in Reference *) pwrspecB169Hc = Sqrt[Abs[barker169FD * Conjugate[barker169FD]]]; ListLinePlot[Abs[barker169FD], PlotRange → All, PlotLabel → "barker169FD: Shown is Sqrt[power spectrum] of the sampled 169 baud code"] sampledbaud169FD: Shown is Sqrt[power spectrum] of the sampled single baud code 0.06
0.05
0.04 ����������
0.03
0.02
0.01
5000
10 000
15 000
20 000
25 000
barker169FD: Shown is Sqrt[power spectrum] of the sampled 169 baud code 0.14 0.12 0.10 ����������
0.08 0.06 0.04 0.02
5000
10 000
15 000
20 000
25 000
��������������������������������������������������������� ������������������������������������������������������������� ����������������������������������������������������
Barker_Codes_v3.2_13-169baud.nb
���
��������������������������������������������������������� ������������������������������������������������������� ������������������������������������������������������������ ������������������������������������������������������� ��������������������������������� ����������
hc169 = barker169FD sampledBaud169FD; decodeFilter169TDa = InverseFourier1 hc169; decodeFilter169TD = decodeFilter169TDa; decodeFilter169TD = RotateRightdecodeFilter169TD, IntegerPartnsamples169 2; x = Re[decodeFilter169TD]; ListLinePlot[x, PlotRange → All] 1.5 1.0 0.5 ����������
5000
10 000
15 000
20 000
25 000
-0.5 -1.0 -1.5
����������������������������������������������������� ��������������������������������������������������� ����������
(* Equation-17, Lehtinen et al *) MisMatchFilter169Out = InverseFourier[ Fourier[PadRight[barker169, nsamples169]] * Fourier[decodeFilter169TD]] * Sqrt[nsamples169] nsamplesbaud169; (* Note the normalization for the Fourier transforms & samplesbaud *) ListLinePlot[Transpose[{plotxvalues169, Abs[MisMatchFilter169Out]}], PlotRange → All, PlotLabel → "Mis-matched compression filter decoding of sampled 169-baud Barker code"] ListLinePlot[Transpose[{plotxvalues169, Log[Abs[MisMatchFilter169Out]]}], PlotRange → All, PlotLabel → "Log10 of the Mis-matched compression filter decoding of sampled 169-baud Barker code"] (* Decoding using the matched filter. *) MatchFilter169Out = Rotate1D[ ListCorrelate[Conjugate[barker169], PadRight[barker169, nsamples169], {1, 1}]]; ListLinePlotTransposeplotxvalues169, Abs[MatchFilter169Out] nsamplesbaud169, PlotRange → All, PlotLabel → "Matched filter decoding of sampled 169-baud Barker code"
13
14 ���
Barker_Codes_v3.2_13-169baud.nb
Mis-matched compression filter decoding of sampled 169-baud Barker code
150
100
����������
50
-10 000
5000
-5000
10 000
Log10 of the Mis-matched compression filter decoding of sampled 169-baud Barker code
-10 000
5000
-5000
10 000
-10 ����������
-20
-30
-40
Matched filter decoding of sampled 169-baud Barker code
150
100
����������
50
-10 000
-5000
5000
10 000
Barker_Codes_v3.2_13-169baud.nb
���
15
������������������-��������������������������������-���������������������������������(���)� ���������������������������������������(������)������������������������������������������������ �����������������������������������������(����������)���������������������������-�������������������� ��������������������������������������������������������������������������������������������������������������� ���������������������������������������������������=��������������������������������������������