From 0cb8ac7bd0e88d6d26c1fda3abcf0977c2e8150b Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Fri, 3 Dec 2021 17:54:07 +0100 Subject: Fix bug that makes jump estimated frequency to unreasonably high values --- tests/correlator/correlator.grc | 285 +++++++++++++++++++--------------------- 1 file changed, 132 insertions(+), 153 deletions(-) (limited to 'tests/correlator/correlator.grc') 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'] -- cgit v1.2.1