Example #1
0
    def __init__(self, k=4.0, tchannel=1, voltage=0):
        gr.hier_block2.__init__(
            self,
            "channel",
            gr.io_signature(1, 1, gr.sizeof_float * 1),
            gr.io_signature(1, 1, gr.sizeof_float * 1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.k = k
        self.tchannel = tchannel
        self.voltage = voltage

        ##################################################
        # Blocks
        ##################################################
        self.channels_fading_model_0_0 = channels.fading_model(
            8, 5 / 32000, False, 4.0, 0)
        self.channels_fading_model_0 = channels.fading_model(
            8, 5 / 32000, True, k, 0)
        self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_float_0_0_0 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_noise_source_x_0 = analog.noise_source_f(
            analog.GR_GAUSSIAN, voltage, 0)
        self.Multiplexer_mux_0 = Multiplexer.mux(tchannel)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Multiplexer_mux_0, 0), (self, 0))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.Multiplexer_mux_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.Multiplexer_mux_0, 2))
        self.connect((self.blocks_complex_to_float_0_0_0, 0),
                     (self.Multiplexer_mux_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.channels_fading_model_0_0, 0))
        self.connect((self.blocks_float_to_complex_0_0, 0),
                     (self.channels_fading_model_0, 0))
        self.connect((self.channels_fading_model_0, 0),
                     (self.blocks_complex_to_float_0_0_0, 0))
        self.connect((self.channels_fading_model_0_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self, 0), (self.blocks_add_xx_0, 1))
        self.connect((self, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self, 0), (self.blocks_float_to_complex_0_0, 0))
Example #2
0
def processInput1tx(file_num, snr):
    freq = numpy.random.permutation([0, -2.5e6, 2.5e6])
    source_A = blocks.vector_source_b(
        map(int, numpy.random.randint(0, 255, 1000000)), True)

    throttle_A = blocks.throttle(gr.sizeof_char * 1, samp_rate_base, True)

    constellation_modulator_A = digital.generic_mod(
        constellation=constellation_variable,
        differential=False,
        samples_per_symbol=sps,
        pre_diff_code=True,
        excess_bw=0.35,
        verbose=False,
        log=False,
    )

    sig_source_A = analog.sig_source_c(upsamp_rate, analog.GR_COS_WAVE,
                                       freq[0],
                                       (10**(snr / 20)) * noise_amplitude, 0)

    resampler_A = filter.rational_resampler_ccc(10,
                                                2,
                                                taps=None,
                                                fractional_bw=None)

    multiply_A = blocks.multiply_vcc(1)

    channel_A = channels.fading_model(12, 0, False, 4.0, 0)

    add_block = blocks.add_vcc(1)

    channel = channels.channel_model(noise_voltage=noise_amplitude,
                                     frequency_offset=0.0,
                                     epsilon=1.0,
                                     taps=(1 + 1j, ),
                                     noise_seed=0,
                                     block_tags=False)

    skip_head = blocks.skiphead(gr.sizeof_gr_complex * 1, 1024)
    head_block = blocks.head(gr.sizeof_gr_complex * 1, 1000000)
    file_sink = blocks.file_sink(
        gr.sizeof_gr_complex * 1,
        'data_1tx_' + str(snr) + 'dB_' + str(file_num) + '.dat', False)

    tb = gr.top_block()

    tb.connect(source_A, throttle_A, constellation_modulator_A, resampler_A,
               (multiply_A, 0))
    tb.connect(sig_source_A, (multiply_A, 1))
    tb.connect(multiply_A, channel_A)

    tb.connect(channel_A, channel)

    tb.connect(channel, skip_head)
    tb.connect(skip_head, head_block)
    tb.connect(head_block, file_sink)

    tb.run()
Example #3
0
 def __init__(self, snr_db=0):
     channel.__init__(self, snr_db=snr_db)
     self.chan = \
         channels.fading_model(
             8,                          # n_max_sinusoids
             1.0/200e3,                  # max Doppler
             False,                      # LOS(True)/NLOS(False)
             4.0,                        # K-value in Rician
             0                           # seed
         )
     self.connect(self, self.chan, self.add)
Example #4
0
    def test_000(self):
        N = 1000  # number of samples to use
        fs = 1000  # baseband sampling rate
        freq = 100

        fDTs = 0.01
        K = 4
        signal = analog.sig_source_c(fs, analog.GR_SIN_WAVE, freq, 1)
        head = blocks.head(gr.sizeof_gr_complex, N)
        op = channels.fading_model(8, fDTs=fDTs, LOS=True, K=K, seed=0)
        snk = blocks.vector_sink_c()
        snk1 = blocks.vector_sink_c()

        self.assertAlmostEqual(K, op.K(), 4)
        self.assertAlmostEqual(fDTs, op.fDTs(), 4)
