From 75edb689e503769dcb1ab228e4a59ea2e0cf8d9e Mon Sep 17 00:00:00 2001 From: sara Date: Tue, 14 Dec 2021 18:57:29 +0100 Subject: BER block angepasst --- flowgraphs/qpsk_hw.grc | 12 +- flowgraphs/qpsk_hw.py | 4 +- flowgraphs/qpsk_sim.grc | 4 +- flowgraphs/qpsk_sim.py | 12 -- notebooks/BER .ipynb | 95 +++++++++- simulation/QAM/lena512color.tiff | Bin 786572 -> 0 bytes simulation/QAM_Fading/qam_fading.py | 7 +- .../QAM_Fading/qam_fading_frequency_selectiv.grc | 207 +++------------------ src/gr-fadingui/grc/fadingui_ber.block.yml | 4 +- src/gr-fadingui/python/ber.py | 34 +++- src/gr-fadingui/python/logger.py | 2 +- 11 files changed, 157 insertions(+), 224 deletions(-) delete mode 100644 simulation/QAM/lena512color.tiff diff --git a/flowgraphs/qpsk_hw.grc b/flowgraphs/qpsk_hw.grc index 2ebc340..a0d6872 100644 --- a/flowgraphs/qpsk_hw.grc +++ b/flowgraphs/qpsk_hw.grc @@ -131,7 +131,7 @@ blocks: id: variable parameters: comment: '' - value: 1e6 + value: 5e5 states: bus_sink: false bus_source: false @@ -361,7 +361,7 @@ blocks: minoutbuf: '0' sps: '1' symbols: access_code_symbols - threshold: '0.85' + threshold: '0.7' threshold_method: digital.THRESHOLD_ABSOLUTE states: bus_sink: false @@ -386,7 +386,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [520, 1100.0] + coordinate: [520, 1084.0] rotation: 0 state: enabled - name: digital_pfb_clock_sync_xxx_0 @@ -424,7 +424,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [1184, 1300.0] + coordinate: [1184, 1292.0] rotation: 0 state: true - name: fadingui_datasource_0 @@ -1000,7 +1000,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [312, 692.0] + coordinate: [336, 684.0] rotation: 0 state: true - name: uhd_usrp_source_0 @@ -1450,7 +1450,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [56, 764.0] + coordinate: [80, 756.0] rotation: 0 state: true diff --git a/flowgraphs/qpsk_hw.py b/flowgraphs/qpsk_hw.py index eb6bf70..9db06a3 100755 --- a/flowgraphs/qpsk_hw.py +++ b/flowgraphs/qpsk_hw.py @@ -81,7 +81,7 @@ class qpsk_hw(gr.top_block, Qt.QWidget): self.sps = sps = 4 self.nfilts = nfilts = 32 self.excess_bw = excess_bw = 0.35 - self.samp_rate = samp_rate = 1e6 + self.samp_rate = samp_rate = 5e5 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), excess_bw, 45*nfilts) self.qpsk_const = qpsk_const = digital.constellation_qpsk().base() self.frame_len = frame_len = len(testvec) +4 @@ -210,7 +210,7 @@ class qpsk_hw(gr.top_block, Qt.QWidget): self.fadingui_ber_0 = fadingui.ber(vgl=testvec + list(np.zeros(4)), vlen=frame_len) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2 * np.pi / 100, rrc_taps, 32, 16, 1.5, 1) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(15, 3e-3, 1, qpsk_const) - self.digital_corr_est_cc_0 = digital.corr_est_cc(access_code_symbols, 1, len(access_code_symbols) // 2, 0.85, digital.THRESHOLD_ABSOLUTE) + self.digital_corr_est_cc_0 = digital.corr_est_cc(access_code_symbols, 1, len(access_code_symbols) // 2, 0.7, digital.THRESHOLD_ABSOLUTE) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk_const, differential=False, diff --git a/flowgraphs/qpsk_sim.grc b/flowgraphs/qpsk_sim.grc index 7be9ec8..a8dd485 100644 --- a/flowgraphs/qpsk_sim.grc +++ b/flowgraphs/qpsk_sim.grc @@ -366,7 +366,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [600, 572.0] + coordinate: [568, 548.0] rotation: 0 state: disabled - name: digital_cma_equalizer_cc_0 @@ -816,7 +816,7 @@ blocks: bus_structure: null coordinate: [1248, 1060.0] rotation: 0 - state: disabled + state: enabled - name: virtual_sink_0 id: virtual_sink parameters: diff --git a/flowgraphs/qpsk_sim.py b/flowgraphs/qpsk_sim.py index b633bba..1e00180 100755 --- a/flowgraphs/qpsk_sim.py +++ b/flowgraphs/qpsk_sim.py @@ -47,11 +47,6 @@ class qpsk_sim(gr.top_block): # Blocks ################################################## self.fadingui_phasecorrection_0 = fadingui.phasecorrection(frame_len) - self.fadingui_netsink_4 = fadingui.netsink(address='udp://localhost:31417', dtype="complex", vlen=1) - self.fadingui_netsink_3 = fadingui.netsink(address='udp://localhost:31419', dtype="complex", vlen=1) - self.fadingui_netsink_1 = fadingui.netsink(address='udp://localhost:31418', dtype="complex", vlen=1) - self.fadingui_netsink_0_0 = fadingui.netsink(address='udp://localhost:31415', dtype="float", vlen=1) - self.fadingui_netsink_0 = fadingui.netsink(address='udp://localhost:31416', dtype="complex", vlen=1) self.fadingui_multipath_fading_0 = fadingui.multipath_fading(amplitudes=[0.12], delays=[1.8], los =True) self.fadingui_ber_0 = fadingui.ber(vgl=testvec + list(np.zeros(4)), vlen=frame_len,address='udp://localhost:31420') self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2 * np.pi / 100, rrc_taps, 32, 16, 1.5, 1) @@ -79,7 +74,6 @@ class qpsk_sim(gr.top_block): self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_char*1, frame_len) self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_char*1, [len(testvec), 4]) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(2, 8, "", False, gr.GR_LSB_FIRST) - self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.analog_random_source_x_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 255, 400))), True) @@ -88,7 +82,6 @@ class qpsk_sim(gr.top_block): # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_mux_0, 1)) - self.connect((self.blocks_complex_to_mag_0, 0), (self.fadingui_netsink_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_stream_mux_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fadingui_ber_0, 0)) @@ -97,17 +90,12 @@ class qpsk_sim(gr.top_block): self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_mux_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.fadingui_multipath_fading_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.fadingui_netsink_1, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_tagged_stream_align_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0)) - self.connect((self.digital_corr_est_cc_0, 1), (self.blocks_complex_to_mag_0, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.fadingui_phasecorrection_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) - self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.fadingui_netsink_4, 0)) self.connect((self.fadingui_multipath_fading_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) - self.connect((self.fadingui_multipath_fading_0, 0), (self.fadingui_netsink_0, 0)) self.connect((self.fadingui_phasecorrection_0, 0), (self.digital_constellation_decoder_cb_0, 0)) - self.connect((self.fadingui_phasecorrection_0, 0), (self.fadingui_netsink_3, 0)) def get_testvec(self): diff --git a/notebooks/BER .ipynb b/notebooks/BER .ipynb index 57675f1..fa70396 100644 --- a/notebooks/BER .ipynb +++ b/notebooks/BER .ipynb @@ -134,7 +134,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 8, "id": "fc4fef77", "metadata": {}, "outputs": [ @@ -144,7 +144,7 @@ "20" ] }, - "execution_count": 12, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -156,7 +156,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 9, "id": "74ae964c", "metadata": {}, "outputs": [ @@ -166,7 +166,7 @@ "array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])" ] }, - "execution_count": 13, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -178,7 +178,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 10, "id": "5a1d95f1", "metadata": {}, "outputs": [ @@ -204,10 +204,93 @@ " print(v)" ] }, + { + "cell_type": "markdown", + "id": "6e96c7bf", + "metadata": {}, + "source": [ + "# Test meister Wert \n" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "90d18368", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Length: 10\n", + "Inp_vector:[31, 53, 18, 227, 155, 238, 132, 35, 65, 243]\n", + "BER 6 in Paket 31\n", + "BER 6 in Paket 53\n", + "BER 4 in Paket 18\n", + "BER 2 in Paket 227\n", + "BER 4 in Paket 155\n", + "BER 12 in Paket 238\n", + "BER 10 in Paket 132\n", + "BER 0 in Paket 35\n", + "BER 6 in Paket 65\n", + "BER 2 in Paket 243\n" + ] + } + ], + "source": [ + "inp = ([31, 53,0x12, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3])\n", + "#inp[1] = ([31, 53,0x12, 0xe5, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3])\n", + "#inp[2] = ([31, 53,0x13, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3])\n", + "\n", + "vgl = ([31, 53] + [0x12, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3])\n", + "\n", + "\n", + "print(f\"Length: {len(inp)}\")\n", + "print(f\"Inp_vector:{inp}\")\n", + " \n", + "for i in inp:\n", + " i = np.array(i, dtype=np.uint8)\n", + " v = np.array(vgl, dtype=np.uint8) ^ i\n", + " ber = sum(np.unpackbits(v))\n", + "\n", + " trueber = ber - 32\n", + " if trueber < 0:\n", + " trueber = 0\n", + " print(f\"BER {trueber} in Paket {i}\")\n", + "\n", + " #print(f\"max BER {np.max(trueber)} in Paket {i}\")\n", + " \n", + " #self.send(self.encode(trueber))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "72ca6e60", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3a891089", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6489bfcc", + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, - "id": "038ceffa", + "id": "fda1e417", "metadata": {}, "outputs": [], "source": [] diff --git a/simulation/QAM/lena512color.tiff b/simulation/QAM/lena512color.tiff deleted file mode 100644 index ffe5c83..0000000 Binary files a/simulation/QAM/lena512color.tiff and /dev/null differ diff --git a/simulation/QAM_Fading/qam_fading.py b/simulation/QAM_Fading/qam_fading.py index 56a3847..cc1bd08 100755 --- a/simulation/QAM_Fading/qam_fading.py +++ b/simulation/QAM_Fading/qam_fading.py @@ -76,7 +76,7 @@ class qam_fading(gr.top_block, Qt.QWidget): ################################################## # Variables ################################################## - self.sps = sps = 2 + self.sps = sps = 4 self.nfilts = nfilts = 32 self.excess_bw = excess_bw = 350e-3 self.timing_loop_bw = timing_loop_bw = 2 * 3.141592653589793 / 100 @@ -91,8 +91,7 @@ class qam_fading(gr.top_block, Qt.QWidget): self.eq_ntaps = eq_ntaps = 15 self.eq_mod = eq_mod = 1 self.eq_gain = eq_gain = .01 - self.const = const = digital.constellation_calcdist([-1-1j, -1+1j, 1+1j, 1-1j], [0, 1, 3, 2], - 4, 1).base() + self.const = const = digital.constellation_qpsk().base() self.chn_taps = chn_taps = [1.0 + 0.0j, ] ################################################## @@ -467,7 +466,7 @@ class qam_fading(gr.top_block, Qt.QWidget): self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(const) self.digital_cma_equalizer_cc_0_0 = digital.cma_equalizer_cc(eq_ntaps, eq_mod, eq_gain, 2) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(eq_ntaps, eq_mod, eq_gain, 2) - self.channels_selective_fading_model_0 = channels.selective_fading_model( 8, ((2*fc*1e9)/(3*10e8))/samp_rate, False, 4, 0, (0,1.8), (1,0.12), 8 ) + self.channels_selective_fading_model_0 = channels.selective_fading_model( 8, ((2*fc*1e9)/(3*10e8))/samp_rate, False, 4, 21, (0,1.8), (1,0.12), 8 ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_volt, frequency_offset=freq_offset, diff --git a/simulation/QAM_Fading/qam_fading_frequency_selectiv.grc b/simulation/QAM_Fading/qam_fading_frequency_selectiv.grc index 02948d2..109a74d 100644 --- a/simulation/QAM_Fading/qam_fading_frequency_selectiv.grc +++ b/simulation/QAM_Fading/qam_fading_frequency_selectiv.grc @@ -54,7 +54,7 @@ blocks: rot_sym: '4' soft_dec_lut: None sym_map: '[0, 1, 3, 2]' - type: calcdist + type: qpsk states: bus_sink: false bus_source: false @@ -127,11 +127,11 @@ blocks: label: fc min_len: '200' orient: Qt.Horizontal - rangeType: int + rangeType: float start: '0' step: '1' - stop: '1000000000' - value: '1' + stop: '10' + value: '2.4' widget: counter_slider states: bus_sink: false @@ -243,7 +243,7 @@ blocks: id: variable parameters: comment: '' - value: '2' + value: '4' states: bus_sink: false bus_source: false @@ -411,28 +411,9 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [464, 324.0] + coordinate: [480, 356.0] rotation: 0 state: enabled -- name: blocks_throttle_0_0 - id: blocks_throttle - parameters: - affinity: '' - alias: '' - comment: '' - ignoretag: 'True' - maxoutbuf: '0' - minoutbuf: '0' - samples_per_second: samp_rate - type: byte - vlen: '1' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [240, 204.0] - rotation: 0 - state: bypassed - name: blocks_unpack_k_bits_bb_0 id: blocks_unpack_k_bits_bb parameters: @@ -522,20 +503,20 @@ blocks: coordinate: [648, 316.0] rotation: 0 state: enabled -- name: channels_selective_fading_model2_0 +- name: channels_selective_fading_model2_1 id: channels_selective_fading_model2 parameters: - K: '5.1' + K: '4.0' LOS: 'False' N: '8' affinity: '' alias: '' comment: '' - delay_maxdev: (0.5,0.7) - delay_std: (1e-4,1e-4) - delays: (0,2e-5/samp_rate) - fDTs: ((4*fc)/(3*10e8))/samp_rate - mags: (1,0.12) + delay_maxdev: (0.5,0.7,0.9) + delay_std: (1e-4,1e-4,1e-4) + delays: (1.0,1.9,2.7) + fDTs: 0.2/samp_rate + mags: (1,0.95,0.8) maxoutbuf: '0' minoutbuf: '0' ntaps: '8' @@ -544,7 +525,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [904, 292.0] + coordinate: [888, 276.0] rotation: 0 state: disabled - name: channels_selective_fading_model_0 @@ -556,18 +537,18 @@ blocks: affinity: '' alias: '' comment: '' - delays: (0,2e-5/samp_rate) - fDTs: ((4*fc)/(3*10e8))/samp_rate + delays: (0,1.8) + fDTs: ((2*fc*1e9)/(3*10e8))/samp_rate mags: (1,0.12) maxoutbuf: '0' minoutbuf: '0' ntaps: '8' - seed: '0' + seed: '21' states: bus_sink: false bus_source: false bus_structure: null - coordinate: [968, 468.0] + coordinate: [976, 404.0] rotation: 0 state: enabled - name: channels_selective_fading_model_2 @@ -684,26 +665,6 @@ blocks: coordinate: [240, 332.0] rotation: 0 state: enabled -- name: digital_constellation_receiver_cb_0 - id: digital_constellation_receiver_cb - parameters: - affinity: '' - alias: '' - comment: '' - constellation: const - fmax: '1' - fmin: '1.5' - loop_bw: timing_loop_bw - maxoutbuf: '0' - minoutbuf: '0' - showports: 'False' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [1376, -64.0] - rotation: 0 - state: disabled - name: digital_costas_loop_cc_0 id: digital_costas_loop_cc parameters: @@ -850,25 +811,6 @@ blocks: coordinate: [1088, 868.0] rotation: 0 state: true -- name: fir_filter_xxx_0 - id: fir_filter_xxx - parameters: - affinity: '' - alias: '' - comment: '' - decim: '1' - maxoutbuf: '0' - minoutbuf: '0' - samp_delay: '0' - taps: rrc_taps - type: ccc - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [488, 212.0] - rotation: 0 - state: bypassed - name: import_0 id: import parameters: @@ -1318,98 +1260,6 @@ blocks: coordinate: [2188.0, 0] rotation: 90 state: enabled -- name: qtgui_const_sink_x_3 - 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: 'False' - gui_hint: '' - label1: '' - label10: '' - label2: '' - 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: '""' - nconnections: '1' - size: '1024' - 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 - 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: [344, 660.0] - rotation: 0 - state: true - name: qtgui_freq_sink_x_0 id: qtgui_freq_sink_x parameters: @@ -1669,30 +1519,28 @@ blocks: state: true connections: -- [analog_random_source_x_0, '0', blocks_throttle_0_0, '0'] - [analog_random_source_x_0, '0', blocks_unpack_k_bits_bb_0_0, '0'] +- [analog_random_source_x_0, '0', digital_constellation_modulator_0, '0'] - [blocks_char_to_float_0, '0', qtgui_freq_sink_x_2_1, '0'] - [blocks_char_to_float_0, '0', qtgui_time_sink_x_0, '0'] - [blocks_char_to_float_0_0, '0', blocks_delay_0, '0'] - [blocks_char_to_float_0_1, '0', qtgui_freq_sink_x_2_1, '1'] - [blocks_char_to_float_0_1, '0', qtgui_time_sink_x_0, '2'] - [blocks_delay_0, '0', qtgui_time_sink_x_0, '1'] -- [blocks_throttle_0, '0', fir_filter_xxx_0, '0'] -- [blocks_throttle_0_0, '0', digital_constellation_modulator_0, '0'] +- [blocks_throttle_0, '0', channels_channel_model_0, '0'] - [blocks_unpack_k_bits_bb_0, '0', blocks_char_to_float_0, '0'] - [blocks_unpack_k_bits_bb_0_0, '0', blocks_char_to_float_0_0, '0'] - [blocks_unpack_k_bits_bb_0_1, '0', blocks_char_to_float_0_1, '0'] - [blocks_vector_source_x_0, '0', digital_constellation_modulator_0, '0'] -- [channels_channel_model_0, '0', channels_selective_fading_model2_0, '0'] +- [channels_channel_model_0, '0', channels_selective_fading_model2_1, '0'] - [channels_channel_model_0, '0', channels_selective_fading_model_0, '0'] - [channels_channel_model_0, '0', channels_selective_fading_model_2, '0'] - [channels_channel_model_0, '0', digital_pfb_clock_sync_xxx_0_0, '0'] - [channels_channel_model_0, '0', qtgui_const_sink_x_0, '1'] - [channels_channel_model_0, '0', qtgui_freq_sink_x_0, '1'] -- [channels_selective_fading_model2_0, '0', digital_pfb_clock_sync_xxx_0, '0'] -- [channels_selective_fading_model2_0, '0', qtgui_const_sink_x_0, '0'] -- [channels_selective_fading_model2_0, '0', qtgui_freq_sink_x_0, '0'] -- [channels_selective_fading_model_0, '0', digital_constellation_receiver_cb_0, '0'] +- [channels_selective_fading_model2_1, '0', digital_pfb_clock_sync_xxx_0, '0'] +- [channels_selective_fading_model2_1, '0', qtgui_const_sink_x_0, '0'] +- [channels_selective_fading_model2_1, '0', qtgui_freq_sink_x_0, '0'] - [channels_selective_fading_model_0, '0', digital_pfb_clock_sync_xxx_0, '0'] - [channels_selective_fading_model_0, '0', qtgui_const_sink_x_0, '0'] - [channels_selective_fading_model_0, '0', qtgui_freq_sink_x_0, '0'] @@ -1706,12 +1554,6 @@ connections: - [digital_constellation_decoder_cb_0, '0', digital_diff_decoder_bb_0, '0'] - [digital_constellation_decoder_cb_0_0, '0', digital_diff_decoder_bb_0_0, '0'] - [digital_constellation_modulator_0, '0', blocks_throttle_0, '0'] -- [digital_constellation_modulator_0, '0', qtgui_const_sink_x_3, '0'] -- [digital_constellation_receiver_cb_0, '0', digital_diff_decoder_bb_0, '0'] -- [digital_constellation_receiver_cb_0, '4', digital_cma_equalizer_cc_0, '0'] -- [digital_constellation_receiver_cb_0, '4', qtgui_const_sink_x_0_0, '0'] -- [digital_constellation_receiver_cb_0, '4', qtgui_const_sink_x_1, '0'] -- [digital_constellation_receiver_cb_0, '4', qtgui_const_sink_x_2, '0'] - [digital_costas_loop_cc_0, '0', digital_constellation_decoder_cb_0, '0'] - [digital_costas_loop_cc_0, '0', qtgui_const_sink_x_2, '0'] - [digital_costas_loop_cc_0_0, '0', digital_constellation_decoder_cb_0_0, '0'] @@ -1724,7 +1566,6 @@ connections: - [digital_pfb_clock_sync_xxx_0, '0', qtgui_const_sink_x_0_0, '0'] - [digital_pfb_clock_sync_xxx_0_0, '0', digital_cma_equalizer_cc_0_0, '0'] - [digital_pfb_clock_sync_xxx_0_0, '0', qtgui_const_sink_x_0_0, '1'] -- [fir_filter_xxx_0, '0', channels_channel_model_0, '0'] metadata: file_format: 1 diff --git a/src/gr-fadingui/grc/fadingui_ber.block.yml b/src/gr-fadingui/grc/fadingui_ber.block.yml index 477f9ff..b0ec75c 100644 --- a/src/gr-fadingui/grc/fadingui_ber.block.yml +++ b/src/gr-fadingui/grc/fadingui_ber.block.yml @@ -5,7 +5,7 @@ category: '[fadingui]' templates: imports: import fadingui make: fadingui.ber(vgl=${vgl}, vlen=${vlen},address=${address}) - + # Make one 'parameters' list entry for every parameter you want settable from the GUI. # Keys include: # * id (makes the value accessible as \$keyname, e.g. in the make entry) @@ -21,7 +21,7 @@ parameters: - id: address label: Address dtype: string - default: "udp://localhost:31415" + default: "udp://localhost:31420" # Make one 'inputs' list entry per input and one 'outputs' list entry per output. diff --git a/src/gr-fadingui/python/ber.py b/src/gr-fadingui/python/ber.py index 205dcd4..1c5debf 100644 --- a/src/gr-fadingui/python/ber.py +++ b/src/gr-fadingui/python/ber.py @@ -23,6 +23,7 @@ import socket from urllib.parse import urlparse import numpy as np +from numpy_ringbuffer import RingBuffer from gnuradio import gr from fadingui.logger import get_logger @@ -42,6 +43,9 @@ class ber(gr.sync_block): self.vgl=vgl self.vlen=vlen + self.ber_samples = RingBuffer(capacity=2000, dtype=int) + self.ber_samples.extend(np.zeros(self.ber_samples.maxlen)) + # Create a socket and parse remote machine url self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.url = urlparse(address) @@ -65,14 +69,23 @@ class ber(gr.sync_block): # FIXME: this could be (very) slow, is there a faster way with numpy? # Maybe numpy.array2string return bytes(str(data) + "\n", "ascii") - + + def ber_stats(self): + ber_max = np.max(self.ber_samples) + ber_min = np.min(self.ber_samples) + ber_avg = np.sum(self.ber_samples) / self.ber_samples.maxlen + + return ber_max, ber_min, ber_avg + def work(self, input_items, output_items): inp = input_items[0] log.debug(f"Length: {len(inp)}") - log.debug(f"Inp_vector:{inp}") + # log.debug(f"Inp_vector:{inp}") + + for i in inp: i = np.array(i, dtype=np.uint8) v = np.array(self.vgl, dtype=np.uint8) ^ i @@ -81,11 +94,20 @@ class ber(gr.sync_block): trueber = ber - 32 if trueber < 0: trueber = 0 - log.debug(f"BER {trueber} in Paket {i}") - - self.send(self.encode(trueber)) + # log.debug(f"BER {trueber} in Paket {i}") + + self.ber_samples.appendleft(trueber) - return len(inp) + ber_max, ber_min, ber_avg = self.ber_stats() + log.debug(f"Statistics: {ber_max}, {ber_min}, {ber_avg}") + + #self.send(self.encode(ber_max, ber_min, ber_avg)) + self.send(self.encode(trueber)) + self.send(self.encode(ber_max)) + self.send(self.encode(ber_min)) + self.send(self.encode(ber_avg)) + + return len(inp) #return len(input_items[0]) diff --git a/src/gr-fadingui/python/logger.py b/src/gr-fadingui/python/logger.py index a101b9e..a189aeb 100644 --- a/src/gr-fadingui/python/logger.py +++ b/src/gr-fadingui/python/logger.py @@ -10,5 +10,5 @@ def get_logger(module): log.addHandler(stdout_handler) stdout_handler.setFormatter(formatter) - log.setLevel(logging.WARNING) + log.setLevel(logging.DEBUG) return log -- cgit v1.2.1