diff --git a/utils/filter_preamble.py b/utils/filter_preamble.py new file mode 100755 index 0000000..7c2bfcf --- /dev/null +++ b/utils/filter_preamble.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +import numpy as np +import matplotlib.pyplot as pp +import rrc + +pre = [1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, + -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, + 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, + -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, + -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, + -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, + 1, -1, -1, 1, 1, 1, 1] + +pre_up = np.zeros(2 * len(pre) + 1) + +pre_up[1::2] = pre + +rrc_coef = rrc.rrc_design(150, 2) + +pre_flt = np.convolve(pre_up, rrc_coef, mode='same') + +print(list(pre_flt)) + +pp.plot(pre_up) +pp.plot(pre_flt) +pp.show() diff --git a/utils/rrc.py b/utils/rrc.py new file mode 100755 index 0000000..8fde6a7 --- /dev/null +++ b/utils/rrc.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +import numpy as np + +def rrc_design(N, samples_per_symbol, roll_off = 0.35): + coef = np.zeros(N) + + k0 = N/2 + Ts = samples_per_symbol + + for k in range(len(coef)): + t = k - k0 + + if t == 0: + coef[k] = 1 / np.sqrt(Ts) * (1 - roll_off + 4 * roll_off / np.pi) + elif abs(t) == (Ts / (4*roll_off)): + coef[k] = roll_off / np.sqrt(2 * Ts) * \ + ( (1 + 2/np.pi) * np.sin(np.pi / (4 * roll_off)) + \ + (1 - 2/np.pi) * np.cos(np.pi / (4 * roll_off)) ) + else: + coef[k] = 1 / np.sqrt(Ts) * \ + ( np.sin(np.pi * t / Ts * (1 - roll_off)) + 4 * roll_off * t / Ts * np.cos(np.pi * t / Ts * (1 + roll_off)) ) / \ + ( np.pi * t / Ts * (1 - (4 * roll_off * t / Ts)**2) ) + + return coef + +if __name__ == "__main__": + import matplotlib.pyplot as pp + + c = rrc_design(50, 5, 0.35) + print(np.sum(c)) + pp.plot(c) + pp.show()