Example #5
0
    def test_000(self):
        N = 1000         # number of samples to use
        fs = 1000        # baseband sampling rate
        freq = 100

        fDTs = 0.01
        K = 4
        signal = analog.sig_source_c(fs, analog.GR_SIN_WAVE, freq, 1)
        head = blocks.head(gr.sizeof_gr_complex, N)
        op = channels.fading_model(8, fDTs=fDTs, LOS=True,
                                   K=K, seed=0)
        snk = blocks.vector_sink_c()
        snk1 = blocks.vector_sink_c()

        self.assertAlmostEqual(K, op.K(), 4)
        self.assertAlmostEqual(fDTs, op.fDTs(), 4)
Example #6
0
    def __init__(self):
        gr.top_block.__init__(self, "Channel Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Channel Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "channel_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sound_card_sample_rate = sound_card_sample_rate = 22000
        self.samples_per_symbol = samples_per_symbol = 16
        self.symbol_rate = symbol_rate = sound_card_sample_rate / samples_per_symbol
        self.rx_frequency_error = rx_frequency_error = 100
        self.quantization_depth = quantization_depth = 16
        self.if_frequency = if_frequency = sound_card_sample_rate / 4

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_1_2_0 = qtgui.time_sink_f(
            500,  #size
            sound_card_sample_rate,  #samp_rate
            "Received signal",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_2_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_2_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_1_2_0.set_y_label("Amplitude", "")

        self.qtgui_time_sink_x_1_2_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_1_2_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                      qtgui.TRIG_SLOPE_POS,
                                                      0.0, 0, 0, "")
        self.qtgui_time_sink_x_1_2_0.enable_autoscale(True)
        self.qtgui_time_sink_x_1_2_0.enable_grid(False)
        self.qtgui_time_sink_x_1_2_0.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_1_2_0.disable_legend()

        labels = ["", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1_2_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1_2_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_2_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_2_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_2_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_2_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_2_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_2_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_2_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_2_0_win)
        self.low_pass_filter_0_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1.66, sound_card_sample_rate,
                            sound_card_sample_rate / 4,
                            sound_card_sample_rate / 8, firdes.WIN_HANN, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1.66, sound_card_sample_rate,
                            sound_card_sample_rate / 4,
                            sound_card_sample_rate / 8, firdes.WIN_HANN, 6.76))
        self.final = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            sound_card_sample_rate,  #bw
            "Distorted baseband signal",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.final.set_update_time(1.0 / 10)
        self._final_win = sip.wrapinstance(self.final.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._final_win)

        self.final.enable_rf_freq(False)

        self.channels_fading_model_0 = channels.fading_model(
            16, 0, False, 4.0, 0)
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            "tx_signal.wav", False)
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(
            "rx_signal.wav", 1, sound_card_sample_rate, quantization_depth)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 sound_card_sample_rate, True)
        self.blocks_multiply_xx_0_0_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0_0_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_sig_source_x_0_1 = analog.sig_source_f(
            sound_card_sample_rate, analog.GR_SIN_WAVE,
            if_frequency + rx_frequency_error, 1, 0)
        self.analog_sig_source_x_0_0_0 = analog.sig_source_f(
            sound_card_sample_rate, analog.GR_COS_WAVE,
            if_frequency + rx_frequency_error, 1, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            sound_card_sample_rate, analog.GR_COS_WAVE, if_frequency, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            sound_card_sample_rate, analog.GR_SIN_WAVE, if_frequency, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_sig_source_x_0_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0, 0))
        self.connect((self.analog_sig_source_x_0_1, 0),
                     (self.blocks_multiply_xx_0_0_1, 1))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_multiply_xx_0_0_0, 1))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_multiply_xx_0_0_1, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.channels_fading_model_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_1, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_wavfile_sink_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_time_sink_x_1_2_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.channels_fading_model_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.channels_fading_model_0, 0), (self.final, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_float_to_complex_0, 0))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48000
        self.seed = seed = 128
        self.m_rate = m_rate = 0.8
        self.if_rate = if_rate = samp_rate * 40
        self.gauss = gauss = 0
        self.fc = fc = 511e3
        self.dpp = dpp = 100.0

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_f(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='FFT Plot',
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=if_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='FFT Plot',
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rational_resampler_xxx_0_1 = filter.rational_resampler_fff(
            interpolation=3,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
            interpolation=40,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.interp_fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, 7500, 100, firdes.WIN_HAMMING, 6.76))
        self.hilbert_fc_0 = filter.hilbert_fc(301, firdes.WIN_HAMMING, 6.76)
        self.channels_fading_model_0 = channels.fading_model(
            8, dpp / if_rate, False, 2, 256)
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            '/media/akio/ssd1/fading_generator/5-263831-B-6.wav', True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate, True)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (m_rate, ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((1, ))
        self.band_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.band_pass(4, if_rate, fc - 8e3, fc + 8e3, 100,
                             firdes.WIN_HAMMING, 6.76))
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            if_rate, analog.GR_COS_WAVE, fc, 1, 0)
        self.analog_am_demod_cf_0 = analog.am_demod_cf(
            channel_rate=fc,
            audio_decim=40,
            audio_pass=7500,
            audio_stop=10e3,
        )
        self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0), (self.analog_am_demod_cf_0, 0))
        self.connect((self.analog_am_demod_cf_0, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.analog_am_demod_cf_0, 0),
                     (self.wxgui_fftsink2_0_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.band_pass_filter_0, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.band_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.hilbert_fc_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.rational_resampler_xxx_0_1, 0))
        self.connect((self.channels_fading_model_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.hilbert_fc_0, 0), (self.channels_fading_model_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0_1, 0),
                     (self.low_pass_filter_0, 0))
