diff options
Diffstat (limited to '')
-rw-r--r-- | notebooks/BER .ipynb | 172 | ||||
-rw-r--r-- | simulation/QAM_Fading/Alte_versionen/qam_fading_FIR_Filter_v1.grc (renamed from simulation/QAM_Fading/qam_fading_FIR_Filter_v1.grc) | 0 | ||||
-rw-r--r-- | simulation/QAM_Fading/Alte_versionen/qam_fading_V2.grc (renamed from simulation/QAM_Fading/qam_fading_V2.grc) | 0 | ||||
-rw-r--r-- | simulation/QAM_Fading/Alte_versionen/qam_fading_V2_mehrere.grc (renamed from simulation/QAM_Fading/qam_fading_V2_mehrere.grc) | 0 | ||||
-rw-r--r-- | simulation/QAM_Fading/Alte_versionen/qam_fading_frequency_selectiv.grc (renamed from simulation/QAM_Fading/qam_fading_frequency_selectiv_copy.grc) | 20 | ||||
-rw-r--r-- | simulation/QAM_Fading/epy_block_0.py | 74 | ||||
-rw-r--r-- | simulation/QAM_Fading/qam_fading_frequency_selectiv.grc | 20 | ||||
-rw-r--r-- | src/gr-fadingui/grc/fadingui_ber.block.yml | 16 | ||||
-rw-r--r-- | src/gr-fadingui/python/ber.py | 29 | ||||
-rwxr-xr-x | src/gr-fadingui/python/qa_ber.py | 13 | ||||
-rw-r--r-- | tests/BER/Bit_error.grc | 66 | ||||
-rwxr-xr-x | tests/BER/Test_Bit_Errorrate.py | 26 |
12 files changed, 257 insertions, 179 deletions
diff --git a/notebooks/BER .ipynb b/notebooks/BER .ipynb index 8e0a6f4..57675f1 100644 --- a/notebooks/BER .ipynb +++ b/notebooks/BER .ipynb @@ -15,47 +15,25 @@ "execution_count": 2, "id": "be1f0d01", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([0, 1])" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "byte1= np.array([0x12, 0xe3, 0x9b])\n", - "byte2 = np.array([0x12, 0xe3, 0x9c])\n", - "b1 = np.array([0,0])\n", - "b2 = np.array([0,1])\n", - "b1\n", - "b2" + "byte2 = np.array([0x12, 0xe3, 0x9c])\n" ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 3, "id": "c256a3d0", "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "[0 0 7]\n" - ] - }, - { "data": { "text/plain": [ - "array([0, 1], dtype=uint8)" + "array([0, 0, 7], dtype=uint8)" ] }, - "execution_count": 6, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -63,41 +41,32 @@ "source": [ "v = byte1^byte2\n", "v1 = np.array (v,dtype = np.uint8)\n", - "print(v1)\n", - "v2 = b1^b2\n", - "v2 = np.array (v2,dtype = np.uint8)\n", - "v2" + "v1" ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 4, "id": "227f0142", - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1]\n" - ] - }, - { "data": { "text/plain": [ - "array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], dtype=uint8)" + "array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,\n", + " 1, 1], dtype=uint8)" ] }, - "execution_count": 7, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "z = np.unpackbits(v1)\n", - "print(z)\n", - "z1 = np.unpackbits(v2)\n", - "z1" + "z" ] }, { @@ -123,26 +92,123 @@ ] }, { - "cell_type": "code", - "execution_count": null, - "id": "0ac2e304", + "cell_type": "markdown", + "id": "1551b295", "metadata": {}, - "outputs": [], - "source": [] + "source": [ + "# TEST Längenanpassung" + ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "id": "034142b6", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "test_byte=np.array([31, 53] + [0x12, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3])\n", + "test_byte\n", + "vlen= 10 " + ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "id": "f203fbce", "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "10" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(test_byte)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "fc4fef77", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "20" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "inp= ([31, 53,0x12, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3]+[30, 53,0x12, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3])\n", + "len(inp)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "74ae964c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "v = test_byte^inp[:vlen]\n", + "v" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "5a1d95f1", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[0 0 0 0 0 0 0 0 0 0]\n", + "[0 0 0 0 0 0 0 0 0 0]\n", + "[0 0 0 0 0 0 0 0 0 0]\n", + "[0 0 0 0 0 0 0 0 0 0]\n", + "[0 0 0 0 0 0 0 0 0 0]\n", + "[0 0 0 0 0 0 0 0 0 0]\n", + "[0 0 0 0 0 0 0 0 0 0]\n", + "[0 0 0 0 0 0 0 0 0 0]\n", + "[0 0 0 0 0 0 0 0 0 0]\n" + ] + } + ], + "source": [ + "for i in range(1,10):\n", + " v = test_byte^inp[:vlen]\n", + " print(v)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "038ceffa", + "metadata": {}, "outputs": [], "source": [] } diff --git a/simulation/QAM_Fading/qam_fading_FIR_Filter_v1.grc b/simulation/QAM_Fading/Alte_versionen/qam_fading_FIR_Filter_v1.grc index ffc47f6..ffc47f6 100644 --- a/simulation/QAM_Fading/qam_fading_FIR_Filter_v1.grc +++ b/simulation/QAM_Fading/Alte_versionen/qam_fading_FIR_Filter_v1.grc diff --git a/simulation/QAM_Fading/qam_fading_V2.grc b/simulation/QAM_Fading/Alte_versionen/qam_fading_V2.grc index 16fa2e3..16fa2e3 100644 --- a/simulation/QAM_Fading/qam_fading_V2.grc +++ b/simulation/QAM_Fading/Alte_versionen/qam_fading_V2.grc diff --git a/simulation/QAM_Fading/qam_fading_V2_mehrere.grc b/simulation/QAM_Fading/Alte_versionen/qam_fading_V2_mehrere.grc index d5444ad..d5444ad 100644 --- a/simulation/QAM_Fading/qam_fading_V2_mehrere.grc +++ b/simulation/QAM_Fading/Alte_versionen/qam_fading_V2_mehrere.grc diff --git a/simulation/QAM_Fading/qam_fading_frequency_selectiv_copy.grc b/simulation/QAM_Fading/Alte_versionen/qam_fading_frequency_selectiv.grc index ce87db8..fc3cebd 100644 --- a/simulation/QAM_Fading/qam_fading_frequency_selectiv_copy.grc +++ b/simulation/QAM_Fading/Alte_versionen/qam_fading_frequency_selectiv.grc @@ -453,24 +453,24 @@ blocks: - name: channels_selective_fading_model_0 id: channels_selective_fading_model parameters: - K: '4' - LOS: 'True' + K: '4.0' + LOS: 'False' N: '8' affinity: '' alias: '' comment: '' - delays: (0,0.3e-6) + delays: (0.0,0.1,1.3) fDTs: '0' - mags: (1,0.39) + mags: (1,0.99,0.97) maxoutbuf: '0' minoutbuf: '0' - ntaps: '3' + ntaps: '4' seed: '0' states: bus_sink: false bus_source: false bus_structure: null - coordinate: [976, 308.0] + coordinate: [944, 316.0] rotation: 0 state: true - name: digital_cma_equalizer_cc_0 @@ -700,7 +700,7 @@ blocks: maxoutbuf: '0' minoutbuf: '0' osps: '1' - sps: 'sps ' + sps: sps * 1.001 taps: rrc_taps type: ccf states: @@ -867,7 +867,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [1036.0, -64] + coordinate: [1044.0, -48] rotation: 90 state: enabled - name: qtgui_const_sink_x_0_0 @@ -1223,7 +1223,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [1080.0, 656] + coordinate: [1024.0, 624] rotation: 270 state: true - name: qtgui_freq_sink_x_2_1 @@ -1305,7 +1305,7 @@ blocks: bus_structure: null coordinate: [2848, 488.0] rotation: 0 - state: disabled + state: true - name: qtgui_time_sink_x_0 id: qtgui_time_sink_x parameters: diff --git a/simulation/QAM_Fading/epy_block_0.py b/simulation/QAM_Fading/epy_block_0.py deleted file mode 100644 index 48fe6e9..0000000 --- a/simulation/QAM_Fading/epy_block_0.py +++ /dev/null @@ -1,74 +0,0 @@ -""" -Embedded Python Blocks: - -Each time this file is saved, GRC will instantiate the first class it finds -to get ports and parameters of your block. The arguments to __init__ will -be the parameters. All of them are required to have default values! -""" - -import numpy as np -from numpy.fft import fft,ifft,fftshift -from gnuradio import gr - - -class blk(gr.sync_block): # other base classes are basic_block, decim_block, interp_block - """Embedded Python Block example - a simple multiply const""" - - def __init__(self, amplitudes=[], delays=[], los=True): # only default arguments here - """arguments to this function show up as parameters in GRC""" - gr.sync_block.__init__( - self, - name='Embedded Python Block', # will show up in GRC - in_sig=[np.complex64], - out_sig=[np.complex64] - ) - # if an attribute with the same name as a parameter is found, - # a callback is registered (properties work, too). - self.amplitudes = amplitudes - self.delays = delays - self.temp = [0] - # if los: - # self.amplitudes.append(1) - # self.delays.append(0) - self.los= 1 - #self.fir = - - def work(self, input_items, output_items): - """example: multiply with constant""" - inp = input_items[0] - oup = output_items[0] - - if len(self.amplitudes) != len(self.delays): - raise Exception("Amplitudes and Delay length dont match") - - # raise Exception("Delay length can't be one") - #if np.min(self.delays)<=1: - # raise Exception("Delay length can't be one") - max_len = np.max(self.delays) - sum_x = np.zeros(max_len) - for(a,d) in zip(self.amplitudes,self.delays): - # if d-1 <= 0: - # x = np.concatenate([[a], np.zeros(max_len-1)]) - # else: - x = np.concatenate([np.zeros(d-1), [a], np.zeros(max_len-d)]) - sum_x += x - - sum_x[0] = self.los - print(sum_x) - - #H_int = fft(sum_x) - - #h = ifft(H_int) - - #h[0]=1 - - y = np.convolve(inp, sum_x) - - y+=np.concatenate([self.temp,np.zeros(len(y)-len(self.temp))]) - - - oup[:] = y[:len(inp)] - self.temp = y[len(inp):] - - - return len(oup)
\ No newline at end of file diff --git a/simulation/QAM_Fading/qam_fading_frequency_selectiv.grc b/simulation/QAM_Fading/qam_fading_frequency_selectiv.grc index fc3cebd..ce87db8 100644 --- a/simulation/QAM_Fading/qam_fading_frequency_selectiv.grc +++ b/simulation/QAM_Fading/qam_fading_frequency_selectiv.grc @@ -453,24 +453,24 @@ blocks: - name: channels_selective_fading_model_0 id: channels_selective_fading_model parameters: - K: '4.0' - LOS: 'False' + K: '4' + LOS: 'True' N: '8' affinity: '' alias: '' comment: '' - delays: (0.0,0.1,1.3) + delays: (0,0.3e-6) fDTs: '0' - mags: (1,0.99,0.97) + mags: (1,0.39) maxoutbuf: '0' minoutbuf: '0' - ntaps: '4' + ntaps: '3' seed: '0' states: bus_sink: false bus_source: false bus_structure: null - coordinate: [944, 316.0] + coordinate: [976, 308.0] rotation: 0 state: true - name: digital_cma_equalizer_cc_0 @@ -700,7 +700,7 @@ blocks: maxoutbuf: '0' minoutbuf: '0' osps: '1' - sps: sps * 1.001 + sps: 'sps ' taps: rrc_taps type: ccf states: @@ -867,7 +867,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [1044.0, -48] + coordinate: [1036.0, -64] rotation: 90 state: enabled - name: qtgui_const_sink_x_0_0 @@ -1223,7 +1223,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [1024.0, 624] + coordinate: [1080.0, 656] rotation: 270 state: true - name: qtgui_freq_sink_x_2_1 @@ -1305,7 +1305,7 @@ blocks: bus_structure: null coordinate: [2848, 488.0] rotation: 0 - state: true + state: disabled - name: qtgui_time_sink_x_0 id: qtgui_time_sink_x parameters: diff --git a/src/gr-fadingui/grc/fadingui_ber.block.yml b/src/gr-fadingui/grc/fadingui_ber.block.yml index 3383df5..3070311 100644 --- a/src/gr-fadingui/grc/fadingui_ber.block.yml +++ b/src/gr-fadingui/grc/fadingui_ber.block.yml @@ -4,7 +4,7 @@ category: '[fadingui]' templates: imports: import fadingui - make: fadingui.ber(vgl=${vgl}) + make: fadingui.ber(vgl=${vgl}, vlen=${vlen}) # Make one 'parameters' list entry for every parameter you want settable from the GUI. # Keys include: @@ -12,12 +12,12 @@ templates: # * label (label shown in the GUI) # * dtype (e.g. int, float, complex, byte, short, xxx_vector, ...) parameters: - - id: vgl - label: Vergleichsparameter - dtype: raw -# - id: ... -# label: ... -# dtype: ... +- id: vgl + label: Vergleichsparameter + dtype: raw +- id: vlen + label: Vec Length + dtype: int # Make one 'inputs' list entry per input and one 'outputs' list entry per output. # Keys include: @@ -30,7 +30,7 @@ inputs: - label: in domain: stream dtype: byte - + vlen: ${vlen} # 'file_format' specifies the version of the GRC yml format used in the file # and should usually not be changed. diff --git a/src/gr-fadingui/python/ber.py b/src/gr-fadingui/python/ber.py index 387b75f..e966f17 100644 --- a/src/gr-fadingui/python/ber.py +++ b/src/gr-fadingui/python/ber.py @@ -30,26 +30,29 @@ class ber(gr.sync_block): """ docstring for block ber """ - def __init__(self, vgl): + def __init__(self, vgl, vlen): gr.sync_block.__init__(self, name="ber", - in_sig=[np.byte, ], + in_sig=[np.dtype(str(vlen) + "b")], out_sig=None) self.vgl=vgl - - + self.vlen=vlen def work(self, input_items, output_items): + inp = input_items[0] - # <+signal processing here+> - - v = self.vgl^inp - v_array= np.array(v,dtype = np.uint8) - - ber = sum(np.unpackbits(v_array)) - - - log.debug(ber) + ber_tot = 0 + log.debug(f"Length: {len(inp)}") + log.debug(f"Inp_vector:{inp}") + + for i in inp: + log.debug(f"In Schlaufe{i}") + v = np.array(self.vgl, dtype=np.uint8)^np.array(i, dtype=np.uint8) + ber = sum(np.unpackbits(v)) + log.debug(f"BER {ber} in Paket {i}") + ber_tot+=ber + log.debug(f"BER Total{ber_tot}") + return len(input_items[0]) diff --git a/src/gr-fadingui/python/qa_ber.py b/src/gr-fadingui/python/qa_ber.py index 8b6d56e..cb6c198 100755 --- a/src/gr-fadingui/python/qa_ber.py +++ b/src/gr-fadingui/python/qa_ber.py @@ -22,6 +22,7 @@ from gnuradio import gr, gr_unittest from gnuradio import blocks from ber import ber +import numpy as np class qa_ber(gr_unittest.TestCase): @@ -32,9 +33,15 @@ class qa_ber(gr_unittest.TestCase): self.tb = None def test_001_t(self): - # set up fg - self.tb.run() - # check data + # pattern = np.array([0xaa], dtype=np.uint8) + # testdata = np.array([0xc0, 0xfa, 0xae] * 4, dtype=np.uint8) + + # src = blocks.vector_source_b(testdata) + # op = ber(pattern) + + # self.tb.connect(src, op) + # self.tb.run() + pass if __name__ == '__main__': diff --git a/tests/BER/Bit_error.grc b/tests/BER/Bit_error.grc index 04c624b..1a1a891 100644 --- a/tests/BER/Bit_error.grc +++ b/tests/BER/Bit_error.grc @@ -56,6 +56,49 @@ blocks: coordinate: [216, 396.0] rotation: 0 state: enabled +- name: vlen + id: variable + parameters: + comment: '' + value: '10' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [216, 196.0] + rotation: 0 + state: true +- name: wrong + id: variable + parameters: + comment: '' + value: list(np.random.randint(0, 255, dtype=np.uint8, size=10)) + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [216, 460.0] + rotation: 0 + state: true +- name: blocks_throttle_0 + id: blocks_throttle + parameters: + affinity: '' + alias: '' + comment: '' + ignoretag: 'True' + maxoutbuf: '0' + minoutbuf: '0' + samples_per_second: samp_rate + type: byte + vlen: vlen + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [448, 292.0] + rotation: 0 + state: true - name: blocks_vector_source_x_0 id: blocks_vector_source_x parameters: @@ -67,8 +110,8 @@ blocks: repeat: 'True' tags: '[]' type: byte - vector: testvec * 1600 - vlen: '1' + vector: testvec + list(np.random.randint(0, 255, dtype=np.uint8, size=10)) + vlen: vlen states: bus_sink: false bus_source: false @@ -83,16 +126,31 @@ blocks: alias: '' comment: '' vgl: testvec + vlen: vlen + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [672, 292.0] + rotation: 0 + state: true +- name: import_0 + id: import + parameters: + alias: '' + comment: '' + imports: import numpy as np states: bus_sink: false bus_source: false bus_structure: null - coordinate: [704, 296.0] + coordinate: [328, 20.0] rotation: 0 state: true connections: -- [blocks_vector_source_x_0, '0', fadingui_ber_0, '0'] +- [blocks_throttle_0, '0', fadingui_ber_0, '0'] +- [blocks_vector_source_x_0, '0', blocks_throttle_0, '0'] metadata: file_format: 1 diff --git a/tests/BER/Test_Bit_Errorrate.py b/tests/BER/Test_Bit_Errorrate.py index 4022997..a861ae7 100755 --- a/tests/BER/Test_Bit_Errorrate.py +++ b/tests/BER/Test_Bit_Errorrate.py @@ -31,6 +31,7 @@ from argparse import ArgumentParser from gnuradio.eng_arg import eng_float, intx from gnuradio import eng_notation import fadingui +import numpy as np from gnuradio import qtgui @@ -70,21 +71,25 @@ class Test_Bit_Errorrate(gr.top_block, Qt.QWidget): ################################################## # Variables ################################################## + self.wrong = wrong = list(np.random.randint(0, 255, dtype=np.uint8, size=10)) + self.vlen = vlen = 10 self.testvec = testvec = [31, 53] + [0x12, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3] self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## - self.fadingui_ber_0 = fadingui.ber(vgl=testvec) - self.blocks_vector_source_x_0 = blocks.vector_source_b(testvec * 1600, True, 1, []) + self.fadingui_ber_0 = fadingui.ber(vgl=testvec, vlen=vlen) + self.blocks_vector_source_x_0 = blocks.vector_source_b(testvec + list(np.random.randint(0, 255, dtype=np.uint8, size=10)), True, vlen, []) + self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*vlen, samp_rate,True) ################################################## # Connections ################################################## - self.connect((self.blocks_vector_source_x_0, 0), (self.fadingui_ber_0, 0)) + self.connect((self.blocks_throttle_0, 0), (self.fadingui_ber_0, 0)) + self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_throttle_0, 0)) def closeEvent(self, event): @@ -92,18 +97,31 @@ class Test_Bit_Errorrate(gr.top_block, Qt.QWidget): self.settings.setValue("geometry", self.saveGeometry()) event.accept() + def get_wrong(self): + return self.wrong + + def set_wrong(self, wrong): + self.wrong = wrong + + def get_vlen(self): + return self.vlen + + def set_vlen(self, vlen): + self.vlen = vlen + def get_testvec(self): return self.testvec def set_testvec(self, testvec): self.testvec = testvec - self.blocks_vector_source_x_0.set_data(self.testvec * 1600, []) + self.blocks_vector_source_x_0.set_data(self.testvec + list(np.random.randint(0, 255, dtype=np.uint8, size=10)), []) def get_samp_rate(self): return self.samp_rate def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate + self.blocks_throttle_0.set_sample_rate(self.samp_rate) |