Exemplo n.º 1
0
    def __init__(self,
                 constellation_points=_def_constellation_points,
                 gray_coded=_def_gray_coded,
                 differential=True,
                 *args,
                 **kwargs):
        """
	Hierarchical block for RRC-filtered DQPSK modulation.

	The input is a byte stream (unsigned char) and the
	output is the complex modulated signal at baseband.

        See generic_mod block for list of parameters.
	"""

        constellation_points = _def_constellation_points
        constellation = digital_swig.constellation_dqpsk()
        if constellation_points != 4:
            raise ValueError(
                'Number of constellation points must be 4 for DQPSK.')
        super(dqpsk_mod, self).__init__(constellation=constellation,
                                        gray_coded=gray_coded,
                                        differential=True,
                                        *args,
                                        **kwargs)
Exemplo n.º 2
0
    def __init__(self, constellation_points=_def_constellation_points,
                 differential=True, *args, **kwargs):

        """
	Hierarchical block for RRC-filtered DQPSK modulation.

	The input is a byte stream (unsigned char) and the
	output is the complex modulated signal at baseband.

        See generic_demod block for list of parameters.
        """
        constellation_points = _def_constellation_points
        constellation = digital_swig.constellation_dqpsk()
        if constellation_points != 4:
            raise ValueError('Number of constellation points must be 4 for DQPSK.')
        super(dqpsk_demod, self).__init__(constellation=constellation,
                                          differential=True,
                                          *args, **kwargs)
Exemplo n.º 3
0
    def __init__(
        self,
        const_1_name="BPSK",
        const_2_name="QPSK",
        element_separation=0,
        file_name="eigenvalues5.csv",
        noise_voltage_1=0,
        noise_voltage_2=0,
        phi_1=70,
        phi_2=41,
        theta_1=45,
        theta_2=75,
    ):
        gr.top_block.__init__(self, "Eigenvalues Grabber")

        ##################################################
        # Parameters
        ##################################################
        self.const_1_name = const_1_name
        self.const_2_name = const_2_name
        self.element_separation = element_separation
        self.file_name = file_name
        self.noise_voltage_1 = noise_voltage_1
        self.noise_voltage_2 = noise_voltage_2
        self.phi_1 = phi_1
        self.phi_2 = phi_2
        self.theta_1 = theta_1
        self.theta_2 = theta_2

        ##################################################
        # Variables
        ##################################################
        if const_1_name == "bpsk":
            self.const_1 = const_1 = digital.constellation_bpsk().base()
        elif const_1_name == "qpsk":
            self.const_1 = const_1 = digital.constellation_qpsk().base()
        elif const_1_name == "dqpsk":
            self.const_1 = const_1 = digital.constellation_dqpsk().base()
        elif const_1_name == "8psk":
            self.const_1 = const_1 = digital.constellation_8psk().base()
        elif const_1_name == "16qam":
            self.const_1 = const_1 = digital.constellation_16qam().base()

        if const_2_name == "bpsk":
            self.const_2 = const_2 = digital.constellation_bpsk().base()
        elif const_2_name == "qpsk":
            self.const_2 = const_2 = digital.constellation_qpsk().base()
        elif const_2_name == "dqpsk":
            self.const_2 = const_2 = digital.constellation_dqpsk().base()
        elif const_2_name == "8psk":
            self.const_2 = const_2 = digital.constellation_8psk().base()
        elif const_2_name == "16qam":
            self.const_2 = const_2 = digital.constellation_16qam().base()

        self.samp_rate = samp_rate = 150000
        self.n = n = 2
        self.my = my = 4
        self.mx = mx = 4
        self.fc = fc = 436e6
        self.bps_2 = bps_2 = const_2.bits_per_symbol()
        self.bps_1 = bps_1 = const_1.bits_per_symbol()

        ##################################################
        # Blocks
        ##################################################
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            const_2.points(), 1
        )
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            const_1.points(), 1
        )
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True)
        self.blocks_packed_to_unpacked_xx_0_0 = blocks.packed_to_unpacked_bb(
            bps_2, gr.GR_MSB_FIRST
        )
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            bps_1, gr.GR_MSB_FIRST
        )
        self.blocks_add_xx_1 = blocks.add_vcc(mx * my)
        self.blocks_add_xx_0_0 = blocks.add_vcc(mx * my)
        self.blocks_add_xx_0 = blocks.add_vcc(mx * my)
        self.beamforming_randomsampler_0 = beamforming.randomsampler(mx * my, 8)
        self.beamforming_phasedarray_0_0 = beamforming.phasedarray(
            mx, my, theta_2, phi_2, 436e6, (299792458 / (2 * fc)), element_separation
        )
        self.beamforming_phasedarray_0 = beamforming.phasedarray(
            mx, my, theta_1, phi_1, 436e6, (299792458 / (2 * fc)), element_separation
        )
        self.beamforming_doaesprit_py_cf_0 = beamforming.doaesprit_py_cf(
            mx, my, fc, (299792458 / (2 * fc)), n, 128, file_name
        )
        self.analog_vectornoise_source_0_0 = analog.vectornoise_source(
            noise_voltage_2, mx * my
        )
        self.analog_vectornoise_source_0 = analog.vectornoise_source(
            noise_voltage_1, mx * my
        )
        self.analog_random_source_x_0_0 = blocks.vector_source_b(
            list(map(int, numpy.random.randint(0, 256, 1000))), False
        )
        self.analog_random_source_x_0 = blocks.vector_source_b(
            list(map(int, numpy.random.randint(0, 256, 1000))), False
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0))
        self.connect(
            (self.analog_random_source_x_0_0, 0), (self.blocks_throttle_0_0, 0)
        )
        self.connect((self.analog_vectornoise_source_0, 0), (self.blocks_add_xx_0, 1))
        self.connect(
            (self.analog_vectornoise_source_0_0, 0), (self.blocks_add_xx_0_0, 1)
        )
        self.connect((self.beamforming_phasedarray_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.beamforming_phasedarray_0_0, 0), (self.blocks_add_xx_0_0, 0))
        self.connect(
            (self.beamforming_randomsampler_0, 0),
            (self.beamforming_doaesprit_py_cf_0, 0),
        )
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_add_xx_1, 1))
        self.connect((self.blocks_add_xx_1, 0), (self.beamforming_randomsampler_0, 0))
        self.connect(
            (self.blocks_packed_to_unpacked_xx_0, 0),
            (self.digital_chunks_to_symbols_xx_0, 0),
        )
        self.connect(
            (self.blocks_packed_to_unpacked_xx_0_0, 0),
            (self.digital_chunks_to_symbols_xx_0_0, 0),
        )
        self.connect(
            (self.blocks_throttle_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)
        )
        self.connect(
            (self.blocks_throttle_0_0, 0), (self.blocks_packed_to_unpacked_xx_0_0, 0)
        )
        self.connect(
            (self.digital_chunks_to_symbols_xx_0, 0),
            (self.beamforming_phasedarray_0, 0),
        )
        self.connect(
            (self.digital_chunks_to_symbols_xx_0_0, 0),
            (self.beamforming_phasedarray_0_0, 0),
        )