Example #8
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 8
        self.nfilts = nfilts = 128
        self.timing_loop_bandwidth = timing_loop_bandwidth = .063
        self.samp_rate = samp_rate = 32000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 45*nfilts)
        self.noise_voltage = noise_voltage = .063
        self.freq_offset = freq_offset = 0
        
        self.BPSK = BPSK = digital.constellation_calcdist(([-1, 1]), ([0, 1]), 4, 1).base()
        

        ##################################################
        # Blocks
        ##################################################
        self._timing_loop_bandwidth_range = Range(.001, .2, .001, .063, 200)
        self._timing_loop_bandwidth_win = RangeWidget(self._timing_loop_bandwidth_range, self.set_timing_loop_bandwidth, "timing_loop_bandwidth", "counter_slider", float)
        self.top_grid_layout.addWidget(self._timing_loop_bandwidth_win, 0,0,1,1)
        self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
        	1024, #size
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0.enable_grid(True)
        self.qtgui_const_sink_x_0_0.enable_axis_labels(True)
        
        if not True:
          self.qtgui_const_sink_x_0_0.disable_legend()
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_0_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
        	1024, #size
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(True)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)
        
        if not True:
          self.qtgui_const_sink_x_0.disable_legend()
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self._noise_voltage_range = Range(0.0, 1, .001, .063, 200)
        self._noise_voltage_win = RangeWidget(self._noise_voltage_range, self.set_noise_voltage, "noise_voltage", "counter_slider", float)
        self.top_grid_layout.addWidget(self._noise_voltage_win, 0,1,1,1)
        self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bandwidth, (rrc_taps), nfilts, nfilts/2, 1.5, 1)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bandwidth, (rrc_taps), nfilts, nfilts/2, 1.5, 1)
        self.digital_constellation_modulator_0 = digital.generic_mod(
          constellation=BPSK,
          differential=False,
          samples_per_symbol=sps,
          pre_diff_code=True,
          excess_bw=0.35,
          verbose=False,
          log=False,
          )
        self.channels_fading_model_0 = channels.fading_model( 8, 10.0/samp_rate, True, 10, 0 )
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True)
        self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 1000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.digital_constellation_modulator_0, 0))    
        self.connect((self.channels_fading_model_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0))    
        self.connect((self.digital_constellation_modulator_0, 0), (self.channels_fading_model_0, 0))    
        self.connect((self.digital_constellation_modulator_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_const_sink_x_0_0, 0))    
        self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.qtgui_const_sink_x_0, 0))    
Example #9
0
                                                    taps=None,
                                                    fractional_bw=None)
        resampler_B = filter.rational_resampler_ccc(10,
                                                    2,
                                                    taps=None,
                                                    fractional_bw=None)
        multiply_A = blocks.multiply_vcc(1)
        multiply_A1 = blocks.multiply_vcc(1)
        multiply_B = blocks.multiply_vcc(1)
        float_to_complex_A = blocks.float_to_complex(1)

        delay_B = blocks.delay(gr.sizeof_gr_complex * 1, 500000)
        sqr_source_A = analog.sig_source_f(samp_rate_base, analog.GR_SQR_WAVE,
                                           -1, signal_amp, 0)

        channel_A = channels.fading_model(12, 0, False, 4.0, 0)
        channel_B = channels.fading_model(12, 0, False, 4.0, 0)
        add_block = blocks.add_vcc(1)

        channel = channels.channel_model(noise_voltage=noise_amplitude,
                                         frequency_offset=0.0,
                                         epsilon=1.0,
                                         taps=(1 + 1j, ),
                                         noise_seed=0,
                                         block_tags=False)

        skip_head = blocks.skiphead(gr.sizeof_gr_complex * 1, 1024)
        head_block = blocks.head(gr.sizeof_gr_complex * 1, 1000000)
        file_sink = blocks.file_sink(
            gr.sizeof_gr_complex * 1, '/home/keyur/data/data_file_2tx/data_' +
            str(snr) + 'dB_' + str(file_num) + '.dat', False)
