From 958c9920a5f05c97952f72c93b2e9dca231cfb8b Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Sat, 27 Nov 2021 19:57:03 +0100 Subject: Start access code cross correlation --- tests/correlator/acproc.py | 48 ++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) (limited to 'tests/correlator/acproc.py') diff --git a/tests/correlator/acproc.py b/tests/correlator/acproc.py index e119520..50c9a38 100755 --- a/tests/correlator/acproc.py +++ b/tests/correlator/acproc.py @@ -2,19 +2,21 @@ import numpy as np import matplotlib.pyplot as plt -import acgen +from acgen import acgen -# Parameters -# samples per symbol -sps = 4 -# number of initial bytes (to ignore) -nzeros = 10 -# length of the access code in bytes -aclen = 2 +# parameters +access_code_bits = [ 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, ] +access_code = list(np.packbits([0] * 3 + access_code_bits)) +padding_zeros = 10 # Create samples -print("Modulating symbols") -acgen.main() +print(f"Modulating symbols for access code {access_code_bits} = {access_code} with after {padding_zeros} empty bytes") +gen = acgen() +gen.set_access_code(access_code) +gen.set_padding_zeros(padding_zeros) + +gen.start() +gen.wait() # Extract one sequence print("Extracting symbol sequence") @@ -27,17 +29,24 @@ plt.title("Raw Data (time domain)") plt.show() # take only symbols -symbols = data[1::sps] +symbols = data[1::gen.sps] + plt.plot(symbols.real, symbols.imag) plt.title("Symbols only (constellation)") plt.show() # where ac symbols start, in symbols -ac_start = nzeros * 8 -ac_end = ac_start + aclen * 8 +ac_start = (padding_zeros) * 8 + 3 # plus three because code is 13 bits +ac_end = ac_start + int(np.ceil(len(access_code_bits) / 2.)) # divided by two because QPSK ac = symbols[ac_start:ac_end] +print(f"Generated {len(ac)} (left padded) symbols from a {len(access_code_bits)} bit sequence") +print(list(ac)) + +print(f"Upsampled to {gen.sps} samples per symbos") +print(sum([[i, i, i, i] for i in ac], [])) + fig, (ax1, ax2) = plt.subplots(2, 1) fig.tight_layout() @@ -51,7 +60,14 @@ plt.show() fir = list(np.conj(ac[::-1])) -# print the symbols -print(f"Generated {len(ac)} symbols from a {aclen} byte sequence") -print("Reversed symbols (for FIR filter):") +# Print the symbols +print("Reversed complex conjugate symbols (for FIR filter):") print(fir) + +# Compute cross correlation + +xc = np.convolve(fir, ac) + +plt.plot(np.abs(xc)) +plt.title("Cross correlation (FIR)") +plt.show() -- cgit v1.2.1