From ca1ecd9f957fcaab66f24f42483cde3d7f330ce1 Mon Sep 17 00:00:00 2001 From: Glenn Bradford <glenn.bradford@unimelb.edu.au> Date: Sat, 14 May 2022 20:42:07 +1000 Subject: [PATCH] update tx/rx phy blocks, fix time_est bug, add marking delay --- examples/cdc_packet_hw_loopback.grc | 404 ++++++++++++++++-- examples/cdc_packet_loopback.grc | 251 +++++------ examples/packet_phy_rx.grc | 248 +++++------ examples/packet_phy_tx.grc | 69 ++- grc/CMakeLists.txt | 1 - grc/elen90089_corr_est_cc.block.yml | 10 +- include/elen90089/corr_est_cc.h | 26 +- lib/corr_est_cc_impl.cc | 38 +- lib/corr_est_cc_impl.h | 7 +- python/CMakeLists.txt | 1 - python/__init__.py | 1 - python/bindings/corr_est_cc_python.cc | 18 +- .../docstrings/corr_est_cc_pydoc_template.h | 6 + python/packet_phy_tx.py | 142 ------ 14 files changed, 708 insertions(+), 514 deletions(-) delete mode 100644 python/packet_phy_tx.py diff --git a/examples/cdc_packet_hw_loopback.grc b/examples/cdc_packet_hw_loopback.grc index 44b6d6f..7937e57 100644 --- a/examples/cdc_packet_hw_loopback.grc +++ b/examples/cdc_packet_hw_loopback.grc @@ -45,7 +45,7 @@ blocks: label3: 16QAM label4: '' labels: '[]' - num_opts: '4' + num_opts: '3' option0: '1' option1: '2' option2: '3' @@ -60,7 +60,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [8, 108.0] + coordinate: [952, 12.0] rotation: 0 state: true - name: default_freq @@ -79,7 +79,7 @@ blocks: id: variable parameters: comment: '' - value: '20' + value: '30' states: bus_sink: false bus_source: false @@ -87,12 +87,36 @@ blocks: coordinate: [440, 76.0] rotation: 0 state: enabled +- name: excess_bw + id: variable + parameters: + comment: '' + value: '0.35' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [192, 76.0] + rotation: 0 + state: enabled +- name: pld_data + id: variable + parameters: + comment: '' + value: np.random.randint(0, 256, 20, dtype=np.uint8) + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [72, 244.0] + rotation: 0 + state: enabled - name: rf_freq id: variable_qtgui_range parameters: comment: '' gui_hint: 0, 0, 1, 1 - label: RF Frequency + label: RF Frequency (Hz) min_len: '200' orient: QtCore.Qt.Horizontal rangeType: float @@ -113,7 +137,7 @@ blocks: parameters: comment: '' gui_hint: 1, 1, 1, 1 - label: Rx Gain + label: Rx Gain (dB) min_len: '200' orient: QtCore.Qt.Horizontal rangeType: float @@ -126,7 +150,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [808, 12.0] + coordinate: [832, 12.0] rotation: 0 state: true - name: samp_rate @@ -170,7 +194,7 @@ blocks: parameters: comment: '' gui_hint: 0, 1, 1, 1 - label: Tx Gain + label: Tx Gain (dB) min_len: '200' orient: QtCore.Qt.Horizontal rangeType: float @@ -183,7 +207,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [688, 12.0] + coordinate: [712, 12.0] rotation: 0 state: true - name: bladeRF_sink_0 @@ -226,13 +250,13 @@ blocks: trigger_signal1: J51_1 tsb_tag_name: '"packet_len"' use_dac: 'False' - verbosity: error + verbosity: warning xb200: none states: bus_sink: false bus_source: false bus_structure: null - coordinate: [880, 148.0] + coordinate: [920, 212.0] rotation: 0 state: enabled - name: bladeRF_source_0 @@ -280,16 +304,30 @@ blocks: trigger_signal0: J51_1 trigger_signal1: J51_1 use_dac: 'False' - verbosity: error + verbosity: warning xb200: none states: bus_sink: false bus_source: false bus_structure: null - coordinate: [304, 356.0] + coordinate: [80, 404.0] rotation: 0 state: enabled -- name: blocks_message_strobe_0 +- name: blocks_message_debug_0 + id: blocks_message_debug + parameters: + affinity: '' + alias: '' + comment: '' + en_uvec: 'True' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [656, 640.0] + rotation: 0 + state: true +- name: blocks_message_strobe_0_0 id: blocks_message_strobe parameters: affinity: '' @@ -297,33 +335,31 @@ blocks: comment: '' maxoutbuf: '0' minoutbuf: '0' - msg: pmt.intern("TEST") - period: '250' + msg: pmt.cons(pmt.PMT_NIL, pmt.init_u8vector(len(pld_data), pld_data)) + period: '500' states: bus_sink: false bus_source: false bus_structure: null - coordinate: [592, 172.0] - rotation: 180 + coordinate: [72, 316.0] + rotation: 0 state: true -- name: blocks_random_pdu_0 - id: blocks_random_pdu +- name: digital_meas_evm_cc_0 + id: digital_meas_evm_cc parameters: affinity: '' alias: '' comment: '' - length_modulo: '2' - mask: '0xFF' + cons: digital.constellation_bpsk() maxoutbuf: '0' - maxsize: '16' + meas_type: digital.evm_measurement_t.EVM_PERCENT minoutbuf: '0' - minsize: '16' states: bus_sink: false bus_source: false bus_structure: null - coordinate: [280, 156.0] - rotation: 180 + coordinate: [616, 600.0] + rotation: 0 state: true - name: elen90089_packet_mac_tx_0 id: elen90089_packet_mac_tx @@ -340,26 +376,209 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [312, 260.0] + coordinate: [368, 308.0] rotation: 0 state: true -- name: packet_phy_tx_0 +- name: import_0 + id: import + parameters: + alias: '' + comment: '' + imports: import numpy as np + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [8, 100.0] + rotation: 0 + state: true +- name: packet_phy_rx_0 + id: packet_phy_rx + parameters: + affinity: '' + alias: '' + comment: '' + excess_bw: excess_bw + maxoutbuf: '0' + minoutbuf: '0' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [336, 456.0] + rotation: 0 + state: true +- name: packet_phy_tx_1 id: packet_phy_tx parameters: affinity: '' alias: '' comment: '' - excess_bw: '0.35' + excess_bw: excess_bw maxoutbuf: '0' minoutbuf: '0' - sps: sps states: bus_sink: false bus_source: false bus_structure: null - coordinate: [584, 264.0] + coordinate: [640, 324.0] rotation: 0 - state: enabled + state: true +- name: qtgui_const_sink_x_0 + id: qtgui_const_sink_x + parameters: + affinity: '' + alias: '' + alpha1: '1.0' + alpha10: '1.0' + alpha2: '1.0' + alpha3: '1.0' + alpha4: '1.0' + alpha5: '1.0' + alpha6: '1.0' + alpha7: '1.0' + alpha8: '1.0' + alpha9: '1.0' + autoscale: 'False' + axislabels: 'True' + color1: '"blue"' + color10: '"red"' + color2: '"red"' + color3: '"red"' + color4: '"red"' + color5: '"red"' + color6: '"red"' + color7: '"red"' + color8: '"red"' + color9: '"red"' + comment: '' + grid: 'True' + gui_hint: 4, 1, 1, 1 + label1: Header + label10: '' + label2: Payload + label3: '' + label4: '' + label5: '' + label6: '' + label7: '' + label8: '' + label9: '' + legend: 'True' + marker1: '0' + marker10: '0' + marker2: '0' + marker3: '0' + marker4: '0' + marker5: '0' + marker6: '0' + marker7: '0' + marker8: '0' + marker9: '0' + name: '"Received Symbols"' + nconnections: '2' + size: (64 + 48)//1 + style1: '0' + style10: '0' + style2: '0' + style3: '0' + style4: '0' + style5: '0' + style6: '0' + style7: '0' + style8: '0' + style9: '0' + tr_chan: '0' + tr_level: '0.0' + tr_mode: qtgui.TRIG_MODE_TAG + tr_slope: qtgui.TRIG_SLOPE_POS + tr_tag: '"phase_est"' + type: complex + update_time: '0.10' + width1: '1' + width10: '1' + width2: '1' + width3: '1' + width4: '1' + width5: '1' + width6: '1' + width7: '1' + width8: '1' + width9: '1' + xmax: '2' + xmin: '-2' + ymax: '2' + ymin: '-2' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [616, 516.0] + rotation: 0 + state: true +- name: qtgui_number_sink + id: qtgui_number_sink + parameters: + affinity: '' + alias: '' + autoscale: 'False' + avg: '0.01' + color1: ("black", "black") + color10: ("black", "black") + color2: ("black", "black") + color3: ("black", "black") + color4: ("black", "black") + color5: ("black", "black") + color6: ("black", "black") + color7: ("black", "black") + color8: ("black", "black") + color9: ("black", "black") + comment: '' + factor1: '1' + factor10: '1' + factor2: '1' + factor3: '1' + factor4: '1' + factor5: '1' + factor6: '1' + factor7: '1' + factor8: '1' + factor9: '1' + graph_type: qtgui.NUM_GRAPH_HORIZ + gui_hint: 5, 0, 1, 2 + label1: Header EVM + label10: '' + label2: Payload EVM + label3: '' + label4: '' + label5: '' + label6: '' + label7: '' + label8: '' + label9: '' + max: '100.0' + min: '0' + name: '"Recevier EVM"' + nconnections: '1' + type: float + unit1: '%' + unit10: '' + unit2: '%' + unit3: '' + unit4: '' + unit5: '' + unit6: '' + unit7: '' + unit8: '' + unit9: '' + update_time: '0.10' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [824, 564.0] + rotation: 0 + state: true - name: qtgui_time_sink_x_0 id: qtgui_time_sink_x parameters: @@ -454,8 +673,8 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [880, 388.0] - rotation: 0 + coordinate: [616, 220.0] + rotation: 180 state: enabled - name: qtgui_time_sink_x_0_0 id: qtgui_time_sink_x @@ -512,8 +731,8 @@ blocks: marker9: '-1' name: '"Received Waveform"' nconnections: '1' - size: '1024' - srate: '1' + size: '512' + srate: samp_rate stemplot: 'False' style1: '1' style10: '1' @@ -551,17 +770,120 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [544, 428.0] + coordinate: [336, 596.0] + rotation: 0 + state: enabled +- name: qtgui_time_sink_x_1 + id: qtgui_time_sink_x + parameters: + affinity: '' + alias: '' + alpha1: '1.0' + alpha10: '1.0' + alpha2: '1.0' + alpha3: '1.0' + alpha4: '1.0' + alpha5: '1.0' + alpha6: '1.0' + alpha7: '1.0' + alpha8: '1.0' + alpha9: '1.0' + autoscale: 'False' + axislabels: 'True' + color1: blue + color10: dark blue + color2: red + color3: green + color4: black + color5: cyan + color6: magenta + color7: yellow + color8: dark red + color9: dark green + comment: '' + ctrlpanel: 'False' + entags: 'True' + grid: 'True' + gui_hint: 4, 0, 1, 1 + label1: Signal 1 + label10: Signal 10 + label2: Signal 2 + label3: Signal 3 + label4: Signal 4 + label5: Signal 5 + label6: Signal 6 + label7: Signal 7 + label8: Signal 8 + label9: Signal 9 + legend: 'True' + marker1: '0' + marker10: '-1' + marker2: '-1' + marker3: '-1' + marker4: '-1' + marker5: '-1' + marker6: '-1' + marker7: '-1' + marker8: '-1' + marker9: '-1' + name: '""' + nconnections: '1' + size: '32' + srate: samp_rate + stemplot: 'False' + style1: '1' + style10: '1' + style2: '1' + style3: '1' + style4: '1' + style5: '1' + style6: '1' + style7: '1' + style8: '1' + style9: '1' + tr_chan: '0' + tr_delay: '0' + tr_level: '0.5' + tr_mode: qtgui.TRIG_MODE_NORM + tr_slope: qtgui.TRIG_SLOPE_POS + tr_tag: '"corr_start"' + type: float + update_time: '0.10' + width1: '1' + width10: '1' + width2: '1' + width3: '1' + width4: '1' + width5: '1' + width6: '1' + width7: '1' + width8: '1' + width9: '1' + ylabel: Amplitude + ymax: '1.2' + ymin: '0' + yunit: '""' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [616, 436.0] rotation: 0 state: enabled connections: +- [bladeRF_source_0, '0', packet_phy_rx_0, '0'] - [bladeRF_source_0, '0', qtgui_time_sink_x_0_0, '0'] -- [blocks_message_strobe_0, strobe, blocks_random_pdu_0, generate] -- [blocks_random_pdu_0, pdus, elen90089_packet_mac_tx_0, mac_sdu] -- [elen90089_packet_mac_tx_0, mac_pdu, packet_phy_tx_0, phy_sdu] -- [packet_phy_tx_0, '0', bladeRF_sink_0, '0'] -- [packet_phy_tx_0, '0', qtgui_time_sink_x_0, '0'] +- [blocks_message_strobe_0_0, strobe, elen90089_packet_mac_tx_0, mac_sdu] +- [digital_meas_evm_cc_0, '0', qtgui_number_sink, '0'] +- [elen90089_packet_mac_tx_0, mac_pdu, packet_phy_tx_1, phy_sdu] +- [packet_phy_rx_0, '0', qtgui_time_sink_x_1, '0'] +- [packet_phy_rx_0, '1', digital_meas_evm_cc_0, '0'] +- [packet_phy_rx_0, '1', qtgui_const_sink_x_0, '0'] +- [packet_phy_rx_0, '2', qtgui_const_sink_x_0, '1'] +- [packet_phy_rx_0, phy_sdu, blocks_message_debug_0, print_pdu] +- [packet_phy_tx_1, '0', bladeRF_sink_0, '0'] +- [packet_phy_tx_1, '0', qtgui_time_sink_x_0, '0'] metadata: file_format: 1 diff --git a/examples/cdc_packet_loopback.grc b/examples/cdc_packet_loopback.grc index 8cd127e..c6f12ae 100644 --- a/examples/cdc_packet_loopback.grc +++ b/examples/cdc_packet_loopback.grc @@ -22,7 +22,7 @@ options: run_options: prompt sizing_mode: fixed thread_safe_setters: '' - title: Transmit + title: CDC Loopback window_size: (1000,1000) states: bus_sink: false @@ -54,13 +54,13 @@ blocks: options: '[0, 1, 2]' orient: Qt.QVBoxLayout type: int - value: '1' + value: '2' widget: combo_box states: bus_sink: false bus_source: false bus_structure: null - coordinate: [1088, 12.0] + coordinate: [1120, 12.0] rotation: 0 state: true - name: chan_gain @@ -81,7 +81,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [832, 12.0] + coordinate: [840, 12.0] rotation: 0 state: true - name: chan_phase @@ -96,13 +96,13 @@ blocks: start: -np.pi step: 2*np.pi/100 stop: np.pi - value: '0.0' + value: np.pi/4 widget: counter_slider states: bus_sink: false bus_source: false bus_structure: null - coordinate: [960, 12.0] + coordinate: [968, 12.0] rotation: 0 state: true - name: excess_bw @@ -135,7 +135,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [568, 12.0] + coordinate: [576, 12.0] rotation: 0 state: true - name: pld_data @@ -147,7 +147,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [48, 172.0] + coordinate: [64, 172.0] rotation: 0 state: enabled - name: samp_rate @@ -180,7 +180,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [448, 12.0] + coordinate: [456, 12.0] rotation: 0 state: true - name: sps @@ -225,7 +225,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [712, 12.0] + coordinate: [720, 12.0] rotation: 0 state: true - name: blocks_message_debug_0 @@ -239,7 +239,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [832, 520.0] + coordinate: [792, 584.0] rotation: 0 state: enabled - name: blocks_message_strobe_0 @@ -251,12 +251,12 @@ blocks: maxoutbuf: '0' minoutbuf: '0' msg: pmt.cons(pmt.PMT_NIL, pmt.init_u8vector(len(pld_data), pld_data)) - period: '1000' + period: '500' states: bus_sink: false bus_source: false bus_structure: null - coordinate: [48, 236.0] + coordinate: [64, 236.0] rotation: 0 state: true - name: blocks_throttle_0 @@ -275,7 +275,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [800, 244.0] + coordinate: [808, 244.0] rotation: 0 state: true - name: channels_channel_model_0 @@ -296,7 +296,24 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [272, 444.0] + coordinate: [280, 404.0] + rotation: 0 + state: true +- name: digital_meas_evm_cc_0 + id: digital_meas_evm_cc + parameters: + affinity: '' + alias: '' + comment: '' + cons: digital.constellation_bpsk() + maxoutbuf: '0' + meas_type: digital.evm_measurement_t.EVM_PERCENT + minoutbuf: '0' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [776, 544.0] rotation: 0 state: true - name: elen90089_packet_mac_tx_0 @@ -314,7 +331,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [344, 228.0] + coordinate: [352, 228.0] rotation: 0 state: true - name: import_0 @@ -339,14 +356,13 @@ blocks: excess_bw: excess_bw maxoutbuf: '0' minoutbuf: '0' - sps: sps states: bus_sink: false bus_source: false bus_structure: null - coordinate: [472, 384.0] + coordinate: [512, 392.0] rotation: 0 - state: enabled + state: true - name: packet_phy_tx_0 id: packet_phy_tx parameters: @@ -356,16 +372,11 @@ blocks: excess_bw: excess_bw maxoutbuf: '0' minoutbuf: '0' - show_burst: 'False' - show_header: 'False' - show_postcrc: 'False' - show_symbols: 'False' - sps: sps states: bus_sink: false bus_source: false bus_structure: null - coordinate: [616, 236.0] + coordinate: [616, 244.0] rotation: 0 state: true - name: qtgui_const_sink_x_0 @@ -396,8 +407,8 @@ blocks: color8: '"red"' color9: '"red"' comment: '' - grid: 'False' - gui_hint: 5, 0, 1, 1 + grid: 'True' + gui_hint: 4, 1, 1, 1 label1: '' label10: '' label2: '' @@ -419,9 +430,9 @@ blocks: marker7: '0' marker8: '0' marker9: '0' - name: '"Timing Recovery"' - nconnections: '1' - size: '256' + name: '"Rx Symbols"' + nconnections: '2' + size: '112' style1: '0' style10: '0' style2: '0' @@ -434,9 +445,9 @@ blocks: style9: '0' tr_chan: '0' tr_level: '0.0' - tr_mode: qtgui.TRIG_MODE_FREE + tr_mode: qtgui.TRIG_MODE_TAG tr_slope: qtgui.TRIG_SLOPE_POS - tr_tag: '""' + tr_tag: '"corr_est"' type: complex update_time: '0.10' width1: '1' @@ -449,50 +460,50 @@ blocks: width7: '1' width8: '1' width9: '1' - xmax: '2' - xmin: '-2' - ymax: '2' - ymin: '-2' + xmax: '1.5' + xmin: '-1.5' + ymax: '1.5' + ymin: '-1.5' states: bus_sink: false bus_source: false bus_structure: null - coordinate: [776, 364.0] + coordinate: [776, 460.0] rotation: 0 - state: true -- name: qtgui_const_sink_x_0_1 - id: qtgui_const_sink_x + state: enabled +- name: qtgui_number_sink_0 + id: qtgui_number_sink parameters: affinity: '' alias: '' - alpha1: '1.0' - alpha10: '1.0' - alpha2: '1.0' - alpha3: '1.0' - alpha4: '1.0' - alpha5: '1.0' - alpha6: '1.0' - alpha7: '1.0' - alpha8: '1.0' - alpha9: '1.0' autoscale: 'False' - axislabels: 'True' - color1: '"blue"' - color10: '"red"' - color2: '"red"' - color3: '"red"' - color4: '"red"' - color5: '"red"' - color6: '"red"' - color7: '"red"' - color8: '"red"' - color9: '"red"' + avg: '0.01' + color1: ("black", "black") + color10: ("black", "black") + color2: ("black", "black") + color3: ("black", "black") + color4: ("black", "black") + color5: ("black", "black") + color6: ("black", "black") + color7: ("black", "black") + color8: ("black", "black") + color9: ("black", "black") comment: '' - grid: 'False' - gui_hint: 5, 1, 1, 1 - label1: Header + factor1: '1' + factor10: '1' + factor2: '1' + factor3: '1' + factor4: '1' + factor5: '1' + factor6: '1' + factor7: '1' + factor8: '1' + factor9: '1' + graph_type: qtgui.NUM_GRAPH_HORIZ + gui_hint: 5, 0, 1, 2 + label1: Header EVM label10: '' - label2: Payload + label2: Payload EVM label3: '' label4: '' label5: '' @@ -500,58 +511,29 @@ blocks: label7: '' label8: '' label9: '' - legend: 'True' - marker1: '0' - marker10: '0' - marker2: '0' - marker3: '0' - marker4: '0' - marker5: '0' - marker6: '0' - marker7: '0' - marker8: '0' - marker9: '0' - name: '"Rx Symbols"' - nconnections: '2' - size: '256' - style1: '0' - style10: '0' - style2: '0' - style3: '0' - style4: '0' - style5: '0' - style6: '0' - style7: '0' - style8: '0' - style9: '0' - tr_chan: '0' - tr_level: '0.0' - tr_mode: qtgui.TRIG_MODE_FREE - tr_slope: qtgui.TRIG_SLOPE_POS - tr_tag: '""' - type: complex + max: '100.0' + min: '0' + name: '"Recevier EVM"' + nconnections: '1' + type: float + unit1: '%' + unit10: '' + unit2: '%' + unit3: '' + unit4: '' + unit5: '' + unit6: '' + unit7: '' + unit8: '' + unit9: '' update_time: '0.10' - width1: '1' - width10: '1' - width2: '1' - width3: '1' - width4: '1' - width5: '1' - width6: '1' - width7: '1' - width8: '1' - width9: '1' - xmax: '2' - xmin: '-2' - ymax: '2' - ymin: '-2' states: bus_sink: false bus_source: false bus_structure: null - coordinate: [776, 444.0] + coordinate: [976, 508.0] rotation: 0 - state: enabled + state: true - name: qtgui_time_sink_x_0 id: qtgui_time_sink_x parameters: @@ -582,7 +564,7 @@ blocks: comment: '' ctrlpanel: 'False' entags: 'True' - grid: 'False' + grid: 'True' gui_hint: 3, 0, 1, 2 label1: In-phase label10: Signal 10 @@ -607,7 +589,7 @@ blocks: marker9: '-1' name: '"Tx Waveform"' nconnections: '1' - size: '1024' + size: '512' srate: samp_rate stemplot: 'False' style1: '1' @@ -639,14 +621,14 @@ blocks: width8: '1' width9: '1' ylabel: Amplitude - ymax: '2' - ymin: '-2' + ymax: '1' + ymin: '-1' yunit: '""' states: bus_sink: false bus_source: false bus_structure: null - coordinate: [992, 292.0] + coordinate: [1016, 292.0] rotation: 0 state: enabled - name: qtgui_time_sink_x_1 @@ -679,8 +661,8 @@ blocks: comment: '' ctrlpanel: 'False' entags: 'True' - grid: 'False' - gui_hint: 4, 0, 1, 2 + grid: 'True' + gui_hint: 4, 0, 1, 1 label1: Signal 1 label10: Signal 10 label2: Signal 2 @@ -692,7 +674,7 @@ blocks: label8: Signal 8 label9: Signal 9 legend: 'True' - marker1: '-1' + marker1: '0' marker10: '-1' marker2: '-1' marker3: '-1' @@ -702,9 +684,9 @@ blocks: marker7: '-1' marker8: '-1' marker9: '-1' - name: '"Correlation"' + name: '"Training Sequence Correlation"' nconnections: '1' - size: '512' + size: '32' srate: '1' stemplot: 'False' style1: '1' @@ -719,10 +701,10 @@ blocks: style9: '1' tr_chan: '0' tr_delay: '0' - tr_level: '0.2' - tr_mode: qtgui.TRIG_MODE_TAG + tr_level: '0.5' + tr_mode: qtgui.TRIG_MODE_NORM tr_slope: qtgui.TRIG_SLOPE_POS - tr_tag: '"corr_start"' + tr_tag: '' type: float update_time: '0.10' width1: '1' @@ -735,15 +717,15 @@ blocks: width7: '1' width8: '1' width9: '1' - ylabel: Squared Magnitude - ymax: '1.5' + ylabel: Mag Squared + ymax: '1.2' ymin: '0' yunit: '""' states: bus_sink: false bus_source: false bus_structure: null - coordinate: [808, 620.0] + coordinate: [776, 364.0] rotation: 0 state: enabled - name: virtual_sink_0 @@ -756,9 +738,9 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [992, 244.0] + coordinate: [1016, 244.0] rotation: 0 - state: true + state: enabled - name: virtual_source_0 id: virtual_source parameters: @@ -769,7 +751,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [56, 476.0] + coordinate: [64, 436.0] rotation: 0 state: true @@ -778,11 +760,12 @@ connections: - [blocks_throttle_0, '0', qtgui_time_sink_x_0, '0'] - [blocks_throttle_0, '0', virtual_sink_0, '0'] - [channels_channel_model_0, '0', packet_phy_rx_0, '0'] +- [digital_meas_evm_cc_0, '0', qtgui_number_sink_0, '0'] - [elen90089_packet_mac_tx_0, mac_pdu, packet_phy_tx_0, phy_sdu] -- [packet_phy_rx_0, '0', qtgui_const_sink_x_0, '0'] -- [packet_phy_rx_0, '2', qtgui_const_sink_x_0_1, '0'] -- [packet_phy_rx_0, '3', qtgui_const_sink_x_0_1, '1'] -- [packet_phy_rx_0, '4', qtgui_time_sink_x_1, '0'] +- [packet_phy_rx_0, '0', qtgui_time_sink_x_1, '0'] +- [packet_phy_rx_0, '1', digital_meas_evm_cc_0, '0'] +- [packet_phy_rx_0, '1', qtgui_const_sink_x_0, '0'] +- [packet_phy_rx_0, '2', qtgui_const_sink_x_0, '1'] - [packet_phy_rx_0, phy_sdu, blocks_message_debug_0, print_pdu] - [packet_phy_tx_0, '0', blocks_throttle_0, '0'] - [virtual_source_0, '0', channels_channel_model_0, '0'] diff --git a/examples/packet_phy_rx.grc b/examples/packet_phy_rx.grc index 96fe171..8167ea3 100644 --- a/examples/packet_phy_rx.grc +++ b/examples/packet_phy_rx.grc @@ -49,7 +49,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [632, 12.0] + coordinate: [560, 12.0] rotation: 0 state: true - name: hdr_format @@ -64,7 +64,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [448, 12.0] + coordinate: [376, 12.0] rotation: 0 state: true - name: nfilts @@ -76,7 +76,19 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [288, 356.0] + coordinate: [768, 332.0] + rotation: 0 + state: enabled +- name: nsymbols + id: variable + parameters: + comment: '' + value: '11' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [768, 396.0] rotation: 0 state: enabled - name: pld_decoder @@ -92,7 +104,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [728, 676.0] + coordinate: [784, 620.0] rotation: 0 state: enabled - name: rrc_taps @@ -101,28 +113,43 @@ blocks: alpha: excess_bw comment: '' gain: nfilts - ntaps: 11*sps*nfilts + ntaps: nsymbols*sps*nfilts samp_rate: sps*nfilts sym_rate: '1.0' states: bus_sink: false bus_source: false bus_structure: null - coordinate: [152, 356.0] + coordinate: [632, 332.0] rotation: 0 state: enabled -- name: training_seq +- name: sps id: variable parameters: comment: '' - value: '[(2.0*int(x) - 1.0) for x in digital.packet_utils.default_access_code]' + value: '2' states: bus_sink: false bus_source: false bus_structure: null - coordinate: [544, 116.0] + coordinate: [192, 12.0] rotation: 0 state: true +- name: training_seq + id: variable_modulate_vector + parameters: + comment: '' + data: '[0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc] + [0x00, ]*2' + mod: digital.generic_mod(hdr_const, False, sps, False, excess_bw, False, False, + True) + taps: '[1]' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [168, 348.0] + rotation: 0 + state: enabled - name: blocks_multiply_by_tag_value_cc_0 id: blocks_multiply_by_tag_value_cc parameters: @@ -137,7 +164,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [760, 164.0] + coordinate: [408, 204.0] rotation: 0 state: true - name: blocks_tagged_stream_to_pdu_1 @@ -154,7 +181,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [472, 620.0] + coordinate: [528, 564.0] rotation: 0 state: enabled - name: blocks_unpack_k_bits_bb_0 @@ -170,9 +197,9 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [448, 524.0] + coordinate: [528, 492.0] rotation: 0 - state: true + state: enabled - name: digital_constellation_decoder_cb_0 id: digital_constellation_decoder_cb parameters: @@ -186,9 +213,9 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [208, 524.0] + coordinate: [288, 492.0] rotation: 0 - state: true + state: enabled - name: digital_crc32_async_bb_0 id: digital_crc32_async_bb parameters: @@ -202,7 +229,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [992, 620.0] + coordinate: [1024, 564.0] rotation: 0 state: enabled - name: digital_header_payload_demux_0 @@ -221,16 +248,16 @@ blocks: output_symbols: 'True' samp_rate: '1' special_tags: '[]' - timing_tag_key: '"rx_time"' - trigger_tag_key: '"corr_start"' + timing_tag_key: '""' + trigger_tag_key: '"time_est"' type: complex states: bus_sink: false bus_source: false bus_structure: null - coordinate: [1056, 140.0] + coordinate: [1088, 132.0] rotation: 0 - state: true + state: enabled - name: digital_protocol_parser_b_0 id: digital_protocol_parser_b parameters: @@ -244,9 +271,9 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [616, 524.0] + coordinate: [688, 492.0] rotation: 0 - state: true + state: enabled - name: digital_symbol_sync_xx_0 id: digital_symbol_sync_xx parameters: @@ -255,7 +282,7 @@ blocks: comment: '' constellation: digital.constellation_bpsk().base() damping: '1.0' - loop_bw: '0.0157' + loop_bw: 6.28/400.0 max_dev: '1.5' maxoutbuf: '0' minoutbuf: '0' @@ -271,9 +298,9 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [152, 164.0] + coordinate: [632, 140.0] rotation: 0 - state: enabled + state: true - name: elen90089_constellation_decoder_cf_0 id: elen90089_constellation_decoder_cf parameters: @@ -289,7 +316,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [208, 604.0] + coordinate: [288, 548.0] rotation: 0 state: enabled - name: elen90089_corr_est_cc_0 @@ -297,16 +324,18 @@ blocks: parameters: affinity: '' alias: '' - comment: '' + comment: "Search for modulated training \nsequence. Note mark delay \naccounts\ + \ for RRC filtering \ndelay in symbol sync block" + mark_delay: '3' maxoutbuf: '0' minoutbuf: '0' - sequence: training_seq + sequence: training_seq[:64*sps] threshold: '0.7' states: bus_sink: false bus_source: false bus_structure: null - coordinate: [544, 176.0] + coordinate: [168, 212.0] rotation: 0 state: true - name: elen90089_costas_loop_cc_0 @@ -324,9 +353,9 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [1464, 96.0] + coordinate: [1488, 80.0] rotation: 0 - state: true + state: enabled - name: elen90089_costas_loop_cc_0_0 id: elen90089_costas_loop_cc parameters: @@ -335,16 +364,16 @@ blocks: comment: '' maxoutbuf: '0' minoutbuf: '0' - order: '2' + order: hdr_const.arity() use_snr: 'False' w: 6.28/200.0 states: bus_sink: false bus_source: false bus_structure: null - coordinate: [1464, 232.0] + coordinate: [1488, 224.0] rotation: 0 - state: true + state: enabled - name: excess_bw id: parameter parameters: @@ -359,7 +388,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [336, 12.0] + coordinate: [264, 12.0] rotation: 0 state: true - name: fec_async_decoder_0 @@ -378,22 +407,9 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [728, 612.0] + coordinate: [784, 556.0] rotation: 0 state: enabled -- name: import_0 - id: import - parameters: - alias: '' - comment: '' - imports: from gnuradio import fec - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [8, 116.0] - rotation: 0 - state: true - name: pad_sink_0 id: pad_sink parameters: @@ -409,16 +425,16 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [360, 116.0] + coordinate: [840, 92.0] rotation: 180 - state: enabled + state: disabled - name: pad_sink_0_0 id: pad_sink parameters: affinity: '' alias: '' comment: '' - label: chan_est + label: equal num_streams: '1' optional: 'True' type: complex @@ -427,34 +443,34 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [808, 116.0] + coordinate: [472, 156.0] rotation: 180 - state: enabled -- name: pad_sink_0_0_0 + state: disabled +- name: pad_sink_0_1 id: pad_sink parameters: affinity: '' alias: '' comment: '' - label: sym_hdr + label: corr num_streams: '1' optional: 'True' - type: complex + type: float vlen: '1' states: bus_sink: false bus_source: false bus_structure: null - coordinate: [1728, 44.0] + coordinate: [408, 268.0] rotation: 0 state: enabled -- name: pad_sink_0_0_0_0 +- name: pad_sink_0_2 id: pad_sink parameters: affinity: '' alias: '' comment: '' - label: sym_pld + label: sym_hdr num_streams: '1' optional: 'True' type: complex @@ -463,34 +479,34 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [1728, 180.0] + coordinate: [1760, 28.0] rotation: 0 state: enabled -- name: pad_sink_1 +- name: pad_sink_0_2_0 id: pad_sink parameters: affinity: '' alias: '' comment: '' - label: header_data + label: sym_pld num_streams: '1' optional: 'True' - type: message + type: complex vlen: '1' states: bus_sink: false bus_source: false bus_structure: null - coordinate: [888, 476.0] + coordinate: [1760, 172.0] rotation: 0 - state: true -- name: pad_sink_2 + state: enabled +- name: pad_sink_1 id: pad_sink parameters: affinity: '' alias: '' comment: '' - label: phy_sdu + label: header num_streams: '1' optional: 'True' type: message @@ -499,26 +515,26 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [1184, 620.0] + coordinate: [968, 492.0] rotation: 0 - state: enabled -- name: pad_sink_7 + state: disabled +- name: pad_sink_2 id: pad_sink parameters: affinity: '' alias: '' comment: '' - label: corr + label: phy_sdu num_streams: '1' optional: 'True' - type: float + type: message vlen: '1' states: bus_sink: false bus_source: false bus_structure: null - coordinate: [608, 244.0] - rotation: 180 + coordinate: [1200, 564.0] + rotation: 0 state: enabled - name: pad_source_0 id: pad_source @@ -537,27 +553,10 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [8, 236.0] - rotation: 0 - state: true -- name: sps - id: parameter - parameters: - alias: '' - comment: '' - hide: none - label: Samps per Symb - short_id: '' - type: intx - value: '2' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [192, 12.0] + coordinate: [16, 228.0] rotation: 0 state: true -- name: virtual_sink_1 +- name: virtual_sink_0 id: virtual_sink parameters: alias: '' @@ -567,10 +566,10 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [1728, 92.0] + coordinate: [1760, 76.0] rotation: 0 state: true -- name: virtual_sink_1_0 +- name: virtual_sink_0_0 id: virtual_sink parameters: alias: '' @@ -580,22 +579,9 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [1728, 228.0] - rotation: 0 - state: true -- name: virtual_sink_2 - id: virtual_sink - parameters: - alias: '' - comment: '' - stream_id: header_data - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [888, 524.0] + coordinate: [1760, 220.0] rotation: 0 - state: true + state: enabled - name: virtual_source_0 id: virtual_source parameters: @@ -606,9 +592,9 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [16, 524.0] + coordinate: [96, 492.0] rotation: 0 - state: true + state: enabled - name: virtual_source_0_0 id: virtual_source parameters: @@ -619,25 +605,12 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [16, 620.0] - rotation: 0 - state: true -- name: virtual_source_1 - id: virtual_source - parameters: - alias: '' - comment: '' - stream_id: header_data - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [768, 236.0] + coordinate: [96, 564.0] rotation: 0 - state: true + state: enabled connections: -- [blocks_multiply_by_tag_value_cc_0, '0', digital_header_payload_demux_0, '0'] +- [blocks_multiply_by_tag_value_cc_0, '0', digital_symbol_sync_xx_0, '0'] - [blocks_multiply_by_tag_value_cc_0, '0', pad_sink_0_0, '0'] - [blocks_tagged_stream_to_pdu_1, pdus, fec_async_decoder_0, in] - [blocks_unpack_k_bits_bb_0, '0', digital_protocol_parser_b_0, '0'] @@ -645,22 +618,21 @@ connections: - [digital_crc32_async_bb_0, out, pad_sink_2, in] - [digital_header_payload_demux_0, '0', elen90089_costas_loop_cc_0, '0'] - [digital_header_payload_demux_0, '1', elen90089_costas_loop_cc_0_0, '0'] +- [digital_protocol_parser_b_0, info, digital_header_payload_demux_0, header_data] - [digital_protocol_parser_b_0, info, pad_sink_1, in] -- [digital_protocol_parser_b_0, info, virtual_sink_2, '0'] -- [digital_symbol_sync_xx_0, '0', elen90089_corr_est_cc_0, '0'] +- [digital_symbol_sync_xx_0, '0', digital_header_payload_demux_0, '0'] - [digital_symbol_sync_xx_0, '0', pad_sink_0, '0'] - [elen90089_constellation_decoder_cf_0, '0', blocks_tagged_stream_to_pdu_1, '0'] - [elen90089_corr_est_cc_0, '0', blocks_multiply_by_tag_value_cc_0, '0'] -- [elen90089_corr_est_cc_0, '1', pad_sink_7, '0'] -- [elen90089_costas_loop_cc_0, '0', pad_sink_0_0_0, '0'] -- [elen90089_costas_loop_cc_0, '0', virtual_sink_1, '0'] -- [elen90089_costas_loop_cc_0_0, '0', pad_sink_0_0_0_0, '0'] -- [elen90089_costas_loop_cc_0_0, '0', virtual_sink_1_0, '0'] +- [elen90089_corr_est_cc_0, '1', pad_sink_0_1, '0'] +- [elen90089_costas_loop_cc_0, '0', pad_sink_0_2, '0'] +- [elen90089_costas_loop_cc_0, '0', virtual_sink_0, '0'] +- [elen90089_costas_loop_cc_0_0, '0', pad_sink_0_2_0, '0'] +- [elen90089_costas_loop_cc_0_0, '0', virtual_sink_0_0, '0'] - [fec_async_decoder_0, out, digital_crc32_async_bb_0, in] -- [pad_source_0, '0', digital_symbol_sync_xx_0, '0'] +- [pad_source_0, '0', elen90089_corr_est_cc_0, '0'] - [virtual_source_0, '0', digital_constellation_decoder_cb_0, '0'] - [virtual_source_0_0, '0', elen90089_constellation_decoder_cf_0, '0'] -- [virtual_source_1, '0', digital_header_payload_demux_0, header_data] metadata: file_format: 1 diff --git a/examples/packet_phy_tx.grc b/examples/packet_phy_tx.grc index e91a642..9e85b2d 100644 --- a/examples/packet_phy_tx.grc +++ b/examples/packet_phy_tx.grc @@ -11,7 +11,7 @@ options: gen_linking: dynamic generate_options: hb hier_block_src_path: '.:' - id: packet_phy_tx_grc + id: packet_phy_tx max_nouts: '0' output_language: python placement: (0,0) @@ -22,7 +22,7 @@ options: run_options: prompt sizing_mode: fixed thread_safe_setters: '' - title: CDC Packet PHY TX (GRC) + title: CDC Packet PHY TX window_size: (1000,1000) states: bus_sink: false @@ -42,7 +42,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [472, 548.0] + coordinate: [472, 612.0] rotation: 0 state: enabled - name: hdr_encoder @@ -76,7 +76,7 @@ blocks: coordinate: [888, 12.0] rotation: 0 state: disabled -- name: header_format_cdc_0 +- name: header_format_cdc id: header_format_cdc parameters: access_code: digital.packet_utils.default_access_code @@ -100,7 +100,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [400, 548.0] + coordinate: [488, 548.0] rotation: 0 state: enabled - name: rrc_taps @@ -108,7 +108,7 @@ blocks: parameters: alpha: excess_bw comment: '' - gain: nfilts + gain: nfilts / 2.0 ntaps: 5*sps*nfilts samp_rate: nfilts sym_rate: '1.0' @@ -119,6 +119,18 @@ blocks: coordinate: [560, 548.0] rotation: 0 state: enabled +- name: sps + id: variable + parameters: + comment: '' + value: '2' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [192, 12.0] + rotation: 0 + state: true - name: taps_per_filt id: variable parameters: @@ -128,7 +140,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [456, 612.0] + coordinate: [456, 676.0] rotation: 0 state: enabled - name: blocks_tagged_stream_multiply_length_0 @@ -137,7 +149,7 @@ blocks: affinity: '' alias: '' c: sps - comment: '' + comment: Update packet length tag by sps lengthtagname: packet_len maxoutbuf: '0' minoutbuf: '0' @@ -192,8 +204,8 @@ blocks: parameters: affinity: '' alias: '' - comment: Generate cdc header - format: header_format_cdc_0 + comment: Generate CDC header + format: header_format_cdc maxoutbuf: '0' minoutbuf: '0' states: @@ -208,7 +220,11 @@ blocks: parameters: affinity: '' alias: '' - comment: '' + comment: 'Map bits to symbols. + + Constellation configurable + + by setting bps tag on input.' constel_header: CONSTEL_BPSK maxoutbuf: '0' minoutbuf: '0' @@ -234,7 +250,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [336, 12.0] + coordinate: [264, 12.0] rotation: 0 state: enabled - name: fec_async_encoder_0_0 @@ -296,7 +312,7 @@ blocks: bus_structure: null coordinate: [392, 124.0] rotation: 0 - state: enabled + state: disabled - name: pad_sink_1_0 id: pad_sink parameters: @@ -314,7 +330,7 @@ blocks: bus_structure: null coordinate: [712, 116.0] rotation: 0 - state: enabled + state: disabled - name: pad_sink_2 id: pad_sink parameters: @@ -330,9 +346,9 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [1240, 236.0] + coordinate: [1232, 140.0] rotation: 0 - state: enabled + state: disabled - name: pad_sink_3 id: pad_sink parameters: @@ -350,7 +366,7 @@ blocks: bus_structure: null coordinate: [488, 388.0] rotation: 0 - state: enabled + state: disabled - name: pad_source_0 id: pad_source parameters: @@ -392,23 +408,6 @@ blocks: coordinate: [488, 436.0] rotation: 0 state: enabled -- name: sps - id: parameter - parameters: - alias: '' - comment: '' - hide: none - label: Samps per symb - short_id: '' - type: intx - value: '2' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [192, 12.0] - rotation: 0 - state: enabled - name: virtual_sink_0 id: virtual_sink parameters: @@ -419,7 +418,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [1216, 188.0] + coordinate: [1232, 188.0] rotation: 0 state: true - name: virtual_source_0 diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt index 9e8303b..6cc623e 100644 --- a/grc/CMakeLists.txt +++ b/grc/CMakeLists.txt @@ -11,7 +11,6 @@ install(FILES elen90089_moe_symbol_sync_cc.block.yml elen90089_symbol_mapper_c.block.yml elen90089_header_format_cdc.block.yml - elen90089_packet_phy_tx.block.yml elen90089_packet_mac_tx.block.yml elen90089_constellation_decoder_cf.block.yml elen90089_costas_loop_cc.block.yml diff --git a/grc/elen90089_corr_est_cc.block.yml b/grc/elen90089_corr_est_cc.block.yml index 959d145..2dfb9d4 100644 --- a/grc/elen90089_corr_est_cc.block.yml +++ b/grc/elen90089_corr_est_cc.block.yml @@ -4,7 +4,11 @@ category: '[elen90089]' templates: imports: import elen90089 - make: elen90089.corr_est_cc(${sequence}, ${threshold}) + make: elen90089.corr_est_cc(${sequence}, ${threshold}, ${mark_delay}) + callbacks: + - set_sequence(${sequence}) + - set_threshold(${threshold}) + - set_mark_delay(${mark_delay}) parameters: - id: sequence @@ -14,6 +18,10 @@ parameters: label: Threshold default: '0.5' dtype: float +- id: mark_delay + label: Marking Delay + default: 0 + dtype: int inputs: - label: in diff --git a/include/elen90089/corr_est_cc.h b/include/elen90089/corr_est_cc.h index 95870f4..0c3acc7 100644 --- a/include/elen90089/corr_est_cc.h +++ b/include/elen90089/corr_est_cc.h @@ -23,12 +23,18 @@ namespace elen90089 { * \li Stream of complex samples. * * Output: - * \li Output stream of input complex samples delayed by sequence length and - * tagged with correlation start and frequency offset estimate - * \li tag 'corr_start': start sample of identified sequence - * \li tag 'freq_est': estimated frequency offset - * - * \li Optional 2nd output stream providing advanced correlator output + * \li Output stream of input complex samples delayed by sequence length + * \li Optional second output stream providing normalized correlator output + * + * Both output streams are tagged with the following stream tags: + * \li tag 'corr_start': normalized correlation value for peak + * \li tag 'corr_est': normalized correlation value for peak + * \li tag 'chan_est': inverse of LLS channel estimate from training seq + * \li tag 'phase_est': hardcoded to zero (phase offset is handled by chan_est) + * \li tag 'time_est': fractional timing sample offset + * Note: 'corr_start' tag is added at the detected peak and all other tags are + * delayed by mark_delay samples to account for possible group delay of downstream + * matched filter block. */ class ELEN90089_API corr_est_cc : virtual public gr::sync_block { @@ -43,15 +49,21 @@ public: * \param sequence Symbol sequence to correlate agains. * \param threshold Correlation threshold to declare sequence found * (0.0 to 1.0) + * \param mark_delay Tag marking delay to account for possible + * group delay of downstream matched filter */ static sptr make(const std::vector<gr_complex>& sequence, - float threshold=0.5); + float threshold=0.5, + unsigned int mark_delay=0); virtual std::vector<gr_complex> sequence() const = 0; virtual void set_sequence(const std::vector<gr_complex>& sequence) = 0; virtual float threshold() const = 0; virtual void set_threshold(float threshold) = 0; + + virtual unsigned int mark_delay(void) const = 0; + virtual void set_mark_delay(unsigned int mark_delay) = 0; }; } // namespace elen90089 diff --git a/lib/corr_est_cc_impl.cc b/lib/corr_est_cc_impl.cc index d27140e..56fba60 100644 --- a/lib/corr_est_cc_impl.cc +++ b/lib/corr_est_cc_impl.cc @@ -14,19 +14,23 @@ namespace gr { namespace elen90089 { corr_est_cc::sptr corr_est_cc::make(const std::vector<gr_complex>& sequence, - float threshold) + float threshold, + unsigned int mark_delay) { - return gnuradio::make_block_sptr<corr_est_cc_impl>(sequence, threshold); + return gnuradio::make_block_sptr<corr_est_cc_impl>( + sequence, threshold, mark_delay); } corr_est_cc_impl::corr_est_cc_impl(const std::vector<gr_complex>& sequence, - float threshold) + float threshold, + unsigned int mark_delay) : gr::sync_block("corr_est_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make2(1, 2, sizeof(gr_complex), sizeof(float))), d_src_id(pmt::intern(alias())), d_sequence(sequence.size()), d_threshold(threshold), + d_mark_delay(mark_delay), d_filter(1, sequence), d_corr(s_nitems), d_corr_mag(s_nitems), @@ -87,6 +91,17 @@ void corr_est_cc_impl::set_threshold(float threshold) d_threshold = threshold; } +unsigned int corr_est_cc_impl::mark_delay() const +{ + return d_mark_delay; +} + +void corr_est_cc_impl::set_mark_delay(unsigned int mark_delay) +{ + gr::thread::scoped_lock lock(d_setlock); + d_mark_delay = mark_delay; +} + double corr_est_cc_impl::estimate_freq_offset(const gr_complex* samples) { double accum = 0; @@ -158,8 +173,11 @@ int corr_est_cc_impl::work(int noutput_items, chan_est = conj(chan_est) / (chan_est*conj(chan_est)); // time phase estimate - center-of-mass (3 samples) - double nom = corr_mag[i-1] + 2*corr_mag[i] + 3*corr_mag[i+1]; - double den = corr_mag[i-1] + corr_mag[i] + corr_mag[i+1]; + float m1 = corr_mag[i-1]; + float m2 = corr_mag[i+0]; + float m3 = corr_mag[i+1] / (d_y_accum + d_y_mag[hist_len+i+1]); + double nom = m1 + 2*m2 + 3*m3; + double den = m1 + m2 + m3; double time_est = (nom/den) - 2.0; // send frequency correction message @@ -179,15 +197,19 @@ int corr_est_cc_impl::work(int noutput_items, pmt::intern("corr_start"), pmt::from_double(corr_mag[i]), d_src_id); - add_item_tag(ch, offset, + add_item_tag(ch, offset + d_mark_delay, + pmt::intern("corr_est"), + pmt::from_double(corr_mag[i]), + d_src_id); + add_item_tag(ch, offset + d_mark_delay, pmt::intern("chan_est"), pmt::from_complex(chan_est), d_src_id); - add_item_tag(ch, offset, + add_item_tag(ch, offset + d_mark_delay, pmt::intern("phase_est"), // reset Costas Loop pmt::from_double(0.0), d_src_id); - add_item_tag(ch, offset, + add_item_tag(ch, offset + d_mark_delay, pmt::intern("time_est"), pmt::from_double(time_est), d_src_id); diff --git a/lib/corr_est_cc_impl.h b/lib/corr_est_cc_impl.h index 479dac5..2a7d686 100644 --- a/lib/corr_est_cc_impl.h +++ b/lib/corr_est_cc_impl.h @@ -23,6 +23,7 @@ private: std::vector<gr_complex> d_sequence; float d_threshold; + unsigned int d_mark_delay; kernel::fft_filter_ccc d_filter; volk::vector<gr_complex> d_corr; @@ -38,7 +39,8 @@ private: public: corr_est_cc_impl(const std::vector<gr_complex>& sequence, - float threshold = 0.5); + float threshold = 0.5, + unsigned int mark_delay=0); ~corr_est_cc_impl() override; @@ -48,6 +50,9 @@ public: float threshold() const override; void set_threshold(float threshold) override; + unsigned int mark_delay() const override; + void set_mark_delay(unsigned int mark_delay) override; + int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) override; diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index ad25110..469d521 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -22,7 +22,6 @@ add_subdirectory(bindings) GR_PYTHON_INSTALL( FILES __init__.py - packet_phy_tx.py packet_mac_tx.py DESTINATION ${GR_PYTHON_DIR}/elen90089 ) diff --git a/python/__init__.py b/python/__init__.py index f726442..d997af0 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -20,6 +20,5 @@ except ModuleNotFoundError: pass # import any pure python here -from .packet_phy_tx import packet_phy_tx from .packet_mac_tx import packet_mac_tx # diff --git a/python/bindings/corr_est_cc_python.cc b/python/bindings/corr_est_cc_python.cc index e602cce..6bed1f9 100644 --- a/python/bindings/corr_est_cc_python.cc +++ b/python/bindings/corr_est_cc_python.cc @@ -13,8 +13,8 @@ /* If manual edits are made, the following tags should be modified accordingly. */ /* BINDTOOL_GEN_AUTOMATIC(0) */ /* BINDTOOL_USE_PYGCCXML(0) */ -/* BINDTOOL_HEADER_FILE(corr_est_cc.h) */ -/* BINDTOOL_HEADER_FILE_HASH(53737d29a95e3a8c008b00324c083e88) */ +/* BINDTOOL_HEADER_FILE(corr_est_cc.h) */ +/* BINDTOOL_HEADER_FILE_HASH(ac063d9b66211941075ac20b1222f1da) */ /***********************************************************************************/ #include <pybind11/complex.h> @@ -40,6 +40,7 @@ void bind_corr_est_cc(py::module& m) .def(py::init(&corr_est_cc::make), py::arg("sequence"), py::arg("threshold") = 0.5, + py::arg("mark_delay") = 0, D(corr_est_cc, make)) .def("sequence", @@ -56,9 +57,18 @@ void bind_corr_est_cc(py::module& m) D(corr_est_cc, threshold)) .def("set_threshold", - &corr_est_cc::set_threshold, + &corr_est_cc::set_threshold, py::arg("threshold"), - D(corr_est_cc, set_threshold)); + D(corr_est_cc, set_threshold)) + + .def("mark_delay", + &corr_est_cc::mark_delay, + D(corr_est_cc, mark_delay)) + + .def("set_mark_delay", + &corr_est_cc::set_mark_delay, + py::arg("mark_delay"), + D(corr_est_cc, set_mark_delay)); } diff --git a/python/bindings/docstrings/corr_est_cc_pydoc_template.h b/python/bindings/docstrings/corr_est_cc_pydoc_template.h index 94f560f..d36fd1a 100644 --- a/python/bindings/docstrings/corr_est_cc_pydoc_template.h +++ b/python/bindings/docstrings/corr_est_cc_pydoc_template.h @@ -39,4 +39,10 @@ static const char *__doc_gr_elen90089_corr_est_cc_set_threshold = R"doc()doc"; + + static const char *__doc_gr_elen90089_corr_est_cc_mark_delay = R"doc()doc"; + + + static const char *__doc_gr_elen90089_corr_est_cc_set_mark_delay = R"doc()doc"; + diff --git a/python/packet_phy_tx.py b/python/packet_phy_tx.py deleted file mode 100644 index 831abba..0000000 --- a/python/packet_phy_tx.py +++ /dev/null @@ -1,142 +0,0 @@ -# -*- coding: utf-8 -*- - -# -# SPDX-License-Identifier: GPL-3.0 -# -# GNU Radio Python Flow Graph -# Title: CDC Packet PHY TX -# Copyright: University of Melbourne -# GNU Radio version: 3.9.5.0 - -from gnuradio import blocks -from gnuradio import digital -from gnuradio import fec -from gnuradio import gr -from gnuradio.filter import firdes -from gnuradio.fft import window -import sys -import signal -from gnuradio.filter import pfb -import elen90089 - - -class packet_phy_tx(gr.hier_block2): - def __init__(self, excess_bw=0.35, sps=2): - gr.hier_block2.__init__( - self, "CDC Packet PHY TX", - gr.io_signature(0, 0, 0), - gr.io_signature.makev(3, 3, [gr.sizeof_gr_complex*1, - gr.sizeof_gr_complex*1, - gr.sizeof_gr_complex*1]), - ) - self.message_port_register_hier_in("phy_sdu") - self.message_port_register_hier_out("postcrc") - self.message_port_register_hier_out("header") - - ################################################## - # Parameters - ################################################## - self.excess_bw = excess_bw - self.sps = sps - - ################################################## - # Variables - ################################################## - self.nfilts = nfilts = 32 - self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts,1.0, excess_bw, 5*sps*nfilts) - self.taps_per_filt = taps_per_filt = len(rrc_taps)/nfilts - self.header_format_cdc_0 = header_format_cdc_0 = elen90089.header_format_cdc(digital.packet_utils.default_access_code, 3, 1) - self.hdr_encoder = hdr_encoder = fec.dummy_encoder_make(1500) - self.filt_delay = filt_delay = int(1+(taps_per_filt-1)//2) - - ################################################## - # Blocks - ################################################## - self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf( - sps, - taps=rrc_taps, - flt_size=nfilts) - self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(filt_delay) - self.fec_async_encoder_0_0 = fec.async_encoder(hdr_encoder, True, False, False, 1500) - self.elen90089_symbol_mapper_c_0 = elen90089.symbol_mapper_c(elen90089.symbol_mapper_c.constel.CONSTEL_BPSK, 'packet_len') - self.digital_protocol_formatter_async_0 = digital.protocol_formatter_async(header_format_cdc_0) - self.digital_crc32_async_bb_1 = digital.crc32_async_bb(False) - self.digital_burst_shaper_xx_0 = digital.burst_shaper_cc(firdes.window(window.WIN_HANN, 20, 0), 0, filt_delay, True, 'packet_len') - self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, 'packet_len', sps) - - - ################################################## - # Connections - ################################################## - self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.digital_protocol_formatter_async_0, 'in')) - self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self, 'postcrc')) - self.msg_connect((self.digital_protocol_formatter_async_0, 'payload'), (self.elen90089_symbol_mapper_c_0, 'pld')) - self.msg_connect((self.digital_protocol_formatter_async_0, 'header'), (self.fec_async_encoder_0_0, 'in')) - self.msg_connect((self.digital_protocol_formatter_async_0, 'header'), (self, 'header')) - self.msg_connect((self.fec_async_encoder_0_0, 'out'), (self.elen90089_symbol_mapper_c_0, 'hdr')) - self.msg_connect((self, 'phy_sdu'), (self.digital_crc32_async_bb_1, 'in')) - self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self, 0)) - self.connect((self.digital_burst_shaper_xx_0, 0), (self, 2)) - self.connect((self.digital_burst_shaper_xx_0, 0), (self.pfb_arb_resampler_xxx_0_0, 0)) - self.connect((self.elen90089_symbol_mapper_c_0, 0), (self.digital_burst_shaper_xx_0, 0)) - self.connect((self.elen90089_symbol_mapper_c_0, 0), (self, 1)) - self.connect((self.pfb_arb_resampler_xxx_0_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) - - - def get_excess_bw(self): - return self.excess_bw - - def set_excess_bw(self, excess_bw): - self.excess_bw = excess_bw - self.set_rrc_taps(firdes.root_raised_cosine(self.nfilts/2, self.nfilts, 1.0, self.excess_bw, 5*self.sps*self.nfilts)) - - def get_sps(self): - return self.sps - - def set_sps(self, sps): - self.sps = sps - self.set_rrc_taps(firdes.root_raised_cosine(self.nfilts/2, self.nfilts, 1.0, self.excess_bw, 5*self.sps*self.nfilts)) - self.blocks_tagged_stream_multiply_length_0.set_scalar(self.sps) - self.pfb_arb_resampler_xxx_0_0.set_rate(self.sps) - - def get_nfilts(self): - return self.nfilts - - def set_nfilts(self, nfilts): - self.nfilts = nfilts - self.set_rrc_taps(firdes.root_raised_cosine(self.nfilts/2, self.nfilts, 1.0, self.excess_bw, 5*self.sps*self.nfilts)) - self.set_taps_per_filt(len(self.rrc_taps)/self.nfilts) - - def get_rrc_taps(self): - return self.rrc_taps - - def set_rrc_taps(self, rrc_taps): - self.rrc_taps = rrc_taps - self.set_taps_per_filt(len(self.rrc_taps)/self.nfilts) - self.pfb_arb_resampler_xxx_0_0.set_taps(self.rrc_taps) - - def get_taps_per_filt(self): - return self.taps_per_filt - - def set_taps_per_filt(self, taps_per_filt): - self.taps_per_filt = taps_per_filt - self.set_filt_delay(int(1+(self.taps_per_filt-1)//2)) - - def get_header_format_cdc_0(self): - return self.header_format_cdc_0 - - def set_header_format_cdc_0(self, header_format_cdc_0): - self.header_format_cdc_0 = header_format_cdc_0 - - def get_hdr_encoder(self): - return self.hdr_encoder - - def set_hdr_encoder(self, hdr_encoder): - self.hdr_encoder = hdr_encoder - - def get_filt_delay(self): - return self.filt_delay - - def set_filt_delay(self, filt_delay): - self.filt_delay = filt_delay - -- GitLab