aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/correlator/correlator.grc285
-rwxr-xr-xtests/correlator/correlator.py41
-rw-r--r--tests/correlator/epy_block_0.py16
-rw-r--r--tests/correlator/epy_block_1.py27
4 files changed, 191 insertions, 178 deletions
diff --git a/tests/correlator/correlator.grc b/tests/correlator/correlator.grc
index 220eaed..0f82f27 100644
--- a/tests/correlator/correlator.grc
+++ b/tests/correlator/correlator.grc
@@ -44,26 +44,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [776, 1140.0]
- rotation: 0
- state: enabled
-- name: access_code_symbols_sps
- id: variable
- parameters:
- comment: ''
- value: '[(1.4142197+1.4142197j), (1.4142197+1.4142197j), (1.4142197+1.4142197j),
- (1.4142197+1.4142197j), (1.4142197-1.4142197j), (1.4142197-1.4142197j), (1.4142197-1.4142197j),
- (1.4142197-1.4142197j), (1.4142197-1.4142197j), (1.4142197-1.4142197j), (1.4142197-1.4142197j),
- (1.4142197-1.4142197j), (-1.4142197-1.4142197j), (-1.4142197-1.4142197j), (-1.4142197-1.4142197j),
- (-1.4142197-1.4142197j), (1.4142197-1.4142197j), (1.4142197-1.4142197j), (1.4142197-1.4142197j),
- (1.4142197-1.4142197j), (1.4142197+1.4142197j), (1.4142197+1.4142197j), (1.4142197+1.4142197j),
- (1.4142197+1.4142197j), (1.4142197+1.4142197j), (1.4142197+1.4142197j), (1.4142197+1.4142197j),
- (1.4142197+1.4142197j)]'
- states:
- bus_sink: false
- bus_source: false
- bus_structure: null
- coordinate: [224, 132.0]
+ coordinate: [768, 1016.0]
rotation: 0
state: enabled
- name: const
@@ -81,7 +62,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [592, 484.0]
+ coordinate: [592, 360.0]
rotation: 0
state: enabled
- name: excess_bw
@@ -93,7 +74,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [496, 484.0]
+ coordinate: [496, 360.0]
rotation: 0
state: enabled
- name: nfilts
@@ -105,7 +86,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [224, 988.0]
+ coordinate: [224, 856.0]
rotation: 0
state: enabled
- name: revconj_access_code_symbols
@@ -120,7 +101,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [48, 564.0]
+ coordinate: [48, 440.0]
rotation: 0
state: enabled
- name: rrc_taps
@@ -132,14 +113,14 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [304, 988.0]
+ coordinate: [304, 856.0]
rotation: 0
state: enabled
- name: samp_rate
id: variable
parameters:
comment: ''
- value: '32000'
+ value: int(1.5e6)
states:
bus_sink: false
bus_source: false
@@ -163,24 +144,24 @@ blocks:
id: variable
parameters:
comment: ''
- value: '[31, 53] + [0x12, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3] '
+ value: '[0x1f, 0x35] + [0x12, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3] '
states:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [48, 492.0]
+ coordinate: [48, 360.0]
rotation: 0
state: enabled
- name: timing_loop_bw
id: variable
parameters:
comment: ''
- value: 2 * 3.141592653589793 / 100
+ value: 2 * np.pi / 100
states:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [224, 1068.0]
+ coordinate: [224, 936.0]
rotation: 0
state: enabled
- name: blocks_complex_to_magphase_0
@@ -196,7 +177,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [1048, 696.0]
+ coordinate: [1040, 568.0]
rotation: 0
state: disabled
- name: blocks_complex_to_magphase_0_0
@@ -212,7 +193,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [1088, 1304.0]
+ coordinate: [1032, 1176.0]
rotation: 0
state: enabled
- name: blocks_multiply_const_vxx_0
@@ -230,7 +211,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [1288, 724.0]
+ coordinate: [1288, 596.0]
rotation: 0
state: disabled
- name: blocks_multiply_const_vxx_0_0
@@ -248,7 +229,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [1376, 1380.0]
+ coordinate: [1376, 1248.0]
rotation: 0
state: disabled
- name: blocks_null_sink_3
@@ -265,7 +246,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [1376, 1432.0]
+ coordinate: [1376, 1304.0]
rotation: 0
state: true
- name: blocks_null_source_0
@@ -284,47 +265,48 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [96, 344.0]
+ coordinate: [96, 200.0]
rotation: 0
state: enabled
-- name: blocks_stream_mux_0
- id: blocks_stream_mux
+- name: blocks_repack_bits_bb_0
+ id: blocks_repack_bits_bb
parameters:
affinity: ''
alias: ''
+ align_output: 'False'
comment: ''
- lengths: '[10, len(testvec)]'
+ endianness: gr.GR_MSB_FIRST
+ k: '2'
+ l: '8'
+ len_tag_key: '""'
maxoutbuf: '0'
minoutbuf: '0'
- num_inputs: '2'
- type: byte
- vlen: '1'
states:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [288, 392.0]
+ coordinate: [672, 1252.0]
rotation: 0
- state: enabled
-- name: blocks_stream_mux_1
+ state: true
+- name: blocks_stream_mux_0
id: blocks_stream_mux
parameters:
affinity: ''
alias: ''
comment: ''
- lengths: '[len(access_code_symbols_sps), sps * (len(testvec) + 15)]'
+ lengths: '[5, len(testvec)]'
maxoutbuf: '0'
minoutbuf: '0'
num_inputs: '2'
- type: complex
+ type: byte
vlen: '1'
states:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [776, 280.0]
+ coordinate: [288, 256.0]
rotation: 0
- state: disabled
+ state: enabled
- name: blocks_throttle_0
id: blocks_throttle
parameters:
@@ -341,25 +323,9 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [1272, 404.0]
+ coordinate: [1272, 268.0]
rotation: 0
state: enabled
-- name: blocks_vector_sink_x_0
- id: blocks_vector_sink_x
- parameters:
- affinity: ''
- alias: ''
- comment: ''
- reserve_items: '1024'
- type: byte
- vlen: '1'
- states:
- bus_sink: false
- bus_source: false
- bus_structure: null
- coordinate: [536, 1392.0]
- rotation: 0
- state: true
- name: blocks_vector_source_x_0
id: blocks_vector_source_x
parameters:
@@ -371,35 +337,15 @@ blocks:
repeat: 'True'
tags: '[]'
type: byte
- vector: testvec * 1600
+ vector: testvec * 500
vlen: '1'
states:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [48, 404.0]
+ coordinate: [48, 268.0]
rotation: 0
state: enabled
-- name: blocks_vector_source_x_1
- id: blocks_vector_source_x
- parameters:
- affinity: ''
- alias: ''
- comment: ''
- maxoutbuf: '0'
- minoutbuf: '0'
- repeat: 'True'
- tags: '[]'
- type: complex
- vector: access_code_symbols_sps
- vlen: '1'
- states:
- bus_sink: false
- bus_source: false
- bus_structure: null
- coordinate: [224, 204.0]
- rotation: 0
- state: disabled
- name: channels_channel_model_0
id: channels_channel_model
parameters:
@@ -411,14 +357,14 @@ blocks:
freq_offset: '0.0001'
maxoutbuf: '0'
minoutbuf: '0'
- noise_voltage: '0.2'
+ noise_voltage: '0.01'
seed: '243'
- taps: -1.4 + .4j
+ taps: np.exp(1j * 30 / 180 * np.pi)
states:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [992, 364.0]
+ coordinate: [1000, 228.0]
rotation: 0
state: enabled
- name: digital_cma_equalizer_cc_0
@@ -437,7 +383,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [528, 812.0]
+ coordinate: [520, 676.0]
rotation: 0
state: enabled
- name: digital_constellation_decoder_cb_0
@@ -453,7 +399,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [248, 1388.0]
+ coordinate: [224, 1260.0]
rotation: 0
state: enabled
- name: digital_constellation_modulator_0
@@ -474,7 +420,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [496, 380.0]
+ coordinate: [504, 244.0]
rotation: 0
state: enabled
- name: digital_corr_est_cc_0
@@ -494,7 +440,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [776, 1020.0]
+ coordinate: [768, 892.0]
rotation: 0
state: enabled
- name: digital_costas_loop_cc_0
@@ -512,9 +458,25 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [1088, 1128.0]
+ coordinate: [1080, 1000.0]
rotation: 0
state: true
+- name: digital_map_bb_0
+ id: digital_map_bb
+ parameters:
+ affinity: ''
+ alias: ''
+ comment: ''
+ map: '[0, 1, 3, 2]'
+ maxoutbuf: '0'
+ minoutbuf: '0'
+ states:
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [496, 1260.0]
+ rotation: 0
+ state: bypassed
- name: digital_pfb_clock_sync_xxx_0
id: digital_pfb_clock_sync_xxx
parameters:
@@ -535,7 +497,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [224, 836.0]
+ coordinate: [224, 700.0]
rotation: 0
state: enabled
- name: epy_block_0
@@ -552,7 +514,7 @@ blocks:
\ block\n self.last = None\n\n # both the phase and frequency\
\ corrections should go through a low pass\n # filter to avoid werid\
\ jumps in the correction. to do that, there are\n # two buffers with\
- \ an index\n self.index = 0\n self.length = 7\n self.freq\
+ \ an index\n self.index = 0\n self.length = 5\n self.freq\
\ = np.zeros(self.length)\n\n def lpf_freq(self, new_sample):\n #\
\ save new sample\n self.freq[self.index] = new_sample\n # increment\
\ index\n self.index = (self.index + 1) % self.length\n\n return\
@@ -561,15 +523,18 @@ blocks:
\ - start.offset\n\n # unpack pmt values into start and end phase\n \
\ sphase = pmt.to_python(start.value)\n ephase = pmt.to_python(end.value)\n\
\n # compute frequency offset between start and end\n # and run\
- \ it through a low pass filter (mean)\n freq = (sphase - ephase) / nsamples\n\
- \ freq = self.lpf_freq(freq)\n\n # debugging\n print(f\"\
- Correction for block of {nsamples:2d} samples is \" \\\n f\"phase={sphase:\
- \ .4f} rad and freq={freq*1e3: .4f} milli rad / sample\")\n\n # compute\
- \ block values\n return sphase * np.ones(nsamples) + freq * np.arange(0,\
- \ nsamples)\n\n def work(self, input_items, output_items):\n # FIXME:\
- \ replace class counter with local variable\n self.counter = self.nitems_written(0)\n\
- \n # nicer aliases\n inp = input_items[0]\n out = output_items[0]\n\
- \n # read phase tags\n is_phase = lambda tag: pmt.to_python(tag.key)\
+ \ it through a low pass filter (mean)\n phasediff = ephase - sphase\n\
+ \n if phasediff > np.pi:\n phasediff -= 2*np.pi\n\n \
+ \ elif phasediff < -np.pi:\n phasediff += 2*np.pi\n\n freq\
+ \ = phasediff / nsamples\n # freq = self.lpf_freq(freq)\n\n #\
+ \ debugging\n print(f\"Correction for block of {nsamples:2d} samples\
+ \ is \" \\\n f\"sphase={sphase: .4f} rad and freq={freq*1e3: .4f}\
+ \ milli rad / sample\")\n\n # compute block values\n return sphase\
+ \ * np.ones(nsamples) + freq * np.arange(0, nsamples)\n\n def work(self,\
+ \ input_items, output_items):\n # FIXME: replace class counter with local\
+ \ variable\n self.counter = self.nitems_written(0)\n\n # nicer\
+ \ aliases\n inp = input_items[0]\n out = output_items[0]\n\n \
+ \ # read phase tags\n is_phase = lambda tag: pmt.to_python(tag.key)\
\ == \"phase_est\"\n tags = list(filter(is_phase, self.get_tags_in_window(0,\
\ 0, len(inp))))\n\n if not tags:\n print(f\"There were no\
\ tags in {len(inp)} samples!\")\n out[:] = inp\n return\
@@ -606,9 +571,35 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [1088, 1040.0]
+ coordinate: [1208, 912.0]
rotation: 0
state: enabled
+- name: epy_block_1
+ id: epy_block
+ parameters:
+ _source_code: "\"\"\"\nEmbedded Python Blocks:\n\nEach time this file is saved,\
+ \ GRC will instantiate the first class it finds\nto get ports and parameters\
+ \ of your block. The arguments to __init__ will\nbe the parameters. All of\
+ \ them are required to have default values!\n\"\"\"\n\nimport numpy as np\n\
+ from gnuradio import gr\n\nnp.set_printoptions(formatter={'int':hex})\n\nclass\
+ \ blk(gr.sync_block):\n def __init__(self):\n gr.sync_block.__init__(\n\
+ \ self,\n name='Printer',\n in_sig=[np.byte],\n\
+ \ out_sig=[]\n )\n\n def work(self, input_items, output_items):\n\
+ \ inp = np.array(input_items[0], dtype=np.uint8)\n print(f\"Decoded\
+ \ {len(inp)} samples:\\n{inp}\")\n\n return len(inp)\n"
+ affinity: ''
+ alias: ''
+ comment: ''
+ maxoutbuf: '0'
+ minoutbuf: '0'
+ states:
+ _io_cache: ('Printer', 'blk', [], [('0', 'byte', 1)], [], '', [])
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [920, 1264.0]
+ rotation: 0
+ state: true
- name: fir_filter_xxx_1
id: fir_filter_xxx
parameters:
@@ -625,9 +616,22 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [776, 828.0]
+ coordinate: [776, 692.0]
rotation: 0
state: disabled
+- name: import_0
+ id: import
+ parameters:
+ alias: ''
+ comment: ''
+ imports: import numpy as np
+ states:
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [184, 12.0]
+ rotation: 0
+ state: true
- name: qtgui_const_sink_x_0
id: qtgui_const_sink_x
parameters:
@@ -717,7 +721,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [776, 716.0]
+ coordinate: [768, 592.0]
rotation: 0
state: enabled
- name: qtgui_const_sink_x_0_0
@@ -809,7 +813,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [1368, 1092.0]
+ coordinate: [1408, 964.0]
rotation: 0
state: enabled
- name: qtgui_const_sink_x_1
@@ -901,7 +905,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [1048, 612.0]
+ coordinate: [1040, 480.0]
rotation: 0
state: disabled
- name: qtgui_time_sink_x_0
@@ -998,7 +1002,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [1320, 604.0]
+ coordinate: [1312, 480.0]
rotation: 0
state: disabled
- name: qtgui_time_sink_x_0_0
@@ -1057,7 +1061,7 @@ blocks:
name: '""'
nconnections: '1'
size: '1024'
- srate: samp_rate
+ srate: samp_rate / sps
stemplot: 'False'
style1: '1'
style10: '1'
@@ -1095,7 +1099,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [1376, 1284.0]
+ coordinate: [1376, 1152.0]
rotation: 0
state: enabled
- name: qtgui_time_sink_x_0_0_0
@@ -1154,7 +1158,7 @@ blocks:
name: '""'
nconnections: '1'
size: '1024'
- srate: samp_rate
+ srate: samp_rate / sps
stemplot: 'False'
style1: '1'
style10: '1'
@@ -1192,7 +1196,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [1048, 940.0]
+ coordinate: [1072, 788.0]
rotation: 0
state: enabled
- name: qtgui_time_sink_x_1_0
@@ -1289,7 +1293,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [808, 452.0]
+ coordinate: [800, 320.0]
rotation: 0
state: enabled
- name: qtgui_time_sink_x_1_1
@@ -1386,7 +1390,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [776, 612.0]
+ coordinate: [768, 480.0]
rotation: 0
state: disabled
- name: qtgui_time_sink_x_2
@@ -1483,7 +1487,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [1480, 708.0]
+ coordinate: [1488, 580.0]
rotation: 0
state: disabled
- name: qtgui_time_sink_x_2_0
@@ -1580,30 +1584,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [1552, 1364.0]
- rotation: 0
- state: disabled
-- name: root_raised_cosine_filter_0
- id: root_raised_cosine_filter
- parameters:
- affinity: ''
- alias: ''
- alpha: excess_bw
- comment: ''
- decim: '1'
- gain: '2'
- interp: '1'
- maxoutbuf: '0'
- minoutbuf: '0'
- ntaps: 11*samp_rate
- samp_rate: samp_rate
- sym_rate: sps * samp_rate
- type: fir_filter_ccf
- states:
- bus_sink: false
- bus_source: false
- bus_structure: null
- coordinate: [496, 180.0]
+ coordinate: [1552, 1232.0]
rotation: 0
state: disabled
- name: virtual_sink_0
@@ -1616,7 +1597,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [1480, 404.0]
+ coordinate: [1488, 268.0]
rotation: 0
state: enabled
- name: virtual_sink_3
@@ -1629,7 +1610,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [1368, 1036.0]
+ coordinate: [1400, 828.0]
rotation: 0
state: true
- name: virtual_source_0
@@ -1642,7 +1623,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [32, 884.0]
+ coordinate: [16, 748.0]
rotation: 0
state: enabled
- name: virtual_source_1
@@ -1655,7 +1636,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
- coordinate: [24, 1388.0]
+ coordinate: [16, 1260.0]
rotation: 0
state: true
@@ -1668,18 +1649,16 @@ connections:
- [blocks_multiply_const_vxx_0, '0', qtgui_time_sink_x_2, '0']
- [blocks_multiply_const_vxx_0_0, '0', qtgui_time_sink_x_2_0, '0']
- [blocks_null_source_0, '0', blocks_stream_mux_0, '0']
+- [blocks_repack_bits_bb_0, '0', epy_block_1, '0']
- [blocks_stream_mux_0, '0', digital_constellation_modulator_0, '0']
-- [blocks_stream_mux_1, '0', channels_channel_model_0, '0']
- [blocks_throttle_0, '0', virtual_sink_0, '0']
- [blocks_vector_source_x_0, '0', blocks_stream_mux_0, '1']
-- [blocks_vector_source_x_1, '0', root_raised_cosine_filter_0, '0']
- [channels_channel_model_0, '0', blocks_throttle_0, '0']
- [digital_cma_equalizer_cc_0, '0', digital_corr_est_cc_0, '0']
- [digital_cma_equalizer_cc_0, '0', fir_filter_xxx_1, '0']
- [digital_cma_equalizer_cc_0, '0', qtgui_const_sink_x_0, '0']
- [digital_cma_equalizer_cc_0, '0', qtgui_time_sink_x_1_1, '0']
-- [digital_constellation_decoder_cb_0, '0', blocks_vector_sink_x_0, '0']
-- [digital_constellation_modulator_0, '0', blocks_stream_mux_1, '1']
+- [digital_constellation_decoder_cb_0, '0', digital_map_bb_0, '0']
- [digital_constellation_modulator_0, '0', channels_channel_model_0, '0']
- [digital_constellation_modulator_0, '0', qtgui_time_sink_x_1_0, '0']
- [digital_corr_est_cc_0, '0', digital_costas_loop_cc_0, '0']
@@ -1687,12 +1666,12 @@ connections:
- [digital_corr_est_cc_0, '0', qtgui_time_sink_x_0_0_0, '0']
- [digital_corr_est_cc_0, '1', blocks_complex_to_magphase_0_0, '0']
- [digital_costas_loop_cc_0, '0', qtgui_const_sink_x_0_0, '1']
+- [digital_map_bb_0, '0', blocks_repack_bits_bb_0, '0']
- [digital_pfb_clock_sync_xxx_0, '0', digital_cma_equalizer_cc_0, '0']
- [epy_block_0, '0', qtgui_const_sink_x_0_0, '0']
- [epy_block_0, '0', virtual_sink_3, '0']
- [fir_filter_xxx_1, '0', blocks_complex_to_magphase_0, '0']
- [fir_filter_xxx_1, '0', qtgui_const_sink_x_1, '0']
-- [root_raised_cosine_filter_0, '0', blocks_stream_mux_1, '0']
- [virtual_source_0, '0', digital_pfb_clock_sync_xxx_0, '0']
- [virtual_source_1, '0', digital_constellation_decoder_cb_0, '0']
diff --git a/tests/correlator/correlator.py b/tests/correlator/correlator.py
index 50283c0..255010a 100755
--- a/tests/correlator/correlator.py
+++ b/tests/correlator/correlator.py
@@ -35,6 +35,8 @@ from argparse import ArgumentParser
from gnuradio.eng_arg import eng_float, intx
from gnuradio import eng_notation
import epy_block_0
+import epy_block_1
+import numpy as np
from gnuradio import qtgui
@@ -77,13 +79,12 @@ class correlator(gr.top_block, Qt.QWidget):
self.sps = sps = 4
self.nfilts = nfilts = 32
self.excess_bw = excess_bw = .35
- self.timing_loop_bw = timing_loop_bw = 2 * 3.141592653589793 / 100
- self.testvec = testvec = [31, 53] + [0x12, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3]
- self.samp_rate = samp_rate = 32000
+ self.timing_loop_bw = timing_loop_bw = 2 * np.pi / 100
+ self.testvec = testvec = [0x1f, 0x35] + [0x12, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3]
+ self.samp_rate = samp_rate = int(1.5e6)
self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), excess_bw, 45*nfilts)
self.revconj_access_code_symbols = revconj_access_code_symbols = [(1.4142135623730951+1.4142135623730951j), (1.4142135623730951+1.4142135623730951j), (1.4142135623730951-1.4142135623730951j), (-1.4142135623730951+1.4142135623730951j), (1.4142135623730951-1.4142135623730951j), (1.4142135623730951-1.4142135623730951j), (1.4142135623730951+1.4142135623730951j), (-1.4142135623730951+1.4142135623730951j)]
self.const = const = digital.constellation_qpsk().base()
- self.access_code_symbols_sps = access_code_symbols_sps = [(1.4142197+1.4142197j), (1.4142197+1.4142197j), (1.4142197+1.4142197j), (1.4142197+1.4142197j), (1.4142197-1.4142197j), (1.4142197-1.4142197j), (1.4142197-1.4142197j), (1.4142197-1.4142197j), (1.4142197-1.4142197j), (1.4142197-1.4142197j), (1.4142197-1.4142197j), (1.4142197-1.4142197j), (-1.4142197-1.4142197j), (-1.4142197-1.4142197j), (-1.4142197-1.4142197j), (-1.4142197-1.4142197j), (1.4142197-1.4142197j), (1.4142197-1.4142197j), (1.4142197-1.4142197j), (1.4142197-1.4142197j), (1.4142197+1.4142197j), (1.4142197+1.4142197j), (1.4142197+1.4142197j), (1.4142197+1.4142197j), (1.4142197+1.4142197j), (1.4142197+1.4142197j), (1.4142197+1.4142197j), (1.4142197+1.4142197j)]
self.access_code_symbols = access_code_symbols = [(-1.4142135623730951-1.4142135623730951j), (1.4142135623730951-1.4142135623730951j), (1.4142135623730951+1.4142135623730951j), (1.4142135623730951+1.4142135623730951j), (-1.4142135623730951-1.4142135623730951j), (1.4142135623730951+1.4142135623730951j), (1.4142135623730951-1.4142135623730951j), (1.4142135623730951-1.4142135623730951j)]
##################################################
@@ -145,7 +146,7 @@ class correlator(gr.top_block, Qt.QWidget):
self.top_grid_layout.setColumnStretch(c, 1)
self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_c(
1024, #size
- samp_rate, #samp_rate
+ samp_rate / sps, #samp_rate
"", #name
1 #number of inputs
)
@@ -195,7 +196,7 @@ class correlator(gr.top_block, Qt.QWidget):
self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win)
self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
1024, #size
- samp_rate, #samp_rate
+ samp_rate / sps, #samp_rate
"", #name
1 #number of inputs
)
@@ -328,6 +329,7 @@ class correlator(gr.top_block, Qt.QWidget):
self.top_grid_layout.setRowStretch(r, 1)
for c in range(1, 2):
self.top_grid_layout.setColumnStretch(c, 1)
+ self.epy_block_1 = epy_block_1.blk()
self.epy_block_0 = epy_block_0.blk()
self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, rrc_taps, nfilts, 16, 1.5, 1)
self.digital_costas_loop_cc_0 = digital.costas_loop_cc(2 * 3.141592653589793 / 100, 4, False)
@@ -343,16 +345,16 @@ class correlator(gr.top_block, Qt.QWidget):
self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(const)
self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(15, 1, .002, 1)
self.channels_channel_model_0 = channels.channel_model(
- noise_voltage=0.2,
+ noise_voltage=0.01,
frequency_offset=0.0001,
epsilon=1.0,
- taps=[-1.4 + .4j],
+ taps=[np.exp(1j * 30 / 180 * np.pi)],
noise_seed=243,
block_tags=False)
- self.blocks_vector_source_x_0 = blocks.vector_source_b(testvec * 1600, True, 1, [])
- self.blocks_vector_sink_x_0 = blocks.vector_sink_b(1, 1024)
+ self.blocks_vector_source_x_0 = blocks.vector_source_b(testvec * 500, True, 1, [])
self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
- self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_char*1, [10, len(testvec)])
+ self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_char*1, [5, len(testvec)])
+ self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(2, 8, "", False, gr.GR_MSB_FIRST)
self.blocks_null_source_0 = blocks.null_source(gr.sizeof_char*1)
self.blocks_null_sink_3 = blocks.null_sink(gr.sizeof_float*1)
self.blocks_complex_to_magphase_0_0 = blocks.complex_to_magphase(1)
@@ -365,13 +367,14 @@ class correlator(gr.top_block, Qt.QWidget):
self.connect((self.blocks_complex_to_magphase_0_0, 1), (self.blocks_null_sink_3, 0))
self.connect((self.blocks_complex_to_magphase_0_0, 0), (self.qtgui_time_sink_x_0_0, 0))
self.connect((self.blocks_null_source_0, 0), (self.blocks_stream_mux_0, 0))
+ self.connect((self.blocks_repack_bits_bb_0, 0), (self.epy_block_1, 0))
self.connect((self.blocks_stream_mux_0, 0), (self.digital_constellation_modulator_0, 0))
self.connect((self.blocks_throttle_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_mux_0, 1))
self.connect((self.channels_channel_model_0, 0), (self.blocks_throttle_0, 0))
self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_corr_est_cc_0, 0))
self.connect((self.digital_cma_equalizer_cc_0, 0), (self.qtgui_const_sink_x_0, 0))
- self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_vector_sink_x_0, 0))
+ self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_repack_bits_bb_0, 0))
self.connect((self.digital_constellation_modulator_0, 0), (self.channels_channel_model_0, 0))
self.connect((self.digital_constellation_modulator_0, 0), (self.qtgui_time_sink_x_1_0, 0))
self.connect((self.digital_corr_est_cc_0, 1), (self.blocks_complex_to_magphase_0_0, 0))
@@ -395,6 +398,8 @@ class correlator(gr.top_block, Qt.QWidget):
def set_sps(self, sps):
self.sps = sps
self.set_rrc_taps(firdes.root_raised_cosine(self.nfilts, self.nfilts, 1.0/float(self.sps), self.excess_bw, 45*self.nfilts))
+ self.qtgui_time_sink_x_0_0.set_samp_rate(self.samp_rate / self.sps)
+ self.qtgui_time_sink_x_0_0_0.set_samp_rate(self.samp_rate / self.sps)
def get_nfilts(self):
return self.nfilts
@@ -422,7 +427,7 @@ class correlator(gr.top_block, Qt.QWidget):
def set_testvec(self, testvec):
self.testvec = testvec
- self.blocks_vector_source_x_0.set_data(self.testvec * 1600, [])
+ self.blocks_vector_source_x_0.set_data(self.testvec * 500, [])
def get_samp_rate(self):
return self.samp_rate
@@ -430,8 +435,8 @@ class correlator(gr.top_block, Qt.QWidget):
def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.blocks_throttle_0.set_sample_rate(self.samp_rate)
- self.qtgui_time_sink_x_0_0.set_samp_rate(self.samp_rate)
- self.qtgui_time_sink_x_0_0_0.set_samp_rate(self.samp_rate)
+ self.qtgui_time_sink_x_0_0.set_samp_rate(self.samp_rate / self.sps)
+ self.qtgui_time_sink_x_0_0_0.set_samp_rate(self.samp_rate / self.sps)
self.qtgui_time_sink_x_1_0.set_samp_rate(self.samp_rate)
def get_rrc_taps(self):
@@ -453,12 +458,6 @@ class correlator(gr.top_block, Qt.QWidget):
def set_const(self, const):
self.const = const
- def get_access_code_symbols_sps(self):
- return self.access_code_symbols_sps
-
- def set_access_code_symbols_sps(self, access_code_symbols_sps):
- self.access_code_symbols_sps = access_code_symbols_sps
-
def get_access_code_symbols(self):
return self.access_code_symbols
diff --git a/tests/correlator/epy_block_0.py b/tests/correlator/epy_block_0.py
index e7599c9..a581a3a 100644
--- a/tests/correlator/epy_block_0.py
+++ b/tests/correlator/epy_block_0.py
@@ -25,7 +25,7 @@ class blk(gr.sync_block):
# filter to avoid werid jumps in the correction. to do that, there are
# two buffers with an index
self.index = 0
- self.length = 7
+ self.length = 5
self.freq = np.zeros(self.length)
def lpf_freq(self, new_sample):
@@ -46,12 +46,20 @@ class blk(gr.sync_block):
# compute frequency offset between start and end
# and run it through a low pass filter (mean)
- freq = (sphase - ephase) / nsamples
- freq = self.lpf_freq(freq)
+ phasediff = ephase - sphase
+
+ if phasediff > np.pi:
+ phasediff -= 2*np.pi
+
+ elif phasediff < -np.pi:
+ phasediff += 2*np.pi
+
+ freq = phasediff / nsamples
+ # freq = self.lpf_freq(freq)
# debugging
print(f"Correction for block of {nsamples:2d} samples is " \
- f"phase={sphase: .4f} rad and freq={freq*1e3: .4f} milli rad / sample")
+ f"sphase={sphase: .4f} rad and freq={freq*1e3: .4f} milli rad / sample")
# compute block values
return sphase * np.ones(nsamples) + freq * np.arange(0, nsamples)
diff --git a/tests/correlator/epy_block_1.py b/tests/correlator/epy_block_1.py
new file mode 100644
index 0000000..d30c2eb
--- /dev/null
+++ b/tests/correlator/epy_block_1.py
@@ -0,0 +1,27 @@
+"""
+Embedded Python Blocks:
+
+Each time this file is saved, GRC will instantiate the first class it finds
+to get ports and parameters of your block. The arguments to __init__ will
+be the parameters. All of them are required to have default values!
+"""
+
+import numpy as np
+from gnuradio import gr
+
+np.set_printoptions(formatter={'int':hex})
+
+class blk(gr.sync_block):
+ def __init__(self):
+ gr.sync_block.__init__(
+ self,
+ name='Printer',
+ in_sig=[np.byte],
+ out_sig=[]
+ )
+
+ def work(self, input_items, output_items):
+ inp = np.array(input_items[0], dtype=np.uint8)
+ print(f"Decoded {len(inp)} samples:\n{inp}")
+
+ return len(inp)