Пример #1
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Dvbs2 Tx")

        ##################################################
        # Variables
        ##################################################
        self.symbol_rate = symbol_rate = 5000000
        self.taps = taps = 50
        self.samp_rate = samp_rate = symbol_rate * 2
        self.rolloff = rolloff = 0.2

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=1280000000,
            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=True,
            avg_alpha=0.13333,
            title="FFT Plot",
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + "bladerf=0,buffers=128,buflen=32768")
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(1280e6, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(15, 0)
        self.osmosdr_sink_0.set_if_gain(0, 0)
        self.osmosdr_sink_0.set_bb_gain(-10, 0)
        self.osmosdr_sink_0.set_antenna("", 0)
        self.osmosdr_sink_0.set_bandwidth(6000000, 0)

        self.fft_filter_xxx_0 = filter.fft_filter_ccc(
            1, (firdes.root_raised_cosine(1, samp_rate, samp_rate / 2, rolloff, taps)), 1
        )
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.dvbs2_physical_cc_0 = dvbs2.physical_cc(
            dvbs2.MOD_16APSK, dvbs2.C9_10, dvbs2.PILOTS_ON, dvbs2.FECFRAME_NORMAL, 0
        )
        self.dvbs2_modulator_bc_0 = dvbs2.modulator_bc(dvbs2.MOD_16APSK, dvbs2.C9_10, dvbs2.FECFRAME_NORMAL)
        self.dvbs2_ldpc_bb_0 = dvbs2.ldpc_bb(dvbs2.C9_10, dvbs2.FECFRAME_NORMAL, dvbs2.MOD_OTHER)
        self.dvbs2_interleaver_bb_0 = dvbs2.interleaver_bb(dvbs2.MOD_16APSK, dvbs2.C_OTHER, dvbs2.FECFRAME_NORMAL)
        self.dvbs2_bch_bb_0 = dvbs2.bch_bb(dvbs2.C9_10, dvbs2.FECFRAME_NORMAL)
        self.dvbs2_bbscrambler_bb_0 = dvbs2.bbscrambler_bb(dvbs2.C9_10, dvbs2.FECFRAME_NORMAL)
        self.dvbs2_bbheader_bb_0 = dvbs2.bbheader_bb(dvbs2.C9_10, dvbs2.RO_0_20, dvbs2.FECFRAME_NORMAL)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1, "/run/shm/adv16apsk910.ts", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.dvbs2_bbheader_bb_0, 0))
        self.connect((self.dvbs2_bbheader_bb_0, 0), (self.dvbs2_bbscrambler_bb_0, 0))
        self.connect((self.dvbs2_bbscrambler_bb_0, 0), (self.dvbs2_bch_bb_0, 0))
        self.connect((self.dvbs2_bch_bb_0, 0), (self.dvbs2_ldpc_bb_0, 0))
        self.connect((self.dvbs2_ldpc_bb_0, 0), (self.dvbs2_interleaver_bb_0, 0))
        self.connect((self.dvbs2_interleaver_bb_0, 0), (self.dvbs2_modulator_bc_0, 0))
        self.connect((self.dvbs2_modulator_bc_0, 0), (self.dvbs2_physical_cc_0, 0))
        self.connect((self.dvbs2_physical_cc_0, 0), (self.fft_filter_xxx_0, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.osmosdr_sink_0, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))