Example #10
0
    def __init__(self):
        gr.top_block.__init__(self, "Varun_Kamble")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Varun_Kamble")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "gfsk")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(
                self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_sink_x_1 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_1.set_update_time(1.0 / 10)
        self._qtgui_sink_x_1_win = sip.wrapinstance(
            self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_1_win)

        self.qtgui_sink_x_1.enable_rf_freq(False)

        self.qtgui_sink_x_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_win)

        self.qtgui_sink_x_0.enable_rf_freq(False)

        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            2  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
            samples_per_symbol=2,
            sensitivity=1.0,
            bt=0.35,
            verbose=False,
            log=False,
        )
        self.digital_gfsk_demod_0 = digital.gfsk_demod(
            samples_per_symbol=2,
            sensitivity=1.0,
            gain_mu=0.175,
            mu=0.5,
            omega_relative_limit=0.005,
            freq_error=0.0,
            verbose=False,
            log=False,
        )
        self.channels_fading_model_0 = channels.fading_model(
            8, 10.0 / samp_rate, False, 4, 0)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_c(
            grc_blks2.packet_encoder(
                samples_per_symbol=2,
                bits_per_symbol=1,
                preamble='',
                access_code='',
                pad_for_usrp=True,
            ),
            payload_length=0,
        )
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_c(
            grc_blks2.packet_decoder(
                access_code='',
                threshold=-1,
                callback=lambda ok, payload: self.blks2_packet_decoder_0.
                recv_pkt(ok, payload),
            ), )
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 1000, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blks2_packet_decoder_0, 0),
                     (self.qtgui_sink_x_1, 0))
        self.connect((self.blks2_packet_encoder_0, 0),
                     (self.digital_gfsk_mod_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blks2_packet_encoder_0, 0))
        self.connect((self.channels_fading_model_0, 0),
                     (self.digital_gfsk_demod_0, 0))
        self.connect((self.channels_fading_model_0, 0),
                     (self.qtgui_const_sink_x_0, 1))
        self.connect((self.digital_gfsk_demod_0, 0),
                     (self.blks2_packet_decoder_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0),
                     (self.channels_fading_model_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0), (self.qtgui_sink_x_0, 0))
