def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Dvbs2 Tx") ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 5000000 self.taps = taps = 100 self.samp_rate = samp_rate = symbol_rate * 2 self.rolloff = rolloff = 0.2 self.frequency = frequency = 1280e6 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=frequency, 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.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.dtv_dvbs2_physical_cc_0 = dtv.dvbs2_physical_cc(dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_16APSK, dtv.PILOTS_ON, 0) self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc(dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_16APSK, dtv.INTERPOLATION_OFF) self.dtv_dvbs2_interleaver_bb_0 = dtv.dvbs2_interleaver_bb(dtv.FECFRAME_NORMAL, dtv.C_OTHER, dtv.MOD_16APSK) self.dtv_dvb_ldpc_bb_0 = dtv.dvb_ldpc_bb(dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_OTHER) self.dtv_dvb_bch_bb_0 = dtv.dvb_bch_bb(dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, ) self.dtv_dvb_bbscrambler_bb_0 = dtv.dvb_bbscrambler_bb(dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, ) self.dtv_dvb_bbheader_bb_0 = dtv.dvb_bbheader_bb(dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.RO_0_20, dtv.INPUTMODE_NORMAL, dtv.INBAND_OFF, 168, 4000000) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/Volumes/work/run/shm/adv16apsk910.ts", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dtv_dvb_bbheader_bb_0, 0)) self.connect((self.dtv_dvb_bbheader_bb_0, 0), (self.dtv_dvb_bbscrambler_bb_0, 0)) self.connect((self.dtv_dvb_bbscrambler_bb_0, 0), (self.dtv_dvb_bch_bb_0, 0)) self.connect((self.dtv_dvb_bch_bb_0, 0), (self.dtv_dvb_ldpc_bb_0, 0)) self.connect((self.dtv_dvb_ldpc_bb_0, 0), (self.dtv_dvbs2_interleaver_bb_0, 0)) self.connect((self.dtv_dvbs2_interleaver_bb_0, 0), (self.dtv_dvbs2_modulator_bc_0, 0)) self.connect((self.dtv_dvbs2_modulator_bc_0, 0), (self.dtv_dvbs2_physical_cc_0, 0)) self.connect((self.dtv_dvbs2_physical_cc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self, constellation, frame_type, code_rate): gr.top_block.__init__(self, "Dvbs2 Tx") ################################################## # Parameters ################################################## # Header is 10 bytes try: frame_length = 1.0 * BBFRAME_LENGTH[frame_type][code_rate] - 80 except KeyError: raise UnknownFrameLength(frame_type, code_rate) # print("Base frame length: %s" % frame_length) frame_length /= 8 # print("Base frame length: %s" % frame_length) assert int( frame_length ) == 1.0 * frame_length, "Frame length {0} won't work because {0}/8 = {1}!".format( frame_length, frame_length / 8.0) frame_length = int(frame_length) self.frame_length = frame_length bits_per_input, bits_per_output = get_ratio(constellation) ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 5000000 self.taps = taps = 100 self.samp_rate = samp_rate = symbol_rate * 2 self.rolloff = rolloff = 0.2 self.noise = noise = 0 self.gain = gain = 1 self.center_freq = center_freq = 1280e6 ################################################## # Blocks ################################################## self.ldpc_encoder_input = blocks.file_sink(gr.sizeof_char * 1, 'ldpc_encoder_input.bin', False) self.ldpc_encoder_input.set_unbuffered(False) self.fir_filter_xxx_0_0 = filter.fir_filter_ccc( 1, (numpy.conj([ 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j ] + [ 0, ] * (89 - 32)))) self.fir_filter_xxx_0_0.declare_sample_delay(0) self.fir_filter_xxx_0 = filter.fir_filter_ccc(1, (numpy.conj([ 0, ] * (89 - 25) + [ 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 - 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 + 1.00000j, 0.00000 + 0.00000j ]))) self.fir_filter_xxx_0.declare_sample_delay(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.dtv_dvbs2_physical_cc_0 = dtv.dvbs2_physical_cc( frame_type, code_rate, dtv.MOD_BPSK, dtv.PILOTS_ON, 0) self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc( frame_type, code_rate, dtv.MOD_BPSK, dtv.INTERPOLATION_OFF) self.dtv_dvbs2_interleaver_bb_0 = dtv.dvbs2_interleaver_bb( frame_type, code_rate, constellation) self.dtv_dvb_ldpc_bb_0 = dtv.dvb_ldpc_bb(dtv.STANDARD_DVBS2, frame_type, code_rate, dtv.MOD_OTHER) self.dtv_dvb_bch_bb_0 = dtv.dvb_bch_bb(dtv.STANDARD_DVBS2, frame_type, code_rate) self.dtv_dvb_bbscrambler_bb_0 = dtv.dvb_bbscrambler_bb( dtv.STANDARD_DVBS2, frame_type, code_rate) self.dtv_dvb_bbheader_bb_0 = dtv.dvb_bbheader_bb( dtv.STANDARD_DVBS2, frame_type, code_rate, dtv.RO_0_20, dtv.INPUTMODE_NORMAL, dtv.INBAND_OFF, 168, 4000000) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( 2, math.pi / 100.0, (firdes.root_raised_cosine( 2 * 32, 32, 1.0 / float(2), 0.35, 11 * 2 * 32)), 32, 16, 1.5, 1) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( math.pi / 100.0, 4, False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate / 10, True) self.blocks_sub_xx_0 = blocks.sub_cc(1) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( bits_per_input, bits_per_output, "", False, gr.GR_MSB_FIRST) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((gain, )) self.blocks_max_xx_0 = blocks.max_ff(1, 1) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_float * 1, 'output.bin', False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_add_xx_2 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.bit_interleaver_output_packed = blocks.file_sink( gr.sizeof_char * 1, 'bit_interleaver_output_packed.bin', False) self.bit_interleaver_output_packed.set_unbuffered(False) self.bit_interleaver_output = blocks.file_sink( gr.sizeof_char * 1, 'bit_interleaver_output.bin', False) self.bit_interleaver_output.set_unbuffered(False) self.bit_interleaver_input = blocks.file_sink( gr.sizeof_char * 1, 'bit_interleaver_input.bin', False) self.bit_interleaver_input.set_unbuffered(False) self.bch_encoder_input = blocks.file_sink(gr.sizeof_char * 1, 'bch_encoder_input.bin', False) self.bch_encoder_input.set_unbuffered(False) self.bb_scrambler_input_0 = blocks.file_sink(gr.sizeof_char * 1, 'bb_scrambler_input.bin', False) self.bb_scrambler_input_0.set_unbuffered(False) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 255, frame_length)), False) self.analog_noise_source_x_1 = analog.noise_source_c( analog.GR_GAUSSIAN, noise, 0) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0) self.analog_agc_xx_0.set_max_gain(8192) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.analog_noise_source_x_1, 0), (self.blocks_add_xx_2, 1)) self.connect((self.analog_random_source_x_0, 0), (self.dtv_dvb_bbheader_bb_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.blocks_add_xx_2, 0), (self.analog_agc_xx_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_max_xx_0, 1)) self.connect((self.blocks_complex_to_mag_0_0, 0), (self.blocks_max_xx_0, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_max_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.fir_filter_xxx_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.bit_interleaver_output_packed, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_complex_to_mag_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_delay_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.dtv_dvb_bbheader_bb_0, 0), (self.bb_scrambler_input_0, 0)) self.connect((self.dtv_dvb_bbheader_bb_0, 0), (self.dtv_dvb_bbscrambler_bb_0, 0)) self.connect((self.dtv_dvb_bbscrambler_bb_0, 0), (self.bch_encoder_input, 0)) self.connect((self.dtv_dvb_bbscrambler_bb_0, 0), (self.dtv_dvb_bch_bb_0, 0)) self.connect((self.dtv_dvb_bch_bb_0, 0), (self.dtv_dvb_ldpc_bb_0, 0)) self.connect((self.dtv_dvb_bch_bb_0, 0), (self.ldpc_encoder_input, 0)) self.connect((self.dtv_dvb_ldpc_bb_0, 0), (self.bit_interleaver_input, 0)) self.connect((self.dtv_dvb_ldpc_bb_0, 0), (self.dtv_dvbs2_interleaver_bb_0, 0)) self.connect((self.dtv_dvbs2_interleaver_bb_0, 0), (self.bit_interleaver_output, 0)) self.connect((self.dtv_dvbs2_interleaver_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.dtv_dvbs2_interleaver_bb_0, 0), (self.dtv_dvbs2_modulator_bc_0, 0)) self.connect((self.dtv_dvbs2_modulator_bc_0, 0), (self.dtv_dvbs2_physical_cc_0, 0)) self.connect((self.dtv_dvbs2_physical_cc_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.blocks_add_xx_2, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.fir_filter_xxx_0_0, 0), (self.blocks_sub_xx_0, 1))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Dvbs Tx") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 1000000 self.username = username = os.environ.get('USER') self.samp_rate = samp_rate = symbol_rate * 2 self.rrc_taps = rrc_taps = 100 self.frequency = frequency = 2440000000 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=frequency, 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.trellis_encoder_xx_0 = trellis.encoder_bb( trellis.fsm(1, 2, (0171, 0133)), 0, 0) if False else trellis.encoder_bb( trellis.fsm(1, 2, (0171, 0133)), 0) self._symbol_rate_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.symbol_rate, callback=self.set_symbol_rate, label='symbol_rate', choices=[250000, 333000, 500000, 1000000, 1200000, 1500000], labels=[ "250kS/s", "333kS/s", "500 kS/s", "1000kS/s", "1200kS/s", "1500kS/s" ], style=wx.RA_HORIZONTAL, ) self.Add(self._symbol_rate_chooser) self.pluto_sink_0 = iio.pluto_sink('', frequency, samp_rate, 20000000, 0x8000, False, 10.0, '', True) self.fft_filter_xxx_0 = filter.fft_filter_ccc( 1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate / 2, 0.35, rrc_taps)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.fec_puncture_xx_0 = fec.puncture_bb(14, 0b11010101100110, 0) self.dtv_dvbt_reed_solomon_enc_0 = dtv.dvbt_reed_solomon_enc( 2, 8, 0x11d, 255, 239, 8, 51, 8) self.dtv_dvbt_energy_dispersal_0 = dtv.dvbt_energy_dispersal(1) self.dtv_dvbt_convolutional_interleaver_0 = dtv.dvbt_convolutional_interleaver( 136, 12, 17) self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc( dtv.FECFRAME_NORMAL, dtv.C5_6, dtv.MOD_QPSK, dtv.INTERPOLATION_ON) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_MSB_FIRST) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(2) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, "/media/" + username + "/PlutoSDR/rpidatv.ts", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dtv_dvbt_energy_dispersal_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.dtv_dvbs2_modulator_bc_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.trellis_encoder_xx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.fec_puncture_xx_0, 0)) self.connect((self.dtv_dvbs2_modulator_bc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.dtv_dvbt_convolutional_interleaver_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.dtv_dvbt_energy_dispersal_0, 0), (self.dtv_dvbt_reed_solomon_enc_0, 0)) self.connect((self.dtv_dvbt_reed_solomon_enc_0, 0), (self.dtv_dvbt_convolutional_interleaver_0, 0)) self.connect((self.fec_puncture_xx_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.pluto_sink_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.trellis_encoder_xx_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Dvbs2 Tx") ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 5000000 self.taps = taps = 100 self.samp_rate = samp_rate = symbol_rate * 2 self.rolloff = rolloff = 0.2 self.frequency = frequency = 1280e6 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=frequency, 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.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.dtv_dvbs2_physical_cc_0 = dtv.dvbs2_physical_cc( dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_16APSK, dtv.PILOTS_ON, 0) self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc( dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_16APSK, dtv.INTERPOLATION_OFF) self.dtv_dvbs2_interleaver_bb_0 = dtv.dvbs2_interleaver_bb( dtv.FECFRAME_NORMAL, dtv.C_OTHER, dtv.MOD_16APSK) self.dtv_dvb_ldpc_bb_0 = dtv.dvb_ldpc_bb(dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_OTHER) self.dtv_dvb_bch_bb_0 = dtv.dvb_bch_bb( dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, ) self.dtv_dvb_bbscrambler_bb_0 = dtv.dvb_bbscrambler_bb( dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, ) self.dtv_dvb_bbheader_bb_0 = dtv.dvb_bbheader_bb( dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.RO_0_20, dtv.INPUTMODE_NORMAL, dtv.INBAND_OFF, 168, 4000000) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, "/Volumes/work/run/shm/adv16apsk910.ts", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dtv_dvb_bbheader_bb_0, 0)) self.connect((self.dtv_dvb_bbheader_bb_0, 0), (self.dtv_dvb_bbscrambler_bb_0, 0)) self.connect((self.dtv_dvb_bbscrambler_bb_0, 0), (self.dtv_dvb_bch_bb_0, 0)) self.connect((self.dtv_dvb_bch_bb_0, 0), (self.dtv_dvb_ldpc_bb_0, 0)) self.connect((self.dtv_dvb_ldpc_bb_0, 0), (self.dtv_dvbs2_interleaver_bb_0, 0)) self.connect((self.dtv_dvbs2_interleaver_bb_0, 0), (self.dtv_dvbs2_modulator_bc_0, 0)) self.connect((self.dtv_dvbs2_modulator_bc_0, 0), (self.dtv_dvbs2_physical_cc_0, 0)) self.connect((self.dtv_dvbs2_physical_cc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self): gr.top_block.__init__(self, "atcs") Qt.QWidget.__init__(self) self.setWindowTitle("atcs") 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", "atcs") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 10762200 self.samp_rate = samp_rate = 32000 self.center_freq = center_freq = 429000000 ################################################## # Blocks ################################################## 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 ) 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(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) 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 range(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_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.fft_filter_xxx_0 = filter.fft_filter_ccf(1, firdes.root_raised_cosine(0.11, symbol_rate, symbol_rate/2, 0.1152, 200), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc( dtv.FECFRAME_NORMAL, dtv.C1_4, dtv.MOD_8VSB, dtv.INTERPOLATION_OFF) self.dtv_atsc_trellis_encoder_0 = dtv.atsc_trellis_encoder() self.dtv_atsc_rs_encoder_0 = dtv.atsc_rs_encoder() self.dtv_atsc_randomizer_0 = dtv.atsc_randomizer() self.dtv_atsc_pad_0 = dtv.atsc_pad() self.dtv_atsc_interleaver_0 = dtv.atsc_interleaver() self.dtv_atsc_field_sync_mux_0 = dtv.atsc_field_sync_mux() self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_char*1, 1024) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, symbol_rate,True) self.blocks_rotator_cc_0 = blocks.rotator_cc(-1.5708) self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_char, 832, 1024, 0) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/home/supernode/Downloads/Glen.ts', True, 0, 0) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, '/home/supernode/Work/microwave_experiments/signal_block/mantap.ts', False) self.blocks_file_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dtv_atsc_pad_0, 0)) self.connect((self.blocks_keep_m_in_n_0, 0), (self.dtv_dvbs2_modulator_bc_0, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_keep_m_in_n_0, 0)) self.connect((self.dtv_atsc_field_sync_mux_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.dtv_atsc_interleaver_0, 0), (self.dtv_atsc_trellis_encoder_0, 0)) self.connect((self.dtv_atsc_pad_0, 0), (self.dtv_atsc_randomizer_0, 0)) self.connect((self.dtv_atsc_randomizer_0, 0), (self.dtv_atsc_rs_encoder_0, 0)) self.connect((self.dtv_atsc_rs_encoder_0, 0), (self.dtv_atsc_interleaver_0, 0)) self.connect((self.dtv_atsc_trellis_encoder_0, 0), (self.dtv_atsc_field_sync_mux_0, 0)) self.connect((self.dtv_dvbs2_modulator_bc_0, 0), (self.blocks_rotator_cc_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.blocks_throttle_0, 0))
def __init__(self): gr.top_block.__init__(self, "DVB-S B200 Transmitter") Qt.QWidget.__init__(self) self.setWindowTitle("DVB-S B200 Transmitter") 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", "dvbs_tx_var_v4") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## #self.symbol_rate = symbol_rate = 1000000 self.symbol_rate = symbol_rate self.variable_qtgui_push_button_0 = variable_qtgui_push_button_0 = 1 self.tx_gain = tx_gain = 45 self.symbol_rate_display = symbol_rate_display = symbol_rate/1000 self.samp_rate = samp_rate = symbol_rate * 2 self.rrc_taps = rrc_taps = 100 #self.fec_display = fec_display = "7/8" self.fec_display = fec_display self.center_freq = center_freq = 1280e6 ################################################## # Blocks ################################################## self._tx_gain_range = Range(0, 89, 1, 65, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'Tx Gain [dB]', "counter_slider", float) self.top_grid_layout.addWidget(self._tx_gain_win, 9,0,1,5) self._center_freq_options = (50e6, 437e6, 1280e6, 2400.0e6, ) self._center_freq_labels = ('50 MHz', '437 MHz', "1'280 MHz", "10'400 MHz", ) self._center_freq_group_box = Qt.QGroupBox('TX Frequency') self._center_freq_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._center_freq_button_group = variable_chooser_button_group() self._center_freq_group_box.setLayout(self._center_freq_box) for i, label in enumerate(self._center_freq_labels): radio_button = Qt.QRadioButton(label) self._center_freq_box.addWidget(radio_button) self._center_freq_button_group.addButton(radio_button, i) self._center_freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._center_freq_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._center_freq_options.index(i))) self._center_freq_callback(self.center_freq) self._center_freq_button_group.buttonClicked[int].connect( lambda i: self.set_center_freq(self._center_freq_options[i])) self.top_grid_layout.addWidget(self._center_freq_group_box, 0,0, 1,5) _variable_qtgui_push_button_0_push_button = Qt.QPushButton('TRANSMIT') self._variable_qtgui_push_button_0_choices = {'Pressed': 0, 'Released': 1} _variable_qtgui_push_button_0_push_button.pressed.connect(lambda: self.set_variable_qtgui_push_button_0(self._variable_qtgui_push_button_0_choices['Pressed'])) _variable_qtgui_push_button_0_push_button.released.connect(lambda: self.set_variable_qtgui_push_button_0(self._variable_qtgui_push_button_0_choices['Released'])) self.top_grid_layout.addWidget(_variable_qtgui_push_button_0_push_button, 10,0,1,5) self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join(("send_frame_size=65536,num_send_frames=256,master_clock_rate=" + str(samp_rate*2), "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0.set_clock_source('external', 0) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_center_freq(uhd.tune_request(center_freq, ((symbol_rate * 1.35) / 2 ) + 1e5), 0) self.uhd_usrp_sink_0_0.set_gain(tx_gain, 0) self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0) self._symbol_rate_display_tool_bar = Qt.QToolBar(self) if "{0:,}".format: self._symbol_rate_display_formatter = "{0:,}".format else: self._symbol_rate_display_formatter = lambda x: x self._symbol_rate_display_tool_bar.addWidget(Qt.QLabel(' Symbol Rate [ks/s] '+": ")) self._symbol_rate_display_label = Qt.QLabel(str(self._symbol_rate_display_formatter(self.symbol_rate_display))) self._symbol_rate_display_tool_bar.addWidget(self._symbol_rate_display_label) self.top_grid_layout.addWidget(self._symbol_rate_display_tool_bar, 1,1,1,1) 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, -20) 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.1) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: 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_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 3,0,6,5) self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate/2, 0.35, rrc_taps)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self._fec_display_tool_bar = Qt.QToolBar(self) if "": self._fec_display_formatter = "" else: self._fec_display_formatter = lambda x: x self._fec_display_tool_bar.addWidget(Qt.QLabel('FEC '+": ")) self._fec_display_label = Qt.QLabel(str(self._fec_display_formatter(self.fec_display))) self._fec_display_tool_bar.addWidget(self._fec_display_label) self.top_grid_layout.addWidget(self._fec_display_tool_bar, 1,3,1,2) self.dtv_dvbt_reed_solomon_enc_0 = dtv.dvbt_reed_solomon_enc(2, 8, 0x11d, 255, 239, 8, 51, 8) self.dtv_dvbt_inner_coder_0 = dtv.dvbt_inner_coder(1, 1512, dtv.MOD_QPSK, dtv.NH, dtv.C5_6) self.dtv_dvbt_energy_dispersal_0 = dtv.dvbt_energy_dispersal(1) self.dtv_dvbt_convolutional_interleaver_0 = dtv.dvbt_convolutional_interleaver(136, 12, 17) self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc(dtv.FECFRAME_NORMAL, dtv.C5_6, dtv.MOD_QPSK, dtv.INTERPOLATION_ON) self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_char*1, 1512) fifo_path = os.path.dirname(os.path.realpath(__file__)) + '/fifo.ts' self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_char*1, fifo_path, True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0_0, 0), (self.dtv_dvbt_energy_dispersal_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.dtv_dvbs2_modulator_bc_0, 0)) self.connect((self.dtv_dvbs2_modulator_bc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.dtv_dvbt_convolutional_interleaver_0, 0), (self.dtv_dvbt_inner_coder_0, 0)) self.connect((self.dtv_dvbt_energy_dispersal_0, 0), (self.dtv_dvbt_reed_solomon_enc_0, 0)) self.connect((self.dtv_dvbt_inner_coder_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.dtv_dvbt_reed_solomon_enc_0, 0), (self.dtv_dvbt_convolutional_interleaver_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.uhd_usrp_sink_0_0, 0))
def __init__(self, constellation, frame_type, code_rate): gr.top_block.__init__(self, "Dvbs2 Tx") ################################################## # Parameters ################################################## # Header is 10 bytes try: frame_length = 1.0 * BBFRAME_LENGTH[frame_type][code_rate] - 80 except KeyError: raise UnknownFrameLength(frame_type, code_rate) # print("Base frame length: %s" % frame_length) frame_length /= 8 # print("Base frame length: %s" % frame_length) assert ( int(frame_length) == 1.0 * frame_length ), "Frame length {0} won't work because {0}/8 = {1}!".format( frame_length, frame_length / 8.0 ) frame_length = int(frame_length) self.frame_length = frame_length bits_per_input, bits_per_output = get_ratio(constellation) ################################################## # Variables ################################################## self.frame_type = frame_type self.constellation = constellation self.symbol_rate = symbol_rate = 5000000 self.taps = taps = 100 self.samp_rate = samp_rate = symbol_rate * 2 self.rolloff = rolloff = 0.2 self.noise = noise = 0 self.gain = gain = 1 self.center_freq = center_freq = 1280e6 self.physical_layer_gold_code = physical_layer_gold_code = 0 self.physical_layer_header_length = physical_layer_header_length = 90 ################################################## # Blocks ################################################## self.undo_bit_stuffing_pilots_off = blocks.keep_m_in_n( gr.sizeof_gr_complex, 1, 2, 0 ) self.undo_bit_stuffing_pilots_on = blocks.keep_m_in_n( gr.sizeof_gr_complex, 1, 2, 0 ) self.plframe_pilots_on_float = blocks.file_sink( gr.sizeof_gr_complex * 1, "plframe_pilots_on_float.bin", False ) self.plframe_pilots_on_float.set_unbuffered(False) self.plframe_pilots_on_fixed_point = blocks.file_sink( gr.sizeof_short * 1, "plframe_pilots_on_fixed_point.bin", False ) self.plframe_pilots_on_fixed_point.set_unbuffered(False) self.plframe_pilots_off_float = blocks.file_sink( gr.sizeof_gr_complex * 1, "plframe_pilots_off_float.bin", False ) self.plframe_pilots_off_float.set_unbuffered(False) self.plframe_pilots_off_fixed_point = blocks.file_sink( gr.sizeof_short * 1, "plframe_pilots_off_fixed_point.bin", False ) self.plframe_pilots_off_fixed_point.set_unbuffered(False) self.plframe_payload_pilots_on_float = blocks.file_sink( gr.sizeof_gr_complex * 1, "plframe_payload_pilots_on_float.bin", False ) self.plframe_payload_pilots_on_float.set_unbuffered(False) self.plframe_payload_pilots_on_fixed_point = blocks.file_sink( gr.sizeof_short * 1, "plframe_payload_pilots_on_fixed_point.bin", False ) self.plframe_payload_pilots_on_fixed_point.set_unbuffered(False) self.plframe_payload_pilots_off_float = blocks.file_sink( gr.sizeof_gr_complex * 1, "plframe_payload_pilots_off_float.bin", False ) self.plframe_payload_pilots_off_float.set_unbuffered(False) self.plframe_payload_pilots_off_fixed_point = blocks.file_sink( gr.sizeof_short * 1, "plframe_payload_pilots_off_fixed_point.bin", False ) self.plframe_payload_pilots_off_fixed_point.set_unbuffered(False) self.plframe_header_pilots_on_float = blocks.file_sink( gr.sizeof_gr_complex * 1, "plframe_header_pilots_on_float.bin", False ) self.plframe_header_pilots_on_float.set_unbuffered(False) self.plframe_header_pilots_on_fixed_point = blocks.file_sink( gr.sizeof_short * 1, "plframe_header_pilots_on_fixed_point.bin", False ) self.plframe_header_pilots_on_fixed_point.set_unbuffered(False) self.plframe_header_pilots_off_float = blocks.file_sink( gr.sizeof_gr_complex * 1, "plframe_header_pilots_off_float.bin", False ) self.plframe_header_pilots_off_float.set_unbuffered(False) self.plframe_header_pilots_off_fixed_point = blocks.file_sink( gr.sizeof_short * 1, "plframe_header_pilots_off_fixed_point.bin", False ) self.plframe_header_pilots_off_fixed_point.set_unbuffered(False) self.pl_complex_to_float_1 = blocks.complex_to_float(1) self.pl_complex_to_float_0_1 = blocks.complex_to_float(1) self.pl_complex_to_float_0_0_0 = blocks.complex_to_float(1) self.pl_complex_to_float_0_0 = blocks.complex_to_float(1) self.pl_complex_to_float_0 = blocks.complex_to_float(1) self.pl_complex_to_float = blocks.complex_to_float(1) self.organize = blocks.multiply_const_vcc((1,)) self.ldpc_encoder_input = blocks.file_sink( gr.sizeof_char * 1, "ldpc_encoder_input.bin", False ) self.ldpc_encoder_input.set_unbuffered(False) self.keep_plframe_payload_pilots_off = blocks.keep_m_in_n( gr.sizeof_gr_complex, self.get_physical_layer_frame_size(dtv.PILOTS_OFF) - physical_layer_header_length, self.get_physical_layer_frame_size(dtv.PILOTS_OFF), 0, ) self.keep_plframe_payload_pilots_on = blocks.keep_m_in_n( gr.sizeof_gr_complex, self.get_physical_layer_frame_size(dtv.PILOTS_ON) - physical_layer_header_length, self.get_physical_layer_frame_size(dtv.PILOTS_ON), 0, ) self.keep_plframe_header_pilots_off = blocks.keep_m_in_n( gr.sizeof_gr_complex, physical_layer_header_length, self.get_physical_layer_frame_size(dtv.PILOTS_OFF), 0, ) self.keep_plframe_header_pilots_on = blocks.keep_m_in_n( gr.sizeof_gr_complex, physical_layer_header_length, self.get_physical_layer_frame_size(dtv.PILOTS_ON), 0, ) self.dtv_dvbs2_physical_cc_with_pilots = dtv.dvbs2_physical_cc( frame_type, code_rate, constellation, dtv.PILOTS_ON, physical_layer_gold_code, ) self.dtv_dvbs2_physical_cc_pilots_off = dtv.dvbs2_physical_cc( frame_type, code_rate, constellation, dtv.PILOTS_OFF, physical_layer_gold_code, ) self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc( frame_type, code_rate, constellation, dtv.INTERPOLATION_OFF ) self.dtv_dvbs2_interleaver_bb_0 = dtv.dvbs2_interleaver_bb( frame_type, code_rate, constellation ) self.dtv_dvb_ldpc_bb_0 = dtv.dvb_ldpc_bb( dtv.STANDARD_DVBS2, frame_type, code_rate, dtv.MOD_OTHER ) self.dtv_dvb_bch_bb_0 = dtv.dvb_bch_bb( dtv.STANDARD_DVBS2, frame_type, code_rate ) self.dtv_dvb_bbscrambler_bb_0 = dtv.dvb_bbscrambler_bb( dtv.STANDARD_DVBS2, frame_type, code_rate ) self.dtv_dvb_bbheader_bb_0 = dtv.dvb_bbheader_bb( dtv.STANDARD_DVBS2, frame_type, code_rate, dtv.RO_0_20, dtv.INPUTMODE_NORMAL, dtv.INBAND_OFF, 168, 4000000, ) self.blocks_stream_mux_0_2 = blocks.stream_mux(gr.sizeof_short * 1, (1, 1)) self.blocks_stream_mux_0_1 = blocks.stream_mux(gr.sizeof_short * 1, (1, 1)) self.blocks_stream_mux_0_0_1 = blocks.stream_mux(gr.sizeof_short * 1, (1, 1)) self.blocks_stream_mux_0_0_0_0 = blocks.stream_mux(gr.sizeof_short * 1, (1, 1)) self.blocks_stream_mux_0_0_0 = blocks.stream_mux(gr.sizeof_short * 1, (1, 1)) self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_short * 1, (1, 1)) self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_short * 1, (1, 1)) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( bits_per_input, bits_per_output, "", False, gr.GR_MSB_FIRST ) self.blocks_float_to_short_0_3 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_2 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_1_1 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_1_0_0 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_1_0 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_1 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_0_2 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_0_1 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_0_0_1 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_0_0_0_0 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_0_0_0 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_0_0 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0_0 = blocks.float_to_short(1, 32768) self.blocks_float_to_short_0 = blocks.float_to_short(1, 32768) self.bit_mapper_output_fixed = blocks.file_sink( gr.sizeof_short * 1, "bit_mapper_output_fixed.bin", False ) self.bit_mapper_output_fixed.set_unbuffered(False) self.bit_mapper_output_float = blocks.file_sink( gr.sizeof_gr_complex * 1, "bit_mapper_output_float.bin", False ) self.bit_mapper_output_float.set_unbuffered(False) self.bit_mapper_complex_to_float = blocks.complex_to_float(1) self.bit_interleaver_output_packed = blocks.file_sink( gr.sizeof_char * 1, "bit_interleaver_output_packed.bin", False ) self.bit_interleaver_output_packed.set_unbuffered(False) self.bit_interleaver_output = blocks.file_sink( gr.sizeof_char * 1, "bit_interleaver_output.bin", False ) self.bit_interleaver_output.set_unbuffered(False) self.bit_interleaver_input = blocks.file_sink( gr.sizeof_char * 1, "bit_interleaver_input.bin", False ) self.bit_interleaver_input.set_unbuffered(False) self.bch_encoder_input = blocks.file_sink( gr.sizeof_char * 1, "bch_encoder_input.bin", False ) self.bch_encoder_input.set_unbuffered(False) self.bb_scrambler_input_0 = blocks.file_sink( gr.sizeof_char * 1, "bb_scrambler_input.bin", False ) self.bb_scrambler_input_0.set_unbuffered(False) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 255, self.frame_length)), False ) ################################################## # Connections ################################################## self.connect( (self.analog_random_source_x_0, 0), (self.dtv_dvb_bbheader_bb_0, 0) ) self.connect( (self.bit_mapper_complex_to_float, 0), (self.blocks_float_to_short_0_0_2, 0) ) self.connect( (self.bit_mapper_complex_to_float, 1), (self.blocks_float_to_short_0_3, 0) ) self.connect((self.blocks_float_to_short_0, 0), (self.blocks_stream_mux_0, 1)) self.connect((self.blocks_float_to_short_0_0, 0), (self.blocks_stream_mux_0, 0)) self.connect( (self.blocks_float_to_short_0_0_0, 0), (self.blocks_stream_mux_0_0, 0) ) self.connect( (self.blocks_float_to_short_0_0_0_0, 0), (self.blocks_stream_mux_0_0_0, 0) ) self.connect( (self.blocks_float_to_short_0_0_0_0_0, 0), (self.blocks_stream_mux_0_0_0_0, 0), ) self.connect( (self.blocks_float_to_short_0_0_0_1, 0), (self.blocks_stream_mux_0_0_1, 0) ) self.connect( (self.blocks_float_to_short_0_0_1, 0), (self.blocks_stream_mux_0_1, 0) ) self.connect( (self.blocks_float_to_short_0_0_2, 0), (self.blocks_stream_mux_0_2, 0) ) self.connect( (self.blocks_float_to_short_0_1, 0), (self.blocks_stream_mux_0_0, 1) ) self.connect( (self.blocks_float_to_short_0_1_0, 0), (self.blocks_stream_mux_0_0_0, 1) ) self.connect( (self.blocks_float_to_short_0_1_0_0, 0), (self.blocks_stream_mux_0_0_0_0, 1) ) self.connect( (self.blocks_float_to_short_0_1_1, 0), (self.blocks_stream_mux_0_0_1, 1) ) self.connect( (self.blocks_float_to_short_0_2, 0), (self.blocks_stream_mux_0_1, 1) ) self.connect( (self.blocks_float_to_short_0_3, 0), (self.blocks_stream_mux_0_2, 1) ) self.connect( (self.blocks_repack_bits_bb_0, 0), (self.bit_interleaver_output_packed, 0) ) self.connect( (self.blocks_stream_mux_0, 0), (self.plframe_pilots_on_fixed_point, 0) ) self.connect( (self.blocks_stream_mux_0_0, 0), (self.plframe_payload_pilots_on_fixed_point, 0), ) self.connect( (self.blocks_stream_mux_0_0_0, 0), (self.plframe_header_pilots_on_fixed_point, 0), ) self.connect( (self.blocks_stream_mux_0_0_0_0, 0), (self.plframe_header_pilots_off_fixed_point, 0), ) self.connect( (self.blocks_stream_mux_0_0_1, 0), (self.plframe_payload_pilots_off_fixed_point, 0), ) self.connect( (self.blocks_stream_mux_0_1, 0), (self.plframe_pilots_off_fixed_point, 0) ) self.connect((self.blocks_stream_mux_0_2, 0), (self.bit_mapper_output_fixed, 0)) self.connect((self.dtv_dvb_bbheader_bb_0, 0), (self.bb_scrambler_input_0, 0)) self.connect( (self.dtv_dvb_bbheader_bb_0, 0), (self.dtv_dvb_bbscrambler_bb_0, 0) ) self.connect((self.dtv_dvb_bbscrambler_bb_0, 0), (self.bch_encoder_input, 0)) self.connect((self.dtv_dvb_bbscrambler_bb_0, 0), (self.dtv_dvb_bch_bb_0, 0)) self.connect((self.dtv_dvb_bch_bb_0, 0), (self.dtv_dvb_ldpc_bb_0, 0)) self.connect((self.dtv_dvb_bch_bb_0, 0), (self.ldpc_encoder_input, 0)) self.connect((self.dtv_dvb_ldpc_bb_0, 0), (self.bit_interleaver_input, 0)) self.connect((self.dtv_dvb_ldpc_bb_0, 0), (self.dtv_dvbs2_interleaver_bb_0, 0)) self.connect( (self.dtv_dvbs2_interleaver_bb_0, 0), (self.bit_interleaver_output, 0) ) self.connect( (self.dtv_dvbs2_interleaver_bb_0, 0), (self.blocks_repack_bits_bb_0, 0) ) self.connect( (self.dtv_dvbs2_interleaver_bb_0, 0), (self.dtv_dvbs2_modulator_bc_0, 0) ) self.connect( (self.dtv_dvbs2_modulator_bc_0, 0), (self.bit_mapper_complex_to_float, 0) ) self.connect((self.dtv_dvbs2_modulator_bc_0, 0), (self.bit_mapper_output_float, 0)) self.connect((self.dtv_dvbs2_modulator_bc_0, 0), (self.organize, 0)) self.connect( (self.dtv_dvbs2_physical_cc_pilots_off, 0), (self.undo_bit_stuffing_pilots_off, 0), ) self.connect( (self.dtv_dvbs2_physical_cc_with_pilots, 0), (self.undo_bit_stuffing_pilots_on, 0), ) self.connect( (self.keep_plframe_header_pilots_off, 0), (self.pl_complex_to_float_0_0_0, 0), ) self.connect( (self.keep_plframe_header_pilots_off, 0), (self.plframe_header_pilots_off_float, 0), ) self.connect( (self.keep_plframe_header_pilots_on, 0), (self.pl_complex_to_float_0_0, 0) ) self.connect( (self.keep_plframe_header_pilots_on, 0), (self.plframe_header_pilots_on_float, 0), ) self.connect( (self.keep_plframe_payload_pilots_off, 0), (self.pl_complex_to_float_0_1, 0) ) self.connect( (self.keep_plframe_payload_pilots_off, 0), (self.plframe_payload_pilots_off_float, 0), ) self.connect( (self.keep_plframe_payload_pilots_on, 0), (self.pl_complex_to_float_0, 0) ) self.connect( (self.keep_plframe_payload_pilots_on, 0), (self.plframe_payload_pilots_on_float, 0), ) self.connect((self.organize, 0), (self.dtv_dvbs2_physical_cc_pilots_off, 0)) self.connect((self.organize, 0), (self.dtv_dvbs2_physical_cc_with_pilots, 0)) self.connect((self.pl_complex_to_float, 1), (self.blocks_float_to_short_0, 0)) self.connect((self.pl_complex_to_float, 0), (self.blocks_float_to_short_0_0, 0)) self.connect( (self.pl_complex_to_float_0, 0), (self.blocks_float_to_short_0_0_0, 0) ) self.connect( (self.pl_complex_to_float_0, 1), (self.blocks_float_to_short_0_1, 0) ) self.connect( (self.pl_complex_to_float_0_0, 0), (self.blocks_float_to_short_0_0_0_0, 0) ) self.connect( (self.pl_complex_to_float_0_0, 1), (self.blocks_float_to_short_0_1_0, 0) ) self.connect( (self.pl_complex_to_float_0_0_0, 0), (self.blocks_float_to_short_0_0_0_0_0, 0), ) self.connect( (self.pl_complex_to_float_0_0_0, 1), (self.blocks_float_to_short_0_1_0_0, 0) ) self.connect( (self.pl_complex_to_float_0_1, 0), (self.blocks_float_to_short_0_0_0_1, 0) ) self.connect( (self.pl_complex_to_float_0_1, 1), (self.blocks_float_to_short_0_1_1, 0) ) self.connect( (self.pl_complex_to_float_1, 0), (self.blocks_float_to_short_0_0_1, 0) ) self.connect( (self.pl_complex_to_float_1, 1), (self.blocks_float_to_short_0_2, 0) ) self.connect( (self.undo_bit_stuffing_pilots_off, 0), (self.keep_plframe_header_pilots_off, 0), ) self.connect( (self.undo_bit_stuffing_pilots_off, 0), (self.keep_plframe_payload_pilots_off, 0), ) self.connect( (self.undo_bit_stuffing_pilots_off, 0), (self.pl_complex_to_float_1, 0) ) self.connect( (self.undo_bit_stuffing_pilots_off, 0), (self.plframe_pilots_off_float, 0) ) self.connect( (self.undo_bit_stuffing_pilots_on, 0), (self.keep_plframe_header_pilots_on, 0), ) self.connect( (self.undo_bit_stuffing_pilots_on, 0), (self.keep_plframe_payload_pilots_on, 0), ) self.connect( (self.undo_bit_stuffing_pilots_on, 0), (self.pl_complex_to_float, 0) ) self.connect( (self.undo_bit_stuffing_pilots_on, 0), (self.plframe_pilots_on_float, 0) )
def __init__(self): gr.top_block.__init__(self, "Dvb S2 Tx Example") Qt.QWidget.__init__(self) self.setWindowTitle("Dvb S2 Tx Example") 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", "dvb_s2_Tx_example") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.vga2_gain_0 = vga2_gain_0 = 10 self.vga1_gain = vga1_gain = -8 self.tx_gain = tx_gain = 35 self.taps = taps = 100 self.symbol_rate = symbol_rate = 5000000 self.samp_rate = samp_rate = 10000000 self.rolloff = rolloff = 0.200 self.center_freq = center_freq = 1280000000 ################################################## # Blocks ################################################## self._vga1_gain_range = Range(-35, -4, 1, -8, 200) self._vga1_gain_win = RangeWidget(self._vga1_gain_range, self.set_vga1_gain, 'VGA#1 Gain', "counter_slider", float) self.top_layout.addWidget(self._vga1_gain_win) self._vga2_gain_0_range = Range(0, 25, 1, 10, 200) self._vga2_gain_0_win = RangeWidget(self._vga2_gain_0_range, self.set_vga2_gain_0, 'VGA#2 Gain', "counter_slider", float) self.top_layout.addWidget(self._vga2_gain_0_win) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_clock_rate(30.72e6, uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(center_freq, 0) self.uhd_usrp_sink_0.set_gain(vga1_gain, 0) self.uhd_usrp_sink_0.set_antenna('tx_gain', 0) self._tx_gain_range = Range(0, 89, 1, 35, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'TXGain', "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(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) 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.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (100, ), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.dtv_dvbs2_physical_cc_0 = dtv.dvbs2_physical_cc( dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_16APSK, dtv.PILOTS_OFF, 0) self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc( dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_16APSK, dtv.INTERPOLATION_OFF) self.dtv_dvbs2_interleaver_bb_0 = dtv.dvbs2_interleaver_bb( dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_16APSK) self.dtv_dvb_ldpc_bb_0 = dtv.dvb_ldpc_bb(dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.MOD_OTHER) self.dtv_dvb_bch_bb_0 = dtv.dvb_bch_bb(dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10) self.dtv_dvb_bbscrambler_bb_0 = dtv.dvb_bbscrambler_bb( dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10) self.dtv_dvb_bbheader_bb_0 = dtv.dvb_bbheader_bb( dtv.STANDARD_DVBS2, dtv.FECFRAME_NORMAL, dtv.C9_10, dtv.RO_0_20, dtv.INPUTMODE_NORMAL, dtv.INBAND_OFF, 168, 4000000) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/Users/ampoulog/Documents/gnuradio/Wireless-communication-systems-Lab/Lab6/example1/adv16apsk910.ts', True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dtv_dvb_bbheader_bb_0, 0)) self.connect((self.dtv_dvb_bbheader_bb_0, 0), (self.dtv_dvb_bbscrambler_bb_0, 0)) self.connect((self.dtv_dvb_bbscrambler_bb_0, 0), (self.dtv_dvb_bch_bb_0, 0)) self.connect((self.dtv_dvb_bch_bb_0, 0), (self.dtv_dvb_ldpc_bb_0, 0)) self.connect((self.dtv_dvb_ldpc_bb_0, 0), (self.dtv_dvbs2_interleaver_bb_0, 0)) self.connect((self.dtv_dvbs2_interleaver_bb_0, 0), (self.dtv_dvbs2_modulator_bc_0, 0)) self.connect((self.dtv_dvbs2_modulator_bc_0, 0), (self.dtv_dvbs2_physical_cc_0, 0)) self.connect((self.dtv_dvbs2_physical_cc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.uhd_usrp_sink_0, 0))