Пример #2
0
def main(args):
    nargs = len(args)
    if nargs == 1:
        infile = args[0]
        outfile = None
    elif nargs == 2:
        infile = args[0]
        outfile = args[1]
    else:
        sys.stderr.write("Usage: dvbs2-blade.py input_file [output_file]\n");
        sys.exit(1)

    symbol_rate = 5000000
    samp_rate = symbol_rate * 2
    frame_size = dvbs2.FECFRAME_NORMAL
    constellation = dvbs2.MOD_16APSK
    code_rate = dvbs2.C9_10
    pilots = dvbs2.PILOTS_ON
    rolloff = dvbs2.RO_0_20
    gold_code = 0
    rrc_taps = 50
    center_freq = 1280000000
    txvga1_gain = -10
    txvga2_gain = 15
    bandwidth = 6000000

    if constellation == dvbs2.MOD_QPSK:
        if (   code_rate == dvbs2.C1_4
            or code_rate == dvbs2.C1_3
            or code_rate == dvbs2.C2_5
            or code_rate == dvbs2.C1_2
            or code_rate == dvbs2.C3_5
            or code_rate == dvbs2.C2_3
            or code_rate == dvbs2.C3_4
            or code_rate == dvbs2.C4_5
            or code_rate == dvbs2.C5_6
            or code_rate == dvbs2.C8_9
            or code_rate == dvbs2.C9_10
            or code_rate == dvbs2.C13_45
            or code_rate == dvbs2.C9_20
            or code_rate == dvbs2.C11_20
            or code_rate == dvbs2.C11_45
            or code_rate == dvbs2.C4_15
            or code_rate == dvbs2.C14_45
            or code_rate == dvbs2.C7_15
            or code_rate == dvbs2.C8_15
            or code_rate == dvbs2.C32_45):
            pass
        else:
            sys.stderr.write("Invalid code rate for QPSK\n");
            sys.exit(1)

    if constellation == dvbs2.MOD_8PSK:
        if (   code_rate == dvbs2.C3_5
            or code_rate == dvbs2.C2_3
            or code_rate == dvbs2.C3_4
            or code_rate == dvbs2.C5_6
            or code_rate == dvbs2.C8_9
            or code_rate == dvbs2.C9_10
            or code_rate == dvbs2.C23_36
            or code_rate == dvbs2.C25_36
            or code_rate == dvbs2.C13_18
            or code_rate == dvbs2.C7_15
            or code_rate == dvbs2.C8_15
            or code_rate == dvbs2.C26_45
            or code_rate == dvbs2.C32_45):
            pass
        else:
            sys.stderr.write("Invalid code rate for 8PSK\n");
            sys.exit(1)

    if constellation == dvbs2.MOD_8APSK:
        if (   code_rate == dvbs2.C100_180
            or code_rate == dvbs2.C104_180):
            pass
        else:
            sys.stderr.write("Invalid code rate for 8APSK\n");
            sys.exit(1)

    if constellation == dvbs2.MOD_16APSK:
        if (   code_rate == dvbs2.C2_3
            or code_rate == dvbs2.C3_4
            or code_rate == dvbs2.C4_5
            or code_rate == dvbs2.C5_6
            or code_rate == dvbs2.C8_9
            or code_rate == dvbs2.C9_10
            or code_rate == dvbs2.C26_45
            or code_rate == dvbs2.C3_5
            or code_rate == dvbs2.C28_45
            or code_rate == dvbs2.C23_36
            or code_rate == dvbs2.C25_36
            or code_rate == dvbs2.C13_18
            or code_rate == dvbs2.C140_180
            or code_rate == dvbs2.C154_180
            or code_rate == dvbs2.C7_15
            or code_rate == dvbs2.C8_15
            or code_rate == dvbs2.C26_45
            or code_rate == dvbs2.C3_5
            or code_rate == dvbs2.C32_45):
            pass
        else:
            sys.stderr.write("Invalid code rate for 16APSK\n");
            sys.exit(1)

    if constellation == dvbs2.MOD_8_8APSK:
        if (   code_rate == dvbs2.C90_180
            or code_rate == dvbs2.C96_180
            or code_rate == dvbs2.C100_180
            or code_rate == dvbs2.C18_30
            or code_rate == dvbs2.C20_30):
            pass
        else:
            sys.stderr.write("Invalid code rate for 8+8APSK\n");
            sys.exit(1)

    if constellation == dvbs2.MOD_32APSK:
        if (   code_rate == dvbs2.C3_4
            or code_rate == dvbs2.C4_5
            or code_rate == dvbs2.C5_6
            or code_rate == dvbs2.C8_9
            or code_rate == dvbs2.C9_10):
            pass
        else:
            sys.stderr.write("Invalid code rate for 32APSK\n");
            sys.exit(1)

    if constellation == dvbs2.MOD_4_12_16APSK:
        if (   code_rate == dvbs2.C2_3
            or code_rate == dvbs2.C32_45):
            pass
        else:
            sys.stderr.write("Invalid code rate for 4+12+16rbAPSK\n");
            sys.exit(1)

    if constellation == dvbs2.MOD_4_8_4_16APSK:
        if (   code_rate == dvbs2.C128_180
            or code_rate == dvbs2.C132_180
            or code_rate == dvbs2.C140_180):
            pass
        else:
            sys.stderr.write("Invalid code rate for 4+8+4+16APSK\n");
            sys.exit(1)

    if constellation == dvbs2.MOD_64APSK:
        if (   code_rate == dvbs2.C128_180):
            pass
        else:
            sys.stderr.write("Invalid code rate for 64APSK\n");
            sys.exit(1)

    if constellation == dvbs2.MOD_4_12_20_28APSK:
        if (   code_rate == dvbs2.C132_180):
            pass
        else:
            sys.stderr.write("Invalid code rate for 4+12+20+28APSK\n");
            sys.exit(1)

    if constellation == dvbs2.MOD_8_16_20_20APSK:
        if (   code_rate == dvbs2.C7_9
            or code_rate == dvbs2.C4_5
            or code_rate == dvbs2.C5_6):
            pass
        else:
            sys.stderr.write("Invalid code rate for 8+16+20+20APSK\n");
            sys.exit(1)

    if constellation == dvbs2.MOD_128APSK:
        if (   code_rate == dvbs2.C135_180
            or code_rate == dvbs2.C140_180):
            pass
        else:
            sys.stderr.write("Invalid code rate for 128APSK\n");
            sys.exit(1)

    if constellation == dvbs2.MOD_256APSK:
        if (   code_rate == dvbs2.C20_30
            or code_rate == dvbs2.C22_30
            or code_rate == dvbs2.C116_180
            or code_rate == dvbs2.C124_180
            or code_rate == dvbs2.C128_180
            or code_rate == dvbs2.C135_180):
            pass
        else:
            sys.stderr.write("Invalid code rate for 256APSK\n");
            sys.exit(1)

    if rolloff == dvbs2.RO_0_05:
        rrc_rolloff = 0.05
    elif rolloff == dvbs2.RO_0_10:
        rrc_rolloff = 0.10
    elif rolloff == dvbs2.RO_0_15:
        rrc_rolloff = 0.15
    elif rolloff == dvbs2.RO_0_20:
        rrc_rolloff = 0.20
    elif rolloff == dvbs2.RO_0_25:
        rrc_rolloff = 0.25
    elif rolloff == dvbs2.RO_0_35:
        rrc_rolloff = 0.35

    if (   code_rate == dvbs2.C3_5
        or code_rate == dvbs2.C4_5
        or code_rate == dvbs2.C5_6
        or code_rate == dvbs2.C7_9
        or code_rate == dvbs2.C13_18
        or code_rate == dvbs2.C23_36
        or code_rate == dvbs2.C25_36
        or code_rate == dvbs2.C26_45
        or code_rate == dvbs2.C28_45
        or code_rate == dvbs2.C90_180
        or code_rate == dvbs2.C96_180
        or code_rate == dvbs2.C100_180
        or code_rate == dvbs2.C116_180
        or code_rate == dvbs2.C124_180
        or code_rate == dvbs2.C128_180
        or code_rate == dvbs2.C135_180
        or code_rate == dvbs2.C140_180):
        code_rate_interleaver = code_rate
    else:
        code_rate_interleaver = dvbs2.C_OTHER

    if (   code_rate == dvbs2.C2_3
        or code_rate == dvbs2.C3_4
        or code_rate == dvbs2.C4_5
        or code_rate == dvbs2.C5_6
        or code_rate == dvbs2.C8_9
        or code_rate == dvbs2.C9_10
        or code_rate == dvbs2.C90_180
        or code_rate == dvbs2.C96_180
        or code_rate == dvbs2.C100_180
        or code_rate == dvbs2.C104_180
        or code_rate == dvbs2.C26_45
        or code_rate == dvbs2.C18_30
        or code_rate == dvbs2.C28_45
        or code_rate == dvbs2.C23_36
        or code_rate == dvbs2.C116_180
        or code_rate == dvbs2.C20_30
        or code_rate == dvbs2.C124_180
        or code_rate == dvbs2.C25_36
        or code_rate == dvbs2.C128_180
        or code_rate == dvbs2.C13_18
        or code_rate == dvbs2.C132_180
        or code_rate == dvbs2.C22_30
        or code_rate == dvbs2.C135_180
        or code_rate == dvbs2.C140_180
        or code_rate == dvbs2.C7_9
        or code_rate == dvbs2.C154_180):
        code_rate_modulator = code_rate
    else:
        code_rate_modulator = dvbs2.C_OTHER

    if constellation == dvbs2.MOD_128APSK:
        constellation_ldpc = constellation
    else:
        constellation_ldpc = dvbs2.MOD_OTHER

    tb = gr.top_block()

    src = blocks.file_source(gr.sizeof_char, infile, True)

    dvbs2_bbheader = dvbs2.bbheader_bb(code_rate, rolloff, frame_size)
    dvbs2_bbscrambler = dvbs2.bbscrambler_bb(code_rate, frame_size)
    dvbs2_bch = dvbs2.bch_bb(code_rate, frame_size)
    dvbs2_ldpc = dvbs2.ldpc_bb(code_rate, frame_size, constellation)
    dvbs2_interleaver = dvbs2.interleaver_bb(constellation, code_rate_interleaver, frame_size)
    dvbs2_modulator = dvbs2.modulator_bc(constellation, code_rate_modulator, frame_size)
    dvbs2_physical = dvbs2.physical_cc(constellation, code_rate, pilots, frame_size, gold_code)

    fft_filter = filter.fft_filter_ccc(1, (firdes.root_raised_cosine(1, samp_rate, samp_rate/2, rrc_rolloff, rrc_taps)), 1)
    fft_filter.declare_sample_delay(0)

    out = osmosdr.sink(args="bladerf=0,buffers=128,buflen=32768")
    out.set_sample_rate(samp_rate)
    out.set_center_freq(center_freq, 0)
    out.set_freq_corr(0, 0)
    out.set_gain(txvga2_gain, 0)
    out.set_bb_gain(txvga1_gain, 0)
    out.set_bandwidth(bandwidth, 0)

    tb.connect(src, dvbs2_bbheader)
    tb.connect(dvbs2_bbheader, dvbs2_bbscrambler)
    tb.connect(dvbs2_bbscrambler, dvbs2_bch)
    tb.connect(dvbs2_bch, dvbs2_ldpc)
    tb.connect(dvbs2_ldpc, dvbs2_interleaver)
    tb.connect(dvbs2_interleaver, dvbs2_modulator)
    tb.connect(dvbs2_modulator, dvbs2_physical)
    tb.connect(dvbs2_physical, fft_filter)
    tb.connect(fft_filter, out)

    if outfile:
        dst = blocks.file_sink(gr.sizeof_gr_complex, outfile)
        tb.connect(fft_filter, dst)

    tb.run()
