From c980e573ec1787c4e02efd5a444009ebe974f4cd Mon Sep 17 00:00:00 2001 From: sara Date: Fri, 12 Nov 2021 19:59:02 +0100 Subject: Fading Angepasst --- simulation/QAM_Fading/qam_fading.py | 84 ++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 29 deletions(-) (limited to 'simulation/QAM_Fading/qam_fading.py') diff --git a/simulation/QAM_Fading/qam_fading.py b/simulation/QAM_Fading/qam_fading.py index c24bd4d..d6ace52 100755 --- a/simulation/QAM_Fading/qam_fading.py +++ b/simulation/QAM_Fading/qam_fading.py @@ -86,10 +86,11 @@ class qam_fading(gr.top_block, Qt.QWidget): self.phase_bw = phase_bw = 2 * 3.141592653589793 / 100 self.noise_volt = noise_volt = 0.0001 self.freq_offset = freq_offset = 0 + self.fading_1 = fading_1 = 2 self.eq_ntaps = eq_ntaps = 15 self.eq_mod = eq_mod = 1 self.eq_gain = eq_gain = .01 - self.const = const = digital.constellation_qpsk().base() + self.const = const = digital.constellation_16qam().base() self.chn_taps = chn_taps = [1.0 + 0.0j, ] ################################################## @@ -114,6 +115,13 @@ class qam_fading(gr.top_block, Qt.QWidget): self.params_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.params_grid_layout_0.setColumnStretch(c, 1) + self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.0, 200) + self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Timing Offset', "counter_slider", float) + self.params_grid_layout_0.addWidget(self._time_offset_win, 0, 1, 1, 1) + for r in range(0, 1): + self.params_grid_layout_0.setRowStretch(r, 1) + for c in range(1, 2): + self.params_grid_layout_0.setColumnStretch(c, 1) self.plots = Qt.QTabWidget() self.plots_widget_0 = Qt.QWidget() self.plots_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.plots_widget_0) @@ -138,6 +146,27 @@ class qam_fading(gr.top_block, Qt.QWidget): self.params_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.params_grid_layout_1.setColumnStretch(c, 1) + self._noise_volt_range = Range(0, 1, 0.01, 0.0001, 200) + self._noise_volt_win = RangeWidget(self._noise_volt_range, self.set_noise_volt, 'Noise Voltage', "counter_slider", float) + self.params_grid_layout_0.addWidget(self._noise_volt_win, 0, 0, 1, 1) + for r in range(0, 1): + self.params_grid_layout_0.setRowStretch(r, 1) + for c in range(0, 1): + self.params_grid_layout_0.setColumnStretch(c, 1) + self._freq_offset_range = Range(-100e-3, 100e-3, 1e-3, 0, 200) + self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Frequency Offset', "counter_slider", float) + self.params_grid_layout_0.addWidget(self._freq_offset_win, 1, 0, 1, 1) + for r in range(1, 2): + self.params_grid_layout_0.setRowStretch(r, 1) + for c in range(0, 1): + self.params_grid_layout_0.setColumnStretch(c, 1) + self._fading_1_range = Range(1, 10, 1, 2, 200) + self._fading_1_win = RangeWidget(self._fading_1_range, self.set_fading_1, 'Fading', "counter_slider", int) + self.params_grid_layout_0.addWidget(self._fading_1_win, 2, 0, 1, 1) + for r in range(2, 3): + self.params_grid_layout_0.setRowStretch(r, 1) + for c in range(0, 1): + self.params_grid_layout_0.setColumnStretch(c, 1) self._eq_gain_range = Range(0, .1, .001, .01, 200) self._eq_gain_win = RangeWidget(self._eq_gain_range, self.set_eq_gain, 'Equalizer Rate', "counter_slider", float) self.params_grid_layout_1.addWidget(self._eq_gain_win, 0, 0, 1, 1) @@ -145,13 +174,6 @@ class qam_fading(gr.top_block, Qt.QWidget): self.params_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.params_grid_layout_1.setColumnStretch(c, 1) - self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.0, 200) - self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Timing Offset', "counter_slider", float) - self.params_grid_layout_0.addWidget(self._time_offset_win, 0, 1, 1, 1) - for r in range(0, 1): - self.params_grid_layout_0.setRowStretch(r, 1) - for c in range(1, 2): - self.params_grid_layout_0.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate @@ -243,7 +265,11 @@ class qam_fading(gr.top_block, Qt.QWidget): self.qtgui_freq_sink_x_2_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_2_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_2_1.pyqwidget(), Qt.QWidget) - self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_2_1_win) + self.plots_grid_layout_1.addWidget(self._qtgui_freq_sink_x_2_1_win, 1, 0, 1, 1) + for r in range(1, 2): + self.plots_grid_layout_1.setRowStretch(r, 1) + for c in range(0, 1): + self.plots_grid_layout_1.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype @@ -464,21 +490,7 @@ class qam_fading(gr.top_block, Qt.QWidget): self.plots_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.plots_grid_layout_0.setColumnStretch(c, 1) - self._noise_volt_range = Range(0, 1, 0.01, 0.0001, 200) - self._noise_volt_win = RangeWidget(self._noise_volt_range, self.set_noise_volt, 'Noise Voltage', "counter_slider", float) - self.params_grid_layout_0.addWidget(self._noise_volt_win, 0, 0, 1, 1) - for r in range(0, 1): - self.params_grid_layout_0.setRowStretch(r, 1) - for c in range(0, 1): - self.params_grid_layout_0.setColumnStretch(c, 1) - self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, [1]+[0 for n in range(0, 2*sps-1)]+[0.2], 0, samp_rate) - self._freq_offset_range = Range(-100e-3, 100e-3, 1e-3, 0, 200) - self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Frequency Offset', "counter_slider", float) - self.params_grid_layout_0.addWidget(self._freq_offset_win, 1, 0, 1, 1) - for r in range(1, 2): - self.params_grid_layout_0.setRowStretch(r, 1) - for c in range(0, 1): - self.params_grid_layout_0.setColumnStretch(c, 1) + self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, [1]+([0]*fading_1)+[0.2], 0, samp_rate) self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf(sps , timing_loop_bw, rrc_taps, nfilts, nfilts/2, 1.5, 1) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, rrc_taps, nfilts, nfilts/2, 1.5, 1) self.digital_map_bb_0_0 = digital.map_bb([0, 1, 3, 2]) @@ -499,6 +511,13 @@ 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_channel_model_0 = channels.channel_model( + noise_voltage=noise_volt, + frequency_offset=freq_offset, + epsilon=time_offset, + taps=chn_taps, + noise_seed=0, + block_tags=False) self.blocks_unpack_k_bits_bb_0_1 = blocks.unpack_k_bits_bb(2) self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(2) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) @@ -522,13 +541,14 @@ class qam_fading(gr.top_block, Qt.QWidget): self.connect((self.blocks_char_to_float_0_1, 0), (self.qtgui_freq_sink_x_2_1, 1)) self.connect((self.blocks_char_to_float_0_1, 0), (self.qtgui_time_sink_x_0, 2)) self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0, 1)) - self.connect((self.blocks_throttle_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0)) - self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) - self.connect((self.blocks_throttle_0, 0), (self.qtgui_const_sink_x_0, 1)) - self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 1)) + self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_1, 0), (self.blocks_char_to_float_0_1, 0)) + self.connect((self.channels_channel_model_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0)) + self.connect((self.channels_channel_model_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) + self.connect((self.channels_channel_model_0, 0), (self.qtgui_const_sink_x_0, 1)) + self.connect((self.channels_channel_model_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.digital_cma_equalizer_cc_0_0, 0), (self.digital_costas_loop_cc_0_0, 0)) @@ -564,7 +584,6 @@ class qam_fading(gr.top_block, Qt.QWidget): def set_sps(self, sps): self.sps = sps self.set_rrc_taps(firdes.root_raised_cosine(self.nfilts, self.nfilts, 1.0/float(self.sps), self.excess_bw, 45*self.nfilts)) - self.freq_xlating_fir_filter_xxx_0.set_taps([1]+[0 for n in range(0, 2*self.sps-1)]+[0.2]) def get_nfilts(self): return self.nfilts @@ -635,6 +654,13 @@ class qam_fading(gr.top_block, Qt.QWidget): self.freq_offset = freq_offset self.channels_channel_model_0.set_frequency_offset(self.freq_offset) + def get_fading_1(self): + return self.fading_1 + + def set_fading_1(self, fading_1): + self.fading_1 = fading_1 + self.freq_xlating_fir_filter_xxx_0.set_taps([1]+([0]*self.fading_1)+[0.2]) + def get_eq_ntaps(self): return self.eq_ntaps -- cgit v1.2.1