def __init__(self): gr.top_block.__init__(self, "METEOR-M2 receiver") ################################################## # Variables ################################################## self.symb_rate = symb_rate = 72e3 self.samp_rate = samp_rate = 960e3 self.decimation = decimation = 4 self.samp_per_sym = samp_per_sym = samp_rate/decimation/symb_rate self.clock_alpha = clock_alpha = 30e-3 self.bitstream_name = bitstream_name = os.getcwd() + "/Data/meteor_LRPT_" + datetime.now().strftime("%d%m%Y_%H%M") + ".s" self.Tuning_offset = Tuning_offset = 300e3 self.LO_freq = LO_freq = 137.903e6 self.BPF_width = BPF_width = 140e3 ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(LO_freq-Tuning_offset, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(42, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(10, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine( 1, samp_rate/decimation, symb_rate, 0.3, 361)) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decimation, (firdes.low_pass(1,samp_rate,BPF_width/2,20e3)), Tuning_offset, samp_rate) (self.freq_xlating_fir_filter_xxx_0).set_processor_affinity([0]) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(1e-3, 4) (self.digital_costas_loop_cc_0).set_processor_affinity([1]) self.digital_constellation_soft_decoder_cf_1 = digital.constellation_soft_decoder_cf(digital.constellation_calcdist(([-1-1j, -1+1j, 1+1j, 1-1j]), ([0, 1, 3, 2]), 4, 1).base()) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(samp_per_sym*(1+0.0), clock_alpha**2/4.0, 0.5, clock_alpha, 0.005) (self.digital_clock_recovery_mm_xx_0).set_processor_affinity([2]) self.blocks_float_to_char_0 = blocks.float_to_char(1, 127) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, bitstream_name, False) self.blocks_file_sink_0_0.set_unbuffered(False) self.analog_rail_ff_0 = analog.rail_ff(-1, 1) self.analog_agc_xx_0 = analog.agc_cc(1000e-4, 0.5, 1.0) self.analog_agc_xx_0.set_max_gain(4000) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_constellation_soft_decoder_cf_1, 0)) self.connect((self.digital_constellation_soft_decoder_cf_1, 0), (self.analog_rail_ff_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Acpqheadphones") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48000 ################################################## # Blocks ################################################## self.blocks_wavfile_sink_0 = blocks.wavfile_sink('pq.wav', 2, samp_rate, 16) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((-1, )) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, 800) self.blocks_add_xx_0 = blocks.add_vff(1) self.audio_source_0 = audio.source(samp_rate, 'hw:1', True) self.audio_sink_0 = audio.sink(samp_rate, 'hw:1', True) self.analog_rail_ff_0 = analog.rail_ff(-0.8, 0.8) self.analog_agc2_xx_0 = analog.agc2_ff(1e-1, 0.5, 0.01, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.analog_rail_ff_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.audio_sink_0, 0)) self.connect((self.audio_source_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.audio_source_0, 0), (self.blocks_delay_0, 0)) self.connect((self.audio_source_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_wavfile_sink_0, 1)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 1))
def test_rail_002(self): lo = -0.75 hi = 0.90 src_data = [-2, -1, -0.5, -0.25, 0, 0.25, 0.5, 1, 2] expected_result = map(lambda x: clip(x, lo, hi), src_data) src = blocks.vector_source_f(src_data) op = analog.rail_ff(lo, hi) dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() result_data = dst.data() self.assertFloatTuplesAlmostEqual(expected_result, result_data, 4)
def test_001_(self): src_data = numpy.array([-1.0, 1.0, -1.0, 1.0]) trg_data = src_data * 0.5 src = blocks.vector_source_f(src_data) dst = blocks.vector_sink_f() rail = analog.rail_ff(-0.5, 0.5) self.tb.connect(src, rail) self.tb.connect(rail, dst) self.tb.run() rsl_data = dst.data() sum = 0 for (u, v) in zip(trg_data, rsl_data): w = u - v sum += w * w sum /= float(len(trg_data)) assert sum < 1e-6
def test_rail_002(self): lo = -0.75 hi = 0.90 src_data = [-2, -1, -0.5, -0.25, 0, 0.25, 0.5, 1, 2] expected_result = [clip(x, lo, hi) for x in src_data] src = blocks.vector_source_f(src_data) op = analog.rail_ff(lo, hi) dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() result_data = dst.data() self.assertFloatTuplesAlmostEqual(expected_result, result_data, 4)
def test_rail_001(self): # Test set/gets hi1 = 1 hi2 = 2 lo1 = -1 lo2 = -2 op = analog.rail_ff(lo1, hi1) op.set_hi(hi2) h = op.hi() self.assertEqual(hi2, h) op.set_lo(lo2) l = op.lo() self.assertEqual(lo2, l)
def __init__(self): gr.top_block.__init__(self, "Meteor QPSK LRPT") # get some variables in place for inputs # # Arguments: # 1. Full path and name of stream file (including file extension) # 2. Gain to be used # 3. Frequency offset (PPM) stream_name = sys.argv[1] gain = float(sys.argv[2]) freq_offset = int(sys.argv[3]) ################################################## # Variables ################################################## self.samp_rate_airspy = samp_rate_airspy = 1250000 self.decim = decim = 8 self.symb_rate = symb_rate = 72000 self.samp_rate = samp_rate = samp_rate_airspy / decim self.sps = sps = (samp_rate * 1.0) / (symb_rate * 1.0) self.pll_alpha = pll_alpha = 0.006 self.freq = freq = 137100000 self.clock_alpha = clock_alpha = 0.002 self.bitstream_name = bitstream_name = stream_name ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.rtlsdr_source_0.set_sample_rate(samp_rate_airspy) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(freq_offset, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(gain, 0) self.rtlsdr_source_0.set_if_gain(0, 0) self.rtlsdr_source_0.set_bb_gain(0, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(1500000, 0) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, samp_rate, symb_rate, 0.6, 361)) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( pll_alpha, 4, False) self.digital_constellation_soft_decoder_cf_1 = digital.constellation_soft_decoder_cf( digital.constellation_calcdist( ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 1).base()) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc( sps, clock_alpha**2 / 4.0, 0.5, clock_alpha, 0.005) self.blocks_float_to_char_0 = blocks.float_to_char(1, 127) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, bitstream_name, False) self.blocks_file_sink_0.set_unbuffered(False) self.analog_rail_ff_0 = analog.rail_ff(-1, 1) self.analog_agc_xx_0 = analog.agc_cc(1000e-4, 0.5, 1.0) self.analog_agc_xx_0.set_max_gain(4000) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_constellation_soft_decoder_cf_1, 0)) self.connect((self.digital_constellation_soft_decoder_cf_1, 0), (self.analog_rail_ff_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "rx APT") Qt.QWidget.__init__(self) self.setWindowTitle("rx APT") 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", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.path_to_save_dir = path_to_save_dir = os.path.expanduser( "~/Desktop") self.samp_rate = samp_rate = 2205000 self.rf_gain = rf_gain = 20 self.if_gain = if_gain = 40 self.freq = freq = 137.62e6 self.file_path = file_path = path_to_save_dir + "/APT_" + datetime.now( ).strftime("%d%m%Y_%H%M") ################################################## # Blocks ################################################## self._rf_gain_range = Range(0, 45, 5, 20, 200) self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, 'RF Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._rf_gain_win) self._if_gain_range = Range(1, 80, 5, 40, 200) self._if_gain_win = RangeWidget(self._if_gain_range, self.set_if_gain, 'IF Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._if_gain_win) self._freq_options = ( 137.62e6, 137.9125e6, 137.1e6, 99.8e6, ) self._freq_labels = ( 'NOAA-15 (137.62MHz)', 'NOAA-18 (137.9125MHz)', 'NOAA-19 (137.1MHz)', 'Test FM', ) self._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel('Frequency' + ": ")) self._freq_combo_box = Qt.QComboBox() self._freq_tool_bar.addWidget(self._freq_combo_box) for label in self._freq_labels: self._freq_combo_box.addItem(label) self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod( self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i))) self._freq_callback(self.freq) self._freq_combo_box.currentIndexChanged.connect( lambda i: self.set_freq(self._freq_options[i])) self.top_grid_layout.addWidget(self._freq_tool_bar) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(rf_gain, 0) self.uhd_usrp_source_0.set_antenna('TX/RX', 0) self.uhd_usrp_source_0.set_bandwidth(samp_rate, 0) self.uhd_usrp_source_0.set_auto_dc_offset(True, 0) self.uhd_usrp_source_0.set_auto_iq_balance(True, 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=samp_rate / 44100, taps=None, fractional_bw=None, ) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc samp_rate, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_win = sip.wrapinstance( self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) self.low_pass_filter_1 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 40000, 4100, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_fff( 1, firdes.low_pass(5, 11025, 2400, 100, firdes.WIN_HAMMING, 6.76)) self.fractional_interpolator_xx_0_0 = filter.fractional_interpolator_ff( 0, 4.8 / 4.16) self.fractional_interpolator_xx_0 = filter.fractional_interpolator_ff( 0, 1.1484375) self.blocks_wavfile_sink_1 = blocks.wavfile_sink( file_path + "_rawIQ.wav", 2, samp_rate, 8) self.blocks_wavfile_sink_0_0 = blocks.wavfile_sink( file_path + ".wav", 1, 4160, 8) self.blocks_wavfile_sink_0 = blocks.wavfile_sink( file_path + ".wav", 1, 11025, 8) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( (if_gain, )) self.blocks_float_to_uchar_0 = blocks.float_to_uchar() self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, file_path + ".dat", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_deinterleave_0 = blocks.deinterleave( gr.sizeof_float * 1, 1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.audio_sink_0 = audio.sink(44100, '', False) self.analog_rail_ff_0 = analog.rail_ff(0, 1) self.analog_fm_demod_cf_0_0 = analog.fm_demod_cf( channel_rate=44100, audio_decim=1, deviation=75000, audio_pass=18000, audio_stop=20000, gain=1.0, tau=75e-6, ) self.analog_fm_demod_cf_0 = analog.fm_demod_cf( channel_rate=44100, audio_decim=4, deviation=75000, audio_pass=15000, audio_stop=16000, gain=1.0, tau=75e-6, ) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 255) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_fm_demod_cf_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.analog_fm_demod_cf_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_fm_demod_cf_0_0, 0), (self.audio_sink_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_wavfile_sink_1, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_wavfile_sink_1, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.fractional_interpolator_xx_0_0, 0)) self.connect((self.blocks_deinterleave_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_deinterleave_0, 1), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.blocks_float_to_uchar_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_float_to_uchar_0, 0)) self.connect((self.fractional_interpolator_xx_0, 0), (self.blocks_deinterleave_0, 0)) self.connect((self.fractional_interpolator_xx_0_0, 0), (self.analog_rail_ff_0, 0)) self.connect((self.fractional_interpolator_xx_0_0, 0), (self.blocks_wavfile_sink_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.fractional_interpolator_xx_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_fm_demod_cf_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_fm_demod_cf_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self, config_file='envsim.ini'): gr.top_block.__init__(self, "Env Sim Server") ################################################## # Parameters ################################################## self.config_file = config_file ################################################## # Variables ################################################## self._usrp_ip_prefix_str_config = ConfigParser.ConfigParser() self._usrp_ip_prefix_str_config.read(config_file) try: usrp_ip_prefix_str = self._usrp_ip_prefix_str_config.get( 'main', 'usrp_ip_prefix') except: usrp_ip_prefix_str = '192.168.40.' self.usrp_ip_prefix_str = usrp_ip_prefix_str self._usrp_ip_base_config = ConfigParser.ConfigParser() self._usrp_ip_base_config.read(config_file) try: usrp_ip_base = self._usrp_ip_base_config.getint( 'main', 'usrp_ip_base') except: usrp_ip_base = 101 self.usrp_ip_base = usrp_ip_base self.num_nodes = num_nodes = 6 self.now = now = time.time() self._increment_usrp_address_bool_config = ConfigParser.ConfigParser() self._increment_usrp_address_bool_config.read(config_file) try: increment_usrp_address_bool = self._increment_usrp_address_bool_config.getboolean( 'main', 'increment_usrp_address') except: increment_usrp_address_bool = True self.increment_usrp_address_bool = increment_usrp_address_bool self.zmq_base_addr = zmq_base_addr = "tcp://10.169.25.150:" self.usrp_ip_list = usrp_ip_list = temp_py_mod.make_usrp_ip_list( increment_usrp_address_bool, usrp_ip_prefix_str, usrp_ip_base, num_nodes) self._samp_rate_config = ConfigParser.ConfigParser() self._samp_rate_config.read(config_file) try: samp_rate = self._samp_rate_config.getfloat('main', 'samp_rate') except: samp_rate = 2e6 self.samp_rate = samp_rate self._port_num_base_config = ConfigParser.ConfigParser() self._port_num_base_config.read(config_file) try: port_num_base = self._port_num_base_config.getint( 'main', 'port_num_base') except: port_num_base = 52001 self.port_num_base = port_num_base self._noise_amp_config = ConfigParser.ConfigParser() self._noise_amp_config.read(config_file) try: noise_amp = self._noise_amp_config.getfloat('main', 'noise_amp') except: noise_amp = .001 self.noise_amp = noise_amp self._host_config = ConfigParser.ConfigParser() self._host_config.read(config_file) try: host = self._host_config.get('main', 'host_ip') except: host = '192.168.40.2' self.host = host self.env_time_int_s = env_time_int_s = int(now) self.env_time_frac_s = env_time_frac_s = now - int(now) self._channel_gain_linear_config = ConfigParser.ConfigParser() self._channel_gain_linear_config.read(config_file) try: channel_gain_linear = self._channel_gain_linear_config.getfloat( 'main', 'channel_gain_linear') except: channel_gain_linear = .01 self.channel_gain_linear = channel_gain_linear ################################################## # Blocks ################################################## self.envsim_zmq_envsim_source_0_2_0_0 = envsim.zmq_envsim_source( "tcp://" + usrp_ip_list[2] + ":" + str(port_num_base + 2), 10, 100, samp_rate, env_time_int_s, env_time_frac_s) self.envsim_zmq_envsim_source_0_2_0 = envsim.zmq_envsim_source( "tcp://" + usrp_ip_list[1] + ":" + str(port_num_base + 1), 10, 100, samp_rate, env_time_int_s, env_time_frac_s) self.envsim_zmq_envsim_source_0_2 = envsim.zmq_envsim_source( "tcp://" + usrp_ip_list[0] + ":" + str(port_num_base + 0), 10, 100, samp_rate, env_time_int_s, env_time_frac_s) self.envsim_zmq_envsim_source_0_1 = envsim.zmq_envsim_source( "tcp://" + usrp_ip_list[3] + ":" + str(port_num_base + 3), 10, 100, samp_rate, env_time_int_s, env_time_frac_s) self.envsim_zmq_envsim_source_0_0 = envsim.zmq_envsim_source( "tcp://" + usrp_ip_list[4] + ":" + str(port_num_base + 4), 10, 100, samp_rate, env_time_int_s, env_time_frac_s) self.envsim_zmq_envsim_source_0 = envsim.zmq_envsim_source( "tcp://" + usrp_ip_list[5] + ":" + str(port_num_base + 5), 10, 100, samp_rate, env_time_int_s, env_time_frac_s) self.envsim_socket_meta_pdu_0_2 = envsim.socket_meta_pdu( "UDP_CLIENT", usrp_ip_list[0], str(port_num_base + 0), 40000, False) self.envsim_socket_meta_pdu_0_1_3 = envsim.socket_meta_pdu( "UDP_CLIENT", usrp_ip_list[2], str(port_num_base + 2), 40000, False) self.envsim_socket_meta_pdu_0_1_2_0 = envsim.socket_meta_pdu( "UDP_CLIENT", usrp_ip_list[5], str(port_num_base + 5), 40000, False) self.envsim_socket_meta_pdu_0_1_1_0 = envsim.socket_meta_pdu( "UDP_CLIENT", usrp_ip_list[4], str(port_num_base + 4), 40000, False) self.envsim_socket_meta_pdu_0_1_0_0 = envsim.socket_meta_pdu( "UDP_CLIENT", usrp_ip_list[3], str(port_num_base + 3), 40000, False) self.envsim_socket_meta_pdu_0_0_0 = envsim.socket_meta_pdu( "UDP_CLIENT", usrp_ip_list[1], str(port_num_base + 1), 40000, False) self.channels_sro_model_0_1 = channels.sro_model( samp_rate, 0.01, 1e3, 2) self.channels_sro_model_0_0 = channels.sro_model( samp_rate, 0.01, 1e3, 1) self.channels_sro_model_0 = channels.sro_model(samp_rate, 0.01, 1e3, 0) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_tagged_stream_to_pdu_0_0 = blocks.tagged_stream_to_pdu( blocks.complex_t, 'packet_len') self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.complex_t, 'packet_len') self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream( gr.sizeof_gr_complex, 1, 2048, "packet_len") self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_gr_complex, 1, 2048, "packet_len") self.blocks_probe_rate_0 = blocks.probe_rate(gr.sizeof_gr_complex * 1, 5000.0, 0.15) self.blocks_multiply_const_xx_0_0 = blocks.multiply_const_cc( channel_gain_linear) self.blocks_multiply_const_xx_0 = blocks.multiply_const_cc( channel_gain_linear) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_float_to_complex_0_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_float_0_1 = blocks.complex_to_float(1) self.blocks_complex_to_float_0_0 = blocks.complex_to_float(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_0_1 = blocks.add_vcc(1) self.blocks_add_xx_0_0_0 = blocks.add_vcc(1) self.blocks_add_xx_0_0 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_rail_ff_0_2 = analog.rail_ff(-1.0, 1.0) self.analog_rail_ff_0_1 = analog.rail_ff(-1.0, 1.0) self.analog_rail_ff_0_0_1 = analog.rail_ff(-1.0, 1.0) self.analog_rail_ff_0_0_0 = analog.rail_ff(-1.0, 1.0) self.analog_rail_ff_0_0 = analog.rail_ff(-1.0, 1.0) self.analog_rail_ff_0 = analog.rail_ff(-1.0, 1.0) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, noise_amp, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_probe_rate_0, 'rate'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.envsim_socket_meta_pdu_0_1_0_0, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.envsim_socket_meta_pdu_0_1_1_0, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.envsim_socket_meta_pdu_0_1_2_0, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self.envsim_socket_meta_pdu_0_0_0, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self.envsim_socket_meta_pdu_0_1_3, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self.envsim_socket_meta_pdu_0_2, 'pdus')) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0_0_0, 1)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_rail_ff_0_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_rail_ff_0_0_0, 0), (self.blocks_float_to_complex_0_0, 0)) self.connect((self.analog_rail_ff_0_0_1, 0), (self.blocks_float_to_complex_0_1, 0)) self.connect((self.analog_rail_ff_0_1, 0), (self.blocks_float_to_complex_0_0, 1)) self.connect((self.analog_rail_ff_0_2, 0), (self.blocks_float_to_complex_0_1, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_xx_0, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_add_xx_0_0_0, 0), (self.blocks_stream_to_tagged_stream_0_0, 0)) self.connect((self.blocks_add_xx_0_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_add_xx_0_1, 0), (self.blocks_multiply_const_xx_0_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.analog_rail_ff_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.analog_rail_ff_0_0, 0)) self.connect((self.blocks_complex_to_float_0_0, 0), (self.analog_rail_ff_0_0_0, 0)) self.connect((self.blocks_complex_to_float_0_0, 1), (self.analog_rail_ff_0_1, 0)) self.connect((self.blocks_complex_to_float_0_1, 0), (self.analog_rail_ff_0_0_1, 0)) self.connect((self.blocks_complex_to_float_0_1, 1), (self.analog_rail_ff_0_2, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.channels_sro_model_0_1, 0)) self.connect((self.blocks_float_to_complex_0_0, 0), (self.channels_sro_model_0_0, 0)) self.connect((self.blocks_float_to_complex_0_1, 0), (self.channels_sro_model_0, 0)) self.connect((self.blocks_multiply_const_xx_0, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.blocks_multiply_const_xx_0_0, 0), (self.blocks_add_xx_0_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_probe_rate_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.channels_sro_model_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.channels_sro_model_0_0, 0), (self.blocks_add_xx_0, 2)) self.connect((self.channels_sro_model_0_1, 0), (self.blocks_add_xx_0, 3)) self.connect((self.envsim_zmq_envsim_source_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.envsim_zmq_envsim_source_0_0, 0), (self.blocks_complex_to_float_0_0, 0)) self.connect((self.envsim_zmq_envsim_source_0_1, 0), (self.blocks_complex_to_float_0_1, 0)) self.connect((self.envsim_zmq_envsim_source_0_2, 0), (self.blocks_add_xx_0_1, 0)) self.connect((self.envsim_zmq_envsim_source_0_2_0, 0), (self.blocks_add_xx_0_1, 1)) self.connect((self.envsim_zmq_envsim_source_0_2_0_0, 0), (self.blocks_add_xx_0_1, 2))
def __init__(self): gr.top_block.__init__(self, "Meteor M2 Receiver 4 USRP (QT) ") Qt.QWidget.__init__(self) self.setWindowTitle("Meteor M2 Receiver 4 USRP (QT) ") 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", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 72000 self.signal_samp_rate = signal_samp_rate = 140e3 self.path_to_save_dir = path_to_save_dir = os.path.expanduser("~/Desktop") self.decim_factor = decim_factor = 4 self.usrp_samp_rate = usrp_samp_rate = signal_samp_rate*decim_factor self.samp_per_sec = samp_per_sec = (signal_samp_rate * 1.0) / (symbol_rate * 1.0) self.rx_freq_old = rx_freq_old = 137.1e6 self.rx_freq = rx_freq = 137.1e6 self.rf_gain = rf_gain = 20 self.record = record = False self.pll_alpha = pll_alpha = 0.015 self.file_path = file_path = path_to_save_dir + "/LRPT_" + datetime.now().strftime("%d%m%Y_%H%M")+".s" self.clock_alpha = clock_alpha = 0.001 ################################################## # Blocks ################################################## self.qtgui_tab_widget_0 = Qt.QTabWidget() self.qtgui_tab_widget_0_widget_0 = Qt.QWidget() self.qtgui_tab_widget_0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_0) self.qtgui_tab_widget_0_grid_layout_0 = Qt.QGridLayout() self.qtgui_tab_widget_0_layout_0.addLayout(self.qtgui_tab_widget_0_grid_layout_0) self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_0, 'Reception') self.qtgui_tab_widget_0_widget_1 = Qt.QWidget() self.qtgui_tab_widget_0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_1) self.qtgui_tab_widget_0_grid_layout_1 = Qt.QGridLayout() self.qtgui_tab_widget_0_layout_1.addLayout(self.qtgui_tab_widget_0_grid_layout_1) self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_1, 'Demodulation') self.qtgui_tab_widget_0_widget_2 = Qt.QWidget() self.qtgui_tab_widget_0_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_2) self.qtgui_tab_widget_0_grid_layout_2 = Qt.QGridLayout() self.qtgui_tab_widget_0_layout_2.addLayout(self.qtgui_tab_widget_0_grid_layout_2) self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_2, 'Decoding') self.top_grid_layout.addWidget(self.qtgui_tab_widget_0) self._rx_freq_options = (137.1e6, 137.9e6, 101.8e6, ) self._rx_freq_labels = ('137.1 MHz', '137.9 MHz', 'Test FM', ) self._rx_freq_tool_bar = Qt.QToolBar(self) self._rx_freq_tool_bar.addWidget(Qt.QLabel('RX Frequency'+": ")) self._rx_freq_combo_box = Qt.QComboBox() self._rx_freq_tool_bar.addWidget(self._rx_freq_combo_box) for label in self._rx_freq_labels: self._rx_freq_combo_box.addItem(label) self._rx_freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._rx_freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._rx_freq_options.index(i))) self._rx_freq_callback(self.rx_freq) self._rx_freq_combo_box.currentIndexChanged.connect( lambda i: self.set_rx_freq(self._rx_freq_options[i])) self.qtgui_tab_widget_0_grid_layout_0.addWidget(self._rx_freq_tool_bar, 0, 2, 1, 1) for r in range(0, 1): self.qtgui_tab_widget_0_grid_layout_0.setRowStretch(r, 1) for c in range(2, 3): self.qtgui_tab_widget_0_grid_layout_0.setColumnStretch(c, 1) self._rf_gain_range = Range(0, 65, 5, 20, 200) self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, 'RF input gain', "counter_slider", float) self.qtgui_tab_widget_0_grid_layout_0.addWidget(self._rf_gain_win, 0, 0, 1, 2) for r in range(0, 1): self.qtgui_tab_widget_0_grid_layout_0.setRowStretch(r, 1) for c in range(0, 2): self.qtgui_tab_widget_0_grid_layout_0.setColumnStretch(c, 1) _record_check_box = Qt.QCheckBox('Raw I/Q Record') self._record_choices = {True: True, False: False} self._record_choices_inv = dict((v,k) for k,v in self._record_choices.iteritems()) self._record_callback = lambda i: Qt.QMetaObject.invokeMethod(_record_check_box, "setChecked", Qt.Q_ARG("bool", self._record_choices_inv[i])) self._record_callback(self.record) _record_check_box.stateChanged.connect(lambda i: self.set_record(self._record_choices[bool(i)])) self.qtgui_tab_widget_0_grid_layout_0.addWidget(_record_check_box, 0, 3, 1, 1) for r in range(0, 1): self.qtgui_tab_widget_0_grid_layout_0.setRowStretch(r, 1) for c in range(3, 4): self.qtgui_tab_widget_0_grid_layout_0.setColumnStretch(c, 1) self._pll_alpha_range = Range(0.001, 0.100, 0.001, 0.015, 200) self._pll_alpha_win = RangeWidget(self._pll_alpha_range, self.set_pll_alpha, 'PLL alpha', "counter_slider", float) self.qtgui_tab_widget_0_grid_layout_2.addWidget(self._pll_alpha_win, 4, 0, 1, 1) for r in range(4, 5): self.qtgui_tab_widget_0_grid_layout_2.setRowStretch(r, 1) for c in range(0, 1): self.qtgui_tab_widget_0_grid_layout_2.setColumnStretch(c, 1) self._clock_alpha_range = Range(0.001, 0.01, 0.001, 0.001, 200) self._clock_alpha_win = RangeWidget(self._clock_alpha_range, self.set_clock_alpha, 'Clock alpha', "counter_slider", float) self.qtgui_tab_widget_0_grid_layout_2.addWidget(self._clock_alpha_win, 3, 0, 1, 1) for r in range(3, 4): self.qtgui_tab_widget_0_grid_layout_2.setRowStretch(r, 1) for c in range(0, 1): self.qtgui_tab_widget_0_grid_layout_2.setColumnStretch(c, 1) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine( 1, signal_samp_rate, symbol_rate, 0.6, 361)) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim_factor, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc signal_samp_rate, #bw 'Shifted signal', #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(True) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [6, 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_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-100, -30) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.qtgui_tab_widget_0_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win, 2, 0, 1, 4) for r in range(2, 3): self.qtgui_tab_widget_0_grid_layout_0.setRowStretch(r, 1) for c in range(0, 4): self.qtgui_tab_widget_0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq+signal_samp_rate, #fc usrp_samp_rate, #bw 'Centered on RAW signal', #name 3 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 0) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(True) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(True) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ['Filtered', 'Shifted', 'RAW', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "black", "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(3): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.qtgui_tab_widget_0_grid_layout_0.addWidget(self._qtgui_freq_sink_x_1_win, 1, 0, 1, 4) for r in range(1, 2): self.qtgui_tab_widget_0_grid_layout_0.setRowStretch(r, 1) for c in range(0, 4): self.qtgui_tab_widget_0_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc signal_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.qtgui_tab_widget_0_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1, 1) for r in range(0, 1): self.qtgui_tab_widget_0_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.qtgui_tab_widget_0_grid_layout_1.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(1.0 / symbol_rate) self.qtgui_const_sink_x_0.set_y_axis(-1, 1) self.qtgui_const_sink_x_0.set_x_axis(-1, 1) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.qtgui_tab_widget_0_grid_layout_2.addWidget(self._qtgui_const_sink_x_0_win, 0, 0, 3, 1) for r in range(0, 3): self.qtgui_tab_widget_0_grid_layout_2.setRowStretch(r, 1) for c in range(0, 1): self.qtgui_tab_widget_0_grid_layout_2.setColumnStretch(c, 1) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 2, usrp_samp_rate, signal_samp_rate, 25e3, firdes.WIN_HAMMING, 6.76)) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(pll_alpha, 4, False) self.digital_constellation_soft_decoder_cf_0 = digital.constellation_soft_decoder_cf(digital.constellation_calcdist(([-1-1j, -1+1j, 1+1j, 1-1j]), ([0, 1, 3, 2]), 4, 1).base()) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(samp_per_sec, clock_alpha**2/4.0, 0.5, clock_alpha, 0.005) self.blocks_wavfile_sink_1 = blocks.wavfile_sink(file_path+"_rawIQ.wav", 2, int(usrp_samp_rate/decim_factor), 8) self.blocks_mute_xx_0 = blocks.mute_cc(bool(record)) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_float_to_char_0 = blocks.float_to_char(1, 127) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, file_path, False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.analog_sig_source_x_0 = analog.sig_source_c(usrp_samp_rate, analog.GR_COS_WAVE, signal_samp_rate, 1, 0) self.analog_rail_ff_0 = analog.rail_ff(-1, 1) self.analog_agc_xx_0 = analog.agc_cc(100e-3, 500e-3, 1.0) self.analog_agc_xx_0.set_max_gain(4e3) self.USRP = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", args='peak=0.003906', channels=range(1), ), ) self.USRP.set_samp_rate(usrp_samp_rate) self.USRP.set_center_freq(rx_freq+signal_samp_rate, 0) self.USRP.set_gain(rf_gain, 0) self.USRP.set_antenna('TX/RX', 0) self.USRP.set_bandwidth(usrp_samp_rate, 0) self.USRP.set_auto_dc_offset(True, 0) self.USRP.set_auto_iq_balance(True, 0) ################################################## # Connections ################################################## self.connect((self.USRP, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.USRP, 0), (self.blocks_mute_xx_0, 0)) self.connect((self.USRP, 0), (self.qtgui_freq_sink_x_1, 2)) self.connect((self.analog_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_wavfile_sink_1, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_wavfile_sink_1, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_freq_sink_x_1, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.blocks_mute_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_constellation_soft_decoder_cf_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_constellation_soft_decoder_cf_0, 0), (self.analog_rail_ff_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_costas_loop_cc_0, 0))
def __init__(self): gr.top_block.__init__(self, "Meteor QPSK LRPT") # get some variables in place for inputs # # Arguments: # 1. Full path and name of stream file (including file extension) # 2. Gain to be used # 3. Frequency offset (PPM) # 4. SDR Device ID from settings.yml (for RTL-SDR source block) # 5. Bias-T (0/1 for RTL-SDR) stream_name = sys.argv[1] gain = float(sys.argv[2]) freq_offset = int(sys.argv[3]) sdr_dev_id = sys.argv[4] bias_t_string = sys.argv[5] bias_t = "1" if not bias_t_string: bias_t = "0" ################################################## # Variables ################################################## self.samp_rate_airspy = samp_rate_airspy = 1250000 self.decim = decim = 8 self.symb_rate = symb_rate = 72000 self.samp_rate = samp_rate = samp_rate_airspy / decim self.sps = sps = (samp_rate * 1.0) / (symb_rate * 1.0) self.pll_alpha = pll_alpha = 0.006 self.freq = freq = 137100000 self.clock_alpha = clock_alpha = 0.002 self.bitstream_name = bitstream_name = stream_name ############################################################################################################################################## # Blocks -- *** NOTE HOW THE VARIABLES ARE CARRIED IN FROM settings.yml - this has to be re-done every time you export the .py from gnuradio ############################################################################################################################################### self.rtlsdr_source_0 = osmosdr.source(args='numchan=' + str(1) + ' ' + 'rtl=' + str(sdr_dev_id) + ',bias=' + bias_t + '') self.rtlsdr_source_0.set_sample_rate(samp_rate_airspy) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(freq_offset, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) # determine if gain is specified or if auto-gain should be used if (gain == 0): self.rtlsdr_source_0.set_gain_mode(True, 0) else: self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(gain, 0) self.rtlsdr_source_0.set_if_gain(0, 0) self.rtlsdr_source_0.set_bb_gain(0, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(1500000, 0) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, samp_rate, symb_rate, 0.6, 361)) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( pll_alpha, 4, False) self.digital_constellation_soft_decoder_cf_1 = digital.constellation_soft_decoder_cf( digital.constellation_calcdist( ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 1).base()) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc( sps, clock_alpha**2 / 4.0, 0.5, clock_alpha, 0.005) self.blocks_float_to_char_0 = blocks.float_to_char(1, 127) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, bitstream_name, False) self.blocks_file_sink_0.set_unbuffered(False) self.analog_rail_ff_0 = analog.rail_ff(-1, 1) self.analog_agc_xx_0 = analog.agc_cc(1000e-4, 0.5, 1.0) self.analog_agc_xx_0.set_max_gain(4000) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_constellation_soft_decoder_cf_1, 0)) self.connect((self.digital_constellation_soft_decoder_cf_1, 0), (self.analog_rail_ff_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Meteor QPSK LRPT") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate_airspy = samp_rate_airspy = 192000 self.decim = decim = 1 self.symb_rate = symb_rate = 72000 self.samp_rate = samp_rate = samp_rate_airspy/decim self.sps = sps = (samp_rate*1.0)/(symb_rate*1.0) self.rfgain = rfgain = 9 self.pll_alpha = pll_alpha = 0.015 self.ifgain = ifgain = 10 self.freq = freq = 137900000 self.clock_alpha = clock_alpha = 0.001 self.bitstream_name = bitstream_name = "/tmp/meteor_LRPT_" + datetime.now().strftime("%d%m%Y_%H%M") + ".s" ################################################## # Blocks ################################################## self.nb_0 = self.nb_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb_0.AddPage(grc_wxgui.Panel(self.nb_0), "SDR FFT") self.nb_0.AddPage(grc_wxgui.Panel(self.nb_0), "QPSK Constellation") self.Add(self.nb_0) _pll_alpha_sizer = wx.BoxSizer(wx.VERTICAL) self._pll_alpha_text_box = forms.text_box( parent=self.nb_0.GetPage(1).GetWin(), sizer=_pll_alpha_sizer, value=self.pll_alpha, callback=self.set_pll_alpha, label="PLL Alpha", converter=forms.float_converter(), proportion=0, ) self._pll_alpha_slider = forms.slider( parent=self.nb_0.GetPage(1).GetWin(), sizer=_pll_alpha_sizer, value=self.pll_alpha, callback=self.set_pll_alpha, minimum=0.001, maximum=0.1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.nb_0.GetPage(1).Add(_pll_alpha_sizer) _clock_alpha_sizer = wx.BoxSizer(wx.VERTICAL) self._clock_alpha_text_box = forms.text_box( parent=self.nb_0.GetPage(1).GetWin(), sizer=_clock_alpha_sizer, value=self.clock_alpha, callback=self.set_clock_alpha, label="Clock Alpha", converter=forms.float_converter(), proportion=0, ) self._clock_alpha_slider = forms.slider( parent=self.nb_0.GetPage(1).GetWin(), sizer=_clock_alpha_sizer, value=self.clock_alpha, callback=self.set_clock_alpha, minimum=0.001, maximum=0.01, num_steps=10, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.nb_0.GetPage(1).Add(_clock_alpha_sizer) self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.nb_0.GetPage(1).GetWin(), title="Scope Plot", sample_rate=symb_rate, v_scale=0.5, v_offset=0, t_scale=0.5, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb_0.GetPage(1).Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb_0.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=5, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=768, fft_rate=25, average=True, avg_alpha=0.1, title="Filtered Spectrum", peak_hold=False, ) self.nb_0.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine( 1, samp_rate, symb_rate, 0.6, 361)) _rfgain_sizer = wx.BoxSizer(wx.VERTICAL) self._rfgain_text_box = forms.text_box( parent=self.GetWin(), sizer=_rfgain_sizer, value=self.rfgain, callback=self.set_rfgain, label="RF Gain", converter=forms.float_converter(), proportion=0, ) self._rfgain_slider = forms.slider( parent=self.GetWin(), sizer=_rfgain_sizer, value=self.rfgain, callback=self.set_rfgain, minimum=1, maximum=15, num_steps=14, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_rfgain_sizer) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) _ifgain_sizer = wx.BoxSizer(wx.VERTICAL) self._ifgain_text_box = forms.text_box( parent=self.GetWin(), sizer=_ifgain_sizer, value=self.ifgain, callback=self.set_ifgain, label="IF Gain", converter=forms.float_converter(), proportion=0, ) self._ifgain_slider = forms.slider( parent=self.GetWin(), sizer=_ifgain_sizer, value=self.ifgain, callback=self.set_ifgain, minimum=1, maximum=15, num_steps=14, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_ifgain_sizer) self.fcdproplus_fcdproplus_0 = fcdproplus.fcdproplus("0",1) self.fcdproplus_fcdproplus_0.set_lna(1) self.fcdproplus_fcdproplus_0.set_mixer_gain(0) self.fcdproplus_fcdproplus_0.set_if_gain(30) self.fcdproplus_fcdproplus_0.set_freq_corr(0) self.fcdproplus_fcdproplus_0.set_freq(137900000) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(pll_alpha, 4) self.digital_constellation_soft_decoder_cf_1 = digital.constellation_soft_decoder_cf(digital.constellation_calcdist(([-1-1j, -1+1j, 1+1j, 1-1j]), ([0, 1, 3, 2]), 4, 1).base()) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(sps, clock_alpha**2/4.0, 0.5, clock_alpha, 0.005) self.blocks_float_to_char_0 = blocks.float_to_char(1, 127) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, bitstream_name, False) self.blocks_file_sink_0.set_unbuffered(False) self.analog_rail_ff_0 = analog.rail_ff(-1, 1) self.analog_agc_xx_0 = analog.agc_cc(1000e-4, 0.5, 1.0) self.analog_agc_xx_0.set_max_gain(4000) ################################################## # Connections ################################################## self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_constellation_soft_decoder_cf_1, 0)) self.connect((self.digital_constellation_soft_decoder_cf_1, 0), (self.analog_rail_ff_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.fcdproplus_fcdproplus_0, 0), (self.rational_resampler_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "NOAA APT Satellite Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("NOAA APT Satellite Receiver") 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", "apt_rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) self._lock = threading.RLock() ################################################## # Variables ################################################## self.satellite_select = satellite_select = 137.62 self.valid_gains = valid_gains = [ 0.0, 0.9, 1.4, 2.7, 3.7, 7.7, 8.7, 12.5, 14.4, 15.7, 16.6, 19.7, 20.7, 22.9, 25.4, 28.0, 29.7, 32.8, 33.8, 36.4, 37.2, 38.6, 40.2, 42.1, 43.4, 43.9, 44.5, 48.0, 49.6 ] self.satellite_frequency = satellite_frequency = satellite_select * 1e6 self.rf_samp_rate = rf_samp_rate = 2.048e6 self.max_doppler = max_doppler = 3000 self.fsk_deviation_hz = fsk_deviation_hz = 17000 self.am_carrier = am_carrier = 2400 self.tuner_frequency = tuner_frequency = satellite_frequency - ( rf_samp_rate / 4) self.rf_gain = rf_gain = valid_gains[-1] self.rail_level = rail_level = 0.5 self.processing_rate = processing_rate = 256000 self.fm_bandwidth = fm_bandwidth = ( 2 * (fsk_deviation_hz + am_carrier)) + max_doppler self.baud_rate = baud_rate = 4160 ################################################## # Blocks ################################################## self.tabs_top = Qt.QTabWidget() self.tabs_top_widget_0 = Qt.QWidget() self.tabs_top_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_top_widget_0) self.tabs_top_grid_layout_0 = Qt.QGridLayout() self.tabs_top_layout_0.addLayout(self.tabs_top_grid_layout_0) self.tabs_top.addTab(self.tabs_top_widget_0, "RF Recieve") self.tabs_top_widget_1 = Qt.QWidget() self.tabs_top_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_top_widget_1) self.tabs_top_grid_layout_1 = Qt.QGridLayout() self.tabs_top_layout_1.addLayout(self.tabs_top_grid_layout_1) self.tabs_top.addTab(self.tabs_top_widget_1, "APT Signal") self.tabs_top_widget_2 = Qt.QWidget() self.tabs_top_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_top_widget_2) self.tabs_top_grid_layout_2 = Qt.QGridLayout() self.tabs_top_layout_2.addLayout(self.tabs_top_grid_layout_2) self.tabs_top.addTab(self.tabs_top_widget_2, "APT Baseband") self.top_grid_layout.addWidget(self.tabs_top, 2, 0, 1, 4) self.tabs_rf = Qt.QTabWidget() self.tabs_rf_widget_0 = Qt.QWidget() self.tabs_rf_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_rf_widget_0) self.tabs_rf_grid_layout_0 = Qt.QGridLayout() self.tabs_rf_layout_0.addLayout(self.tabs_rf_grid_layout_0) self.tabs_rf.addTab(self.tabs_rf_widget_0, "Spectrum") self.tabs_rf_widget_1 = Qt.QWidget() self.tabs_rf_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_rf_widget_1) self.tabs_rf_grid_layout_1 = Qt.QGridLayout() self.tabs_rf_layout_1.addLayout(self.tabs_rf_grid_layout_1) self.tabs_rf.addTab(self.tabs_rf_widget_1, "Waterfall") self.tabs_rf_widget_2 = Qt.QWidget() self.tabs_rf_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_rf_widget_2) self.tabs_rf_grid_layout_2 = Qt.QGridLayout() self.tabs_rf_layout_2.addLayout(self.tabs_rf_grid_layout_2) self.tabs_rf.addTab(self.tabs_rf_widget_2, "Scope") self.tabs_top_layout_0.addWidget(self.tabs_rf) self.tabs_apt_data = Qt.QTabWidget() self.tabs_apt_data_widget_0 = Qt.QWidget() self.tabs_apt_data_layout_0 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.tabs_apt_data_widget_0) self.tabs_apt_data_grid_layout_0 = Qt.QGridLayout() self.tabs_apt_data_layout_0.addLayout(self.tabs_apt_data_grid_layout_0) self.tabs_apt_data.addTab(self.tabs_apt_data_widget_0, "Scope") self.tabs_apt_data_widget_1 = Qt.QWidget() self.tabs_apt_data_layout_1 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.tabs_apt_data_widget_1) self.tabs_apt_data_grid_layout_1 = Qt.QGridLayout() self.tabs_apt_data_layout_1.addLayout(self.tabs_apt_data_grid_layout_1) self.tabs_apt_data.addTab(self.tabs_apt_data_widget_1, "Raster") self.tabs_top_layout_1.addWidget(self.tabs_apt_data) self._satellite_select_options = [137.62, 137.9125, 137.1] self._satellite_select_labels = [ 'NOAA 15 (137.62 MHz)', 'NOAA 18 (137.9125 MHz)', 'NOAA 19 (137.1 MHz)' ] self._satellite_select_tool_bar = Qt.QToolBar(self) self._satellite_select_tool_bar.addWidget( Qt.QLabel("Satellite Select" + ": ")) self._satellite_select_combo_box = Qt.QComboBox() self._satellite_select_tool_bar.addWidget( self._satellite_select_combo_box) for label in self._satellite_select_labels: self._satellite_select_combo_box.addItem(label) self._satellite_select_callback = lambda i: Qt.QMetaObject.invokeMethod( self._satellite_select_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._satellite_select_options.index(i))) self._satellite_select_callback(self.satellite_select) self._satellite_select_combo_box.currentIndexChanged.connect( lambda i: self.set_satellite_select(self._satellite_select_options[ i])) self.top_grid_layout.addWidget(self._satellite_select_tool_bar, 0, 0, 1, 1) self._rf_gain_options = valid_gains self._rf_gain_labels = map(str, self._rf_gain_options) self._rf_gain_tool_bar = Qt.QToolBar(self) self._rf_gain_tool_bar.addWidget(Qt.QLabel("RF Gain" + ": ")) self._rf_gain_combo_box = Qt.QComboBox() self._rf_gain_tool_bar.addWidget(self._rf_gain_combo_box) for label in self._rf_gain_labels: self._rf_gain_combo_box.addItem(label) self._rf_gain_callback = lambda i: Qt.QMetaObject.invokeMethod( self._rf_gain_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._rf_gain_options.index(i))) self._rf_gain_callback(self.rf_gain) self._rf_gain_combo_box.currentIndexChanged.connect( lambda i: self.set_rf_gain(self._rf_gain_options[i])) self.top_grid_layout.addWidget(self._rf_gain_tool_bar, 0, 1, 1, 1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype satellite_frequency, #fc processing_rate // 2, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.50) self.qtgui_waterfall_sink_x_0.enable_grid(False) if not False: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [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_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-40, 0) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_rf_layout_1.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( baud_rate / 2, #size baud_rate, #samp_rate 'APT Full Line', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-0.5, 1.5) self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0.01, 0, 'SyncA') self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_time_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tabs_apt_data_layout_0.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size processing_rate // 2, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) 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_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) 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.tabs_rf_layout_2.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_time_raster_sink_x_0 = qtgui.time_raster_sink_f( baud_rate, 120 * 3, baud_rate // 2, ([]), ([]), "", 1, ) self.qtgui_time_raster_sink_x_0.set_update_time(0.10) self.qtgui_time_raster_sink_x_0.set_intensity_range(-0.5, 1.5) self.qtgui_time_raster_sink_x_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [1, 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_time_raster_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_raster_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_raster_sink_x_0.set_color_map(i, colors[i]) self.qtgui_time_raster_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_raster_sink_x_0_win = sip.wrapinstance( self.qtgui_time_raster_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_apt_data_layout_1.addWidget( self._qtgui_time_raster_sink_x_0_win) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 16.64e3, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1_0.set_update_time(0.10) self.qtgui_freq_sink_x_1_0.set_y_axis(-40, 0) self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_1_0.enable_grid(False) self.qtgui_freq_sink_x_1_0.set_fft_average(0.2) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1_0.set_plot_pos_half(not True) labels = ["Raw", "AGC Output", "", "", "", "", "", "", "", ""] 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_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget) self.tabs_top_layout_2.addWidget(self._qtgui_freq_sink_x_1_0_win) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype satellite_frequency, #fc processing_rate // 2, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-100, 0) self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(0.2) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ["Raw", "AGC Output", "", "", "", "", "", "", "", ""] 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(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.tabs_rf_layout_0.addWidget(self._qtgui_freq_sink_x_1_win) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, processing_rate // 2, fm_bandwidth + 1e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 2, firdes.low_pass(1, processing_rate, 60e3, 15e3, firdes.WIN_HAMMING, 6.76)) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, processing_rate, True) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, "/Users/bjmclaug/Downloads/noaa-12_256k.dat", False) self.blocks_file_meta_sink_0 = blocks.file_meta_sink( gr.sizeof_float * 1, "/Users/bjmclaug/source/stem_station/noaa12_sample.dat", baud_rate, 1, blocks.GR_FILE_FLOAT, False, baud_rate * (60 * 20), "", True) self.blocks_file_meta_sink_0.set_unbuffered(False) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.apt_am_demod_0 = apt_am_demod( parameter_apt_gain=1, parameter_samp_rate=processing_rate / 2, ) self.analog_rail_ff_0_0 = analog.rail_ff(-rail_level, rail_level) self.analog_rail_ff_0 = analog.rail_ff(-rail_level, rail_level) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( (processing_rate // 2) / (2 * math.pi * fsk_deviation_hz / 8.0)) self.analog_agc3_xx_0 = analog.agc3_cc(0.25, 0.5, 0.9, 1.0, 1) self.analog_agc3_xx_0.set_max_gain(1) ################################################## # Connections ################################################## self.connect((self.analog_agc3_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.apt_am_demod_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_rail_ff_0_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.apt_am_demod_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.apt_am_demod_0, 0), (self.qtgui_time_raster_sink_x_0, 0)) self.connect((self.apt_am_demod_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.analog_rail_ff_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.analog_rail_ff_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_agc3_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_freq_sink_x_1, 1)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lang Tx") ################################################## # Variables ################################################## plutoip = os.environ.get('PLUTO_IP') if plutoip == None: plutoip = 'pluto.local' plutoip = 'ip:' + plutoip self.ToneBurst = ToneBurst = False self.PTT = PTT = False self.Mode = Mode = 0 self.MicGain = MicGain = 5.0 self.KEY = KEY = False self.Filt_Low = Filt_Low = 300 self.Filt_High = Filt_High = 3000 self.FMMIC = FMMIC = 50 self.FFTEn = FFTEn = 0 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=11, decimation=1, taps=None, fractional_bw=None, ) self.pluto_sink_0 = iio.pluto_sink(plutoip, 1000000000, 528000, 2000000, 0x800, False, 0, '', True) self.logpwrfft_x_0 = logpwrfft.logpwrfft_c( sample_rate=48000, fft_size=512, ref_scale=2, frame_rate=15, avg_alpha=0.9, average=True, ) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_float * 512, '127.0.0.1', 7374, 1472, False) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 512) self.blocks_mute_xx_0_0 = blocks.mute_cc(bool(not PTT)) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_4 = blocks.multiply_const_vcc( ((Mode < 4) or (Mode == 5), )) self.blocks_multiply_const_vxx_3 = blocks.multiply_const_vcc( (Mode == 4, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff( (FMMIC / 5.0, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( ((MicGain / 10.0) * (not (Mode == 2)) * (not (Mode == 3)), )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_add_xx_2 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_add_const_vxx_0 = blocks.add_const_vcc( ((0.5 * int(Mode == 5)) + (int(Mode == 2) * KEY) + (int(Mode == 3) * KEY), )) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_float * 512, num_inputs=1, num_outputs=2, input_index=0, output_index=FFTEn, ) self.band_pass_filter_1 = filter.fir_filter_fff( 1, firdes.band_pass(1, 48000, 200, 3500, 100, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0_0 = filter.fir_filter_ccc( 1, firdes.complex_band_pass(1, 48000, Filt_Low, Filt_High, 100, firdes.WIN_HAMMING, 6.76)) self.audio_source_0 = audio.source(48000, "hw:CARD=Device,DEV=0", False) self.analog_sig_source_x_1 = analog.sig_source_f( 48000, analog.GR_COS_WAVE, 1750, 1.0 * ToneBurst, 0) self.analog_sig_source_x_0 = analog.sig_source_c( 48000, analog.GR_COS_WAVE, 0, 1, 0) self.analog_rail_ff_0 = analog.rail_ff(-1, 1) self.analog_nbfm_tx_0 = analog.nbfm_tx( audio_rate=48000, quad_rate=48000, tau=1000e-6, max_dev=250, fh=-1, ) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) self.analog_agc2_xx_1 = analog.agc2_cc(1e-1, 1e-1, 1.3 - (0.65 * (int(Mode == 5))), 1.0) self.analog_agc2_xx_1.set_max_gain(10) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_1, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_nbfm_tx_0, 0), (self.blocks_multiply_const_vxx_3, 0)) self.connect((self.analog_rail_ff_0, 0), (self.band_pass_filter_1, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.blocks_multiply_const_vxx_4, 0)) self.connect((self.band_pass_filter_1, 0), (self.analog_nbfm_tx_0, 0)) self.connect((self.blks2_selector_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blks2_selector_0, 1), (self.blocks_udp_sink_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.analog_rail_ff_0, 0)) self.connect((self.blocks_add_xx_2, 0), (self.logpwrfft_x_0, 0)) self.connect((self.blocks_add_xx_2, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_3, 0), (self.blocks_add_xx_2, 0)) self.connect((self.blocks_multiply_const_vxx_4, 0), (self.blocks_add_xx_2, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_agc2_xx_1, 0)) self.connect((self.blocks_mute_xx_0_0, 0), (self.pluto_sink_0, 0)) self.connect((self.logpwrfft_x_0, 0), (self.blks2_selector_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_mute_xx_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Meteor QPSK LRPT") ################################################## # Variables ################################################## self.samp_rate_airspy = samp_rate_airspy = 1250000 self.decim = decim = 8 self.symb_rate = symb_rate = 72000 self.samp_rate = samp_rate = samp_rate_airspy / decim self.sps = sps = (samp_rate * 1.0) / (symb_rate * 1.0) self.pll_alpha = pll_alpha = 0.006 self.freq = freq = 137100000 self.clock_alpha = clock_alpha = 0.002 #self.bitstream_name = bitstream_name = "/home/pi/weather/meteor_LRPT_" + datetime.now().strftime("%d%m%Y_%H%M") + ".s" self.bitstream_name = bitstream_name = sys.argv[4] + ".s" ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.rtlsdr_source_0.set_sample_rate(samp_rate_airspy) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(3, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(32.8, 0) self.rtlsdr_source_0.set_if_gain(0, 0) self.rtlsdr_source_0.set_bb_gain(0, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(1500000, 0) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, samp_rate, symb_rate, 0.6, 361)) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( pll_alpha, 4, False) self.digital_constellation_soft_decoder_cf_1 = digital.constellation_soft_decoder_cf( digital.constellation_calcdist( ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 1).base()) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc( sps, clock_alpha**2 / 4.0, 0.5, clock_alpha, 0.005) self.blocks_float_to_char_0 = blocks.float_to_char(1, 127) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, bitstream_name, False) self.blocks_file_sink_0.set_unbuffered(False) self.analog_rail_ff_0 = analog.rail_ff(-1, 1) self.analog_agc_xx_0 = analog.agc_cc(1000e-4, 0.5, 1.0) self.analog_agc_xx_0.set_max_gain(4000) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_constellation_soft_decoder_cf_1, 0)) self.connect((self.digital_constellation_soft_decoder_cf_1, 0), (self.analog_rail_ff_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_0, 0))
def __init__(self, inputfile='', outputfile='0'): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") 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", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.inputfile = inputfile self.outputfile = outputfile ################################################## # Variables ################################################## self.decimation = decimation = 1 self.symb_rate = symb_rate = 72e3 self.samp_rate = samp_rate = 0.900001e6 / decimation self.ted_gain = ted_gain = 1 self.sps = sps = (samp_rate) / symb_rate self.qpsk = qpsk = digital.constellation_calcdist( ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 1).base() self.loop_bw = loop_bw = 0.002 self.fft_min = fft_min = -160 self.fft_max = fft_max = -15 self.dec_taps = dec_taps = firdes.low_pass(1.0, samp_rate, 141e3, 20e3, firdes.WIN_HAMMING, 6.76) self.d_factor = d_factor = 2 ################################################## # Blocks ################################################## self._ted_gain_range = Range(0.1, 2, 0.1, 1, 200) self._ted_gain_win = RangeWidget(self._ted_gain_range, self.set_ted_gain, "ted_gain", "counter_slider", float) self.top_grid_layout.addWidget(self._ted_gain_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self._loop_bw_range = Range(0.001, 0.1, 0.001, 0.002, 200) self._loop_bw_win = RangeWidget(self._loop_bw_range, self.set_loop_bw, "loop_bw", "counter_slider", float) self.top_grid_layout.addWidget(self._loop_bw_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._d_factor_range = Range(0.1, 2, 0.1, 2, 200) self._d_factor_win = RangeWidget(self._d_factor_range, self.set_d_factor, "d_factor", "counter_slider", float) self.top_grid_layout.addWidget(self._d_factor_win, 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.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, samp_rate, symb_rate, 3, 300)) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 3 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(9, 13) 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(True) 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 = ['error', 't_inst', 't_avg', '', '', '', '', '', '', ''] 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, 2, 0, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 100e3, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(fft_min, fft_max) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "red", "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_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 2, 1, 1, 1) for r in range(2, 3): 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_0_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-1.5, 1.5) self.qtgui_const_sink_x_0_0.set_x_axis(-1.5, 1.5) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) self.qtgui_const_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 2, 2, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.fir_filter_xxx_0 = filter.fir_filter_ccf(decimation, (dec_taps)) self.fir_filter_xxx_0.declare_sample_delay(0) self.digital_symbol_sync_xx_0 = digital.symbol_sync_cc( digital.TED_MUELLER_AND_MULLER, sps, loop_bw, d_factor, ted_gain, 1, 1, digital.constellation_bpsk().base(), digital.IR_MMSE_8TAP, 128, ([])) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( loop_bw, 4, False) self.digital_constellation_soft_decoder_cf_1 = digital.constellation_soft_decoder_cf( digital.constellation_calcdist( ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 1).base()) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate * 25 * decimation, True) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_float_to_char_0 = blocks.float_to_char(1, 127) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_float * 1, '/home/nacho/Desktop/Proyecto-Final/data/gqrx_20190914_121650_137100000_900001_fc.raw', False) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/nacho/Desktop/Proyecto-Final/data/2019_09_14.s', False) self.blocks_file_sink_0_0.set_unbuffered(False) self.blocks_deinterleave_0 = blocks.deinterleave( gr.sizeof_float * 1, 1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((10, )) self.analog_rail_ff_0 = analog.rail_ff(-1, 1) self.analog_agc_xx_0_0_0 = analog.agc_ff(1e-5, 1, 0.5) self.analog_agc_xx_0_0_0.set_max_gain(4e3) self.analog_agc_xx_0_0 = analog.agc_ff(1e-5, 1, 0.5) self.analog_agc_xx_0_0.set_max_gain(4e3) self.analog_agc_xx_0 = analog.agc_cc(1e-5, 1, 1) self.analog_agc_xx_0.set_max_gain(4e3) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.analog_agc_xx_0_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_agc_xx_0_0_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_deinterleave_0, 0), (self.analog_agc_xx_0_0, 0)) self.connect((self.blocks_deinterleave_0, 1), (self.analog_agc_xx_0_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_deinterleave_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.digital_constellation_soft_decoder_cf_1, 0), (self.analog_rail_ff_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_soft_decoder_cf_1, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 1), (self.blocks_add_const_vxx_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 3), (self.qtgui_time_sink_x_0, 2)) self.connect((self.digital_symbol_sync_xx_0, 2), (self.qtgui_time_sink_x_0, 1)) self.connect((self.fir_filter_xxx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_symbol_sync_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.qtgui_freq_sink_x_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Testautocancellation") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48000 self.func_getfreq = func_getfreq = 800 * 10 ################################################## # Blocks ################################################## self.probe_getfreq = blocks.probe_signal_f() def _func_getfreq_probe(): while True: val = self.probe_getfreq.level() try: self.set_func_getfreq(val) except AttributeError: pass time.sleep(1.0 / (1)) _func_getfreq_thread = threading.Thread(target=_func_getfreq_probe) _func_getfreq_thread.daemon = True _func_getfreq_thread.start() self.fractional_interpolator_xx_0 = filter.fractional_interpolator_ff( 0, 0.1) self.blocks_wavfile_sink_0 = blocks.wavfile_sink( '/dev/stdout', 1, samp_rate, 16) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((-1, )) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, 10) self.blocks_delay_1 = blocks.delay(gr.sizeof_float * 1, int(func_getfreq)) self.blocks_add_xx_1 = blocks.add_vff(1) self.audio_source_0 = audio.source(samp_rate, 'hw:1', True) self.analog_rail_ff_0 = analog.rail_ff(-0.8, 0.8) self.analog_agc2_xx_1 = analog.agc2_ff(1e-1, 1e-2, 0.1, 1.0) self.analog_agc2_xx_1.set_max_gain(65536) self.powerquality_getfreqcpp_0 = powerquality.getfreqcpp(0.1) ################################################## # Connections ################################################## self.connect((self.powerquality_getfreqcpp_0, 0), (self.probe_getfreq, 0)) self.connect((self.analog_agc2_xx_1, 0), (self.analog_rail_ff_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.audio_source_0, 0), (self.fractional_interpolator_xx_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_delay_1, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.analog_agc2_xx_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_delay_1, 0)) self.connect((self.fractional_interpolator_xx_0, 0), (self.powerquality_getfreqcpp_0, 0)) self.connect((self.fractional_interpolator_xx_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.fractional_interpolator_xx_0, 0), (self.blocks_multiply_const_vxx_1, 0))
def __init__(self): gr.top_block.__init__(self, "Noaa Apt") Qt.QWidget.__init__(self) self.setWindowTitle("Noaa Apt") 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", "noaa_apt") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 300e3 self.fcarrier_i = fcarrier_i = 47.4e3 self.fcarrier_d = fcarrier_d = 41.3e3 self.fcarrier = fcarrier = -73.18e3 self.ch_rate = ch_rate = 96e3 ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'RF Input') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Subcarrier') self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, 'Image Scan Line') self.top_layout.addWidget(self.tab) self.rational_resampler_xxx_3 = filter.rational_resampler_fff( interpolation=11025, decimation=int(ch_rate), taps=None, fractional_bw=None, ) self.rational_resampler_xxx_2 = filter.rational_resampler_fff( interpolation=4160, decimation=4800, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=1, decimation=10, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(ch_rate), decimation=int(samp_rate), taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc ch_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(False) if not False: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [6, 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_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-110, -30) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win, 1, 0, 1, 1) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 2048, #size 4160, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-200, 400) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(True) self.qtgui_time_sink_x_1.enable_axis_labels(False) self.qtgui_time_sink_x_1.enable_control_panel(False) if not False: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 4096, #size ch_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-8, 8) 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(True) self.qtgui_time_sink_x_0.enable_axis_labels(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not False: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_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.tab_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0, 0, 1, 1) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_f( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-80, 0) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(True) self.qtgui_freq_sink_x_1.set_fft_average(0.1) self.qtgui_freq_sink_x_1.enable_axis_labels(False) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not 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 xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.tab_grid_layout_1.addWidget(self._qtgui_freq_sink_x_1_win, 1, 0, 1, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc ch_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(-120, -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.05) self.qtgui_freq_sink_x_0.enable_axis_labels(False) 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.tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1, 1) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, (1, ), fcarrier, samp_rate) self.fft_filter_xxx_0 = filter.fft_filter_fff( 1, (firdes.low_pass(1, ch_rate, 4800, 1200, firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.blocks_wavfile_sink_0 = blocks.wavfile_sink( 'aptfull2.wav', 1, 11025, 16) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_float * 1, 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff( (1.0 / 20, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((50, )) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( 100000, 1e-5, 4000) self.blocks_keep_one_in_n_1 = blocks.keep_one_in_n( gr.sizeof_float * 1, 2) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, 2) self.blocks_float_to_uchar_0 = blocks.float_to_uchar() self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, '/home/handiko/gqrx_20180412_230748_137696953_300000_fc.raw', False) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.analog_rail_ff_0 = analog.rail_ff(0, 255) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( ch_rate / (2 * math.pi * (40e3) / 8.0)) ################################################## # Connections ################################################## self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_uchar_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.blocks_float_to_uchar_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_keep_one_in_n_1, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_rail_ff_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_skiphead_0, 0), (self.blocks_keep_one_in_n_1, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.rational_resampler_xxx_3, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_skiphead_0, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rational_resampler_xxx_3, 0), (self.blocks_multiply_const_vxx_1, 0))
def __init__(self): gr.top_block.__init__(self, "Meteor QPSK LRPT") ################################################## # Variables ################################################## self.freq = freq = 137900000 self.symb_rate = symb_rate = 72000 self.samp_rate = samp_rate = 128000 self.doppler_freq = doppler_freq = freq self.sps = sps = (samp_rate * 1.0) / (symb_rate * 1.0) self.samp_rate_rtlsdr = samp_rate_rtlsdr = 1536000 self.pll_alpha = pll_alpha = float(sys.argv[2]) self.doppler_shift = doppler_shift = doppler_freq - freq self.decim = decim = 8 self.clock_alpha = clock_alpha = .001 self.bitstream_name = bitstream_name = sys.argv[1] + '.s' ################################################## # Blocks ################################################## self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, samp_rate, symb_rate, 0.6, 361)) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=int(samp_rate_rtlsdr / samp_rate), taps=None, fractional_bw=None, ) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.osmosdr_source_0.set_sample_rate(samp_rate_rtlsdr) self.osmosdr_source_0.set_center_freq(freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(44, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.gpredict_doppler_0 = gpredict.doppler(self.set_doppler_freq, "localhost", 4532, True) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( pll_alpha, 4, False) self.digital_constellation_soft_decoder_cf_1 = digital.constellation_soft_decoder_cf( digital.constellation_calcdist( ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 1).base()) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc( sps, clock_alpha**2 / 4.0, 0.5, clock_alpha, 0.005) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_float_to_char_0 = blocks.float_to_char(1, 127) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, bitstream_name, False) self.blocks_file_sink_0.set_unbuffered(False) self.analog_sig_source_x_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, doppler_shift, 1, 0) self.analog_rail_ff_0 = analog.rail_ff(-1, 1) self.analog_agc_xx_0 = analog.agc_cc(1000e-4, 0.5, 1.0) self.analog_agc_xx_0.set_max_gain(4000) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_constellation_soft_decoder_cf_1, 0)) self.connect((self.digital_constellation_soft_decoder_cf_1, 0), (self.analog_rail_ff_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_costas_loop_cc_0, 0))
def __init__(self, large_sig_len=0.0015, signal_mult=2, freq=433866000): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.large_sig_len = large_sig_len self.signal_mult = signal_mult self.freq = freq ################################################## # Variables ################################################## self.samp_rate = samp_rate = 240000 ################################################## # Blocks ################################################## self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(0.2, 1) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(-24, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(1, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(50, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, 10000, 10000, firdes.WIN_HAMMING, 6.76)) self.blocks_threshold_ff_2 = blocks.threshold_ff(0, 0, 0) self.blocks_threshold_ff_1 = blocks.threshold_ff(0, 0, 0) self.blocks_sub_xx_2 = blocks.sub_ff(1) self.blocks_sub_xx_1 = blocks.sub_ff(1) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "localhost", "52001", 10000, False) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((signal_mult, )) self.blocks_moving_average_xx_1 = blocks.moving_average_ff(int(samp_rate*large_sig_len), 0.8/samp_rate/large_sig_len, 4000) self.blocks_float_to_char_1 = blocks.float_to_char(1, 1) self.blocks_float_to_char_0_0 = blocks.float_to_char(1, 1) self.blocks_delay_1 = blocks.delay(gr.sizeof_float*1, int(samp_rate*0.00005)) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.bitgate_triggered_bits_0 = bitgate.triggered_bits(int(samp_rate*large_sig_len*5), False) self.analog_rail_ff_1 = analog.rail_ff(0.001, 1) self.analog_rail_ff_0 = analog.rail_ff(0, 1) ################################################## # Connections ################################################## self.msg_connect((self.bitgate_triggered_bits_0, 'pdus'), (self.blocks_socket_pdu_0, 'pdus')) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_char_0_0, 0)) self.connect((self.analog_rail_ff_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.analog_rail_ff_1, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_delay_1, 0), (self.blocks_float_to_char_1, 0)) self.connect((self.blocks_float_to_char_0_0, 0), (self.bitgate_triggered_bits_0, 1)) self.connect((self.blocks_float_to_char_1, 0), (self.bitgate_triggered_bits_0, 0)) self.connect((self.blocks_moving_average_xx_1, 0), (self.blocks_sub_xx_1, 1)) self.connect((self.blocks_moving_average_xx_1, 0), (self.blocks_sub_xx_2, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_moving_average_xx_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.analog_rail_ff_0, 0)) self.connect((self.blocks_sub_xx_1, 0), (self.blocks_sub_xx_2, 0)) self.connect((self.blocks_sub_xx_1, 0), (self.blocks_threshold_ff_1, 0)) self.connect((self.blocks_sub_xx_2, 0), (self.blocks_threshold_ff_2, 0)) self.connect((self.blocks_threshold_ff_1, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_threshold_ff_1, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_threshold_ff_2, 0), (self.blocks_delay_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_sub_xx_1, 0))
def __init__(self): gr.top_block.__init__(self, "Lang Tx") ################################################## # Variables ################################################## self.ToneBurst = ToneBurst = False self.PTT = PTT = False self.Mode = Mode = 0 self.MicGain = MicGain = 5.0 self.KEY = KEY = False self.Filt_Low = Filt_Low = 300 self.Filt_High = Filt_High = 3000 self.FMMIC = FMMIC = 50 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=11, decimation=1, taps=None, fractional_bw=None, ) self.pluto_sink_0 = iio.pluto_sink('ip:pluto.local', 1000000000, 528000, 2000000, 0x800, False, 0, '', True) self.blocks_mute_xx_0_0 = blocks.mute_cc(bool(not PTT)) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_4 = blocks.multiply_const_vcc( ((Mode < 4) or (Mode == 5), )) self.blocks_multiply_const_vxx_3 = blocks.multiply_const_vcc( (Mode == 4, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff( (FMMIC / 5.0, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( ((MicGain / 10.0) * (not (Mode == 2)) * (not (Mode == 3)), )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_add_xx_2 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_add_const_vxx_0 = blocks.add_const_vcc( ((0.5 * int(Mode == 5)) + (int(Mode == 2) * KEY) + (int(Mode == 3) * KEY), )) self.band_pass_filter_1 = filter.fir_filter_fff( 1, firdes.band_pass(1, 48000, 200, 3500, 100, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0_0 = filter.fir_filter_ccc( 1, firdes.complex_band_pass(1, 48000, Filt_Low, Filt_High, 100, firdes.WIN_HAMMING, 6.76)) self.audio_source_0 = audio.source(48000, "hw:CARD=Device,DEV=0", False) self.analog_sig_source_x_1 = analog.sig_source_f( 48000, analog.GR_COS_WAVE, 1750, 1.0 * ToneBurst, 0) self.analog_sig_source_x_0 = analog.sig_source_c( 48000, analog.GR_COS_WAVE, 0, 1, 0) self.analog_rail_ff_0 = analog.rail_ff(-1, 1) self.analog_nbfm_tx_0 = analog.nbfm_tx( audio_rate=48000, quad_rate=48000, tau=1000e-6, max_dev=250, fh=-1, ) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) self.analog_agc2_xx_1 = analog.agc2_cc(1e-1, 1e-1, 1.3 - (0.65 * (int(Mode == 5))), 1.0) self.analog_agc2_xx_1.set_max_gain(10) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_1, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_nbfm_tx_0, 0), (self.blocks_multiply_const_vxx_3, 0)) self.connect((self.analog_rail_ff_0, 0), (self.band_pass_filter_1, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.blocks_multiply_const_vxx_4, 0)) self.connect((self.band_pass_filter_1, 0), (self.analog_nbfm_tx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.analog_rail_ff_0, 0)) self.connect((self.blocks_add_xx_2, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_3, 0), (self.blocks_add_xx_2, 0)) self.connect((self.blocks_multiply_const_vxx_4, 0), (self.blocks_add_xx_2, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_agc2_xx_1, 0)) self.connect((self.blocks_mute_xx_0_0, 0), (self.pluto_sink_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_mute_xx_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2E6 ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(131.550E6, 0) self.rtlsdr_source_0.set_freq_corr(50, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(True, 0) self.rtlsdr_source_0.set_gain(50, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(3E3, 0) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=1, decimation=10, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=480000, decimation=200000, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [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_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_1.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_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_1_win) self.low_pass_filter_0 = filter.fir_filter_ccf( 10, firdes.low_pass(1, samp_rate, 3E3, 25E3, firdes.WIN_HAMMING, 6.76)) self.blocks_wavfile_sink_0_0 = blocks.wavfile_sink( "/home/chris/Desktop/filteredAcarsNew", 1, 48000, 8) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.audio_sink_1 = audio.sink(48000, "", True) self.analog_simple_squelch_cc_1 = analog.simple_squelch_cc(-25, 0.001) self.analog_rail_ff_0 = analog.rail_ff(0, 1) ################################################## # Connections ################################################## self.connect((self.analog_rail_ff_0, 0), (self.audio_sink_1, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_wavfile_sink_0_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.analog_simple_squelch_cc_1, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_simple_squelch_cc_1, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.analog_rail_ff_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0))
def __init__(self): gr.top_block.__init__(self, "Clipping effect demonstration") Qt.QWidget.__init__(self) self.setWindowTitle("Clipping effect demonstration") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 100000 self.signal_amp = signal_amp = -150 self.sigfreq = sigfreq = samp_rate * 1.0247385 / 11.0 self.noise_amp = noise_amp = -150 self.clipping = clipping = 1 self.center = center = samp_rate / 11.0 self.bw = bw = samp_rate / 2 ################################################## # Blocks ################################################## self._signal_amp_range = Range(-150, 10, 5, -150, 200) self._signal_amp_win = RangeWidget(self._signal_amp_range, self.set_signal_amp, 'Singal Power', "counter_slider", float) self.top_grid_layout.addWidget(self._signal_amp_win, 2, 0, 1, 1) self._sigfreq_range = Range(0, samp_rate / 2, 1000, samp_rate * 1.0247385 / 11.0, 200) self._sigfreq_win = RangeWidget(self._sigfreq_range, self.set_sigfreq, 'Signal Freq', "counter_slider", float) self.top_grid_layout.addWidget(self._sigfreq_win, 3, 0, 1, 1) self._noise_amp_range = Range(-150, 0, 5, -150, 200) self._noise_amp_win = RangeWidget(self._noise_amp_range, self.set_noise_amp, 'Noise Power', "counter_slider", float) self.top_grid_layout.addWidget(self._noise_amp_win, 2, 1, 1, 1) self._clipping_options = [1, 2, 3, 4, 5] self._clipping_labels = map(str, self._clipping_options) self._clipping_tool_bar = Qt.QToolBar(self) self._clipping_tool_bar.addWidget(Qt.QLabel('Clipping' + ": ")) self._clipping_combo_box = Qt.QComboBox() self._clipping_tool_bar.addWidget(self._clipping_combo_box) for label in self._clipping_labels: self._clipping_combo_box.addItem(label) self._clipping_callback = lambda i: Qt.QMetaObject.invokeMethod( self._clipping_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._clipping_options.index(i))) self._clipping_callback(self.clipping) self._clipping_combo_box.currentIndexChanged.connect( lambda i: self.set_clipping(self._clipping_options[i])) self.top_grid_layout.addWidget(self._clipping_tool_bar, 4, 0, 1, 1) self._center_range = Range(0, samp_rate / 2, 100, samp_rate / 11.0, 200) self._center_win = RangeWidget(self._center_range, self.set_center, 'Center Freq', "counter_slider", float) self.top_grid_layout.addWidget(self._center_win, 3, 1, 1, 1) self._bw_range = Range(samp_rate / 100.0, samp_rate / 2, 100, samp_rate / 2, 200) self._bw_win = RangeWidget(self._bw_range, self.set_bw, 'BW', "counter_slider", float) self.top_grid_layout.addWidget(self._bw_win, 4, 1, 1, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 128, #size samp_rate, #samp_rate '', #name 4 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1 - clipping, 1 + clipping) 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_NORM, 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) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['Input', 'Clipped', 'Max', 'Min', '', '', '', '', '', ''] widths = [2, 2, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "green", "cyan", "cyan", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 2, 2, 1, 1, 1, 1, 1, 1] markers = [0, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(4): 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, 0, 1, 2) self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( 10000, 100, -1 - clipping, 1 + clipping, '', 1) self.qtgui_histogram_sink_x_0.set_update_time(0.10) self.qtgui_histogram_sink_x_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0.enable_accumulate(False) self.qtgui_histogram_sink_x_0.enable_grid(False) self.qtgui_histogram_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_histogram_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_histogram_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_win = sip.wrapinstance( self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_histogram_sink_x_0_win, 0, 1, 1, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 2048, #size firdes.WIN_FLATTOP, #wintype 0, #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(-200, 0) 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 "float" == "float" or "float" == "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, 0, 0, 1, 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_add_xx_0 = blocks.add_vff(1) self.band_pass_filter_0 = filter.fir_filter_fff( 1, firdes.band_pass( 1, samp_rate, max(bw / 15.0, center - bw / 2.0), min(samp_rate / 2.0 - bw / 15.0, center + bw / 2.0), bw / 5.0, firdes.WIN_HANN, 6.76)) self.analog_sig_source_x_1_0 = analog.sig_source_f( samp_rate, analog.GR_CONST_WAVE, 0, -clipping, 0) self.analog_sig_source_x_1 = analog.sig_source_f( samp_rate, analog.GR_CONST_WAVE, 0, clipping, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, sigfreq, pow(10.0, signal_amp / 20.0), 0) self.analog_rail_ff_0 = analog.rail_ff(-clipping, clipping) self.analog_noise_source_x_0 = analog.noise_source_f( analog.GR_GAUSSIAN, pow(10.0, noise_amp / 20.0), 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_sig_source_x_1, 0), (self.qtgui_time_sink_x_0, 2)) self.connect((self.analog_sig_source_x_1_0, 0), (self.qtgui_time_sink_x_0, 3)) self.connect((self.band_pass_filter_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.analog_rail_ff_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "NOAA APT Satellite Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("NOAA APT Satellite Receiver") 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", "apt_rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) self._lock = threading.RLock() ################################################## # Variables ################################################## self.satellite_select = satellite_select = 137.62 self.valid_gains = valid_gains = [0.0, 0.9, 1.4, 2.7, 3.7, 7.7, 8.7, 12.5, 14.4, 15.7, 16.6, 19.7, 20.7, 22.9, 25.4, 28.0, 29.7, 32.8, 33.8, 36.4, 37.2, 38.6, 40.2, 42.1, 43.4, 43.9, 44.5, 48.0, 49.6] self.satellite_frequency = satellite_frequency = satellite_select * 1e6 self.rf_samp_rate = rf_samp_rate = 2.048e6 self.max_doppler = max_doppler = 3000 self.fsk_deviation_hz = fsk_deviation_hz = 17000 self.am_carrier = am_carrier = 2400 self.tuner_frequency = tuner_frequency = satellite_frequency - (rf_samp_rate / 4) self.rf_gain = rf_gain = valid_gains[-1] self.rail_level = rail_level = 0.5 self.processing_rate = processing_rate = 256000 self.fm_bandwidth = fm_bandwidth = (2 * (fsk_deviation_hz + am_carrier)) + max_doppler self.baud_rate = baud_rate = 4160 ################################################## # Blocks ################################################## self.tabs_top = Qt.QTabWidget() self.tabs_top_widget_0 = Qt.QWidget() self.tabs_top_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_top_widget_0) self.tabs_top_grid_layout_0 = Qt.QGridLayout() self.tabs_top_layout_0.addLayout(self.tabs_top_grid_layout_0) self.tabs_top.addTab(self.tabs_top_widget_0, "RF Recieve") self.tabs_top_widget_1 = Qt.QWidget() self.tabs_top_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_top_widget_1) self.tabs_top_grid_layout_1 = Qt.QGridLayout() self.tabs_top_layout_1.addLayout(self.tabs_top_grid_layout_1) self.tabs_top.addTab(self.tabs_top_widget_1, "APT Signal") self.tabs_top_widget_2 = Qt.QWidget() self.tabs_top_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_top_widget_2) self.tabs_top_grid_layout_2 = Qt.QGridLayout() self.tabs_top_layout_2.addLayout(self.tabs_top_grid_layout_2) self.tabs_top.addTab(self.tabs_top_widget_2, "APT Baseband") self.top_grid_layout.addWidget(self.tabs_top, 2, 0, 1, 4) self.tabs_rf = Qt.QTabWidget() self.tabs_rf_widget_0 = Qt.QWidget() self.tabs_rf_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_rf_widget_0) self.tabs_rf_grid_layout_0 = Qt.QGridLayout() self.tabs_rf_layout_0.addLayout(self.tabs_rf_grid_layout_0) self.tabs_rf.addTab(self.tabs_rf_widget_0, "Spectrum") self.tabs_rf_widget_1 = Qt.QWidget() self.tabs_rf_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_rf_widget_1) self.tabs_rf_grid_layout_1 = Qt.QGridLayout() self.tabs_rf_layout_1.addLayout(self.tabs_rf_grid_layout_1) self.tabs_rf.addTab(self.tabs_rf_widget_1, "Waterfall") self.tabs_rf_widget_2 = Qt.QWidget() self.tabs_rf_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_rf_widget_2) self.tabs_rf_grid_layout_2 = Qt.QGridLayout() self.tabs_rf_layout_2.addLayout(self.tabs_rf_grid_layout_2) self.tabs_rf.addTab(self.tabs_rf_widget_2, "Scope") self.tabs_top_layout_0.addWidget(self.tabs_rf) self.tabs_apt_data = Qt.QTabWidget() self.tabs_apt_data_widget_0 = Qt.QWidget() self.tabs_apt_data_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_apt_data_widget_0) self.tabs_apt_data_grid_layout_0 = Qt.QGridLayout() self.tabs_apt_data_layout_0.addLayout(self.tabs_apt_data_grid_layout_0) self.tabs_apt_data.addTab(self.tabs_apt_data_widget_0, "Scope") self.tabs_apt_data_widget_1 = Qt.QWidget() self.tabs_apt_data_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_apt_data_widget_1) self.tabs_apt_data_grid_layout_1 = Qt.QGridLayout() self.tabs_apt_data_layout_1.addLayout(self.tabs_apt_data_grid_layout_1) self.tabs_apt_data.addTab(self.tabs_apt_data_widget_1, "Raster") self.tabs_top_layout_1.addWidget(self.tabs_apt_data) self._satellite_select_options = [137.62, 137.9125, 137.1] self._satellite_select_labels = ['NOAA 15 (137.62 MHz)', 'NOAA 18 (137.9125 MHz)', 'NOAA 19 (137.1 MHz)'] self._satellite_select_tool_bar = Qt.QToolBar(self) self._satellite_select_tool_bar.addWidget(Qt.QLabel("Satellite Select"+": ")) self._satellite_select_combo_box = Qt.QComboBox() self._satellite_select_tool_bar.addWidget(self._satellite_select_combo_box) for label in self._satellite_select_labels: self._satellite_select_combo_box.addItem(label) self._satellite_select_callback = lambda i: Qt.QMetaObject.invokeMethod(self._satellite_select_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._satellite_select_options.index(i))) self._satellite_select_callback(self.satellite_select) self._satellite_select_combo_box.currentIndexChanged.connect( lambda i: self.set_satellite_select(self._satellite_select_options[i])) self.top_grid_layout.addWidget(self._satellite_select_tool_bar, 0, 0, 1, 1) self._rf_gain_options = valid_gains self._rf_gain_labels = map(str, self._rf_gain_options) self._rf_gain_tool_bar = Qt.QToolBar(self) self._rf_gain_tool_bar.addWidget(Qt.QLabel("RF Gain"+": ")) self._rf_gain_combo_box = Qt.QComboBox() self._rf_gain_tool_bar.addWidget(self._rf_gain_combo_box) for label in self._rf_gain_labels: self._rf_gain_combo_box.addItem(label) self._rf_gain_callback = lambda i: Qt.QMetaObject.invokeMethod(self._rf_gain_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._rf_gain_options.index(i))) self._rf_gain_callback(self.rf_gain) self._rf_gain_combo_box.currentIndexChanged.connect( lambda i: self.set_rf_gain(self._rf_gain_options[i])) self.top_grid_layout.addWidget(self._rf_gain_tool_bar, 0, 1 , 1, 1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype satellite_frequency, #fc processing_rate // 2, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.50) self.qtgui_waterfall_sink_x_0.enable_grid(False) if not False: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [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_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-40, 0) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_rf_layout_1.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( baud_rate / 2, #size baud_rate, #samp_rate 'APT Full Line', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-0.5, 1.5) self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0.01, 0, 'SyncA') self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_time_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tabs_apt_data_layout_0.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size processing_rate // 2, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) 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_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) 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.tabs_rf_layout_2.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_time_raster_sink_x_0 = qtgui.time_raster_sink_f( baud_rate, 120*3, baud_rate // 2, ([]), ([]), "", 1, ) self.qtgui_time_raster_sink_x_0.set_update_time(0.10) self.qtgui_time_raster_sink_x_0.set_intensity_range(-0.5, 1.5) self.qtgui_time_raster_sink_x_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [1, 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_time_raster_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_raster_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_raster_sink_x_0.set_color_map(i, colors[i]) self.qtgui_time_raster_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_raster_sink_x_0_win = sip.wrapinstance(self.qtgui_time_raster_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_apt_data_layout_1.addWidget(self._qtgui_time_raster_sink_x_0_win) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 16.64e3, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1_0.set_update_time(0.10) self.qtgui_freq_sink_x_1_0.set_y_axis(-40, 0) self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_1_0.enable_grid(False) self.qtgui_freq_sink_x_1_0.set_fft_average(0.2) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1_0.set_plot_pos_half(not True) labels = ["Raw", "AGC Output", "", "", "", "", "", "", "", ""] 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_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget) self.tabs_top_layout_2.addWidget(self._qtgui_freq_sink_x_1_0_win) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype satellite_frequency, #fc processing_rate // 2, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-100, 0) self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(0.2) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ["Raw", "AGC Output", "", "", "", "", "", "", "", ""] 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(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.tabs_rf_layout_0.addWidget(self._qtgui_freq_sink_x_1_win) self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, processing_rate // 2, fm_bandwidth + 1e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(2, firdes.low_pass( 1, processing_rate, 60e3, 15e3, firdes.WIN_HAMMING, 6.76)) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, processing_rate,True) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/Users/bjmclaug/Downloads/noaa-12_256k.dat", False) self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_float*1, "/Users/bjmclaug/source/stem_station/noaa12_sample.dat", baud_rate, 1, blocks.GR_FILE_FLOAT, False, baud_rate * (60 * 20), "", True) self.blocks_file_meta_sink_0.set_unbuffered(False) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.apt_am_demod_0 = apt_am_demod( parameter_apt_gain=1, parameter_samp_rate=processing_rate / 2, ) self.analog_rail_ff_0_0 = analog.rail_ff(-rail_level, rail_level) self.analog_rail_ff_0 = analog.rail_ff(-rail_level, rail_level) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf((processing_rate // 2)/(2*math.pi*fsk_deviation_hz/8.0)) self.analog_agc3_xx_0 = analog.agc3_cc(0.25, 0.5, 0.9, 1.0, 1) self.analog_agc3_xx_0.set_max_gain(1) ################################################## # Connections ################################################## self.connect((self.analog_agc3_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.apt_am_demod_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_rail_ff_0_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.apt_am_demod_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.apt_am_demod_0, 0), (self.qtgui_time_raster_sink_x_0, 0)) self.connect((self.apt_am_demod_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.analog_rail_ff_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.analog_rail_ff_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_agc3_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_freq_sink_x_1, 1)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Testaudiostreamport") self.freq_wavelength = 8000 ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48000 self.fundamental_wavelength_samples = fundamental_wavelength_samples = 800 self.freq_wavelength = freq_wavelength = 8000 self.myVectorLength = myVectorLength = 32 self.lowpass_cutoff_freq = 4000 self.n_keep = (self.samp_rate/2)/self.lowpass_cutoff_freq # allow the rms post suppression thread to track if changes aren't happening, which suggests a dead flowgraph. self.rmspostsup_nochange_count = 0 ################################################## # Blocks ################################################## self.probe_avg_frequency = blocks.probe_signal_f() if ("getfreq_alpha" in SETTINGS["streamer"]): myGetfreqAlpha = SETTINGS["streamer"]["getfreq_alpha"] else: myGetfreqAlpha = 0.1 self.powerquality_getfreqcpp_0 = powerquality.getfreqcpp(myGetfreqAlpha) self.fractional_interpolator_xx_0_0 = filter.fractional_interpolator_ff(0, 0.1) self.fractional_interpolator_xx_0 = filter.fractional_interpolator_ff(0, 0.1) self.blocks_wavfile_sink_0 = blocks.wavfile_sink('/dev/stdout', 2, samp_rate, 16) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_float*1, samp_rate*10,True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate*10,True) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((-1, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((-1, )) # self.blocks_getfreq_average_value = blocks.moving_average_ff(1000, 0.001, 40) self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n(gr.sizeof_float*1, 10) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_float*1, 10) self.blocks_delay_1 = blocks.delay(gr.sizeof_float*1, int(round(freq_wavelength))) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, int(round(freq_wavelength))) self.blocks_add_xx_1 = blocks.add_vff(1) self.blocks_add_xx_0 = blocks.add_vff(1) # Calculation of RMS power post-suppression (amplitude of harmonics), also will vary based on effectiveness of the muting. rmsPostSuppressionAlpha = SETTINGS["streamer"]["rmsPostSuppressionAlpha"] # TODO: tune this rmsPostSuppressionAverageLength = SETTINGS["streamer"]["rmsPostSuppressionAverageLength"] # TODO: tune this rmsPostSuppressionAverageScale = SETTINGS["streamer"]["rmsPostSuppressionAverageScale"] # TODO: tune this log("TODO: Tune the Post suppression Alpha value for both RMS and average RMS. Or even remove the averaging if possible.") # Channel 1: Define the blocks needed to calculate and probe the average RMS harmonic power self.blocks_rmsPostSuppression_ch1 = blocks.rms_ff(rmsPostSuppressionAlpha) self.blocks_averagePostSuppression_ch1 = blocks.moving_average_ff(rmsPostSuppressionAverageLength,rmsPostSuppressionAverageScale,4000) # TODO: tune this self.probe_rmsPostSuppression_ch1 = blocks.probe_signal_f() # Channel 2: Define the blocks needed to calculate and probe the average RMS harmonic power self.blocks_rmsPostSuppression_ch2 = blocks.rms_ff(rmsPostSuppressionAlpha) self.blocks_averagePostSuppression_ch2 = blocks.moving_average_ff(rmsPostSuppressionAverageLength,rmsPostSuppressionAverageScale,4000) # TODO: tune this self.probe_rmsPostSuppression_ch2 = blocks.probe_signal_f() # channel 1: Connect the RMS harmonic blocks self.connect((self.blocks_rmsPostSuppression_ch1,0),(self.blocks_averagePostSuppression_ch1,0)) self.connect((self.blocks_averagePostSuppression_ch1,0),(self.probe_rmsPostSuppression_ch1,0)) # Channel 2: Connect the RMS harmonic blocks self.connect((self.blocks_rmsPostSuppression_ch2,0),(self.blocks_averagePostSuppression_ch2,0)) self.connect((self.blocks_averagePostSuppression_ch2,0),(self.probe_rmsPostSuppression_ch2,0)) # Connect Channels 1 and 2 to the larger flow. self.connect((self.blocks_keep_one_in_n_0,0),(self.blocks_rmsPostSuppression_ch1,0)) self.connect((self.blocks_keep_one_in_n_0_0,0),(self.blocks_rmsPostSuppression_ch2,0)) # Left channel TCP connection # log("Connecting to " + getConfigValue("pqserver") + ":" + str(getConfigValue("left_channel_tap_port"))) # self.blocks_socket_pdu_left_inputchannel = blocks.socket_pdu( # "TCP_CLIENT", # getConfigValue("pqserver"), # str(getConfigValue("left_channel_tap_port")), # 10000, # this arg is unused because we are client # False) # this arg is unused because we are client # self.blocks_pdu_to_tagged_stream_left = blocks.pdu_to_tagged_stream( # blocks.float_t, # SETTINGS["networking_tap1"]["length_tag_name"]) self.zeromq_sub_source_left = zeromq.sub_source(gr.sizeof_float, 1, SETTINGS["streamer"]["zmq_server_uri_left_channel"], 5000, True, -1) # optimization: if left and right channels are specified as the same source then make a single connection to the source. if SETTINGS["streamer"]["zmq_server_uri_left_channel"] == SETTINGS["streamer"]["zmq_server_uri_right_channel"]: self.zeromq_sub_source_right = self.zeromq_sub_source_left log("Optimization: Only making a single connection to PQ server since left and right streamer channels have same ZMQ URI.") else: # Connection URI/address to server is different for left and right channel so make a second connection for right channel. self.zeromq_sub_source_right = zeromq.sub_source(gr.sizeof_float, 1, SETTINGS["streamer"]["zmq_server_uri_right_channel"], 5000, True, -1) # self.msg_connect((self.blocks_socket_pdu_left_inputchannel,"pdus"),(self.blocks_pdu_to_tagged_stream_left,"pdus")) # # # Right Channel TCP connection # log("Connecting to " + getConfigValue("pqserver") + ":" + str(getConfigValue("right_channel_tap_port"))) # self.blocks_socket_pdu_right_inputchannel = blocks.socket_pdu( # "TCP_CLIENT", # getConfigValue("pqserver"), # str(getConfigValue("right_channel_tap_port")), # 10000, # this arg is unused because we are client # False) # this arg is unused because we are client # self.blocks_pdu_to_tagged_stream_right = blocks.pdu_to_tagged_stream( # blocks.float_t, # SETTINGS["networking_tap1"]["length_tag_name"]) # self.msg_connect((self.blocks_socket_pdu_right_inputchannel, "pdus"), (self.blocks_pdu_to_tagged_stream_right, "pdus")) self.analog_rail_ff_1 = analog.rail_ff(-0.8, 0.8) self.analog_rail_ff_0 = analog.rail_ff(-0.8, 0.8) # myDecay of 1e-2 (0.01) sounds great when input voltage to the Pi is clean (dirty rectifier voltage can introduce periodic bumps and thumbs that mess up AGC). # myDecay of 0.1: pretty quick. Useful for exposing the thumb phenomenon that I'm currently investigating. 1e-2 (0.01) gets drown down due to thump but thump not very audible. # Sensible default myDecay = 1e-2 # Allow overriding in config file. if ("agc_decay_rate" in SETTINGS["streamer"]): myDecay = SETTINGS["streamer"]["agc_decay_rate"] self.analog_agc2_xx_1 = analog.agc2_ff(0.1, myDecay, 0.1, 1.0) self.analog_agc2_xx_1.set_max_gain(65536) self.analog_agc2_xx_0 = analog.agc2_ff(0.1, myDecay, 0.1, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.analog_rail_ff_0, 0)) self.connect((self.analog_agc2_xx_1, 0), (self.analog_rail_ff_1, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.analog_rail_ff_1, 0), (self.blocks_wavfile_sink_0, 1)) self.connect((self.zeromq_sub_source_left, 0), (self.fractional_interpolator_xx_0, 0)) self.connect((self.zeromq_sub_source_right, 0), (self.fractional_interpolator_xx_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_keep_one_in_n_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_delay_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_keep_one_in_n_0_0, 0), (self.analog_agc2_xx_1, 0)) self.connect((self.powerquality_getfreqcpp_0, 0), (self.probe_avg_frequency, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.powerquality_getfreqcpp_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_delay_1, 0)) self.connect((self.fractional_interpolator_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.fractional_interpolator_xx_0_0, 0), (self.blocks_throttle_0_0, 0)) # self.connect((self.powerquality_getfreqcpp_0, 0), (self.blocks_getfreq_average_value, 0)) ### Define FFT related blocks LEFT-CHANNEL ONLY FOR NOW. self.fft_vxx_0 = fft.fft_vfc(myVectorLength, True, (window.blackmanharris(myVectorLength)), 1) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_float*1, myVectorLength) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_float*1, self.n_keep) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(myVectorLength) self.blocks_throttle = blocks.throttle(gr.sizeof_float * 1, self.samp_rate, True) self.blocks_fft_vector_sink_0 = blocks.vector_sink_f(self.myVectorLength) ### Connect FFT BLOCKS. # Down-sample / decimate the input. We pick up the flowgraph after AGC but before the rail. self.connect((self.analog_agc2_xx_0, 0), (self.blocks_keep_one_in_n_0, 0)) # Convert the stream to a vector in preparation for FFT self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_stream_to_vector_0, 0)) # Perform FFT analysis of the stream. self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) # Send FFT data (phase and magnitude) into a mag^2 block to get strength of each bin self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) # Send the final result (magnitudes in each fft bin) into vector sink. # self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_fft_vector_sink_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_fft_vector_sink_0, 0))
def __init__(self, large_sig_len=0.0015, signal_mult=2, freq=433866000): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.large_sig_len = large_sig_len self.signal_mult = signal_mult self.freq = freq ################################################## # Variables ################################################## self.samp_rate = samp_rate = 240000 ################################################## # Blocks ################################################## self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff( 0.2, 1) self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(-24, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(1, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(50, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 10000, 10000, firdes.WIN_HAMMING, 6.76)) self.blocks_threshold_ff_2 = blocks.threshold_ff(0, 0, 0) self.blocks_threshold_ff_1 = blocks.threshold_ff(0, 0, 0) self.blocks_sub_xx_2 = blocks.sub_ff(1) self.blocks_sub_xx_1 = blocks.sub_ff(1) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "localhost", "52001", 10000, False) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff( (signal_mult, )) self.blocks_moving_average_xx_1 = blocks.moving_average_ff( int(samp_rate * large_sig_len), 0.8 / samp_rate / large_sig_len, 4000) self.blocks_float_to_char_1 = blocks.float_to_char(1, 1) self.blocks_float_to_char_0_0 = blocks.float_to_char(1, 1) self.blocks_delay_1 = blocks.delay(gr.sizeof_float * 1, int(samp_rate * 0.00005)) self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.bitgate_triggered_bits_0 = bitgate.triggered_bits( int(samp_rate * large_sig_len * 5), False) self.analog_rail_ff_1 = analog.rail_ff(0.001, 1) self.analog_rail_ff_0 = analog.rail_ff(0, 1) ################################################## # Connections ################################################## self.msg_connect((self.bitgate_triggered_bits_0, 'pdus'), (self.blocks_socket_pdu_0, 'pdus')) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_char_0_0, 0)) self.connect((self.analog_rail_ff_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.analog_rail_ff_1, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_delay_1, 0), (self.blocks_float_to_char_1, 0)) self.connect((self.blocks_float_to_char_0_0, 0), (self.bitgate_triggered_bits_0, 1)) self.connect((self.blocks_float_to_char_1, 0), (self.bitgate_triggered_bits_0, 0)) self.connect((self.blocks_moving_average_xx_1, 0), (self.blocks_sub_xx_1, 1)) self.connect((self.blocks_moving_average_xx_1, 0), (self.blocks_sub_xx_2, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_moving_average_xx_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.analog_rail_ff_0, 0)) self.connect((self.blocks_sub_xx_1, 0), (self.blocks_sub_xx_2, 0)) self.connect((self.blocks_sub_xx_1, 0), (self.blocks_threshold_ff_1, 0)) self.connect((self.blocks_sub_xx_2, 0), (self.blocks_threshold_ff_2, 0)) self.connect((self.blocks_threshold_ff_1, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_threshold_ff_1, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_threshold_ff_2, 0), (self.blocks_delay_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_sub_xx_1, 0))
def __init__(self): gr.top_block.__init__(self, "M2 Lrpt") Qt.QWidget.__init__(self) self.setWindowTitle("M2 Lrpt") 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", "m2_lrpt") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.baudrate = baudrate = 72000 self.ch_rate = ch_rate = baudrate * 2.0 self.sps = sps = int(ch_rate) / baudrate self.nfilt = nfilt = 32 self.eb = eb = 0.7 self.source = source = 1 self.samp_rate = samp_rate = 300e3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilt, nfilt, 1.0 / sps, eb, 8 * sps * nfilt) self.rf_rate = rf_rate = 2.4e6 self.rate = rate = [0, 2.4e6, 150e3] self.gmu = gmu = 0.002 self.filename = filename = "meteor_LRPT_72kbaud_" + datetime.now( ).strftime("%d%m%Y_%H%M") + ".s" self.device = device = [ 0, "rtl=0", "file=gqrx_20180415_012338_137900000_150000_fc.raw,rate=150e3,throttle=True" ] self.bw = bw = 6.28 / 100 ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'RF Spectrum') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Symbol Synchronization') self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, 'Softbits') self.top_layout.addWidget(self.tab) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, ch_rate, baudrate * 1.0, 0.7, 32 * sps)) self.rational_resampler_xxx_1_0 = filter.rational_resampler_ccc( interpolation=int(samp_rate), decimation=int(rate[source]), taps=None, fractional_bw=490e-3, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(ch_rate), decimation=int(samp_rate), taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'RF Spectrogram', #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not False: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [6, 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_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-100, -50) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win, 1, 0, 1, 1) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size baudrate * 2, #samp_rate 'Soft Bitstream', #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-2, 2) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(True) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) if not False: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "red", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 2048, #size baudrate, #samp_rate 'Symbol Soft Decision', #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-2, 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) if not False: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "Dark Blue", "dark red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [0, 0, 1, 1, 1, 1, 1, 1, 1, 1] markers = [2, 2, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [0.5, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) 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.tab_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0, 1, 1, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'RF Spectrum', #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(-100, -50) 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.tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 2048, #size 'Symbol Constellation', #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not False: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "Dark Blue", "dark red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [2, 2, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [0.3, 0.3, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_1.addWidget(self._qtgui_const_sink_x_0_win, 0, 0, 1, 1) self.osmosdr_source_0_0 = osmosdr.source(args="numchan=" + str(1) + " " + device[source]) self.osmosdr_source_0_0.set_sample_rate(rate[source]) self.osmosdr_source_0_0.set_center_freq(137.9e6, 0) self.osmosdr_source_0_0.set_freq_corr(52, 0) self.osmosdr_source_0_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0_0.set_gain_mode(False, 0) self.osmosdr_source_0_0.set_gain(45, 0) self.osmosdr_source_0_0.set_if_gain(20, 0) self.osmosdr_source_0_0.set_bb_gain(20, 0) self.osmosdr_source_0_0.set_antenna('', 0) self.osmosdr_source_0_0.set_bandwidth(0, 0) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( 6.28 / 200, 4, False) self.digital_constellation_soft_decoder_cf_1 = digital.constellation_soft_decoder_cf( digital.constellation_calcdist( ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 1).base()) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc( 16, 1.0, 6.28 / 400, 1) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc( (ch_rate / baudrate) * (1 + 0.0), 0.25 * gmu * gmu, 0.5, gmu, 0.005) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1) self.blocks_float_to_char_0 = blocks.float_to_char(1, 127) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, filename, False) self.blocks_file_sink_0.set_unbuffered(False) self.analog_rail_ff_0 = analog.rail_ff(-1, 1) self.analog_agc_xx_0 = analog.agc_cc(1e-2, 0.25, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_constellation_soft_decoder_cf_1, 0), (self.analog_rail_ff_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_soft_decoder_cf_1, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.osmosdr_source_0_0, 0), (self.rational_resampler_xxx_1_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.rational_resampler_xxx_1_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_1_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_1_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))