Пример #3
0
    def __init__(self):
        gr.top_block.__init__(self, "Dvbs2 Tx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Dvbs2 Tx")
        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", "dvbs2_tx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.symbol_rate = symbol_rate = 5000000
        self.vga2_gain = vga2_gain = 10
        self.vga1_gain = vga1_gain = -8
        self.tx_gain = tx_gain = 50
        self.taps = taps = 100
        self.samp_rate = samp_rate = symbol_rate * 2
        self.rolloff = rolloff = 0.2
        self.center_freq = center_freq = 1280e6

        ##################################################
        # Blocks
        ##################################################
        self._vga2_gain_range = Range(0, 25, 1, 10, 200)
        self._vga2_gain_win = RangeWidget(self._vga2_gain_range, self.set_vga2_gain, "vga2_gain", "counter_slider", int)
        self.top_layout.addWidget(self._vga2_gain_win)
        self._vga1_gain_range = Range(-35, -4, 1, -8, 200)
        self._vga1_gain_win = RangeWidget(self._vga1_gain_range, self.set_vga1_gain, "vga1_gain", "counter_slider", int)
        self.top_layout.addWidget(self._vga1_gain_win)
        self._tx_gain_range = Range(0, 89, 1, 50, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, "tx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._tx_gain_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	center_freq, #fc
        	samp_rate, #bw
        	"", #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(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_freq_sink_x_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        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_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + 'bladerf=0,buffers=128,buflen=32768' )
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(center_freq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(vga2_gain, 0)
        self.osmosdr_sink_0.set_if_gain(0, 0)
        self.osmosdr_sink_0.set_bb_gain(vga1_gain, 0)
        self.osmosdr_sink_0.set_antenna('', 0)
        self.osmosdr_sink_0.set_bandwidth(6000000, 0)
          
        self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate/2, rolloff, taps)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.dvbs2_physical_cc_0 = dvbs2.physical_cc(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_16APSK, dvbs2.PILOTS_ON, 0)
        self.dvbs2_modulator_bc_0 = dvbs2.modulator_bc(dvbs2.FECFRAME_NORMAL,
        dvbs2.C9_10, dvbs2.MOD_16APSK)
        self.dvbs2_ldpc_bb_0 = dvbs2.ldpc_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_OTHER)
        self.dvbs2_interleaver_bb_0 = dvbs2.interleaver_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.MOD_16APSK)
        self.dvbs2_bch_bb_0 = dvbs2.bch_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10)
        self.dvbs2_bbscrambler_bb_0 = dvbs2.bbscrambler_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10)
        self.dvbs2_bbheader_bb_0 = dvbs2.bbheader_bb(dvbs2.FECFRAME_NORMAL, dvbs2.C9_10, dvbs2.RO_0_20)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/run/shm/adv16apsk910.ts', True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.dvbs2_bbheader_bb_0, 0))    
        self.connect((self.dvbs2_bbheader_bb_0, 0), (self.dvbs2_bbscrambler_bb_0, 0))    
        self.connect((self.dvbs2_bbscrambler_bb_0, 0), (self.dvbs2_bch_bb_0, 0))    
        self.connect((self.dvbs2_bch_bb_0, 0), (self.dvbs2_ldpc_bb_0, 0))    
        self.connect((self.dvbs2_interleaver_bb_0, 0), (self.dvbs2_modulator_bc_0, 0))    
        self.connect((self.dvbs2_ldpc_bb_0, 0), (self.dvbs2_interleaver_bb_0, 0))    
        self.connect((self.dvbs2_modulator_bc_0, 0), (self.dvbs2_physical_cc_0, 0))    
        self.connect((self.dvbs2_physical_cc_0, 0), (self.fft_filter_xxx_0, 0))    
        self.connect((self.fft_filter_xxx_0, 0), (self.osmosdr_sink_0, 0))    
        self.connect((self.fft_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0))