Example #11
0
    def __init__(self):
        gr.top_block.__init__(self, "Ofdm02")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Ofdm02")
        try:
             self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
             pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "ofdm02")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.timing = timing = 1.0001
        self.samp_rate = samp_rate = 100000
        self.packet_len = packet_len = 50
        self.noise = noise = 0.01
        self.len_tag_key = len_tag_key = "packet_len"
        self.freq = freq = 0.01
        self.fft_len = fft_len = 128

        ##################################################
        # Blocks
        ##################################################
        self._timing_layout = Qt.QVBoxLayout()
        self._timing_tool_bar = Qt.QToolBar(self)
        self._timing_layout.addWidget(self._timing_tool_bar)
        self._timing_tool_bar.addWidget(Qt.QLabel("Timing Offset"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._timing_counter = qwt_counter_pyslot()
        self._timing_counter.setRange(0.999, 1.001, 0.0001)
        self._timing_counter.setNumButtons(2)
        self._timing_counter.setValue(self.timing)
        self._timing_tool_bar.addWidget(self._timing_counter)
        self._timing_counter.valueChanged.connect(self.set_timing)
        self._timing_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._timing_slider.setRange(0.999, 1.001, 0.0001)
        self._timing_slider.setValue(self.timing)
        self._timing_slider.setMinimumWidth(200)
        self._timing_slider.valueChanged.connect(self.set_timing)
        self._timing_layout.addWidget(self._timing_slider)
        self.top_grid_layout.addLayout(self._timing_layout, 2,0,1,1)
        self._noise_layout = Qt.QVBoxLayout()
        self._noise_tool_bar = Qt.QToolBar(self)
        self._noise_layout.addWidget(self._noise_tool_bar)
        self._noise_tool_bar.addWidget(Qt.QLabel("Noise Voltage"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._noise_counter = qwt_counter_pyslot()
        self._noise_counter.setRange(0, 3, 0.01)
        self._noise_counter.setNumButtons(2)
        self._noise_counter.setValue(self.noise)
        self._noise_tool_bar.addWidget(self._noise_counter)
        self._noise_counter.valueChanged.connect(self.set_noise)
        self._noise_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._noise_slider.setRange(0, 3, 0.01)
        self._noise_slider.setValue(self.noise)
        self._noise_slider.setMinimumWidth(200)
        self._noise_slider.valueChanged.connect(self.set_noise)
        self._noise_layout.addWidget(self._noise_slider)
        self.top_grid_layout.addLayout(self._noise_layout, 1,0,1,1)
        self._freq_layout = Qt.QVBoxLayout()
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_layout.addWidget(self._freq_tool_bar)
        self._freq_tool_bar.addWidget(Qt.QLabel("Frequency Offset"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._freq_counter = qwt_counter_pyslot()
        self._freq_counter.setRange(-1, 1, 0.01)
        self._freq_counter.setNumButtons(2)
        self._freq_counter.setValue(self.freq)
        self._freq_tool_bar.addWidget(self._freq_counter)
        self._freq_counter.valueChanged.connect(self.set_freq)
        self._freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._freq_slider.setRange(-1, 1, 0.01)
        self._freq_slider.setValue(self.freq)
        self._freq_slider.setMinimumWidth(200)
        self._freq_slider.valueChanged.connect(self.set_freq)
        self._freq_layout.addWidget(self._freq_slider)
        self.top_grid_layout.addLayout(self._freq_layout, 1,1,1,1)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"QT GUI Plot", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 0,1,1,1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"QT GUI Plot", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-80, 10)
        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0,0,1,1)
        self.digital_ofdm_tx_0 = digital.ofdm_tx(
        	  fft_len=fft_len, cp_len=fft_len/4,
        	  packet_length_tag_key=len_tag_key,
        	  bps_header=1,
        	  bps_payload=2,
        	  rolloff=0,
        	  debug_log=False,
        	  scramble_bits=False
        	 )
        self.digital_ofdm_rx_0 = digital.ofdm_rx(
        	  fft_len=fft_len, cp_len=fft_len/4,
        	  frame_length_tag_key='frame_'+"rx_len",
        	  packet_length_tag_key="rx_len",
        	  bps_header=1,
        	  bps_payload=2,
        	  debug_log=False,
        	  scramble_bits=False
        	 )
        self.channels_fading_model_0 = channels.fading_model( 8, 10.0/samp_rate, False, 4.0, 0 )
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=noise,
        	frequency_offset=freq,
        	epsilon=timing,
        	taps=(1.0, ),
        	noise_seed=0,
        	block_tags=False
        )
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char*1, "", ""); self.blocks_tag_debug_0.set_display(True)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, packet_len, len_tag_key)
        self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 1000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.channels_fading_model_0, 0))
        self.connect((self.channels_fading_model_0, 0), (self.channels_channel_model_0, 0))
        self.connect((self.channels_channel_model_0, 0), (self.digital_ofdm_rx_0, 0))
        self.connect((self.channels_channel_model_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.channels_channel_model_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tag_debug_0, 0))
    def __init__(self, args):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48000
        self.seed = seed = args.seed
        self.m_rate = m_rate = args.m_rate
        self.if_rate = if_rate = samp_rate * 40
        self.gauss = gauss = args.gauss
        self.fc = fc = args.fc
        self.dpp = dpp = args.dop

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0_1 = filter.rational_resampler_fff(
            interpolation=3,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
            interpolation=40,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.low_pass_filter_1_0 = filter.fir_filter_fff(
            40, firdes.low_pass(1, if_rate, 7500, 100, firdes.WIN_HAMMING,
                                6.76))
        self.low_pass_filter_1 = filter.fir_filter_fff(
            40, firdes.low_pass(1, if_rate, 7500, 100, firdes.WIN_HAMMING,
                                6.76))
        self.low_pass_filter_0 = filter.interp_fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, 7500, 100, firdes.WIN_HAMMING, 6.76))
        self.hilbert_fc_0 = filter.hilbert_fc(301, firdes.WIN_HAMMING, 6.76)
        self.high_pass_filter_0_1 = filter.fir_filter_fff(
            1, firdes.high_pass(1, samp_rate, 50, 10, firdes.WIN_HAMMING,
                                6.76))
        self.high_pass_filter_0_0_0_0 = filter.fir_filter_fff(
            1, firdes.high_pass(1, samp_rate, 50, 10, firdes.WIN_HAMMING,
                                6.76))
        self.high_pass_filter_0_0_0 = filter.fir_filter_fff(
            1, firdes.high_pass(1, samp_rate, 50, 10, firdes.WIN_HAMMING,
                                6.76))
        self.high_pass_filter_0_0 = filter.fir_filter_fff(
            1, firdes.high_pass(1, samp_rate, 50, 10, firdes.WIN_HAMMING,
                                6.76))
        self.high_pass_filter_0 = filter.fir_filter_fff(
            1, firdes.high_pass(1, samp_rate, 50, 10, firdes.WIN_HAMMING,
                                6.76))
        self.channels_fading_model_0 = channels.fading_model(
            8, dpp / if_rate, True, 2, 256)
        self.blocks_wavfile_source_0 = blocks.wavfile_source(file1, False)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate, True)
        self.blocks_multiply_xx_1_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (m_rate, ))
        self.blocks_file_sink_0_5 = blocks.file_sink(gr.sizeof_float * 1,
                                                     file2, False)
        self.blocks_file_sink_0_5.set_unbuffered(False)
        self.blocks_file_sink_0_4 = blocks.file_sink(gr.sizeof_float * 1,
                                                     file3, False)
        self.blocks_file_sink_0_4.set_unbuffered(False)
        self.blocks_file_sink_0_3 = blocks.file_sink(gr.sizeof_float * 1,
                                                     file4, False)
        self.blocks_file_sink_0_3.set_unbuffered(False)
        self.blocks_file_sink_0_2 = blocks.file_sink(gr.sizeof_float * 1,
                                                     file5, False)
        self.blocks_file_sink_0_2.set_unbuffered(False)
        self.blocks_file_sink_0_1 = blocks.file_sink(gr.sizeof_float * 1,
                                                     file6, False)
        self.blocks_file_sink_0_1.set_unbuffered(False)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_float * 1,
                                                     file7, False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float * 1, file8,
                                                   False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_add_xx_0_0_0 = blocks.add_vcc(1)
        self.blocks_add_xx_0_0 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((1, ))
        self.band_pass_filter_0_1 = filter.fir_filter_ccf(
            1,
            firdes.band_pass(4, if_rate, fc - 7.5e3, fc + 7.5e3, 100,
                             firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0_0_0 = filter.fir_filter_ccf(
            1,
            firdes.band_pass(4, if_rate, fc - 7.5e3, fc + 7.5e3, 100,
                             firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0_0 = filter.fir_filter_ccf(
            1,
            firdes.band_pass(4, if_rate, fc - 7.5e3, fc + 7.5e3, 100,
                             firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.band_pass(4, if_rate, fc - 7.5e3, fc + 7.5e3, 100,
                             firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.band_pass(4, if_rate, fc - 7.5e3, fc + 7.5e3, 100,
                             firdes.WIN_HAMMING, 6.76))
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            if_rate, analog.GR_COS_WAVE, fc, 1, 0)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(
            analog.GR_GAUSSIAN, gauss, seed, 8192)
        self.analog_am_demod_cf_0_1 = analog.am_demod_cf(
            channel_rate=fc,
            audio_decim=40,
            audio_pass=7500,
            audio_stop=10e3,
        )
        self.analog_am_demod_cf_0_0_0_0 = analog.am_demod_cf(
            channel_rate=fc,
            audio_decim=40,
            audio_pass=7500,
            audio_stop=10e3,
        )
        self.analog_am_demod_cf_0_0_0 = analog.am_demod_cf(
            channel_rate=fc,
            audio_decim=40,
            audio_pass=7500,
            audio_stop=10e3,
        )
        self.analog_am_demod_cf_0_0 = analog.am_demod_cf(
            channel_rate=fc,
            audio_decim=40,
            audio_pass=7500,
            audio_stop=10e3,
        )
        self.analog_am_demod_cf_0 = analog.am_demod_cf(
            channel_rate=fc,
            audio_decim=40,
            audio_pass=7500,
            audio_stop=10e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_am_demod_cf_0, 0),
                     (self.high_pass_filter_0, 0))
        self.connect((self.analog_am_demod_cf_0_0, 0),
                     (self.high_pass_filter_0_0, 0))
        self.connect((self.analog_am_demod_cf_0_0_0, 0),
                     (self.high_pass_filter_0_0_0, 0))
        self.connect((self.analog_am_demod_cf_0_0_0_0, 0),
                     (self.high_pass_filter_0_0_0_0, 0))
        self.connect((self.analog_am_demod_cf_0_1, 0),
                     (self.high_pass_filter_0_1, 0))
        self.connect((self.analog_fastnoise_source_x_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.analog_fastnoise_source_x_0, 0),
                     (self.blocks_add_xx_0_0, 1))
        self.connect((self.analog_fastnoise_source_x_0, 0),
                     (self.blocks_add_xx_0_0_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_1_0, 1))
        self.connect((self.band_pass_filter_0, 0),
                     (self.analog_am_demod_cf_0, 0))
        self.connect((self.band_pass_filter_0, 0),
                     (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.band_pass_filter_0_0, 0),
                     (self.analog_am_demod_cf_0_0, 0))
        self.connect((self.band_pass_filter_0_0_0, 0),
                     (self.analog_am_demod_cf_0_0_0, 0))
        self.connect((self.band_pass_filter_0_0_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.band_pass_filter_0_0_0_0, 0),
                     (self.analog_am_demod_cf_0_0_0_0, 0))
        self.connect((self.band_pass_filter_0_1, 0),
                     (self.analog_am_demod_cf_0_1, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.band_pass_filter_0, 0))
        self.connect((self.blocks_add_xx_0_0, 0),
                     (self.band_pass_filter_0_1, 0))
        self.connect((self.blocks_add_xx_0_0_0, 0),
                     (self.band_pass_filter_0_0_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0),
                     (self.blocks_multiply_xx_1_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_add_xx_0_0_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0), (self.hilbert_fc_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.low_pass_filter_1, 0))
        self.connect((self.blocks_multiply_xx_1_0, 0),
                     (self.low_pass_filter_1_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.rational_resampler_xxx_0_1, 0))
        self.connect((self.channels_fading_model_0, 0),
                     (self.band_pass_filter_0_0_0, 0))
        self.connect((self.channels_fading_model_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.channels_fading_model_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.high_pass_filter_0, 0),
                     (self.blocks_file_sink_0_5, 0))
        self.connect((self.high_pass_filter_0_0, 0),
                     (self.blocks_file_sink_0_3, 0))
        self.connect((self.high_pass_filter_0_0_0, 0),
                     (self.blocks_file_sink_0_2, 0))
        self.connect((self.high_pass_filter_0_0_0_0, 0),
                     (self.blocks_file_sink_0_1, 0))
        self.connect((self.high_pass_filter_0_1, 0),
                     (self.blocks_file_sink_0_4, 0))
        self.connect((self.hilbert_fc_0, 0), (self.band_pass_filter_0_0, 0))
        self.connect((self.hilbert_fc_0, 0), (self.blocks_add_xx_0_0, 0))
        self.connect((self.hilbert_fc_0, 0), (self.channels_fading_model_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.low_pass_filter_1, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.low_pass_filter_1_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0_1, 0),
                     (self.low_pass_filter_0, 0))
Example #13
0
def processInput5tx(file_num, snr):
    freq = numpy.random.permutation([0, -2.5e6, 2.5e6])
    snr_new = numpy.random.permutation(
        [snr - 5, snr + 5, snr - 10, snr + 10, snr])

    source_A = blocks.vector_source_b(
        map(int, numpy.random.randint(0, 255, 1000000)), True)
    source_B = blocks.vector_source_b(
        map(int, numpy.random.randint(0, 255, 1000000)), True)
    source_C = blocks.vector_source_b(
        map(int, numpy.random.randint(0, 255, 1000000)), True)
    source_D = blocks.vector_source_b(
        map(int, numpy.random.randint(0, 255, 1000000)), True)
    source_E = blocks.vector_source_b(
        map(int, numpy.random.randint(0, 255, 1000000)), True)

    throttle_A = blocks.throttle(gr.sizeof_char * 1, samp_rate_base, True)
    throttle_B = blocks.throttle(gr.sizeof_char * 1, samp_rate_base, True)
    throttle_C = blocks.throttle(gr.sizeof_char * 1, samp_rate_base, True)
    throttle_D = blocks.throttle(gr.sizeof_char * 1, samp_rate_base, True)
    throttle_E = blocks.throttle(gr.sizeof_char * 1, samp_rate_base, True)

    constellation_modulator_A = digital.generic_mod(
        constellation=constellation_variable,
        differential=False,
        samples_per_symbol=sps,
        pre_diff_code=True,
        excess_bw=0.35,
        verbose=False,
        log=False,
    )
    constellation_modulator_B = digital.generic_mod(
        constellation=constellation_variable,
        differential=False,
        samples_per_symbol=sps,
        pre_diff_code=True,
        excess_bw=0.35,
        verbose=False,
        log=False,
    )
    constellation_modulator_C = digital.generic_mod(
        constellation=constellation_variable,
        differential=False,
        samples_per_symbol=sps,
        pre_diff_code=True,
        excess_bw=0.35,
        verbose=False,
        log=False,
    )
    constellation_modulator_D = digital.generic_mod(
        constellation=constellation_variable,
        differential=False,
        samples_per_symbol=sps,
        pre_diff_code=True,
        excess_bw=0.35,
        verbose=False,
        log=False,
    )

    constellation_modulator_E = digital.generic_mod(
        constellation=constellation_variable,
        differential=False,
        samples_per_symbol=sps,
        pre_diff_code=True,
        excess_bw=0.35,
        verbose=False,
        log=False,
    )
    sig_source_A = analog.sig_source_c(
        upsamp_rate, analog.GR_COS_WAVE, freq[1],
        (10**(float(snr_new[0]) / 20)) * noise_amplitude, 0)
    sig_source_B = analog.sig_source_c(
        upsamp_rate, analog.GR_COS_WAVE, freq[1],
        (10**(float(snr_new[1]) / 20)) * noise_amplitude, 0)
    sig_source_C = analog.sig_source_c(
        upsamp_rate, analog.GR_COS_WAVE, freq[0],
        (10**(float(snr_new[2]) / 20)) * noise_amplitude, 0)
    sig_source_D = analog.sig_source_c(
        upsamp_rate, analog.GR_COS_WAVE, freq[2],
        (10**(float(snr_new[3]) / 20)) * noise_amplitude, 0)
    sig_source_E = analog.sig_source_c(
        upsamp_rate, analog.GR_COS_WAVE, freq[2],
        (10**(float(snr_new[4]) / 20)) * noise_amplitude, 0)

    const_A = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0)
    const_D = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0)

    resampler_A = filter.rational_resampler_ccc(10,
                                                2,
                                                taps=None,
                                                fractional_bw=None)
    resampler_B = filter.rational_resampler_ccc(10,
                                                2,
                                                taps=None,
                                                fractional_bw=None)
    resampler_C = filter.rational_resampler_ccc(10,
                                                2,
                                                taps=None,
                                                fractional_bw=None)
    resampler_D = filter.rational_resampler_ccc(10,
                                                2,
                                                taps=None,
                                                fractional_bw=None)
    resampler_E = filter.rational_resampler_ccc(10,
                                                2,
                                                taps=None,
                                                fractional_bw=None)
    multiply_A = blocks.multiply_vcc(1)
    multiply_B = blocks.multiply_vcc(1)
    multiply_C = blocks.multiply_vcc(1)
    multiply_D = blocks.multiply_vcc(1)
    multiply_E = blocks.multiply_vcc(1)
    float_to_complex_A = blocks.float_to_complex(1)
    float_to_complex_D = blocks.float_to_complex(1)

    delay_B = blocks.delay(gr.sizeof_gr_complex * 1, 500000)
    delay_E = blocks.delay(gr.sizeof_gr_complex * 1, 500000)
    sqr_source_A = analog.sig_source_f(samp_rate_base, analog.GR_SQR_WAVE, -1,
                                       signal_amp, 0)
    sqr_source_D = analog.sig_source_f(samp_rate_base, analog.GR_SQR_WAVE, -1,
                                       signal_amp, 0)

    channel_A = channels.fading_model(12, 0, False, 4.0, 0)
    channel_B = channels.fading_model(12, 0, False, 4.0, 0)
    channel_C = channels.fading_model(12, 0, False, 4.0, 0)
    channel_D = channels.fading_model(12, 0, False, 4.0, 0)
    channel_E = channels.fading_model(12, 0, False, 4.0, 0)
    add_block = blocks.add_vcc(1)

    channel = channels.channel_model(noise_voltage=noise_amplitude,
                                     frequency_offset=0.0,
                                     epsilon=1.0,
                                     taps=(1 + 1j, ),
                                     noise_seed=0,
                                     block_tags=False)

    skip_head = blocks.skiphead(gr.sizeof_gr_complex * 1, 1024)
    head_block = blocks.head(gr.sizeof_gr_complex * 1, 1000000)
    file_sink = blocks.file_sink(
        gr.sizeof_gr_complex * 1,
        'data_5tx_' + str(snr) + 'dB_' + str(file_num) + '.dat', False)

    tb = gr.top_block()

    tb.connect(source_A, throttle_A, constellation_modulator_A, resampler_A,
               (multiply_A, 0))
    tb.connect(sig_source_A, (multiply_A, 1))
    tb.connect(sqr_source_A, (float_to_complex_A, 0))
    tb.connect(const_A, (float_to_complex_A, 1))
    tb.connect(float_to_complex_A, (multiply_A, 2))
    tb.connect(multiply_A, channel_A, (add_block, 0))

    tb.connect(source_B, throttle_B, constellation_modulator_B, resampler_B,
               (multiply_B, 0))
    tb.connect(sig_source_B, (multiply_B, 1))
    tb.connect(multiply_B, channel_B, delay_B, (add_block, 1))

    tb.connect(source_C, throttle_C, constellation_modulator_C, resampler_C,
               (multiply_C, 0))
    tb.connect(sig_source_C, (multiply_C, 1))
    tb.connect(multiply_C, channel_C, (add_block, 2))

    tb.connect(source_D, throttle_D, constellation_modulator_D, resampler_D,
               (multiply_D, 0))
    tb.connect(sig_source_D, (multiply_D, 1))
    tb.connect(sqr_source_D, (float_to_complex_D, 0))
    tb.connect(const_D, (float_to_complex_D, 1))
    tb.connect(float_to_complex_D, (multiply_D, 2))
    tb.connect(multiply_D, channel_D, (add_block, 3))

    tb.connect(source_E, throttle_E, constellation_modulator_E, resampler_E,
               (multiply_E, 0))
    tb.connect(sig_source_E, (multiply_E, 1))
    tb.connect(multiply_E, channel_E, delay_E, (add_block, 4))
    tb.connect(add_block, channel, skip_head)
    tb.connect(skip_head, head_block)
    tb.connect(head_block, file_sink)

    tb.run()
Example #14
0
 def _build(self, component):
     """
     Base classe abstract method.
     @param component The decorator component.
     """
     return channels.fading_model(8, 0.1, False, 0.001, 0)