Exemplo n.º 4
0
def dqpsk_constellation(m=_def_constellation_points):
    if m != _def_constellation_points:
        raise ValueError("DQPSK can only have 4 constellation points.")
    return digital_swig.constellation_dqpsk()
Exemplo n.º 5
0
    def __init__(self):
        gr.top_block.__init__(self, "Soft Decoder Example")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Soft Decoder Example")
        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", "constellation_soft_decoder")
        self.restoreGeometry(
            self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.samp_rate = samp_rate = 100000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), 0.35, 11 * sps * nfilts)
        self.noise_volt = noise_volt = 0.0001
        self.delay = delay = 29

        self.constel = constel = digital.constellation_dqpsk().base()

        self.constel.gen_soft_dec_lut(8)
        self.arity = arity = 4

        ##################################################
        # Blocks
        ##################################################
        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,
                                           'Channel: Noise Voltage', "slider",
                                           float)
        self.top_grid_layout.addWidget(self._noise_volt_win, 0, 0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._delay_options = (
            29,
            58,
            116,
        )
        self._delay_labels = (
            'BPSK',
            'QPSK',
            'QAM16',
        )
        self._delay_tool_bar = Qt.QToolBar(self)
        self._delay_tool_bar.addWidget(Qt.QLabel('Delay' + ": "))
        self._delay_combo_box = Qt.QComboBox()
        self._delay_tool_bar.addWidget(self._delay_combo_box)
        for label in self._delay_labels:
            self._delay_combo_box.addItem(label)
        self._delay_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._delay_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._delay_options.index(i)))
        self._delay_callback(self.delay)
        self._delay_combo_box.currentIndexChanged.connect(
            lambda i: self.set_delay(self._delay_options[i]))
        self.top_grid_layout.addWidget(self._delay_tool_bar, 0, 1, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            500,  #size
            samp_rate,  #samp_rate
            '',  #name
            3  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.05)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 2)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['Soft', 'Hard', 'Orig', '', '', '', '', '', '', '']
        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(3):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 1, 1, 1,
                                       1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_1 = qtgui.const_sink_c(
            1024,  #size
            '',  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_1.set_update_time(0.10)
        self.qtgui_const_sink_x_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_1.enable_autoscale(False)
        self.qtgui_const_sink_x_1.enable_grid(False)
        self.qtgui_const_sink_x_1.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_1.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_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_1_win = sip.wrapinstance(
            self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_1_win, 1, 0, 1,
                                       1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 6.28 / 100.0, (rrc_taps), nfilts, nfilts / 2, 1.5, 1)
        self.digital_map_bb_0_0 = digital.map_bb((constel.pre_diff_code()))
        self.digital_constellation_soft_decoder_cf_0 = digital.constellation_soft_decoder_cf(
            constel)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=constel,
            differential=False,
            samples_per_symbol=sps,
            pre_diff_code=True,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            constel)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=noise_volt,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(1.0, ),
            noise_seed=0,
            block_tags=False)
        self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(
            constel.bits_per_symbol())
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate,
                                                 True)
        self.blocks_repack_bits_bb_0_0_0 = blocks.repack_bits_bb(
            2, 8, "", True, gr.GR_MSB_FIRST)
        self.blocks_file_source_0_0 = blocks.file_source(
            gr.sizeof_char * 1, '/home/andre/Desktop/letra.txt', True)
        self.blocks_file_source_0_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/andre/Desktop/transmitido/depois.txt',
            False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_char * 1, int(delay))
        self.blocks_char_to_float_0_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_char_to_float_0_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_char_to_float_0_0_0, 0),
                     (self.qtgui_time_sink_x_0, 2))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_char_to_float_0_0_0, 0))
        self.connect((self.blocks_file_source_0_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_unpack_k_bits_bb_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.digital_constellation_modulator_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_delay_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_char_to_float_0_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_repack_bits_bb_0_0_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_map_bb_0_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.digital_constellation_soft_decoder_cf_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_map_bb_0_0, 0),
                     (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_constellation_soft_decoder_cf_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.qtgui_const_sink_x_1, 0))
Exemplo n.º 6
0
def dqpsk_constellation(m=_def_constellation_points):
    if m != _def_constellation_points:
        raise ValueError("DQPSK can only have 4 constellation points.")
    return digital_swig.constellation_dqpsk()