def test02(self): # Test QPSK sync M = 4 theta = 0 loop_bw = cmath.pi / 100.0 fmin = -0.5 fmax = 0.5 mu = 0.5 gain_mu = 0.01 omega = 2 gain_omega = 0.001 omega_rel = 0.001 self.test = digital.mpsk_receiver_cc(M, theta, loop_bw, fmin, fmax, mu, gain_mu, omega, gain_omega, omega_rel) data = 10000 * [ complex(0.707, 0.707), complex(-0.707, 0.707), complex(-0.707, -0.707), complex(0.707, -0.707) ] data = [0.5 * d for d in data] self.src = blocks.vector_source_c(data, False) self.snk = blocks.vector_sink_c() # pulse shaping interpolation filter nfilts = 32 excess_bw = 0.35 ntaps = 11 * int(omega * nfilts) rrc_taps0 = filter.firdes.root_raised_cosine(nfilts, nfilts, 1.0, excess_bw, ntaps) rrc_taps1 = filter.firdes.root_raised_cosine(1, omega, 1.0, excess_bw, 11 * omega) self.rrc0 = filter.pfb_arb_resampler_ccf(omega, rrc_taps0) self.rrc1 = filter.fir_filter_ccf(1, rrc_taps1) self.tb.connect(self.src, self.rrc0, self.rrc1, self.test, self.snk) self.tb.run() expected_result = 10000 * [ complex(-0.5, +0.0), complex(+0.0, -0.5), complex(+0.5, +0.0), complex(+0.0, +0.5) ] dst_data = self.snk.data() # Only compare last Ncmp samples Nstrt = 30000 Ncmp = 1000 expected_result = expected_result[Nstrt:Nstrt + Ncmp] dst_data = dst_data[Nstrt:Nstrt + Ncmp] #for e,d in zip(expected_result, dst_data): # print "{0:+.02f} {1:+.02f}".format(e, d) self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 1)
def __init__(self, sample_rate, symbol_rate): gr.hier_block2.__init__(self, "dvb_s_demodulator_cc", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature omega = sample_rate / symbol_rate gain_omega = omega * omega / 4.0 freq_beta = freq_alpha * freq_alpha / 4.0 mu = 0.0 gain_mu = 0.05 omega_relative_limit = 0.005 # Automatic gain control self.agc = gr.agc2_cc( 0.06, # Attack rate 0.001, # Decay rate 1, # Reference 1, # Initial gain 100) # Max gain # Frequency correction with band-edge filters FLL freq_beta = freq_alpha * freq_alpha / 4 self.freq_recov = digital.fll_band_edge_cc(omega, dvb_swig.RRC_ROLLOFF_FACTOR, 11 * int(omega), freq_bw) self.freq_recov.set_alpha(freq_alpha) self.freq_recov.set_beta(freq_beta) self.receiver = digital.mpsk_receiver_cc(M, 0, freq_bw, fmin, fmax, mu, gain_mu, omega, gain_omega, omega_relative_limit) self.receiver.set_alpha(freq_alpha) self.receiver.set_beta(freq_beta) self.rotate = gr.multiply_const_cc(0.707 + 0.707j) self.connect(self, self.agc, self.freq_recov, self.receiver, self.rotate, self)
def test02(self): # Test QPSK sync M = 4 theta = 0 loop_bw = cmath.pi/100.0 fmin = -0.5 fmax = 0.5 mu = 0.5 gain_mu = 0.01 omega = 2 gain_omega = 0.001 omega_rel = 0.001 self.test = digital.mpsk_receiver_cc(M, theta, loop_bw, fmin, fmax, mu, gain_mu, omega, gain_omega, omega_rel) data = 10000*[complex( 0.707, 0.707), complex(-0.707, 0.707), complex(-0.707, -0.707), complex( 0.707, -0.707)] data = [0.5*d for d in data] self.src = blocks.vector_source_c(data, False) self.snk = blocks.vector_sink_c() # pulse shaping interpolation filter nfilts = 32 excess_bw = 0.35 ntaps = 11 * int(omega*nfilts) rrc_taps0 = filter.firdes.root_raised_cosine( nfilts, nfilts, 1.0, excess_bw, ntaps) rrc_taps1 = filter.firdes.root_raised_cosine( 1, omega, 1.0, excess_bw, 11*omega) self.rrc0 = filter.pfb_arb_resampler_ccf(omega, rrc_taps0) self.rrc1 = filter.fir_filter_ccf(1, rrc_taps1) self.tb.connect(self.src, self.rrc0, self.rrc1, self.test, self.snk) self.tb.run() expected_result = 10000*[complex(-0.5, +0.0), complex(+0.0, -0.5), complex(+0.5, +0.0), complex(+0.0, +0.5)] # get data after a settling period dst_data = self.snk.data()[200:] # Only compare last Ncmp samples Ncmp = 1000 len_e = len(expected_result) len_d = len(dst_data) expected_result = expected_result[len_e - Ncmp - 1:-1] dst_data = dst_data[len_d - Ncmp:] #for e,d in zip(expected_result, dst_data): # print "{0:+.02f} {1:+.02f}".format(e, d) self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 1)
def test01(self): # Test BPSK sync M = 2 theta = 0 loop_bw = cmath.pi / 100.0 fmin = -0.5 fmax = 0.5 mu = 0.5 gain_mu = 0.01 omega = 2 gain_omega = 0.001 omega_rel = 0.001 self.test = digital.mpsk_receiver_cc(M, theta, loop_bw, fmin, fmax, mu, gain_mu, omega, gain_omega, omega_rel) data = 10000 * [complex(1, 0), complex(-1, 0)] #data = [2*random.randint(0,1)-1 for x in xrange(10000)] self.src = blocks.vector_source_c(data, False) self.snk = blocks.vector_sink_c() # pulse shaping interpolation filter nfilts = 32 excess_bw = 0.35 ntaps = 11 * int(omega * nfilts) rrc_taps0 = filter.firdes.root_raised_cosine(nfilts, nfilts, 1.0, excess_bw, ntaps) rrc_taps1 = filter.firdes.root_raised_cosine(1, omega, 1.0, excess_bw, 11 * omega) self.rrc0 = filter.pfb_arb_resampler_ccf(omega, rrc_taps0) self.rrc1 = filter.fir_filter_ccf(1, rrc_taps1) self.tb.connect(self.src, self.rrc0, self.rrc1, self.test, self.snk) self.tb.run() expected_result = [0.5 * d for d in data] dst_data = self.snk.data() # Only compare last Ncmp samples Ncmp = 1000 len_e = len(expected_result) len_d = len(dst_data) expected_result = expected_result[len_e - Ncmp:] dst_data = dst_data[len_d - Ncmp:] #for e,d in zip(expected_result, dst_data): # print "{0:+.02f} {1:+.02f}".format(e, d) self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 1)
def test01(self): # Test BPSK sync M = 2 theta = 0 loop_bw = cmath.pi/100.0 fmin = -0.5 fmax = 0.5 mu = 0.5 gain_mu = 0.01 omega = 2 gain_omega = 0.001 omega_rel = 0.001 self.test = digital.mpsk_receiver_cc(M, theta, loop_bw, fmin, fmax, mu, gain_mu, omega, gain_omega, omega_rel) data = 10000*[complex(1,0), complex(-1,0)] #data = [2*random.randint(0,1)-1 for x in xrange(10000)] self.src = blocks.vector_source_c(data, False) self.snk = blocks.vector_sink_c() # pulse shaping interpolation filter nfilts = 32 excess_bw = 0.35 ntaps = 11 * int(omega*nfilts) rrc_taps0 = filter.firdes.root_raised_cosine( nfilts, nfilts, 1.0, excess_bw, ntaps) rrc_taps1 = filter.firdes.root_raised_cosine( 1, omega, 1.0, excess_bw, 11*omega) self.rrc0 = filter.pfb_arb_resampler_ccf(omega, rrc_taps0) self.rrc1 = filter.fir_filter_ccf(1, rrc_taps1) self.tb.connect(self.src, self.rrc0, self.rrc1, self.test, self.snk) self.tb.run() expected_result = [-0.5*d for d in data] dst_data = self.snk.data() # Only Ncmp samples after Nstrt samples Nstrt = 9000 Ncmp = 1000 expected_result = expected_result[Nstrt:Nstrt+Ncmp] dst_data = dst_data[Nstrt:Nstrt+Ncmp] #for e,d in zip(expected_result, dst_data): # print "{0:+.02f} {1:+.02f}".format(e, d) self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 1)
def __init__(self, sample_rate, symbol_rate): gr.hier_block2.__init__( self, "dvb_s_demodulator_cc", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature omega = sample_rate / symbol_rate gain_omega = omega * omega / 4.0 freq_beta = freq_alpha * freq_alpha / 4.0 mu = 0.0 gain_mu = 0.05 omega_relative_limit = 0.005 # Automatic gain control self.agc = gr.agc2_cc( 0.06, # Attack rate 0.001, # Decay rate 1, # Reference 1, # Initial gain 100) # Max gain # Frequency correction with band-edge filters FLL freq_beta = freq_alpha * freq_alpha / 4 self.freq_recov = digital.fll_band_edge_cc(omega, dvb_swig.RRC_ROLLOFF_FACTOR, 11 * int(omega), freq_bw) self.freq_recov.set_alpha(freq_alpha) self.freq_recov.set_beta(freq_beta) self.receiver = digital.mpsk_receiver_cc(M, 0, freq_bw, fmin, fmax, mu, gain_mu, omega, gain_omega, omega_relative_limit) self.receiver.set_alpha(freq_alpha) self.receiver.set_beta(freq_beta) self.rotate = gr.multiply_const_cc(0.707 + 0.707j) self.connect(self, self.agc, self.freq_recov, self.receiver, self.rotate, self)
def _connect_rds_flow(self): xlate_bandwidth = 100000 audio_decim = 5 sample_rate = self._sample_rate baseband_rate = sample_rate / self.bb_decim freq_offset = 0 cosine_filter = grf.fir_filter_ccf( 1, firdes.root_raised_cosine(1, baseband_rate / audio_decim, 2375, 1, 100)) fir0 = grf.freq_xlating_fir_filter_ccc( 1, firdes.low_pass(1, sample_rate, xlate_bandwidth, 100000), freq_offset, sample_rate) fir1 = grf.freq_xlating_fir_filter_fcc( audio_decim, firdes.low_pass(2500.0, baseband_rate, 2.4e3, 2e3, firdes.WIN_HAMMING), 57e3, baseband_rate) mpsk_receiver = digital.mpsk_receiver_cc( 2, 0, cmath.pi / 100.0, -0.06, 0.06, 0.5, 0.05, baseband_rate / audio_decim / 2375.0, 0.001, 0.005) complex_to_real = blocks.complex_to_real(1) binary_slicer = digital.binary_slicer_fb() keep_one_in_2 = blocks.keep_one_in_n(gr.sizeof_char * 1, 2) diff_decoder = digital.diff_decoder_bb(2) self.connect(self.rtlsdr_source, fir0, self.wfm_rcv_rds, fir1, cosine_filter, mpsk_receiver, complex_to_real, binary_slicer, keep_one_in_2, diff_decoder, self.rds_decoder) # RDS Decoder -> RDS Parser -> RDS Adapter self.msg_connect(self.rds_decoder, b'out', self.rds_parser, b'in') self.msg_connect(self.rds_parser, b'out', self.rds_adapter, b'in')
def __init__(self): gr.top_block.__init__(self, "FM Radio") Qt.QWidget.__init__(self) self.setWindowTitle("FM Radio") 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", "fm_radio") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## 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.samp_rate = samp_rate = 2.048e6 self.baseband_decimation = baseband_decimation = 10 self.rf_gain = rf_gain = len(valid_gains)-1 self.rds_dec = rds_dec = 10 self.pilot_tone = pilot_tone = 19e3 self.baseband_rate = baseband_rate = samp_rate // baseband_decimation self.stereo_subcarrier = stereo_subcarrier = pilot_tone * 2 self.stereo_button = stereo_button = 0 self.slider_volume = slider_volume = 0 self.sdr_gain = sdr_gain = valid_gains[rf_gain] self.rds_symbols_per_bit = rds_symbols_per_bit = 2 self.rds_subcarrier = rds_subcarrier = pilot_tone * 3 self.rds_samp_rate = rds_samp_rate = baseband_rate / rds_dec self.rds_bitrate = rds_bitrate = 1.1875e3 self.rds_bandwidth = rds_bandwidth = 2.83e3 self.fm_station = fm_station = 102.7 self.fm_broadcast_seperation = fm_broadcast_seperation = 0.2 self.fm_broadcast_low = fm_broadcast_low = 87.1 self.fm_broadcast_high = fm_broadcast_high = 107.9 self.audio_rate = audio_rate = 48e3 ################################################## # Blocks ################################################## self.notebook_top = Qt.QTabWidget() self.notebook_top_widget_0 = Qt.QWidget() self.notebook_top_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_top_widget_0) self.notebook_top_grid_layout_0 = Qt.QGridLayout() self.notebook_top_layout_0.addLayout(self.notebook_top_grid_layout_0) self.notebook_top.addTab(self.notebook_top_widget_0, "RF Receive") self.notebook_top_widget_1 = Qt.QWidget() self.notebook_top_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_top_widget_1) self.notebook_top_grid_layout_1 = Qt.QGridLayout() self.notebook_top_layout_1.addLayout(self.notebook_top_grid_layout_1) self.notebook_top.addTab(self.notebook_top_widget_1, "Baseband") self.notebook_top_widget_2 = Qt.QWidget() self.notebook_top_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_top_widget_2) self.notebook_top_grid_layout_2 = Qt.QGridLayout() self.notebook_top_layout_2.addLayout(self.notebook_top_grid_layout_2) self.notebook_top.addTab(self.notebook_top_widget_2, "Mono Audio") self.notebook_top_widget_3 = Qt.QWidget() self.notebook_top_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_top_widget_3) self.notebook_top_grid_layout_3 = Qt.QGridLayout() self.notebook_top_layout_3.addLayout(self.notebook_top_grid_layout_3) self.notebook_top.addTab(self.notebook_top_widget_3, "Sub-Carrier Generation") self.notebook_top_widget_4 = Qt.QWidget() self.notebook_top_layout_4 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_top_widget_4) self.notebook_top_grid_layout_4 = Qt.QGridLayout() self.notebook_top_layout_4.addLayout(self.notebook_top_grid_layout_4) self.notebook_top.addTab(self.notebook_top_widget_4, "Stereo") self.notebook_top_widget_5 = Qt.QWidget() self.notebook_top_layout_5 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_top_widget_5) self.notebook_top_grid_layout_5 = Qt.QGridLayout() self.notebook_top_layout_5.addLayout(self.notebook_top_grid_layout_5) self.notebook_top.addTab(self.notebook_top_widget_5, "RDS") self.top_grid_layout.addWidget(self.notebook_top, 3, 0, 1, 8) self._slider_volume_range = Range(0, 11.1, 0.1, 0, 100) self._slider_volume_win = RangeWidget(self._slider_volume_range, self.set_slider_volume, 'Volume', "counter_slider", float) self.top_grid_layout.addWidget(self._slider_volume_win, 1, 1, 1, 1) self.notebook_subcarriers = Qt.QTabWidget() self.notebook_subcarriers_widget_0 = Qt.QWidget() self.notebook_subcarriers_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_subcarriers_widget_0) self.notebook_subcarriers_grid_layout_0 = Qt.QGridLayout() self.notebook_subcarriers_layout_0.addLayout(self.notebook_subcarriers_grid_layout_0) self.notebook_subcarriers.addTab(self.notebook_subcarriers_widget_0, "Pilot Signal") self.notebook_subcarriers_widget_1 = Qt.QWidget() self.notebook_subcarriers_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_subcarriers_widget_1) self.notebook_subcarriers_grid_layout_1 = Qt.QGridLayout() self.notebook_subcarriers_layout_1.addLayout(self.notebook_subcarriers_grid_layout_1) self.notebook_subcarriers.addTab(self.notebook_subcarriers_widget_1, "Spectrum") self.notebook_top_grid_layout_3.addWidget(self.notebook_subcarriers, 0, 0, 1, 1) self.notebook_rds = Qt.QTabWidget() self.notebook_rds_widget_0 = Qt.QWidget() self.notebook_rds_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_rds_widget_0) self.notebook_rds_grid_layout_0 = Qt.QGridLayout() self.notebook_rds_layout_0.addLayout(self.notebook_rds_grid_layout_0) self.notebook_rds.addTab(self.notebook_rds_widget_0, "RDS Signal") self.notebook_rds_widget_1 = Qt.QWidget() self.notebook_rds_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_rds_widget_1) self.notebook_rds_grid_layout_1 = Qt.QGridLayout() self.notebook_rds_layout_1.addLayout(self.notebook_rds_grid_layout_1) self.notebook_rds.addTab(self.notebook_rds_widget_1, "RDS Bitstream") self.notebook_top_grid_layout_5.addWidget(self.notebook_rds, 0, 0, 1, 1) self._fm_station_range = Range(fm_broadcast_low, fm_broadcast_high, fm_broadcast_seperation, 102.7, 200) self._fm_station_win = RangeWidget(self._fm_station_range, self.set_fm_station, "FM Station", "counter_slider", float) self.top_grid_layout.addWidget(self._fm_station_win, 0, 0, 1, 8) self._stereo_button_options = (0, 1, ) self._stereo_button_labels = ("Mono", "Stereo", ) self._stereo_button_tool_bar = Qt.QToolBar(self) self._stereo_button_tool_bar.addWidget(Qt.QLabel("Audio Output"+": ")) self._stereo_button_combo_box = Qt.QComboBox() self._stereo_button_tool_bar.addWidget(self._stereo_button_combo_box) for label in self._stereo_button_labels: self._stereo_button_combo_box.addItem(label) self._stereo_button_callback = lambda i: Qt.QMetaObject.invokeMethod(self._stereo_button_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._stereo_button_options.index(i))) self._stereo_button_callback(self.stereo_button) self._stereo_button_combo_box.currentIndexChanged.connect( lambda i: self.set_stereo_button(self._stereo_button_options[i])) self.top_grid_layout.addWidget(self._stereo_button_tool_bar, 1, 2, 1, 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(fm_station * 1e6, 0) self.rtlsdr_source_0.set_freq_corr(14, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 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(sdr_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(0, 0) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine( 2, rds_samp_rate, rds_bitrate * rds_symbols_per_bit, 0.275, 16)) self._rf_gain_range = Range(0, len(valid_gains)-1, 1, len(valid_gains)-1, 200) self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, "RF Gain", "counter_slider", int) self.top_grid_layout.addWidget(self._rf_gain_win, 1, 0, 1, 1) self.rds_qt_panel_0 = self.rds_qt_panel_0 = rds.qt_panel() self.notebook_top_layout_5.addWidget(self.rds_qt_panel_0) self.rational_resampler_xxx_0_0_0_1 = filter.rational_resampler_fff( interpolation=int(audio_rate), decimation=int(baseband_rate), taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0_0_0 = filter.rational_resampler_fff( interpolation=int(audio_rate), decimation=int(baseband_rate), taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_fff( interpolation=int(audio_rate), decimation=int(baseband_rate), taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "RBDS Bit Stream", #name 2 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1.7, 1.7) self.qtgui_time_sink_x_1.set_y_label("Amplitude", "") self.qtgui_time_sink_x_1.enable_tags(-1, False) 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_control_panel(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ["Raw Bit Stream", "Differential Decoded", "", "", "", "", "", "", "", ""] 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): 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.notebook_rds_layout_1.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size baseband_rate, #samp_rate "19 KHz Pilot Signal", #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.5, 1.5) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "counts") self.qtgui_time_sink_x_0.enable_tags(-1, False) 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 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.notebook_subcarriers_grid_layout_0.addWidget(self._qtgui_time_sink_x_0_win, 0, 1, 1, 1) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc rds_samp_rate, #bw "RDS Subcarrier Signal (DSB-SSC)", #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(1.0) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1.disable_legend() if complex == type(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(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.notebook_rds_grid_layout_0 .addWidget(self._qtgui_freq_sink_x_1_win, 0, 0, 1, 1) self.qtgui_freq_sink_x_0_1_0_1_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "Stereo Audio Left", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_1_0_1_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_1_0_1_0.set_y_axis(-100, -30) self.qtgui_freq_sink_x_0_1_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_1_0_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_1_0_1_0.enable_grid(False) self.qtgui_freq_sink_x_0_1_0_1_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0_1_0_1_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_1_0_1_0.disable_legend() if float == type(float()): self.qtgui_freq_sink_x_0_1_0_1_0.set_plot_pos_half(not False) labels = ["Stereo Left", "Stereo Right", "", "", "", "", "", "", "", ""] 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_0_1_0_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_1_0_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_1_0_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_1_0_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_1_0_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_1_0_1_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_1_0_1_0.pyqwidget(), Qt.QWidget) self.notebook_top_grid_layout_4.addWidget(self._qtgui_freq_sink_x_0_1_0_1_0_win, 0, 0, 1, 1) self.qtgui_freq_sink_x_0_1_0_1 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "Stereo Audio Right", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_1_0_1.set_update_time(0.10) self.qtgui_freq_sink_x_0_1_0_1.set_y_axis(-100, -30) self.qtgui_freq_sink_x_0_1_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_1_0_1.enable_autoscale(False) self.qtgui_freq_sink_x_0_1_0_1.enable_grid(False) self.qtgui_freq_sink_x_0_1_0_1.set_fft_average(0.1) self.qtgui_freq_sink_x_0_1_0_1.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_1_0_1.disable_legend() if float == type(float()): self.qtgui_freq_sink_x_0_1_0_1.set_plot_pos_half(not False) labels = ["Stereo Right", "Stereo Right", "", "", "", "", "", "", "", ""] 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_0_1_0_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_1_0_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_1_0_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_1_0_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_1_0_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_1_0_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_1_0_1.pyqwidget(), Qt.QWidget) self.notebook_top_grid_layout_4.addWidget(self._qtgui_freq_sink_x_0_1_0_1_win, 0, 1, 1, 1) self.qtgui_freq_sink_x_0_1_0_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc baseband_rate, #bw "Pilot & Stereo Carrier", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_1_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_1_0_0.set_y_axis(-80, 0) self.qtgui_freq_sink_x_0_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_1_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_1_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_1_0_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0_1_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_1_0_0.disable_legend() if float == type(float()): self.qtgui_freq_sink_x_0_1_0_0.set_plot_pos_half(not False) labels = ["Pilot Tone", "Stereo Carrier", "RDS Carrier", "", "", "", "", "", "", ""] 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_0_1_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_1_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_1_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_1_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_1_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_1_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_1_0_0.pyqwidget(), Qt.QWidget) self.notebook_subcarriers_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_1_0_0_win, 0, 0, 1, 1) self.qtgui_freq_sink_x_0_0_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "Mono Audio (L+R)", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_0.set_y_axis(-100, -30) self.qtgui_freq_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0_0.disable_legend() if float == type(float()): self.qtgui_freq_sink_x_0_0_0.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(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.notebook_top_grid_layout_2.addWidget(self._qtgui_freq_sink_x_0_0_0_win, 1, 0, 1, 5) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc baseband_rate, #bw "FM Baseband", #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(-100, -30) 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(False) self.qtgui_freq_sink_x_0_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0.disable_legend() if float == type(float()): self.qtgui_freq_sink_x_0_0.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_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.notebook_top_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 1, 1, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype fm_station * 1e6, #fc samp_rate, #bw "RF Frequency", #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(-90, 0) 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(0.1) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if complex == type(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.notebook_top_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 1, 1, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "RDS BPSK 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(-1.6, 1.6) self.qtgui_const_sink_x_0.set_x_axis(-1.6, 1.6) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) if not False: self.qtgui_const_sink_x_0.disable_legend() labels = ["RBDS BPSK", "", "", "", "", "", "", "", "", ""] 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.notebook_rds_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 0, 1, 1, 1) self.low_pass_filter_4 = filter.fir_filter_fff(1, firdes.low_pass( 1, baseband_rate, 60e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2 = filter.fir_filter_fff(1, firdes.low_pass( 1, baseband_rate, 16e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = filter.fir_filter_fff(1, firdes.low_pass( 10, baseband_rate, 15e3, 3e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(baseband_decimation, firdes.low_pass( 1, samp_rate, 75e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.gr_rds_parser_0 = rds.parser(False, False, 1) self.gr_rds_decoder_0 = rds.decoder(False, False) self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_fcc(rds_dec, (firdes.low_pass(2500,baseband_rate,rds_bandwidth,1e3,firdes.WIN_HAMMING)), rds_subcarrier, baseband_rate) self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc(2, 0, (2 * cmath.pi) / 100, -0.00006, 0.00006, 0.5, 0.05, rds_samp_rate / (rds_bitrate * 2), ((rds_samp_rate / (rds_bitrate * 2)) ** 2)/ 4, 0.005) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_uchar_to_float_0_0 = blocks.uchar_to_float() self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_multiply_xx_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_1_0_1_0_1 = blocks.multiply_const_vff((11, )) self.blocks_multiply_const_vxx_1_0_1_0_0 = blocks.multiply_const_vff((11, )) self.blocks_multiply_const_vxx_1_0_1_0 = blocks.multiply_const_vff((11, )) self.blocks_multiply_const_vxx_1_0_1 = blocks.multiply_const_vff((slider_volume, )) self.blocks_multiply_const_vxx_1_0_0 = blocks.multiply_const_vff((slider_volume, )) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((slider_volume, )) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_char*1, 2) self.blocks_complex_to_real_1 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((0.5, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1.5, )) self.blks2_selector_0_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=2, num_outputs=1, input_index=0, output_index=0, ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=2, num_outputs=1, input_index=0, output_index=0, ) self.band_pass_filter_1 = filter.fir_filter_fff(1, firdes.band_pass( 1, baseband_rate, stereo_subcarrier - 0.5e3, stereo_subcarrier + 0.5e3, 0.5e3, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0_0 = filter.fir_filter_fff(1, firdes.band_pass( 1, baseband_rate, 23e3, 53e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_fcc(1, firdes.complex_band_pass( 1, baseband_rate, pilot_tone - 0.5e3, pilot_tone+0.5e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=baseband_rate, audio_decimation=1, ) self.analog_pll_refout_cc_0 = analog.pll_refout_cc(1e-3, 2 * cmath.pi * (19000+200) / baseband_rate, 2 * cmath.pi * (19000-200) / baseband_rate) self.analog_fm_deemph_0_0_0_1 = analog.fm_deemph(fs=baseband_rate, tau=75e-6) self.analog_fm_deemph_0_0_0_0 = analog.fm_deemph(fs=baseband_rate, tau=75e-6) self.analog_fm_deemph_0_0_0 = analog.fm_deemph(fs=baseband_rate, tau=75e-6) ################################################## # Connections ################################################## self.msg_connect((self.gr_rds_decoder_0, 'out'), (self.gr_rds_parser_0, 'in')) self.msg_connect((self.gr_rds_parser_0, 'out'), (self.rds_qt_panel_0, 'in')) self.connect((self.analog_fm_deemph_0_0_0, 0), (self.rational_resampler_xxx_0_0_0, 0)) self.connect((self.analog_fm_deemph_0_0_0_0, 0), (self.rational_resampler_xxx_0_0_0_0, 0)) self.connect((self.analog_fm_deemph_0_0_0_1, 0), (self.rational_resampler_xxx_0_0_0_1, 0)) self.connect((self.analog_pll_refout_cc_0, 0), (self.blocks_complex_to_real_1, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.low_pass_filter_4, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_pll_refout_cc_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.band_pass_filter_1, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.band_pass_filter_1, 0), (self.qtgui_freq_sink_x_0_1_0_0, 1)) self.connect((self.blks2_selector_0, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_selector_0_0, 0), (self.audio_sink_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_time_sink_x_1, 1)) self.connect((self.blocks_add_const_vxx_0_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.analog_fm_deemph_0_0_0_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_real_1, 0), (self.qtgui_freq_sink_x_0_1_0_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blks2_selector_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_freq_sink_x_0_1_0_1, 1)) self.connect((self.blocks_multiply_const_vxx_1_0_0, 0), (self.blks2_selector_0_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0_0, 0), (self.qtgui_freq_sink_x_0_1_0_1_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0_1, 0), (self.blks2_selector_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0_1, 0), (self.blks2_selector_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0_1, 0), (self.qtgui_freq_sink_x_0_0_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0_1_0, 0), (self.qtgui_freq_sink_x_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0_1_0_0, 0), (self.qtgui_freq_sink_x_0_1_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_1_0_1_0_1, 0), (self.qtgui_freq_sink_x_0_1_0_1_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.band_pass_filter_1, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.low_pass_filter_2, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.analog_fm_deemph_0_0_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_add_const_vxx_0_0, 0)) self.connect((self.blocks_uchar_to_float_0_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_uchar_to_float_0_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.gr_rds_decoder_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.analog_fm_deemph_0_0_0_1, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.low_pass_filter_2, 0), (self.blocks_add_xx_0, 1)) self.connect((self.low_pass_filter_2, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.low_pass_filter_4, 0), (self.band_pass_filter_0, 0)) self.connect((self.low_pass_filter_4, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.low_pass_filter_4, 0), (self.freq_xlating_fir_filter_xxx_1, 0)) self.connect((self.low_pass_filter_4, 0), (self.low_pass_filter_1, 0)) self.connect((self.low_pass_filter_4, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.blocks_multiply_const_vxx_1_0_1_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0_0, 0), (self.blocks_multiply_const_vxx_1_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0_0, 0), (self.blocks_multiply_const_vxx_1_0_1_0_1, 0)) self.connect((self.rational_resampler_xxx_0_0_0_1, 0), (self.blocks_multiply_const_vxx_1_0_1, 0)) self.connect((self.rational_resampler_xxx_0_0_0_1, 0), (self.blocks_multiply_const_vxx_1_0_1_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_mpsk_receiver_cc_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.qtgui_freq_sink_x_1, 1)) self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self): gr.top_block.__init__( self, "Downlink from TVAC (This should run all the time)") Qt.QWidget.__init__(self) self.setWindowTitle( "Downlink from TVAC (This should run all the time)") 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", "downlink") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.block_len_enc = block_len_enc = 1024 / 8 * 2 self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist( ([-1, 1]), ([0, 1]), 4, 1).base() self.samp_rate_factor = samp_rate_factor = 5 self.samp_rate = samp_rate = 250000 self.rgain = rgain = 0 self.payload = payload = block_len_enc + 4 self.freq_offset_flag = freq_offset_flag = 0 self.freq_offset = freq_offset = 0 ################################################## # Blocks ################################################## self._rgain_range = Range(0, 11, 1, 0, 200) self._rgain_win = RangeWidget(self._rgain_range, self.set_rgain, 'RX Gain', "counter_slider", float) self.top_layout.addWidget(self._rgain_win) self._freq_offset_range = Range(-400e3, 400e3, 1.5e3, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Frequency Offset', "counter_slider", float) self.top_layout.addWidget(self._freq_offset_win) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=1, decimation=5, taps=None, fractional_bw=None, ) self.qtgui_sink_x_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name False, #plotfreq False, #plotwaterfall False, #plottime True, #plotconst ) self.qtgui_sink_x_1.set_update_time(1.0 / 10) self._qtgui_sink_x_1_win = sip.wrapinstance( self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_1_win) self.qtgui_sink_x_1.enable_rf_freq(False) self.qtgui_sink_x_0_0_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Vor Sync", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0_0_1.set_update_time(1.0 / 10) self._qtgui_sink_x_0_0_1_win = sip.wrapinstance( self.qtgui_sink_x_0_0_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_0_1_win) self.qtgui_sink_x_0_0_1.enable_rf_freq(False) self.qtgui_sink_x_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate * samp_rate_factor, #bw "Vor Sync", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_0_win) self.qtgui_sink_x_0_0.enable_rf_freq(False) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + 'bladerf=1269166c0b71088680ad4ec53222be07,xb200=144M') self.osmosdr_source_0.set_sample_rate(samp_rate * samp_rate_factor) self.osmosdr_source_0.set_center_freq(145.95e6, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(rgain, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self._freq_offset_flag_range = Range(0, 1, 1, 0, 200) self._freq_offset_flag_win = RangeWidget(self._freq_offset_flag_range, self.set_freq_offset_flag, 'Enable flatsat freq', "counter_slider", float) self.top_layout.addWidget(self._freq_offset_flag_win) self.fir_filter_xxx_0 = filter.fir_filter_ccc(samp_rate_factor, (1, )) self.fir_filter_xxx_0.declare_sample_delay(0) self.digital_mpsk_receiver_cc_0_0 = digital.mpsk_receiver_cc( 2, 0, cmath.pi / 100.0, -0.05, 0.05, 0.25, 0.05, 4, 4, 0.005) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( variable_constellation_0) self.ccsds_softbits_msg_to_bytes_b_0 = ccsds.softbits_msg_to_bytes_b() self.ccsds_randomiser_softbits_0 = ccsds.randomiser_softbits( 0x95, 0xFF) self.ccsds_mpsk_ambiguity_resolver_f_0 = ccsds.mpsk_ambiguity_resolver_f( 2, '49E0DCC7', 32, 1, 0.8, block_len_enc, 0) self.ccsds_message_info_0 = ccsds.message_info(10) self.ccsds_ldpc_decoder_0 = ccsds.ldpc_decoder( '/tmp/AR4JA_r12_k1024n.a', ccsds.LDPC_SYS_FRONT, ccsds.LDPC_PUNCT_BACK, 512, tuple(([]))) self.ccsds_blob_msg_sink_b_0 = ccsds.blob_msg_sink_b(256 / 2) self.blocks_udp_sink_0_1 = blocks.udp_sink(gr.sizeof_char * 1, '127.0.0.1', 5431, 256, True) self.blocks_udp_sink_0_0 = blocks.udp_sink(gr.sizeof_char * 1, '127.0.0.1', 5433, 1472, True) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex * 1, '127.0.0.1', 5435, 1472, True) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_char * 1) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 0.5) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, )) self.band_pass_filter_0 = filter.fir_filter_ccc( 1, firdes.complex_band_pass(1, samp_rate * samp_rate_factor, 40e3, 60e3, 6e3, firdes.WIN_HAMMING, 6.76)) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate * samp_rate_factor, analog.GR_COS_WAVE, -freq_offset, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -50000, 1, 0) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 0.5, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.ccsds_blob_msg_sink_b_0, 'out'), (self.ccsds_message_info_0, 'in')) self.msg_connect((self.ccsds_ldpc_decoder_0, 'out'), (self.ccsds_softbits_msg_to_bytes_b_0, 'in')) self.msg_connect((self.ccsds_mpsk_ambiguity_resolver_f_0, 'out'), (self.ccsds_randomiser_softbits_0, 'in')) self.msg_connect((self.ccsds_randomiser_softbits_0, 'out'), (self.ccsds_ldpc_decoder_0, 'in')) self.connect((self.analog_agc_xx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.ccsds_mpsk_ambiguity_resolver_f_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_sink_x_0_0_1, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.ccsds_softbits_msg_to_bytes_b_0, 0), (self.blocks_null_sink_1, 0)) self.connect((self.ccsds_softbits_msg_to_bytes_b_0, 0), (self.blocks_udp_sink_0_1, 0)) self.connect((self.ccsds_softbits_msg_to_bytes_b_0, 0), (self.ccsds_blob_msg_sink_b_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_udp_sink_0_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0_0, 0), (self.qtgui_sink_x_1, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.osmosdr_source_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_sink_x_0_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.digital_mpsk_receiver_cc_0_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__( self, title="Stereo FM receiver and RDS Decoder") _icon_path = "/usr/share/icons/hicolor/24x24/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1000000 self.bb_decim = bb_decim = 4 self.freq_offset = freq_offset = 250000 self.freq = freq = 97e6 self.baseband_rate = baseband_rate = samp_rate / bb_decim self.audio_decim = audio_decim = 5 self.xlate_bandwidth = xlate_bandwidth = 100000 self.volume = volume = 0 self.gain = gain = 20 self.freq_tune = freq_tune = freq - freq_offset self.audio_rate = audio_rate = 48000 self.audio_decim_rate = audio_decim_rate = baseband_rate / audio_decim ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label='Volume', converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=-20, maximum=10, num_steps=300, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_volume_sizer, 0, 1, 1, 1) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Demod") self.nb.AddPage(grc_wxgui.Panel(self.nb), "L+R") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Pilot") self.nb.AddPage(grc_wxgui.Panel(self.nb), "DSBSC") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS") self.nb.AddPage(grc_wxgui.Panel(self.nb), "L-R") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS constellation") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Waterfall") self.GridAdd(self.nb, 2, 0, 1, 2) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label='RF Gain', converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=49.6, num_steps=124, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_sizer, 0, 0, 1, 1) _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label='Freq', converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=88.1e6, maximum=107.9e6, num_steps=99, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_freq_sizer, 1, 0, 1, 2) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_f( self.nb.GetPage(8).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=baseband_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title='Waterfall Plot', ) self.nb.GetPage(8).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_1 = scopesink2.scope_sink_c( self.nb.GetPage(7).GetWin(), title='Scope Plot', sample_rate=2375, v_scale=0.4, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label='Counts', ) self.nb.GetPage(7).Add(self.wxgui_scopesink2_1.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.nb.GetPage(3).GetWin(), title='Pilot', sample_rate=baseband_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label='Counts', ) self.nb.GetPage(3).Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0_0_0_1_0_1 = fftsink2.fft_sink_c( self.nb.GetPage(5).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=audio_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title='RDS', peak_hold=False, ) self.nb.GetPage(5).Add(self.wxgui_fftsink2_0_0_0_1_0_1.win) self.wxgui_fftsink2_0_0_0_1_0_0 = fftsink2.fft_sink_f( self.nb.GetPage(6).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=-50, ref_scale=2.0, sample_rate=baseband_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title='L-R', peak_hold=False, ) self.nb.GetPage(6).Add(self.wxgui_fftsink2_0_0_0_1_0_0.win) self.wxgui_fftsink2_0_0_0_1 = fftsink2.fft_sink_f( self.nb.GetPage(4).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=baseband_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title='DSBSC Sub-carrier', peak_hold=False, ) self.nb.GetPage(4).Add(self.wxgui_fftsink2_0_0_0_1.win) self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_f( self.nb.GetPage(2).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=audio_decim_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title='L+R', peak_hold=False, ) self.nb.GetPage(2).Add(self.wxgui_fftsink2_0_0_0.win) self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_f( self.nb.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=baseband_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.8, title='FM Demod', peak_hold=False, ) self.nb.GetPage(1).Add(self.wxgui_fftsink2_0_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=-30, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.8, title='Baseband', peak_hold=False, ) self.nb.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 / bb_decim / audio_decim, 2375, 1, 100)) self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff( interpolation=audio_rate, decimation=audio_decim_rate, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=audio_rate, decimation=audio_decim_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) self.osmosdr_source_0.set_center_freq(freq_tune, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(gain, 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.gr_rds_parser_0 = rds.parser(True, False, 0) self.gr_rds_panel_0 = rds.rdsPanel(freq, self.GetWin()) self.Add(self.gr_rds_panel_0.panel) self.gr_rds_decoder_0 = rds.decoder(False, False) self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_fcc( audio_decim, (firdes.low_pass(2500.0, baseband_rate, 2.4e3, 2e3, firdes.WIN_HAMMING)), 57e3, baseband_rate) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, (firdes.low_pass(1, samp_rate, xlate_bandwidth, 100000)), freq_offset, samp_rate) self.fir_filter_xxx_5 = filter.fir_filter_fff( audio_decim, (firdes.low_pass(1.0, baseband_rate, 20e3, 40e3, firdes.WIN_HAMMING))) self.fir_filter_xxx_5.declare_sample_delay(0) self.fir_filter_xxx_3 = filter.fir_filter_fff( 1, (firdes.band_pass(1.0, baseband_rate, 38e3 - 13e3, 38e3 + 13e3, 3e3, firdes.WIN_HAMMING))) self.fir_filter_xxx_3.declare_sample_delay(0) self.fir_filter_xxx_2 = filter.fir_filter_fcc( 1, (firdes.complex_band_pass(1.0, baseband_rate, 19e3 - 500, 19e3 + 500, 1e3, firdes.WIN_HAMMING))) self.fir_filter_xxx_2.declare_sample_delay(0) self.fir_filter_xxx_1 = filter.fir_filter_fff( audio_decim, (firdes.low_pass(1.0, baseband_rate, 13e3, 3e3, firdes.WIN_HAMMING))) self.fir_filter_xxx_1.declare_sample_delay(0) self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc( 2, 0, 1 * cmath.pi / 100.0, -0.06, 0.06, 0.5, 0.05, samp_rate / bb_decim / audio_decim / 2375.0, 0.001, 0.005) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff( (10**(1. * (volume + 15) / 10), )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (10**(1. * (volume + 15) / 10), )) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_char * 1, 2) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.audio_sink_0 = audio.sink(audio_rate, '', True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=samp_rate, audio_decimation=bb_decim, ) self.analog_pll_refout_cc_0 = analog.pll_refout_cc( 0.001, 2 * math.pi * (19000 + 200) / baseband_rate, 2 * math.pi * (19000 - 200) / baseband_rate) self.analog_fm_deemph_0_0_0 = analog.fm_deemph(fs=audio_decim_rate, tau=75e-6) self.analog_fm_deemph_0_0 = analog.fm_deemph(fs=audio_decim_rate, tau=75e-6) ################################################## # Connections ################################################## self.msg_connect((self.gr_rds_decoder_0, 'out'), (self.gr_rds_parser_0, 'in')) self.msg_connect((self.gr_rds_parser_0, 'out'), (self.gr_rds_panel_0, 'in')) self.connect((self.analog_fm_deemph_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.analog_fm_deemph_0_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_pll_refout_cc_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.analog_pll_refout_cc_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.analog_wfm_rcv_0, 0), (self.fir_filter_xxx_1, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.fir_filter_xxx_2, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.fir_filter_xxx_3, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.freq_xlating_fir_filter_xxx_1, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.analog_fm_deemph_0_0_0, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_imag_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.fir_filter_xxx_5, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_fftsink2_0_0_0_1_0_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_complex_to_imag_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.analog_fm_deemph_0_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.gr_rds_decoder_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.wxgui_fftsink2_0_0_0, 0)) self.connect((self.fir_filter_xxx_2, 0), (self.analog_pll_refout_cc_0, 0)) self.connect((self.fir_filter_xxx_3, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.fir_filter_xxx_3, 0), (self.wxgui_fftsink2_0_0_0_1, 0)) self.connect((self.fir_filter_xxx_5, 0), (self.blocks_add_xx_0, 1)) self.connect((self.fir_filter_xxx_5, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.wxgui_fftsink2_0_0_0_1_0_1, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.audio_sink_0, 1)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_mpsk_receiver_cc_0, 0))
def __init__(self, options, args): gr.top_block.__init__(self, "RDS Tropo Detector") pubsub.__init__(self) # Retrieve the selected options self.options = options self._verbose = options.verbose # Variables self.freq = 99.5e6 self.samp_rate = 1000000 # TODO FIX : sampling rate self.bb_decim = 4 self.freq_offset = baseband_rate = self.samp_rate/self.bb_decim self.audio_decim = 5 self.xlate_bandwidth = 100000 self.gain = 20 self.freq_tune = self.freq - self.freq_offset # Initialize the device using OsmoSDR library self.src = osmosdr.source(options.args) try: self.src.get_sample_rates().start() except RuntimeError: print "Source has no sample rates (wrong device arguments?)." sys.exit(1) # Set the antenna if(options.antenna): self.src.set_antenna(options.antenna) # Apply the selected settings self.src.set_sample_rate(options.samp_rate) #self.src.set_sample_rate(self.samp_rate) self.src.set_center_freq(self.freq_tune, 0) self.src.set_freq_corr(0, 0) self.src.set_dc_offset_mode(0, 0) self.src.set_iq_balance_mode(0, 0) self.src.set_gain_mode(False, 0) self.src.set_gain(self.gain, 0) self.src.set_if_gain(20, 0) self.src.set_bb_gain(20, 0) self.src.set_antenna("", 0) self.src.set_bandwidth(0, 0) # Blocks self.fir_in = filter.freq_xlating_fir_filter_ccc(1, (firdes.low_pass(1, self.samp_rate, self.xlate_bandwidth, 100000)), self.freq_offset, self.samp_rate) self.fm_demod = analog.wfm_rcv( quad_rate=self.samp_rate, audio_decimation=self.bb_decim, ) self.fir_bb = filter.freq_xlating_fir_filter_fcf( self.audio_decim, (firdes.low_pass(2500.0,baseband_rate,2.4e3,2e3,firdes.WIN_HAMMING)), 57e3, baseband_rate) self.rrc = filter.fir_filter_ccf(1, firdes.root_raised_cosine( 1, self.samp_rate/self.bb_decim/self.audio_decim, 2375, 1, 100)) self.mpsk_demod = digital.mpsk_receiver_cc(2, 0, 1*cmath.pi/100.0, -0.06, 0.06, 0.5, 0.05, self.samp_rate/self.bb_decim/self.audio_decim/ 2375.0, 0.001, 0.005) self.complex_to_real = blocks.complex_to_real(1) self.slicer = digital.binary_slicer_fb() self.skip = blocks.keep_one_in_n(1, 2) self.diff = digital.diff_decoder_bb(2) self.rds_decoder = rds.decoder(False, False) self.rds_parser = rds.parser(False, False, 1) self.rds_pi_extract = rds_pi() # Connections self.connect((self.src, 0), (self.fir_in, 0)) self.connect((self.fir_in, 0), (self.fm_demod, 0)) self.connect((self.fm_demod, 0), (self.fir_bb, 0)) self.connect((self.fir_bb, 0), (self.rrc, 0)) self.connect((self.rrc, 0), (self.mpsk_demod, 0)) self.connect((self.mpsk_demod, 0), (self.complex_to_real, 0)) self.connect((self.complex_to_real, 0), (self.slicer, 0)) self.connect((self.slicer, 0), (self.skip, 0)) self.connect((self.skip, 0), (self.diff, 0)) self.connect((self.diff, 0), (self.rds_decoder, 0)) self.msg_connect((self.rds_decoder, 'out'), (self.rds_parser, 'in')) self.msg_connect((self.rds_parser, 'out'), (self.rds_pi_extract, 'in'))
def __init__(self): gr.top_block.__init__(self, "Tetra Rx Multi") options = self.get_options() self.src = blocks.file_source(gr.sizeof_gr_complex*1, "/tmp/myout1.ch", False) ################################################## # Variables ################################################## self.srate_rx = srate_rx = options.sample_rate self.channels = srate_rx / 25000 self.srate_channel = 36000 self.afc_period = 15 self.afc_gain = 0.01 self.afc_channel = options.auto_tune or -1 self.afc_ppm_step = 100 self.debug = options.debug self.last_pwr = -100000 self.sig_det_period = 10 self.sig_det_bw = sig_det_bw = options.sig_detection_bw or srate_rx if self.sig_det_bw <= 1.: self.sig_det_bw *= srate_rx self.sig_det_threshold = options.sig_detection_threshold self.sig_det_channels = [] for ch in range(self.channels): if ch >= self.channels / 2: ch_ = (self.channels - ch - 1) else: ch_ = ch if (float(ch_) / self.channels * 2) <= (self.sig_det_bw / srate_rx): self.sig_det_channels.append(ch) self.channels = 10 ################################################## # RPC server ################################################## self.xmlrpc_server = SimpleXMLRPCServer.SimpleXMLRPCServer( ("localhost", options.listen_port), allow_none=True) self.xmlrpc_server.register_instance(self) threading.Thread(target=self.xmlrpc_server.serve_forever).start() ################################################## # Rx Blocks and connections ################################################## out_type, dst_path = options.output.split("://", 1) if out_type == "udp": dst_ip, dst_port = dst_path.split(':', 1) self.blocks_deinterleave_0 = blocks.deinterleave(gr.sizeof_gr_complex*1, 1) self.squelch = [] self.digital_mpsk_receiver_cc = [] self.diff_phasor = [] self.complex_to_arg = [] self.multiply_const = [] self.add_const = [] self.float_to_uchar = [] self.map_bits = [] self.unpack_k_bits = [] self.blocks_sink = [] for ch in range(0, self.channels): mpsk = digital.mpsk_receiver_cc( 4, math.pi/4, math.pi/100.0, -0.5, 0.5, 0.25, 0.001, 2, 0.001, 0.001) diff_phasor = digital.diff_phasor_cc() complex_to_arg = blocks.complex_to_arg(1) multiply_const = blocks.multiply_const_vff((2./math.pi, )) add_const = blocks.add_const_vff((1.5, )) float_to_uchar = blocks.float_to_uchar() map_bits = digital.map_bb(([3, 2, 0, 1, 3])) unpack_k_bits = blocks.unpack_k_bits_bb(2) brmchannels = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71] #brmchannels = [11,4,3,64,45,47,53,8,68,6,56,49,17,54,65,5,71,22,48,7,50] # itds kancl #brmchannels = [23,13,40,69,59,7,42,54,5,14,4,56,45,46,67,55,66,44,71,49,31,57,0,65,70] # doma - dole #brmchannels = [23,13,59,40,69,7,49,60,42,70,4,50,66,67,3,14,57,33,46,22,68,32,39,24,6,12,43,58,48,17,5,56,65,29,54,30,16,52,53,41,47,2,34,44,8] # doma - strecha #brmchannels = [67, 7, 23, 70] # doma - strecha - SDS #brmchannels = [67, 7, 23, 70,9,71,64,63,62,61,55,51,45,38,37,36,35,31,28,27,26,25,21,20,19,18,15,11,10,1,0] # doma - strecha - komplement if out_type == 'udp': sink = blocks.udp_sink(gr.sizeof_gr_char, dst_ip, int(dst_port)+ch, 1472, True) elif out_type == 'file': sink = blocks.file_sink(gr.sizeof_char, dst_path % ch, False) sink.set_unbuffered(True) else: raise ValueError("Invalid output URL '%s'" % options.output) print "connect %i"%ch if ch in brmchannels: self.connect((self.blocks_deinterleave_0, ch), #(squelch, 0), (mpsk, 0), (diff_phasor, 0), (complex_to_arg, 0), (multiply_const, 0), (add_const, 0), (float_to_uchar, 0), (map_bits, 0), (unpack_k_bits, 0), (sink, 0)) self.digital_mpsk_receiver_cc.append(mpsk) self.diff_phasor.append(diff_phasor) self.complex_to_arg.append(complex_to_arg) self.multiply_const.append(multiply_const) self.add_const.append(add_const) self.float_to_uchar.append(float_to_uchar) self.map_bits.append(map_bits) self.unpack_k_bits.append(unpack_k_bits) self.blocks_sink.append(sink) self.connect( (self.src, 0), (self.blocks_deinterleave_0, 0)) ################################################## # signal strenght identification ################################################## ''' self.pwr_probes = [] for ch in range(self.channels): pwr_probe = analog.probe_avg_mag_sqrd_c(0, 1./self.srate_channel) self.pwr_probes.append(pwr_probe) print "connect %i"%ch self.connect((self.blocks_deinterleave_0, ch), (pwr_probe, 0)) def _sig_det_probe(): while True: pwr = [self.pwr_probes[ch].level() for ch in range(self.channels) if ch in self.sig_det_channels] pwr = [10 * math.log10(p) for p in pwr if p > 0.] if not pwr: continue pwr = min(pwr) + self.sig_det_threshold print "power threshold target %f"%pwr if abs(pwr - self.last_pwr) > (self.sig_det_threshold / 2): for s in []: s.set_threshold(pwr) self.last_pwr = pwr time.sleep(self.sig_det_period) if self.sig_det_threshold is not None: self._sig_det_probe_thread = threading.Thread(target=_sig_det_probe) self._sig_det_probe_thread.daemon = True self._sig_det_probe_thread.start() ''' ################################################## # AFC blocks and connections ################################################## self.afc_selector = grc_blks2.selector( item_size=gr.sizeof_gr_complex, num_inputs=self.channels, num_outputs=1, input_index=0, output_index=0, ) self.afc_demod = analog.quadrature_demod_cf(self.srate_channel/(2*math.pi)) samp_afc = self.srate_channel*self.afc_period / 2 self.afc_avg = blocks.moving_average_ff(samp_afc, 1./samp_afc*self.afc_gain) self.afc_probe = blocks.probe_signal_f() def _afc_probe(): rt = 0.0 while True: time.sleep(self.afc_period) if self.afc_channel == -1: continue err = self.afc_probe.level() freq = err * self.afc_gain print "err: %f\tfreq: %f\trt %f" % (err, freq, rt) changed = False if err < -1: rt += 0.1 changed = True elif err > 1: rt -= 0.1 changed = True if changed: os.system("echo \"setrot %f\" | nc localhost 3333"%rt) self.afc_channel = 0 self._afc_err_thread = threading.Thread(target=_afc_probe) self._afc_err_thread.daemon = True self._afc_err_thread.start() for ch in range(self.channels): print "connect %i"%ch self.connect((self.blocks_deinterleave_0, ch), (self.afc_selector, ch)) self.connect( (self.afc_selector, 0), (self.afc_demod, 0), (self.afc_avg, 0), (self.afc_probe, 0)) if self.afc_channel != -1: self.afc_selector.set_input_index(self.afc_channel)
def __init__(self, samples_per_symbol=_def_samples_per_symbol, excess_bw=_def_excess_bw, costas_alpha=_def_costas_alpha, gain_mu=_def_gain_mu, mu=_def_mu, omega_relative_limit=_def_omega_relative_limit, gray_code=_def_gray_code, verbose=_def_verbose, log=_def_log): """ Hierarchical block for RRC-filtered CQPSK demodulation The input is the complex modulated signal at baseband. The output is a stream of floats in [ -3 / -1 / +1 / +3 ] @param samples_per_symbol: samples per symbol >= 2 @type samples_per_symbol: float @param excess_bw: Root-raised cosine filter excess bandwidth @type excess_bw: float @param costas_alpha: loop filter gain @type costas_alphas: float @param gain_mu: for M&M block @type gain_mu: float @param mu: for M&M block @type mu: float @param omega_relative_limit: for M&M block @type omega_relative_limit: float @param gray_code: Tell modulator to Gray code the bits @type gray_code: bool @param verbose: Print information about modulator? @type verbose: bool @param debug: Print modualtion data to files? @type debug: bool """ gr.hier_block2.__init__(self, "cqpsk_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_float)) # Output signature self._samples_per_symbol = samples_per_symbol self._excess_bw = excess_bw self._costas_alpha = costas_alpha self._mm_gain_mu = gain_mu self._mm_mu = mu self._mm_omega_relative_limit = omega_relative_limit self._gray_code = gray_code if samples_per_symbol < 2: raise TypeError, "sbp must be >= 2, is %d" % samples_per_symbol arity = pow(2,self.bits_per_symbol()) # Automatic gain control scale = (1.0/16384.0) self.pre_scaler = blocks.multiply_const_cc(scale) # scale the signal from full-range to +-1 #self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100) self.agc = analog.feedforward_agc_cc(16, 2.0) # RRC data filter ntaps = 11 * samples_per_symbol self.rrc_taps = firdes.root_raised_cosine( 1.0, # gain self._samples_per_symbol, # sampling rate 1.0, # symbol rate self._excess_bw, # excess bandwidth (roll-off factor) ntaps) self.rrc_filter=filter.interp_fir_filter_ccf(1, self.rrc_taps) if not self._mm_gain_mu: sbs_to_mm = {2: 0.050, 3: 0.075, 4: 0.11, 5: 0.125, 6: 0.15, 7: 0.15} self._mm_gain_mu = sbs_to_mm[samples_per_symbol] self._mm_omega = self._samples_per_symbol self._mm_gain_omega = .25 * self._mm_gain_mu * self._mm_gain_mu self._costas_beta = 0.25 * self._costas_alpha * self._costas_alpha fmin = -0.025 fmax = 0.025 if not _def_has_gr_digital: self.receiver=gr.mpsk_receiver_cc(arity, pi/4.0, self._costas_alpha, self._costas_beta, fmin, fmax, self._mm_mu, self._mm_gain_mu, self._mm_omega, self._mm_gain_omega, self._mm_omega_relative_limit) else: self.receiver=digital.mpsk_receiver_cc(arity, pi/4.0, 2*pi/150, fmin, fmax, self._mm_mu, self._mm_gain_mu, self._mm_omega, self._mm_gain_omega, self._mm_omega_relative_limit) #self.receiver.set_alpha(self._costas_alpha) #self.receiver.set_beta(self._costas_beta) # Perform Differential decoding on the constellation self.diffdec = digital.diff_phasor_cc() # take angle of the difference (in radians) self.to_float = blocks.complex_to_arg() # convert from radians such that signal is in -3/-1/+1/+3 self.rescale = blocks.multiply_const_ff( 1 / (pi / 4) ) if verbose: self._print_verbage() if log: self._setup_logging() # Connect & Initialize base class self.connect(self, self.pre_scaler, self.agc, self.rrc_filter, self.receiver, self.diffdec, self.to_float, self.rescale, self)
def __init__(self): gr.top_block.__init__(self, "Tetra Rx Multi") options = self.get_options() ################################################## # Variables ################################################## self.srate_rx = srate_rx = options.sample_rate self.channels = srate_rx / 25000 self.srate_channel = 36000 self.afc_period = 5 self.afc_gain = 1. self.afc_channel = options.auto_tune or -1 self.afc_ppm_step = 100 self.debug = options.debug self.last_pwr = -100000 self.sig_det_period = 1 self.sig_det_bw = sig_det_bw = options.sig_detection_bw or srate_rx if self.sig_det_bw <= 1.: self.sig_det_bw *= srate_rx self.sig_det_threshold = options.sig_detection_threshold self.sig_det_channels = [] for ch in range(self.channels): if ch >= self.channels / 2: ch_ = (self.channels - ch - 1) else: ch_ = ch if (float(ch_) / self.channels * 2) <= (self.sig_det_bw / srate_rx): self.sig_det_channels.append(ch) ################################################## # RPC server ################################################## self.xmlrpc_server = SimpleXMLRPCServer.SimpleXMLRPCServer( ("localhost", options.listen_port), allow_none=True) self.xmlrpc_server.register_instance(self) threading.Thread(target=self.xmlrpc_server.serve_forever).start() ################################################## # Rx Blocks and connections ################################################## self.src = osmosdr.source(args=options.args) self.src.set_sample_rate(srate_rx) self.src.set_center_freq(options.frequency, 0) self.src.set_freq_corr(options.ppm, 0) self.src.set_dc_offset_mode(0, 0) self.src.set_iq_balance_mode(0, 0) if options.gain is not None: self.src.set_gain_mode(False, 0) self.src.set_gain(36, 0) else: self.src.set_gain_mode(True, 0) out_type, dst_path = options.output.split("://", 1) if out_type == "udp": dst_ip, dst_port = dst_path.split(':', 1) self.freq_xlating = freq_xlating_fft_filter_ccc(1, (1, ), 0, srate_rx) self.channelizer = pfb.channelizer_ccf( self.channels, (firdes.root_raised_cosine(1, srate_rx, 18000, 0.35, 1024)), 36. / 25., 100) self.squelch = [] self.digital_mpsk_receiver_cc = [] self.diff_phasor = [] self.complex_to_arg = [] self.multiply_const = [] self.add_const = [] self.float_to_uchar = [] self.map_bits = [] self.unpack_k_bits = [] self.blocks_sink = [] for ch in range(0, self.channels): squelch = analog.pwr_squelch_cc(0, 0.001, 0, True) mpsk = digital.mpsk_receiver_cc(4, math.pi / 4, math.pi / 100.0, -0.5, 0.5, 0.25, 0.001, 2, 0.001, 0.001) diff_phasor = digital.diff_phasor_cc() complex_to_arg = blocks.complex_to_arg(1) multiply_const = blocks.multiply_const_vff((2. / math.pi, )) add_const = blocks.add_const_vff((1.5, )) float_to_uchar = blocks.float_to_uchar() map_bits = digital.map_bb(([3, 2, 0, 1, 3])) unpack_k_bits = blocks.unpack_k_bits_bb(2) if out_type == 'udp': sink = blocks.udp_sink(gr.sizeof_gr_char, dst_ip, int(dst_port) + ch, 1472, True) elif out_type == 'file': sink = blocks.file_sink(gr.sizeof_char, dst_path % ch, False) sink.set_unbuffered(True) else: raise ValueError("Invalid output URL '%s'" % options.output) self.connect((self.channelizer, ch), (squelch, 0), (mpsk, 0), (diff_phasor, 0), (complex_to_arg, 0), (multiply_const, 0), (add_const, 0), (float_to_uchar, 0), (map_bits, 0), (unpack_k_bits, 0), (sink, 0)) self.squelch.append(squelch) self.digital_mpsk_receiver_cc.append(mpsk) self.diff_phasor.append(diff_phasor) self.complex_to_arg.append(complex_to_arg) self.multiply_const.append(multiply_const) self.add_const.append(add_const) self.float_to_uchar.append(float_to_uchar) self.map_bits.append(map_bits) self.unpack_k_bits.append(unpack_k_bits) self.blocks_sink.append(sink) self.connect((self.src, 0), (self.freq_xlating, 0), (self.channelizer, 0)) ################################################## # signal strenght identification ################################################## self.pwr_probes = [] for ch in range(self.channels): pwr_probe = analog.probe_avg_mag_sqrd_c(0, 1. / self.srate_channel) self.pwr_probes.append(pwr_probe) self.connect((self.channelizer, ch), (pwr_probe, 0)) def _sig_det_probe(): while True: pwr = [ self.pwr_probes[ch].level() for ch in range(self.channels) if ch in self.sig_det_channels ] pwr = [10 * math.log10(p) for p in pwr if p > 0.] if not pwr: continue pwr = min(pwr) + self.sig_det_threshold print "Power level for squelch % 5.1f" % pwr if abs(pwr - self.last_pwr) > (self.sig_det_threshold / 2): for s in self.squelch: s.set_threshold(pwr) self.last_pwr = pwr time.sleep(self.sig_det_period) if self.sig_det_threshold is not None: self._sig_det_probe_thread = threading.Thread( target=_sig_det_probe) self._sig_det_probe_thread.daemon = True self._sig_det_probe_thread.start() ################################################## # AFC blocks and connections ################################################## self.afc_selector = grc_blks2.selector( item_size=gr.sizeof_gr_complex, num_inputs=self.channels, num_outputs=1, input_index=0, output_index=0, ) self.afc_demod = analog.quadrature_demod_cf(self.srate_channel / (2 * math.pi)) samp_afc = self.srate_channel * self.afc_period / 2 self.afc_avg = blocks.moving_average_ff(samp_afc, 1. / samp_afc * self.afc_gain) self.afc_probe = blocks.probe_signal_f() def _afc_probe(): while True: time.sleep(self.afc_period) if self.afc_channel == -1: continue err = self.afc_probe.level() if abs(err) < self.afc_ppm_step: continue freq = self.freq_xlating.center_freq + err * self.afc_gain if self.debug: print "err: %f\tfreq: %f" % ( err, freq, ) self.freq_xlating.set_center_freq(freq) self._afc_err_thread = threading.Thread(target=_afc_probe) self._afc_err_thread.daemon = True self._afc_err_thread.start() for ch in range(self.channels): self.connect((self.channelizer, ch), (self.afc_selector, ch)) self.connect((self.afc_selector, 0), (self.afc_demod, 0), (self.afc_avg, 0), (self.afc_probe, 0)) if self.afc_channel != -1: self.afc_selector.set_input_index(self.afc_channel)
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.sr_rf = sr_rf = 2500000 self.decimate = decimate = 400 self.sr_lo = sr_lo = sr_rf / decimate self.f_rf = f_rf = 434645000 self.f_lo = f_lo = 455.2 ################################################## # 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, "Tuning") 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, "IQ Display") 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, "PSK Output") self.top_layout.addWidget(self.tab) self._f_rf_layout = Qt.QVBoxLayout() self._f_rf_tool_bar = Qt.QToolBar(self) self._f_rf_layout.addWidget(self._f_rf_tool_bar) self._f_rf_tool_bar.addWidget(Qt.QLabel("RF Freq" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._f_rf_counter = qwt_counter_pyslot() self._f_rf_counter.setRange(434644000, 434646000, 1) self._f_rf_counter.setNumButtons(2) self._f_rf_counter.setValue(self.f_rf) self._f_rf_tool_bar.addWidget(self._f_rf_counter) self._f_rf_counter.valueChanged.connect(self.set_f_rf) self._f_rf_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._f_rf_slider.setRange(434644000, 434646000, 1) self._f_rf_slider.setValue(self.f_rf) self._f_rf_slider.setMinimumWidth(200) self._f_rf_slider.valueChanged.connect(self.set_f_rf) self._f_rf_layout.addWidget(self._f_rf_slider) self.tab_layout_0.addLayout(self._f_rf_layout) self._f_lo_layout = Qt.QVBoxLayout() self._f_lo_tool_bar = Qt.QToolBar(self) self._f_lo_layout.addWidget(self._f_lo_tool_bar) self._f_lo_tool_bar.addWidget(Qt.QLabel("LO Freq" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._f_lo_counter = qwt_counter_pyslot() self._f_lo_counter.setRange(0, 2000, .1) self._f_lo_counter.setNumButtons(2) self._f_lo_counter.setValue(self.f_lo) self._f_lo_tool_bar.addWidget(self._f_lo_counter) self._f_lo_counter.valueChanged.connect(self.set_f_lo) self._f_lo_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._f_lo_slider.setRange(0, 2000, .1) self._f_lo_slider.setValue(self.f_lo) self._f_lo_slider.setMinimumWidth(200) self._f_lo_slider.valueChanged.connect(self.set_f_lo) self._f_lo_layout.addWidget(self._f_lo_slider) self.tab_layout_0.addLayout(self._f_lo_layout) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( sr_lo, #size sr_lo, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(.03) self.qtgui_time_sink_x_0.set_y_axis(-.02, .02) 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) 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.tab_layout_0.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_1 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_1.set_update_time(0.10) self.qtgui_number_sink_1.set_title("") labels = ["Signal RMS", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_1.set_min(i, -1) self.qtgui_number_sink_1.set_max(i, 1) self.qtgui_number_sink_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_1.set_label(i, labels[i]) self.qtgui_number_sink_1.set_unit(i, units[i]) self.qtgui_number_sink_1.set_factor(i, factor[i]) self.qtgui_number_sink_1.enable_autoscale(False) self._qtgui_number_sink_1_win = sip.wrapinstance( self.qtgui_number_sink_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_1_win) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.03) self.qtgui_number_sink_0.set_title("") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_number_sink_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-.02, .02) self.qtgui_const_sink_x_1.set_x_axis(-.02, .02) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance( self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-.02, .02) self.qtgui_const_sink_x_0.set_x_axis(-.02, .02) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [1, 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.tab_layout_0.addWidget(self._qtgui_const_sink_x_0_win) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "airspy=0") self.osmosdr_source_0.set_sample_rate(sr_rf) self.osmosdr_source_0.set_center_freq(f_rf, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(3, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 100, (firdes.low_pass(1, sr_rf, 2000, 100)), f_lo, sr_rf) self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc( 2, 0, cmath.pi / 100.0, -0.5, 0.5, 0.25, 0.01, 2, 0.001, 0.001) self.blocks_rms_xx_0 = blocks.rms_cf(0.0001) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (sr_lo / (2 * 3.14159), )) self.analog_pll_freqdet_cf_0 = analog.pll_freqdet_cf(.06, 0.6, -.6) ################################################## # Connections ################################################## self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_pll_freqdet_cf_0, 0)) self.connect((self.analog_pll_freqdet_cf_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.digital_mpsk_receiver_cc_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.qtgui_number_sink_1, 0))
def __init__(self): 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") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.refresh = refresh = 0.1 self.const1 = const1 = digital.constellation_bpsk().base() ################################################## # Blocks ################################################## self.tabs = Qt.QTabWidget() self.tabs_widget_0 = Qt.QWidget() self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_0) self.tabs_grid_layout_0 = Qt.QGridLayout() self.tabs_layout_0.addLayout(self.tabs_grid_layout_0) self.tabs.addTab(self.tabs_widget_0, 'Analysis') self.tabs_widget_1 = Qt.QWidget() self.tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_1) self.tabs_grid_layout_1 = Qt.QGridLayout() self.tabs_layout_1.addLayout(self.tabs_grid_layout_1) self.tabs.addTab(self.tabs_widget_1, 'DSB-AM') self.tabs_widget_2 = Qt.QWidget() self.tabs_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_2) self.tabs_grid_layout_2 = Qt.QGridLayout() self.tabs_layout_2.addLayout(self.tabs_grid_layout_2) self.tabs.addTab(self.tabs_widget_2, 'BPSK') self.top_layout.addWidget(self.tabs) self._refresh_range = Range(0.001, 3, 0.01, 0.1, 200) self._refresh_win = RangeWidget(self._refresh_range, self.set_refresh, "refresh", "counter_slider", float) self.top_grid_layout.addWidget(self._refresh_win, 0, 0, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 1)] self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f( 1024 / 8, #size samp_rate, #samp_rate "Decoded Value", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(refresh) self.qtgui_time_sink_x_1_0.set_y_axis(-1, 2) self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0.enable_grid(True) self.qtgui_time_sink_x_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_2.addWidget(self._qtgui_time_sink_x_1_0_win, 1, 0, 1, 1) [self.tabs_grid_layout_2.setRowStretch(r, 1) for r in range(1, 2)] [self.tabs_grid_layout_2.setColumnStretch(c, 1) for c in range(0, 1)] self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #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, 200) 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) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: 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.tabs_layout_1.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024 * 8, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(refresh) self.qtgui_time_sink_x_0_0.set_y_axis(-128, 128) 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, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: 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_grid_layout_0.addWidget(self._qtgui_time_sink_x_0_0_win, 0, 2, 1, 1) [self.tabs_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)] [self.tabs_grid_layout_0.setColumnStretch(c, 1) for c in range(2, 3)] self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024 * 8, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(refresh) self.qtgui_time_sink_x_0.set_y_axis(-128, 128) 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 = ['', '', '', '', '', '', '', '', '', ''] 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): 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_grid_layout_0.addWidget(self._qtgui_time_sink_x_0_win, 0, 0, 1, 1) [self.tabs_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)] [self.tabs_grid_layout_0.setColumnStretch(c, 1) for c in range(0, 1)] self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(refresh) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) self.qtgui_const_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_2.addWidget(self._qtgui_const_sink_x_0_0_win, 0, 0, 1, 1) [self.tabs_grid_layout_2.setRowStretch(r, 1) for r in range(0, 1)] [self.tabs_grid_layout_2.setColumnStretch(c, 1) for c in range(0, 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(refresh) self.qtgui_const_sink_x_0.set_y_axis(-128, 128) self.qtgui_const_sink_x_0.set_x_axis(-128, 128) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 1, 0, 1, 1) [self.tabs_grid_layout_0.setRowStretch(r, 1) for r in range(1, 2)] [self.tabs_grid_layout_0.setColumnStretch(c, 1) for c in range(0, 1)] self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc( 4, 0, cmath.pi / 100.0, -0.05, 0.05, 0.25, 0.01, 2, 0.001, 0.001) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=const1, differential=True, samples_per_symbol=4, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( const1) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1, '/tmp/iqpipe', 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_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-127, )) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_deinterleave_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_1_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_1, 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_file_source_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.digital_mpsk_receiver_cc_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.qtgui_const_sink_x_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Stereo Fm") Qt.QWidget.__init__(self) self.setWindowTitle("Stereo Fm") 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", "stereo_fm") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.demod_rate = demod_rate = 192000 self.audio_decimation = audio_decimation = 4 self.audio_rate = audio_rate = demod_rate / audio_decimation self.width_of_transition_band = width_of_transition_band = audio_rate / 32 self.volume = volume = 1 self.stereo_carr_loop_bw = stereo_carr_loop_bw = 2.0 * math.pi * 10 / 100 self.samp_rate = samp_rate = 1000e3 self.range1 = range1 = 88.1 self.max_freq = max_freq = 2.0 * math.pi * (80) * 1e3 / demod_rate self.loop_bw = loop_bw = 2.0 * math.pi * 28 / 100 ################################################## # Blocks ################################################## self._range1_layout = Qt.QVBoxLayout() self._range1_tool_bar = Qt.QToolBar(self) self._range1_layout.addWidget(self._range1_tool_bar) self._range1_tool_bar.addWidget(Qt.QLabel("Tune" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot("double") def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._range1_counter = qwt_counter_pyslot() self._range1_counter.setRange(88, 108, 0.1) self._range1_counter.setNumButtons(2) self._range1_counter.setValue(self.range1) self._range1_tool_bar.addWidget(self._range1_counter) self._range1_counter.valueChanged.connect(self.set_range1) self._range1_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._range1_slider.setRange(88, 108, 0.1) self._range1_slider.setValue(self.range1) self._range1_slider.setMinimumWidth(200) self._range1_slider.valueChanged.connect(self.set_range1) self._range1_layout.addWidget(self._range1_slider) self.top_layout.addLayout(self._range1_layout) self._volume_layout = Qt.QVBoxLayout() self._volume_tool_bar = Qt.QToolBar(self) self._volume_layout.addWidget(self._volume_tool_bar) self._volume_tool_bar.addWidget(Qt.QLabel("Volume" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot("double") def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._volume_counter = qwt_counter_pyslot() self._volume_counter.setRange(0.000001, 100, 0.01) self._volume_counter.setNumButtons(2) self._volume_counter.setValue(self.volume) self._volume_tool_bar.addWidget(self._volume_counter) self._volume_counter.valueChanged.connect(self.set_volume) self._volume_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._volume_slider.setRange(0.000001, 100, 0.01) self._volume_slider.setValue(self.volume) self._volume_slider.setMinimumWidth(200) self._volume_slider.valueChanged.connect(self.set_volume) self._volume_layout.addWidget(self._volume_slider) self.top_layout.addLayout(self._volume_layout) self.stereo_carrier_pll_recovery = analog.pll_refout_cc( stereo_carr_loop_bw, -2.0 * math.pi * 18990 / demod_rate, -2.0 * math.pi * 19010 / demod_rate ) self.stereo_carrier__filter = filter.fir_filter_fcc( 1, firdes.complex_band_pass(1, demod_rate, -19020, -18980, width_of_transition_band, firdes.WIN_HAMMING, 6.76), ) self.stereo_carr_gen = blocks.multiply_vcc(1) self.rtl2832_source_0 = baz.rtl_source_c(defer_creation=True, output_size=gr.sizeof_gr_complex) self.rtl2832_source_0.set_verbose(True) self.rtl2832_source_0.set_vid(0x0) self.rtl2832_source_0.set_pid(0x0) self.rtl2832_source_0.set_tuner_name("") self.rtl2832_source_0.set_default_timeout(0) self.rtl2832_source_0.set_use_buffer(True) self.rtl2832_source_0.set_fir_coefficients(([])) self.rtl2832_source_0.set_read_length(0) if self.rtl2832_source_0.create() == False: raise Exception("Failed to create RTL2832 Source: rtl2832_source_0") self.rtl2832_source_0.set_sample_rate(samp_rate) self.rtl2832_source_0.set_frequency(range1 * 1e6) self.rtl2832_source_0.set_auto_gain_mode(True) self.rtl2832_source_0.set_relative_gain(True) self.rtl2832_source_0.set_gain(1) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, 192000, 2375 / 2, 0.4, 100) ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=demod_rate, decimation=int(samp_rate), taps=None, fractional_bw=None ) self.qtgui_const_sink_x_1 = qtgui.const_sink_c(1024, "", 1) # size # name # number of inputs self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(True) self.qtgui_const_sink_x_1.enable_grid(True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_1_win) self.fm_demod = analog.pll_freqdet_cf(loop_bw, max_freq, -max_freq) self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc( 2, 0, 1 * cmath.pi / 100.0, -0.06, 0.06, 0.5, 0.05, demod_rate / 2375.0, 0.001, 0.005 ) self.RDS_signal_gen = blocks.multiply_vcc(1) self.RDS_sig_filter = filter.fir_filter_fcc( 1, firdes.complex_band_pass( 1, demod_rate, 57000 - 1500, 57000 + 1500, width_of_transition_band, firdes.WIN_HAMMING, 6.76 ), ) self.RDS_carr_gen = blocks.multiply_vcc(1) ################################################## # Connections ################################################## self.connect((self.RDS_carr_gen, 0), (self.RDS_signal_gen, 0)) self.connect((self.RDS_sig_filter, 0), (self.RDS_signal_gen, 1)) self.connect((self.RDS_signal_gen, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.fm_demod, 0), (self.RDS_sig_filter, 0)) self.connect((self.fm_demod, 0), (self.stereo_carrier__filter, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.fm_demod, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_mpsk_receiver_cc_0, 0)) self.connect((self.rtl2832_source_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.stereo_carr_gen, 0), (self.RDS_carr_gen, 1)) self.connect((self.stereo_carrier__filter, 0), (self.stereo_carrier_pll_recovery, 0)) self.connect((self.stereo_carrier_pll_recovery, 0), (self.RDS_carr_gen, 0)) self.connect((self.stereo_carrier_pll_recovery, 0), (self.stereo_carr_gen, 1)) self.connect((self.stereo_carrier_pll_recovery, 0), (self.stereo_carr_gen, 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.sr_rf = sr_rf = 2500000 self.decimate = decimate = 400 self.sr_lo = sr_lo = sr_rf/decimate self.f_rf = f_rf = 434645000 self.f_lo = f_lo = 455.2 ################################################## # 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, "Tuning") 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, "IQ Display") 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, "PSK Output") self.top_layout.addWidget(self.tab) self._f_rf_layout = Qt.QVBoxLayout() self._f_rf_tool_bar = Qt.QToolBar(self) self._f_rf_layout.addWidget(self._f_rf_tool_bar) self._f_rf_tool_bar.addWidget(Qt.QLabel("RF Freq"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._f_rf_counter = qwt_counter_pyslot() self._f_rf_counter.setRange(434644000, 434646000, 1) self._f_rf_counter.setNumButtons(2) self._f_rf_counter.setValue(self.f_rf) self._f_rf_tool_bar.addWidget(self._f_rf_counter) self._f_rf_counter.valueChanged.connect(self.set_f_rf) self._f_rf_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._f_rf_slider.setRange(434644000, 434646000, 1) self._f_rf_slider.setValue(self.f_rf) self._f_rf_slider.setMinimumWidth(200) self._f_rf_slider.valueChanged.connect(self.set_f_rf) self._f_rf_layout.addWidget(self._f_rf_slider) self.tab_layout_0.addLayout(self._f_rf_layout) self._f_lo_layout = Qt.QVBoxLayout() self._f_lo_tool_bar = Qt.QToolBar(self) self._f_lo_layout.addWidget(self._f_lo_tool_bar) self._f_lo_tool_bar.addWidget(Qt.QLabel("LO Freq"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._f_lo_counter = qwt_counter_pyslot() self._f_lo_counter.setRange(0, 2000, .1) self._f_lo_counter.setNumButtons(2) self._f_lo_counter.setValue(self.f_lo) self._f_lo_tool_bar.addWidget(self._f_lo_counter) self._f_lo_counter.valueChanged.connect(self.set_f_lo) self._f_lo_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._f_lo_slider.setRange(0, 2000, .1) self._f_lo_slider.setValue(self.f_lo) self._f_lo_slider.setMinimumWidth(200) self._f_lo_slider.valueChanged.connect(self.set_f_lo) self._f_lo_layout.addWidget(self._f_lo_slider) self.tab_layout_0.addLayout(self._f_lo_layout) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( sr_lo, #size sr_lo, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(.03) self.qtgui_time_sink_x_0.set_y_axis(-.02, .02) 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) 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.tab_layout_0.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_1 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1 ) self.qtgui_number_sink_1.set_update_time(0.10) self.qtgui_number_sink_1.set_title("") labels = ["Signal RMS", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_1.set_min(i, -1) self.qtgui_number_sink_1.set_max(i, 1) self.qtgui_number_sink_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_1.set_label(i, labels[i]) self.qtgui_number_sink_1.set_unit(i, units[i]) self.qtgui_number_sink_1.set_factor(i, factor[i]) self.qtgui_number_sink_1.enable_autoscale(False) self._qtgui_number_sink_1_win = sip.wrapinstance(self.qtgui_number_sink_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_1_win) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0.set_update_time(0.03) self.qtgui_number_sink_0.set_title("") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_number_sink_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-.02, .02) self.qtgui_const_sink_x_1.set_x_axis(-.02, .02) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-.02, .02) self.qtgui_const_sink_x_0.set_x_axis(-.02, .02) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [1, 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.tab_layout_0.addWidget(self._qtgui_const_sink_x_0_win) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "airspy=0" ) self.osmosdr_source_0.set_sample_rate(sr_rf) self.osmosdr_source_0.set_center_freq(f_rf, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(3, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(100, (firdes.low_pass(1, sr_rf, 2000, 100)), f_lo, sr_rf) self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc(2, 0, cmath.pi/100.0, -0.5, 0.5, 0.25, 0.01, 2, 0.001, 0.001) self.blocks_rms_xx_0 = blocks.rms_cf(0.0001) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((sr_lo / (2 * 3.14159), )) self.analog_pll_freqdet_cf_0 = analog.pll_freqdet_cf(.06, 0.6, -.6) ################################################## # Connections ################################################## self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_pll_freqdet_cf_0, 0)) self.connect((self.analog_pll_freqdet_cf_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.digital_mpsk_receiver_cc_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.qtgui_number_sink_1, 0))
def __init__(self): gr.top_block.__init__(self, "Tetra Rx Multi") options = self.get_options() self.src = blocks.file_source(gr.sizeof_gr_complex * 1, "/tmp/myout1.ch", False) ################################################## # Variables ################################################## self.srate_rx = srate_rx = options.sample_rate self.channels = srate_rx / 25000 self.srate_channel = 36000 self.afc_period = 15 self.afc_gain = 0.01 self.afc_channel = options.auto_tune or -1 self.afc_ppm_step = 100 self.debug = options.debug self.last_pwr = -100000 self.sig_det_period = 10 self.sig_det_bw = sig_det_bw = options.sig_detection_bw or srate_rx if self.sig_det_bw <= 1.: self.sig_det_bw *= srate_rx self.sig_det_threshold = options.sig_detection_threshold self.sig_det_channels = [] for ch in range(self.channels): if ch >= self.channels / 2: ch_ = (self.channels - ch - 1) else: ch_ = ch if (float(ch_) / self.channels * 2) <= (self.sig_det_bw / srate_rx): self.sig_det_channels.append(ch) self.channels = 10 ################################################## # RPC server ################################################## self.xmlrpc_server = SimpleXMLRPCServer.SimpleXMLRPCServer( ("localhost", options.listen_port), allow_none=True) self.xmlrpc_server.register_instance(self) threading.Thread(target=self.xmlrpc_server.serve_forever).start() ################################################## # Rx Blocks and connections ################################################## out_type, dst_path = options.output.split("://", 1) if out_type == "udp": dst_ip, dst_port = dst_path.split(':', 1) self.blocks_deinterleave_0 = blocks.deinterleave( gr.sizeof_gr_complex * 1, 1) self.squelch = [] self.digital_mpsk_receiver_cc = [] self.diff_phasor = [] self.complex_to_arg = [] self.multiply_const = [] self.add_const = [] self.float_to_uchar = [] self.map_bits = [] self.unpack_k_bits = [] self.blocks_sink = [] for ch in range(0, self.channels): mpsk = digital.mpsk_receiver_cc(4, math.pi / 4, math.pi / 100.0, -0.5, 0.5, 0.25, 0.001, 2, 0.001, 0.001) diff_phasor = digital.diff_phasor_cc() complex_to_arg = blocks.complex_to_arg(1) multiply_const = blocks.multiply_const_vff((2. / math.pi, )) add_const = blocks.add_const_vff((1.5, )) float_to_uchar = blocks.float_to_uchar() map_bits = digital.map_bb(([3, 2, 0, 1, 3])) unpack_k_bits = blocks.unpack_k_bits_bb(2) brmchannels = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71 ] #brmchannels = [11,4,3,64,45,47,53,8,68,6,56,49,17,54,65,5,71,22,48,7,50] # itds kancl #brmchannels = [23,13,40,69,59,7,42,54,5,14,4,56,45,46,67,55,66,44,71,49,31,57,0,65,70] # doma - dole #brmchannels = [23,13,59,40,69,7,49,60,42,70,4,50,66,67,3,14,57,33,46,22,68,32,39,24,6,12,43,58,48,17,5,56,65,29,54,30,16,52,53,41,47,2,34,44,8] # doma - strecha #brmchannels = [67, 7, 23, 70] # doma - strecha - SDS #brmchannels = [67, 7, 23, 70,9,71,64,63,62,61,55,51,45,38,37,36,35,31,28,27,26,25,21,20,19,18,15,11,10,1,0] # doma - strecha - komplement if out_type == 'udp': sink = blocks.udp_sink(gr.sizeof_gr_char, dst_ip, int(dst_port) + ch, 1472, True) elif out_type == 'file': sink = blocks.file_sink(gr.sizeof_char, dst_path % ch, False) sink.set_unbuffered(True) else: raise ValueError("Invalid output URL '%s'" % options.output) print "connect %i" % ch if ch in brmchannels: self.connect( (self.blocks_deinterleave_0, ch), #(squelch, 0), (mpsk, 0), (diff_phasor, 0), (complex_to_arg, 0), (multiply_const, 0), (add_const, 0), (float_to_uchar, 0), (map_bits, 0), (unpack_k_bits, 0), (sink, 0)) self.digital_mpsk_receiver_cc.append(mpsk) self.diff_phasor.append(diff_phasor) self.complex_to_arg.append(complex_to_arg) self.multiply_const.append(multiply_const) self.add_const.append(add_const) self.float_to_uchar.append(float_to_uchar) self.map_bits.append(map_bits) self.unpack_k_bits.append(unpack_k_bits) self.blocks_sink.append(sink) self.connect((self.src, 0), (self.blocks_deinterleave_0, 0)) ################################################## # signal strenght identification ################################################## ''' self.pwr_probes = [] for ch in range(self.channels): pwr_probe = analog.probe_avg_mag_sqrd_c(0, 1./self.srate_channel) self.pwr_probes.append(pwr_probe) print "connect %i"%ch self.connect((self.blocks_deinterleave_0, ch), (pwr_probe, 0)) def _sig_det_probe(): while True: pwr = [self.pwr_probes[ch].level() for ch in range(self.channels) if ch in self.sig_det_channels] pwr = [10 * math.log10(p) for p in pwr if p > 0.] if not pwr: continue pwr = min(pwr) + self.sig_det_threshold print "power threshold target %f"%pwr if abs(pwr - self.last_pwr) > (self.sig_det_threshold / 2): for s in []: s.set_threshold(pwr) self.last_pwr = pwr time.sleep(self.sig_det_period) if self.sig_det_threshold is not None: self._sig_det_probe_thread = threading.Thread(target=_sig_det_probe) self._sig_det_probe_thread.daemon = True self._sig_det_probe_thread.start() ''' ################################################## # AFC blocks and connections ################################################## self.afc_selector = grc_blks2.selector( item_size=gr.sizeof_gr_complex, num_inputs=self.channels, num_outputs=1, input_index=0, output_index=0, ) self.afc_demod = analog.quadrature_demod_cf(self.srate_channel / (2 * math.pi)) samp_afc = self.srate_channel * self.afc_period / 2 self.afc_avg = blocks.moving_average_ff(samp_afc, 1. / samp_afc * self.afc_gain) self.afc_probe = blocks.probe_signal_f() def _afc_probe(): rt = 0.0 while True: time.sleep(self.afc_period) if self.afc_channel == -1: continue err = self.afc_probe.level() freq = err * self.afc_gain print "err: %f\tfreq: %f\trt %f" % (err, freq, rt) changed = False if err < -1: rt += 0.1 changed = True elif err > 1: rt -= 0.1 changed = True if changed: os.system("echo \"setrot %f\" | nc localhost 3333" % rt) self.afc_channel = 0 self._afc_err_thread = threading.Thread(target=_afc_probe) self._afc_err_thread.daemon = True self._afc_err_thread.start() for ch in range(self.channels): print "connect %i" % ch self.connect((self.blocks_deinterleave_0, ch), (self.afc_selector, ch)) self.connect((self.afc_selector, 0), (self.afc_demod, 0), (self.afc_avg, 0), (self.afc_probe, 0)) if self.afc_channel != -1: self.afc_selector.set_input_index(self.afc_channel)
def __init__(self): gr.top_block.__init__(self, "DSRC RSU Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("DSRC RSU 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", "rsu_receiver") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.symbol_per_second = symbol_per_second = 250e3 self.samp_per_symb = samp_per_symb = 20 self.usrp_samples_per_second = usrp_samples_per_second = 100e6 self.input_rate = input_rate = int(samp_per_symb * symbol_per_second) self.subcarrier_freq = subcarrier_freq = 1.5e6 self.lowpass_coeff = lowpass_coeff = firdes.low_pass( 1.0, input_rate, 100e3, 100e3, firdes.WIN_HAMMING, 6.76) self.gain = gain = 1.0 self.decimation_rate = decimation_rate = int(usrp_samples_per_second / input_rate) ################################################## # Blocks ################################################## self._subcarrier_freq_tool_bar = Qt.QToolBar(self) self._subcarrier_freq_tool_bar.addWidget( Qt.QLabel('Subcarrier frequency' + ": ")) self._subcarrier_freq_line_edit = Qt.QLineEdit( str(self.subcarrier_freq)) self._subcarrier_freq_tool_bar.addWidget( self._subcarrier_freq_line_edit) self._subcarrier_freq_line_edit.returnPressed.connect( lambda: self.set_subcarrier_freq( eng_notation.str_to_num( str(self._subcarrier_freq_line_edit.text().toAscii())))) self.top_layout.addWidget(self._subcarrier_freq_tool_bar) self.usrp_source = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.usrp_source.set_samp_rate(input_rate) self.usrp_source.set_center_freq(5.8e9, 0) self.usrp_source.set_gain(gain, 0) self.usrp_source.set_antenna('RX2', 0) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 256, #size input_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(-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(True) 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 = ['', '', '', '', '', '', '', '', '', ''] 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.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.file_sink = blocks.file_sink(gr.sizeof_char * gr.sizeof_char, 'binary_nrz_data', False) self.file_sink.set_unbuffered(False) self.dsrcmod_nrzi_to_nrz_bb_0 = dsrcmod.nrzi_to_nrz_bb(1) self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc( 2, 0, cmath.pi / 100.0, -0.00393, 0.00393, 0.5, 0.05, samp_per_symb, (samp_per_symb * samp_per_symb) / 4, 0.005) self.complex_to_real = blocks.complex_to_real(1) self.channel_filter = filter.freq_xlating_fir_filter_ccf( 1, (lowpass_coeff), 5.8e9 + subcarrier_freq, input_rate) self.binary_slicer = digital.binary_slicer_fb() ################################################## # Connections ################################################## self.connect((self.binary_slicer, 0), (self.dsrcmod_nrzi_to_nrz_bb_0, 0)) self.connect((self.channel_filter, 0), (self.digital_mpsk_receiver_cc_0, 0)) self.connect((self.complex_to_real, 0), (self.binary_slicer, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.complex_to_real, 0)) self.connect((self.dsrcmod_nrzi_to_nrz_bb_0, 0), (self.file_sink, 0)) self.connect((self.usrp_source, 0), (self.channel_filter, 0)) self.connect((self.usrp_source, 0), (self.qtgui_time_sink_x_0, 0))
def __init__(self): gr.top_block.__init__( self, "Downlink from TVAC (This should run all the time)") ################################################## # Variables ################################################## self.block_len_enc = block_len_enc = 1024 / 8 * 2 self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist( ([-1, 1]), ([0, 1]), 4, 1).base() self.samp_rate_factor = samp_rate_factor = 5 self.samp_rate = samp_rate = 250000 self.rgain = rgain = 0 self.payload = payload = block_len_enc + 4 self.freq_offset = freq_offset = 0 ################################################## # Blocks ################################################## self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=1, decimation=5, taps=None, fractional_bw=None, ) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + 'rtl_tcp=10.0.0.51:1234') self.osmosdr_source_0.set_sample_rate(samp_rate * samp_rate_factor) self.osmosdr_source_0.set_center_freq(145.95, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(rgain, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.fir_filter_xxx_0 = filter.fir_filter_ccc(samp_rate_factor, (1, )) self.fir_filter_xxx_0.declare_sample_delay(0) self.digital_mpsk_receiver_cc_0_0 = digital.mpsk_receiver_cc( 2, 0, cmath.pi / 100.0, -0.05, 0.05, 0.25, 0.05, 4, 4, 0.005) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( variable_constellation_0) self.ccsds_softbits_msg_to_bytes_b_0 = ccsds.softbits_msg_to_bytes_b() self.ccsds_randomiser_softbits_0 = ccsds.randomiser_softbits( 0x95, 0xFF) self.ccsds_mpsk_ambiguity_resolver_f_0 = ccsds.mpsk_ambiguity_resolver_f( 2, '49E0DCC7', 32, 1, 0.8, block_len_enc, 0) self.ccsds_message_info_0 = ccsds.message_info( "Block received and sent to Nanolink: ", 10) self.ccsds_ldpc_decoder_0 = ccsds.ldpc_decoder( '/tmp/AR4JA_r12_k1024n.a', ccsds.LDPC_SYS_FRONT, ccsds.LDPC_PUNCT_BACK, 512, tuple(([]))) self.ccsds_blob_msg_sink_b_0 = ccsds.blob_msg_sink_b(256 / 2) self.blocks_udp_sink_0_1 = blocks.udp_sink(gr.sizeof_char * 1, '127.0.0.1', 5431, 256, True) self.blocks_udp_sink_0_0 = blocks.udp_sink(gr.sizeof_char * 1, '127.0.0.1', 5433, 1472, True) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex * 1, '127.0.0.1', 5435, 1472, True) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_char * 1) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 0.5) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, )) self.band_pass_filter_0 = filter.fir_filter_ccc( 1, firdes.complex_band_pass(1, samp_rate * samp_rate_factor, 40e3, 60e3, 6e3, firdes.WIN_HAMMING, 6.76)) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate * samp_rate_factor, analog.GR_COS_WAVE, -freq_offset, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -50000, 1, 0) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 0.5, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.ccsds_blob_msg_sink_b_0, 'out'), (self.ccsds_message_info_0, 'in')) self.msg_connect((self.ccsds_ldpc_decoder_0, 'out'), (self.ccsds_softbits_msg_to_bytes_b_0, 'in')) self.msg_connect((self.ccsds_mpsk_ambiguity_resolver_f_0, 'out'), (self.ccsds_randomiser_softbits_0, 'in')) self.msg_connect((self.ccsds_randomiser_softbits_0, 'out'), (self.ccsds_ldpc_decoder_0, 'in')) self.connect((self.analog_agc_xx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.ccsds_mpsk_ambiguity_resolver_f_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.ccsds_softbits_msg_to_bytes_b_0, 0), (self.blocks_null_sink_1, 0)) self.connect((self.ccsds_softbits_msg_to_bytes_b_0, 0), (self.blocks_udp_sink_0_1, 0)) self.connect((self.ccsds_softbits_msg_to_bytes_b_0, 0), (self.ccsds_blob_msg_sink_b_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_udp_sink_0_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.osmosdr_source_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.digital_mpsk_receiver_cc_0_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Stereo FM receiver and RDS Decoder") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1000000 self.bb_decim = bb_decim = 4 self.freq_offset = freq_offset = 250000 self.freq = freq = 101.5 self.baseband_rate = baseband_rate = samp_rate/bb_decim self.audio_decim = audio_decim = 5 self.xlate_bandwidth = xlate_bandwidth = 100000 self.gain = gain = 20 self.freq_tune = freq_tune = freq - freq_offset self.audio_rate = audio_rate = 48000 self.audio_decim_rate = audio_decim_rate = baseband_rate/audio_decim ################################################## # Blocks ################################################## self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Demod") self.nb.AddPage(grc_wxgui.Panel(self.nb), "L+R") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Pilot") self.nb.AddPage(grc_wxgui.Panel(self.nb), "DSBSC") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS") self.nb.AddPage(grc_wxgui.Panel(self.nb), "L-R") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS constellation") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Waterfall") self.GridAdd(self.nb, 2, 0, 1, 2) self.wxgui_scopesink2_1 = scopesink2.scope_sink_c( self.nb.GetPage(7).GetWin(), title="Scope Plot", sample_rate=2375, v_scale=0.4, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(7).Add(self.wxgui_scopesink2_1.win) self.wxgui_fftsink2_0_0_0_1_0_1 = fftsink2.fft_sink_c( self.nb.GetPage(5).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=audio_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="RDS", peak_hold=False, ) self.nb.GetPage(5).Add(self.wxgui_fftsink2_0_0_0_1_0_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=-30, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.8, title="Baseband", peak_hold=False, ) self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.rtl_sdr_source0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtl_sdr_source0.set_sample_rate(samp_rate) self.rtl_sdr_source0.set_center_freq(freq_tune, 0) self.rtl_sdr_source0.set_freq_corr(0, 0) self.rtl_sdr_source0.set_dc_offset_mode(0, 0) self.rtl_sdr_source0.set_iq_balance_mode(0, 0) self.rtl_sdr_source0.set_gain_mode(False, 0) self.rtl_sdr_source0.set_gain(gain, 0) self.rtl_sdr_source0.set_if_gain(20, 0) self.rtl_sdr_source0.set_bb_gain(20, 0) self.rtl_sdr_source0.set_antenna("", 0) self.rtl_sdr_source0.set_bandwidth(0, 0) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine( 1, samp_rate/bb_decim/audio_decim, 2375, 1, 100)) self.gr_rds_parser_0 = rds.parser(True, False) self.gr_rds_panel_0 = rds.rdsPanel(freq, self.GetWin()) self.Add(self.gr_rds_panel_0.panel) self.gr_rds_decoder_0 = rds.decoder(False, False) self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_fcc(audio_decim, (firdes.low_pass(2500.0,baseband_rate,2.4e3,2e3,firdes.WIN_HAMMING)), 57e3, baseband_rate) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (firdes.low_pass(1, samp_rate, xlate_bandwidth, 100000)), freq_offset, samp_rate) self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc(2, 0, 1*cmath.pi/100.0, -0.06, 0.06, 0.5, 0.05, samp_rate/bb_decim/audio_decim/ 2375.0, 0.001, 0.005) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_char*1, 2) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=samp_rate, audio_decimation=bb_decim, ) ################################################## # Connections ################################################## self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.freq_xlating_fir_filter_xxx_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.wxgui_fftsink2_0_0_0_1_0_1, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_mpsk_receiver_cc_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.rtl_sdr_source0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.gr_rds_decoder_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.gr_rds_decoder_0, "out", self.gr_rds_parser_0, "in") self.msg_connect(self.gr_rds_parser_0, "out", self.gr_rds_panel_0, "in")
def __init__(self): gr.top_block.__init__(self, "Downlink for EM") Qt.QWidget.__init__(self) self.setWindowTitle("Downlink for EM") 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", "downlink_em") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.block_len_enc = block_len_enc = 1024 / 8 * 2 self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist( ([-1, 1]), ([0, 1]), 4, 1).base() self.samp_rate = samp_rate = 250000 self.payload = payload = block_len_enc + 4 self.oversample = oversample = 5 self.frequency_offset_correction = frequency_offset_correction = 89e2 ################################################## # Blocks ################################################## self._frequency_offset_correction_range = Range( -120000, 120000, 100, 89e2, 200) self._frequency_offset_correction_win = RangeWidget( self._frequency_offset_correction_range, self.set_frequency_offset_correction, 'Frequency Correction', "counter_slider", float) self.top_grid_layout.addWidget(self._frequency_offset_correction_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.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=1, decimation=5, taps=None, fractional_bw=None, ) self.qtgui_sink_x_0_0_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 145.79e6, #fc samp_rate * 4, #bw "Vor Sync", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0_0_1.set_update_time(1.0 / 10) self._qtgui_sink_x_0_0_1_win = sip.wrapinstance( self.qtgui_sink_x_0_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_0_1_win, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_sink_x_0_0_1.enable_rf_freq(False) self.qtgui_sink_x_0_0_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / 5, #bw "Vor Sync", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0_0_0_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_0_0_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_sink_x_0_0_0_0.enable_rf_freq(False) self.qtgui_sink_x_0_0_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / 5, #bw "Vor Sync", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0_0_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_0_0_win, 3, 0, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_sink_x_0_0_0.enable_rf_freq(False) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.osmosdr_source_0.set_sample_rate(samp_rate * oversample) self.osmosdr_source_0.set_center_freq(145.85e6, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 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(30 * 1, 0) self.osmosdr_source_0.set_if_gain(30 * 1, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.digital_mpsk_receiver_cc_0_0 = digital.mpsk_receiver_cc( 2, 0, 31.41e-3, -0.01, 0.01, 0.25, 0.05, samp_rate / 5 / 12.5e3, 0.01, 0.005) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( variable_constellation_0) self.ccsds_softbits_msg_to_bytes_b_0 = ccsds.softbits_msg_to_bytes_b() self.ccsds_send_nanolink_0 = ccsds.send_nanolink( "https://move2radio.lrt.mw.tum.de") self.ccsds_randomiser_softbits_0 = ccsds.randomiser_softbits( 0x95, 0xFF) self.ccsds_mpsk_ambiguity_resolver_f_0 = ccsds.mpsk_ambiguity_resolver_f( 2, '49E0DCC7', 32, 1, 0.8, block_len_enc, 0) self.ccsds_ldpc_decoder_0 = ccsds.ldpc_decoder( '/tmp/AR4JA_r12_k1024n.a', ccsds.LDPC_SYS_FRONT, ccsds.LDPC_PUNCT_BACK, 512, tuple(([]))) self.ccsds_blob_msg_sink_b_0 = ccsds.blob_msg_sink_b(256 / 2) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 0.5) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, )) self.band_pass_filter_0 = filter.fir_filter_ccc( oversample, firdes.complex_band_pass(1, samp_rate * oversample, 40e3, 60e3, 6e3, firdes.WIN_HAMMING, 6.76)) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate * oversample, analog.GR_COS_WAVE, frequency_offset_correction, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -50000, 1, 0) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 0.5, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.ccsds_blob_msg_sink_b_0, 'out'), (self.ccsds_send_nanolink_0, 'in')) self.msg_connect((self.ccsds_ldpc_decoder_0, 'out'), (self.ccsds_softbits_msg_to_bytes_b_0, 'in')) self.msg_connect((self.ccsds_mpsk_ambiguity_resolver_f_0, 'out'), (self.ccsds_randomiser_softbits_0, 'in')) self.msg_connect((self.ccsds_randomiser_softbits_0, 'out'), (self.ccsds_ldpc_decoder_0, 'in')) self.connect((self.analog_agc_xx_0, 0), (self.qtgui_sink_x_0_0_0_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.band_pass_filter_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.ccsds_mpsk_ambiguity_resolver_f_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.qtgui_sink_x_0_0_1, 0)) self.connect((self.ccsds_softbits_msg_to_bytes_b_0, 0), (self.ccsds_blob_msg_sink_b_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0_0, 0), (self.qtgui_sink_x_0_0_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.digital_mpsk_receiver_cc_0_0, 0))
def __init__(self): gr.top_block.__init__(self) self.qapp = QtGui.QApplication(sys.argv) self._sample_rate = 2000e3 self.sps = 2 self.excess_bw = 0.35 self.gray_code = digital.mod_codes.GRAY_CODE fftsize = 2048 self.data = scipy.random.randint(0, 255, 1000) self.src = gr.vector_source_b(self.data.tolist(), True) self.mod = digital.dqpsk_mod(self.gray_code, samples_per_symbol=self.sps, excess_bw=self.excess_bw, verbose=False, log=False) self.rrctaps = gr.firdes.root_raised_cosine(1, self.sps, 1, self.excess_bw, 21) self.rx_rrc = gr.fir_filter_ccf(1, self.rrctaps) # Set up the carrier & clock recovery parameters self.arity = 4 self.mu = 0.5 self.gain_mu = 0.05 self.omega = self.sps self.gain_omega = .25 * self.gain_mu * self.gain_mu self.omega_rel_lim = 0.05 self._loop_bw = 2*scipy.pi/100.0 self.fmin = -1000/self.sample_rate() self.fmax = 1000/self.sample_rate() self.receiver = digital.mpsk_receiver_cc(self.arity, 0, self._loop_bw, self.fmin, self.fmax, self.mu, self.gain_mu, self.omega, self.gain_omega, self.omega_rel_lim) self.snr_dB = 15 noise = self.get_noise_voltage(self.snr_dB) self.fo = 100/self.sample_rate() self.to = 1.0 self.channel = gr.channel_model(noise, self.fo, self.to) self.thr = gr.throttle(gr.sizeof_char, self._sample_rate) self.snk_tx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, 0, self._sample_rate*self.sps, "Tx", True, True, True, True) self.snk_rx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, 0, self._sample_rate, "Rx", True, True, True, True) self.connect(self.src, self.thr, self.mod, self.channel, self.snk_tx) self.connect(self.channel, self.rx_rrc, self.receiver, self.snk_rx) pyTxQt = self.snk_tx.pyqwidget() pyTx = sip.wrapinstance(pyTxQt, QtGui.QWidget) pyRxQt = self.snk_rx.pyqwidget() pyRx = sip.wrapinstance(pyRxQt, QtGui.QWidget) self.main_box = dialog_box(pyTx, pyRx, self); self.main_box.show()
def __init__(self, samples_per_symbol=_def_samples_per_symbol, excess_bw=_def_excess_bw, costas_alpha=_def_costas_alpha, gain_mu=_def_gain_mu, mu=_def_mu, omega_relative_limit=_def_omega_relative_limit, gray_code=_def_gray_code, verbose=_def_verbose, log=_def_log): """ Hierarchical block for RRC-filtered CQPSK demodulation The input is the complex modulated signal at baseband. The output is a stream of floats in [ -3 / -1 / +1 / +3 ] @param samples_per_symbol: samples per symbol >= 2 @type samples_per_symbol: float @param excess_bw: Root-raised cosine filter excess bandwidth @type excess_bw: float @param costas_alpha: loop filter gain @type costas_alphas: float @param gain_mu: for M&M block @type gain_mu: float @param mu: for M&M block @type mu: float @param omega_relative_limit: for M&M block @type omega_relative_limit: float @param gray_code: Tell modulator to Gray code the bits @type gray_code: bool @param verbose: Print information about modulator? @type verbose: bool @param debug: Print modualtion data to files? @type debug: bool """ gr.hier_block2.__init__(self, "cqpsk_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_float)) # Output signature self._samples_per_symbol = samples_per_symbol self._excess_bw = excess_bw self._costas_alpha = costas_alpha self._mm_gain_mu = gain_mu self._mm_mu = mu self._mm_omega_relative_limit = omega_relative_limit self._gray_code = gray_code if samples_per_symbol < 2: raise TypeError, "sbp must be >= 2, is %d" % samples_per_symbol arity = pow(2,self.bits_per_symbol()) # Automatic gain control scale = (1.0/16384.0) self.pre_scaler = blocks.multiply_const_cc(scale) # scale the signal from full-range to +-1 #self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100) self.agc = analog.feedforward_agc_cc(16, 2.0) # RRC data filter ntaps = 11 * samples_per_symbol self.rrc_taps = filter.firdes.root_raised_cosine( 1.0, # gain self._samples_per_symbol, # sampling rate 1.0, # symbol rate self._excess_bw, # excess bandwidth (roll-off factor) ntaps) self.rrc_filter=filter.interp_fir_filter_ccf(1, self.rrc_taps) if not self._mm_gain_mu: sbs_to_mm = {2: 0.050, 3: 0.075, 4: 0.11, 5: 0.125, 6: 0.15, 7: 0.15} self._mm_gain_mu = sbs_to_mm[samples_per_symbol] self._mm_omega = self._samples_per_symbol self._mm_gain_omega = .25 * self._mm_gain_mu * self._mm_gain_mu self._costas_beta = 0.25 * self._costas_alpha * self._costas_alpha fmin = -0.025 fmax = 0.025 self.receiver=digital.mpsk_receiver_cc(arity, pi/4.0, 2*pi/150, fmin, fmax, self._mm_mu, self._mm_gain_mu, self._mm_omega, self._mm_gain_omega, self._mm_omega_relative_limit) self.receiver.set_alpha(self._costas_alpha) self.receiver.set_beta(self._costas_beta) # Perform Differential decoding on the constellation self.diffdec = digital.diff_phasor_cc() # take angle of the difference (in radians) self.to_float = blocks.complex_to_arg() # convert from radians such that signal is in -3/-1/+1/+3 self.rescale = blocks.multiply_const_ff( 1 / (pi / 4) ) if verbose: self._print_verbage() if log: self._setup_logging() # Connect & Initialize base class self.connect(self, self.pre_scaler, self.agc, self.rrc_filter, self.receiver, self.diffdec, self.to_float, self.rescale, self)
def __init__(self): gr.top_block.__init__(self) self.qapp = QtGui.QApplication(sys.argv) self._sample_rate = 2000e3 self.sps = 2 self.excess_bw = 0.35 self.gray_code = digital.mod_codes.GRAY_CODE fftsize = 2048 self.data = scipy.random.randint(0, 255, 1000) self.src = blocks.vector_source_b(self.data.tolist(), True) self.mod = digital.dqpsk_mod(self.gray_code, samples_per_symbol=self.sps, excess_bw=self.excess_bw, verbose=False, log=False) self.rrctaps = filter.firdes.root_raised_cosine( 1, self.sps, 1, self.excess_bw, 21) self.rx_rrc = filter.fir_filter_ccf(1, self.rrctaps) # Set up the carrier & clock recovery parameters self.arity = 4 self.mu = 0.5 self.gain_mu = 0.05 self.omega = self.sps self.gain_omega = .25 * self.gain_mu * self.gain_mu self.omega_rel_lim = 0.05 self._loop_bw = 2 * scipy.pi / 100.0 self.fmin = -1000 / self.sample_rate() self.fmax = 1000 / self.sample_rate() self.receiver = digital.mpsk_receiver_cc(self.arity, 0, self._loop_bw, self.fmin, self.fmax, self.mu, self.gain_mu, self.omega, self.gain_omega, self.omega_rel_lim) self.snr_dB = 15 noise = self.get_noise_voltage(self.snr_dB) self.fo = 100 / self.sample_rate() self.to = 1.0 self.channel = channels.channel_model(noise, self.fo, self.to) self.thr = blocks.throttle(gr.sizeof_char, self._sample_rate) self.snk_tx = qtgui.sink_c(fftsize, filter.firdes.WIN_BLACKMAN_hARRIS, 0, self._sample_rate * self.sps, "Tx", True, True, True, True) self.snk_rx = qtgui.sink_c(fftsize, filter.firdes.WIN_BLACKMAN_hARRIS, 0, self._sample_rate, "Rx", True, True, True, True) self.connect(self.src, self.thr, self.mod, self.channel, self.snk_tx) self.connect(self.channel, self.rx_rrc, self.receiver, self.snk_rx) pyTxQt = self.snk_tx.pyqwidget() pyTx = sip.wrapinstance(pyTxQt, QtGui.QWidget) pyRxQt = self.snk_rx.pyqwidget() pyRx = sip.wrapinstance(pyRxQt, QtGui.QWidget) self.main_box = dialog_box(pyTx, pyRx, self) self.main_box.show()
def __init__(self): gr.top_block.__init__(self, "Tetra Rx Multi") options = self.get_options() ################################################## # Variables ################################################## self.srate_rx = srate_rx = options.sample_rate self.channels = srate_rx / 25000 self.srate_channel = 36000 self.afc_period = 5 self.afc_gain = 1. self.afc_channel = options.auto_tune or -1 self.afc_ppm_step = 100 self.debug = options.debug self.last_pwr = -100000 self.sig_det_period = 1 self.sig_det_bw = sig_det_bw = options.sig_detection_bw or srate_rx if self.sig_det_bw <= 1.: self.sig_det_bw *= srate_rx self.sig_det_threshold = options.sig_detection_threshold self.sig_det_channels = [] for ch in range(self.channels): if ch >= self.channels / 2: ch_ = (self.channels - ch - 1) else: ch_ = ch if (float(ch_) / self.channels * 2) <= (self.sig_det_bw / srate_rx): self.sig_det_channels.append(ch) ################################################## # RPC server ################################################## self.xmlrpc_server = SimpleXMLRPCServer.SimpleXMLRPCServer( ("localhost", options.listen_port), allow_none=True) self.xmlrpc_server.register_instance(self) threading.Thread(target=self.xmlrpc_server.serve_forever).start() ################################################## # Rx Blocks and connections ################################################## self.src = osmosdr.source( args=options.args ) self.src.set_sample_rate(srate_rx) self.src.set_center_freq(options.frequency, 0) self.src.set_freq_corr(options.ppm, 0) self.src.set_dc_offset_mode(0, 0) self.src.set_iq_balance_mode(0, 0) if options.gain is not None: self.src.set_gain_mode(False, 0) self.src.set_gain(36, 0) else: self.src.set_gain_mode(True, 0) out_type, dst_path = options.output.split("://", 1) if out_type == "udp": dst_ip, dst_port = dst_path.split(':', 1) self.freq_xlating = freq_xlating_fft_filter_ccc(1, (1, ), 0, srate_rx) self.channelizer = pfb.channelizer_ccf( self.channels, (firdes.root_raised_cosine(1, srate_rx, 18000, 0.35, 1024)), 36./25., 100) self.squelch = [] self.digital_mpsk_receiver_cc = [] self.diff_phasor = [] self.complex_to_arg = [] self.multiply_const = [] self.add_const = [] self.float_to_uchar = [] self.map_bits = [] self.unpack_k_bits = [] self.blocks_sink = [] for ch in range(0, self.channels): squelch = analog.pwr_squelch_cc(0, 0.001, 0, True) mpsk = digital.mpsk_receiver_cc( 4, math.pi/4, math.pi/100.0, -0.5, 0.5, 0.25, 0.001, 2, 0.001, 0.001) diff_phasor = digital.diff_phasor_cc() complex_to_arg = blocks.complex_to_arg(1) multiply_const = blocks.multiply_const_vff((2./math.pi, )) add_const = blocks.add_const_vff((1.5, )) float_to_uchar = blocks.float_to_uchar() map_bits = digital.map_bb(([3, 2, 0, 1, 3])) unpack_k_bits = blocks.unpack_k_bits_bb(2) if out_type == 'udp': sink = blocks.udp_sink(gr.sizeof_gr_char, dst_ip, int(dst_port)+ch, 1472, True) elif out_type == 'file': sink = blocks.file_sink(gr.sizeof_char, dst_path % ch, False) sink.set_unbuffered(True) else: raise ValueError("Invalid output URL '%s'" % options.output) self.connect((self.channelizer, ch), (squelch, 0), (mpsk, 0), (diff_phasor, 0), (complex_to_arg, 0), (multiply_const, 0), (add_const, 0), (float_to_uchar, 0), (map_bits, 0), (unpack_k_bits, 0), (sink, 0)) self.squelch.append(squelch) self.digital_mpsk_receiver_cc.append(mpsk) self.diff_phasor.append(diff_phasor) self.complex_to_arg.append(complex_to_arg) self.multiply_const.append(multiply_const) self.add_const.append(add_const) self.float_to_uchar.append(float_to_uchar) self.map_bits.append(map_bits) self.unpack_k_bits.append(unpack_k_bits) self.blocks_sink.append(sink) self.connect( (self.src, 0), (self.freq_xlating, 0), (self.channelizer, 0)) ################################################## # signal strenght identification ################################################## self.pwr_probes = [] for ch in range(self.channels): pwr_probe = analog.probe_avg_mag_sqrd_c(0, 1./self.srate_channel) self.pwr_probes.append(pwr_probe) self.connect((self.channelizer, ch), (pwr_probe, 0)) def _sig_det_probe(): while True: pwr = [self.pwr_probes[ch].level() for ch in range(self.channels) if ch in self.sig_det_channels] pwr = [10 * math.log10(p) for p in pwr if p > 0.] if not pwr: continue pwr = min(pwr) + self.sig_det_threshold print "Power level for squelch % 5.1f" % pwr if abs(pwr - self.last_pwr) > (self.sig_det_threshold / 2): for s in self.squelch: s.set_threshold(pwr) self.last_pwr = pwr time.sleep(self.sig_det_period) if self.sig_det_threshold is not None: self._sig_det_probe_thread = threading.Thread(target=_sig_det_probe) self._sig_det_probe_thread.daemon = True self._sig_det_probe_thread.start() ################################################## # AFC blocks and connections ################################################## self.afc_selector = grc_blks2.selector( item_size=gr.sizeof_gr_complex, num_inputs=self.channels, num_outputs=1, input_index=0, output_index=0, ) self.afc_demod = analog.quadrature_demod_cf(self.srate_channel/(2*math.pi)) samp_afc = self.srate_channel*self.afc_period / 2 self.afc_avg = blocks.moving_average_ff(samp_afc, 1./samp_afc*self.afc_gain) self.afc_probe = blocks.probe_signal_f() def _afc_probe(): while True: time.sleep(self.afc_period) if self.afc_channel == -1: continue err = self.afc_probe.level() if abs(err) < self.afc_ppm_step: continue freq = self.freq_xlating.center_freq + err * self.afc_gain if self.debug: print "err: %f\tfreq: %f" % (err, freq, ) self.freq_xlating.set_center_freq(freq) self._afc_err_thread = threading.Thread(target=_afc_probe) self._afc_err_thread.daemon = True self._afc_err_thread.start() for ch in range(self.channels): self.connect((self.channelizer, ch), (self.afc_selector, ch)) self.connect( (self.afc_selector, 0), (self.afc_demod, 0), (self.afc_avg, 0), (self.afc_probe, 0)) if self.afc_channel != -1: self.afc_selector.set_input_index(self.afc_channel)
def __init__(self): gr.top_block.__init__( self, "Downlink from TVAC (This should run all the time)") Qt.QWidget.__init__(self) self.setWindowTitle( "Downlink from TVAC (This should run all the time)") 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", "downlink") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.freq_offset = freq_offset = 0 self.freq = freq = 145.95e6 self.block_len_enc = block_len_enc = 1024 / 8 * 2 self.variable_qtgui_label_0 = variable_qtgui_label_0 = 0 self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist( ([-1, 1]), ([0, 1]), 4, 1).base() self.samp_rate_factor = samp_rate_factor = 5 self.samp_rate = samp_rate = 250000 self.rgain = rgain = 40 self.real_center_freq = real_center_freq = freq + freq_offset self.payload = payload = block_len_enc + 4 self.freq_offset_flag = freq_offset_flag = 0 ################################################## # Blocks ################################################## self._freq_offset_range = Range(-400e3, 400e3, 1.5e3, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Frequency Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_offset_win) self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_formatter = None else: self._variable_qtgui_label_0_formatter = lambda x: str(x) self._variable_qtgui_label_0_tool_bar.addWidget( Qt.QLabel("variable_qtgui_label_0" + ": ")) self._variable_qtgui_label_0_label = Qt.QLabel( str( self._variable_qtgui_label_0_formatter( self.variable_qtgui_label_0))) self._variable_qtgui_label_0_tool_bar.addWidget( self._variable_qtgui_label_0_label) self.top_grid_layout.addWidget(self._variable_qtgui_label_0_tool_bar) self._rgain_range = Range(0, 50, 1, 40, 200) self._rgain_win = RangeWidget(self._rgain_range, self.set_rgain, 'RX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._rgain_win) self._real_center_freq_tool_bar = Qt.QToolBar(self) if None: self._real_center_freq_formatter = None else: self._real_center_freq_formatter = lambda x: eng_notation.num_to_str( x) self._real_center_freq_tool_bar.addWidget( Qt.QLabel('Real center freq' + ": ")) self._real_center_freq_label = Qt.QLabel( str(self._real_center_freq_formatter(self.real_center_freq))) self._real_center_freq_tool_bar.addWidget(self._real_center_freq_label) self.top_grid_layout.addWidget(self._real_center_freq_tool_bar) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=1, decimation=5, taps=None, fractional_bw=None, ) self.qtgui_sink_x_0_0_1 = qtgui.sink_c( 4096, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Vor Sync", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0_0_1.set_update_time(1.0 / 10) self._qtgui_sink_x_0_0_1_win = sip.wrapinstance( self.qtgui_sink_x_0_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_0_1_win) self.qtgui_sink_x_0_0_1.enable_rf_freq(False) self.qtgui_sink_x_0_0 = qtgui.sink_c( 32768, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate * samp_rate_factor, #bw "Vor Sync", #name False, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_0_win) self.qtgui_sink_x_0_0.enable_rf_freq(False) self._freq_offset_flag_range = Range(0, 1, 1, 0, 200) self._freq_offset_flag_win = RangeWidget(self._freq_offset_flag_range, self.set_freq_offset_flag, 'Enable flatsat freq', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_offset_flag_win) self.fir_filter_xxx_0 = filter.fir_filter_ccc(samp_rate_factor, (1, )) self.fir_filter_xxx_0.declare_sample_delay(0) self.digital_mpsk_receiver_cc_0_0 = digital.mpsk_receiver_cc( 2, 0, cmath.pi / 100.0, -0.05, 0.05, 0.25, 0.05, 4, 4, 0.005) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( variable_constellation_0) self.ccsds_softbits_msg_to_bytes_b_0 = ccsds.softbits_msg_to_bytes_b() self.ccsds_randomiser_softbits_0 = ccsds.randomiser_softbits( 0x95, 0xFF) self.ccsds_mpsk_ambiguity_resolver_f_0 = ccsds.mpsk_ambiguity_resolver_f( 2, '49E0DCC7', 32, 1, 0.8, block_len_enc, 0) self.ccsds_message_info_0 = ccsds.message_info( "Block received and sent to Nanolink: ", 20) self.ccsds_ldpc_decoder_0 = ccsds.ldpc_decoder( '/tmp/AR4JA_r12_k1024n.a', ccsds.LDPC_SYS_FRONT, ccsds.LDPC_PUNCT_BACK, 512, tuple(([]))) self.ccsds_blob_msg_sink_b_0 = ccsds.blob_msg_sink_b(256 / 2) self.blocks_wavfile_source_0 = blocks.wavfile_source( '/app/input/source.wav', True) self.blocks_udp_sink_0_1 = blocks.udp_sink(gr.sizeof_char * 1, '127.0.0.1', 5431, 256, True) self.blocks_udp_sink_0_0 = blocks.udp_sink(gr.sizeof_char * 1, '127.0.0.1', 5433, 1472, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_char * 1) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_message_debug_1_0_0 = blocks.message_debug() self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 0.5) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, )) self.band_pass_filter_0 = filter.fir_filter_ccc( 1, firdes.complex_band_pass(1, samp_rate * samp_rate_factor, -220e3, -180e3, 6e3, firdes.WIN_HAMMING, 6.76)) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate * samp_rate_factor, analog.GR_COS_WAVE, -freq_offset, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -50000, 1, 0) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 0.5, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.ccsds_blob_msg_sink_b_0, 'out'), (self.blocks_message_debug_1_0_0, 'print_pdu')) self.msg_connect((self.ccsds_blob_msg_sink_b_0, 'out'), (self.ccsds_message_info_0, 'in')) self.msg_connect((self.ccsds_ldpc_decoder_0, 'out'), (self.ccsds_softbits_msg_to_bytes_b_0, 'in')) self.msg_connect((self.ccsds_mpsk_ambiguity_resolver_f_0, 'out'), (self.ccsds_randomiser_softbits_0, 'in')) self.msg_connect((self.ccsds_randomiser_softbits_0, 'out'), (self.ccsds_ldpc_decoder_0, 'in')) self.connect((self.analog_agc_xx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.ccsds_mpsk_ambiguity_resolver_f_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_sink_x_0_0_1, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_sink_x_0_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_wavfile_source_0, 1), (self.blocks_float_to_complex_0, 1)) self.connect((self.ccsds_softbits_msg_to_bytes_b_0, 0), (self.blocks_null_sink_1, 0)) self.connect((self.ccsds_softbits_msg_to_bytes_b_0, 0), (self.blocks_udp_sink_0_1, 0)) self.connect((self.ccsds_softbits_msg_to_bytes_b_0, 0), (self.ccsds_blob_msg_sink_b_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_udp_sink_0_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.rational_resampler_xxx_1, 0), (self.digital_mpsk_receiver_cc_0_0, 0))
def __init__(self, rxPort=52002, txPort=52001): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Parameters ################################################## self.rxPort = rxPort self.txPort = txPort ################################################## # Variables ################################################## self.localOscillator = localOscillator = 14070000 self.threshold = threshold = -200 self.samp_rate = samp_rate = 48000 self.rxPhase = rxPhase = .84 self.rxMagnitude = rxMagnitude = 0.854 self.freqFine = freqFine = 0 self.freq = freq = localOscillator self.bandwidth = bandwidth = 50 ################################################## # Blocks ################################################## _threshold_sizer = wx.BoxSizer(wx.VERTICAL) self._threshold_text_box = forms.text_box( parent=self.GetWin(), sizer=_threshold_sizer, value=self.threshold, callback=self.set_threshold, label="threshold", converter=forms.float_converter(), proportion=0, ) self._threshold_slider = forms.slider( parent=self.GetWin(), sizer=_threshold_sizer, value=self.threshold, callback=self.set_threshold, minimum=-500, maximum=500, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_threshold_sizer) self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tuning") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "scope") self.Add(self.notebook_0) _freqFine_sizer = wx.BoxSizer(wx.VERTICAL) self._freqFine_text_box = forms.text_box( parent=self.GetWin(), sizer=_freqFine_sizer, value=self.freqFine, callback=self.set_freqFine, label="Tuning", converter=forms.float_converter(), proportion=0, ) self._freqFine_slider = forms.slider( parent=self.GetWin(), sizer=_freqFine_sizer, value=self.freqFine, callback=self.set_freqFine, minimum=-500, maximum=500, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freqFine_sizer) _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label="Frequency", converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=localOscillator-samp_rate, maximum=localOscillator+samp_rate, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_sizer) _bandwidth_sizer = wx.BoxSizer(wx.VERTICAL) self._bandwidth_text_box = forms.text_box( parent=self.GetWin(), sizer=_bandwidth_sizer, value=self.bandwidth, callback=self.set_bandwidth, label="Signal Bandwidth", converter=forms.float_converter(), proportion=0, ) self._bandwidth_slider = forms.slider( parent=self.GetWin(), sizer=_bandwidth_sizer, value=self.bandwidth, callback=self.set_bandwidth, minimum=30, maximum=5000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_bandwidth_sizer) self.wxgui_waterfallsink2_0_0_0 = waterfallsink2.waterfall_sink_c( self.notebook_0.GetPage(1).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=125*8, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.notebook_0.GetPage(1).Add(self.wxgui_waterfallsink2_0_0_0.win) self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=125*8, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0_0.win) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=localOscillator, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0.win) self.low_pass_filter_0_1 = filter.fir_filter_ccf(samp_rate/125/8, firdes.low_pass( 1, samp_rate, 500, 500, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, 30, 30, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(samp_rate/125/8, firdes.low_pass( 1, samp_rate, bandwidth, bandwidth, firdes.WIN_HAMMING, 6.76)) self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc(2, 0, cmath.pi/100.0, -0.5, 0.5, 0.25, 0.01, 125*8/31.25, 0.001, 0.001) self.blocks_transcendental_1 = blocks.transcendental("sin", "float") self.blocks_transcendental_0 = blocks.transcendental("cos", "float") self.blocks_throttle_0_1 = blocks.throttle(gr.sizeof_float*1, samp_rate) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, 31.25) self.blocks_threshold_ff_0 = blocks.threshold_ff(1e-12, 1e-12, 0) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, int(samp_rate/31.25)) self.blocks_null_source_1 = blocks.null_source(gr.sizeof_float*1) self.blocks_null_source_0_0 = blocks.null_source(gr.sizeof_float*1) self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float*1) self.blocks_multiply_xx_0_2 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((rxMagnitude, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_float_to_complex_1_0 = blocks.float_to_complex(1) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, )) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=txPort, server=False, ) self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=rxPort, server=False, ) self.audio_source_0 = audio.source(samp_rate, "", True) self.audio_sink_0 = audio.sink(samp_rate, "", True) self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(threshold, 1) self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -freqFine, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq+freqFine-localOscillator, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, -(freq-localOscillator), 1, 0) self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, rxPhase*3.14159/180.0) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.blks2_tcp_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_throttle_0_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_float_to_complex_0_1, 0), (self.blocks_multiply_xx_0_1, 1)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_transcendental_1, 0)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_transcendental_0, 0)) self.connect((self.blocks_transcendental_0, 0), (self.blocks_float_to_complex_0_1, 0)) self.connect((self.blocks_transcendental_1, 0), (self.blocks_float_to_complex_0_1, 1)) self.connect((self.blocks_null_source_0, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_float_to_complex_1, 1)) self.connect((self.blocks_float_to_complex_1, 0), (self.blocks_multiply_xx_0_1, 0)) self.connect((self.blocks_null_source_0_0, 0), (self.blocks_float_to_complex_1_0, 1)) self.connect((self.audio_source_0, 1), (self.blocks_float_to_complex_1_0, 0)) self.connect((self.blocks_float_to_complex_1_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.blocks_null_source_1, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blks2_tcp_sink_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.analog_simple_squelch_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.analog_simple_squelch_cc_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_delay_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_throttle_0_1, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_multiply_xx_0_2, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0_2, 1)) self.connect((self.blocks_multiply_xx_0_2, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0_1, 0)) self.connect((self.low_pass_filter_0_1, 0), (self.wxgui_waterfallsink2_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.digital_mpsk_receiver_cc_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.wxgui_waterfallsink2_0_0_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.audio_sink_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.audio_sink_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.wxgui_waterfallsink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="JMPXRDS Receiver (based on gr_rds)") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) self._lock = threading.RLock() ################################################## # Variables ################################################## self.volume = volume = -3 self.mpx_samp_rate_0 = mpx_samp_rate_0 = 192000 self.mpx_samp_rate = mpx_samp_rate = 192000 self.audio_samp_rate = audio_samp_rate = 96000 ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label='Volume', converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=-20, maximum=10, num_steps=300, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_volume_sizer, 0, 0, 1, 1) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "MPX Plot") self.nb.AddPage(grc_wxgui.Panel(self.nb), "MPX Waterfall") self.nb.AddPage(grc_wxgui.Panel(self.nb), "L+R") self.nb.AddPage(grc_wxgui.Panel(self.nb), "L-R") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS Plot") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS Constelation") self.GridAdd(self.nb, 1, 0, 1, 1) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_f( self.nb.GetPage(1).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=mpx_samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title='MPX Waterfall Plot', ) self.nb.GetPage(1).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_1 = scopesink2.scope_sink_c( self.nb.GetPage(5).GetWin(), title='Scope Plot', sample_rate=mpx_samp_rate / 4, v_scale=0.4, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label='Counts', ) self.nb.GetPage(5).Add(self.wxgui_scopesink2_1.win) self.wxgui_fftsink2_0_0_1 = fftsink2.fft_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=mpx_samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.8, title='MPX FFT', peak_hold=False, win=window.flattop, ) self.nb.GetPage(0).Add(self.wxgui_fftsink2_0_0_1.win) self.wxgui_fftsink2_0_0_0_1_0_1 = fftsink2.fft_sink_c( self.nb.GetPage(4).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=mpx_samp_rate/4, fft_size=1024, fft_rate=12, average=False, avg_alpha=None, title='RDS', peak_hold=False, win=window.blackmanharris, ) self.nb.GetPage(4).Add(self.wxgui_fftsink2_0_0_0_1_0_1.win) self.wxgui_fftsink2_0_0_0_1 = fftsink2.fft_sink_f( self.nb.GetPage(3).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=mpx_samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title='L-R', peak_hold=False, win=window.flattop, ) self.nb.GetPage(3).Add(self.wxgui_fftsink2_0_0_0_1.win) self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_f( self.nb.GetPage(2).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=mpx_samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title='L+R', peak_hold=False, win=window.flattop, ) self.nb.GetPage(2).Add(self.wxgui_fftsink2_0_0_0.win) self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_f( self.nb.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=mpx_samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.8, title='MPX FFT', peak_hold=False, win=window.flattop, ) self.nb.GetPage(0).Add(self.wxgui_fftsink2_0_0.win) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine( 1, mpx_samp_rate/4, 2375, 1, 100)) self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff( interpolation=audio_samp_rate, decimation=mpx_samp_rate, taps=None, fractional_bw=0.4, ) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=audio_samp_rate, decimation=mpx_samp_rate, taps=None, fractional_bw=0.4, ) self.gr_rds_parser_0 = rds.parser(False, False, 0) self.gr_rds_panel_0 = rds.rdsPanel(96700000, self.GetWin()) self.Add(self.gr_rds_panel_0.panel) self.gr_rds_decoder_0 = rds.decoder(False, False) self.freq_xlating_fir_filter_xxx_2 = filter.freq_xlating_fir_filter_fcf(1, (firdes.low_pass(1.0,mpx_samp_rate,17e3,3e3,firdes.WIN_HAMMING)), 38000, mpx_samp_rate) self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_fcc(4, (firdes.low_pass(1.0,mpx_samp_rate,2.4e3,2e3,firdes.WIN_HAMMING)), 57e3, mpx_samp_rate) self.fir_filter_xxx_1 = filter.fir_filter_fff(1, (firdes.low_pass(1.0,mpx_samp_rate,17e3,3e3,firdes.WIN_HAMMING))) self.fir_filter_xxx_1.declare_sample_delay(0) self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc(2, 0, 1*cmath.pi/100.0, -0.06, 0.06, 0.5, 0.05, mpx_samp_rate/4/2375.0, 0.001, 0.005) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((10**(1.*(volume)/10), )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10**(1.*(volume)/10), )) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_char*1, 2) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_float*1, '/tmp/jmpxrds_rtp_client.sock', False) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.audio_sink_0 = audio.sink(audio_samp_rate, '', True) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(1) self.analog_fm_deemph_0_0_0 = analog.fm_deemph(fs=mpx_samp_rate, tau=50e-6) self.analog_fm_deemph_0_0 = analog.fm_deemph(fs=mpx_samp_rate, tau=50e-6) ################################################## # Connections ################################################## self.msg_connect((self.gr_rds_decoder_0, 'out'), (self.gr_rds_parser_0, 'in')) self.msg_connect((self.gr_rds_parser_0, 'out'), (self.gr_rds_panel_0, 'in')) self.connect((self.analog_fm_deemph_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.analog_fm_deemph_0_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.wxgui_fftsink2_0_0_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.analog_fm_deemph_0_0_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_complex_to_real_0, 0), (self.wxgui_fftsink2_0_0_0_1, 0)) self.connect((self.blocks_complex_to_real_0_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.fir_filter_xxx_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.freq_xlating_fir_filter_xxx_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.freq_xlating_fir_filter_xxx_2, 0)) self.connect((self.blocks_file_source_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.analog_fm_deemph_0_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.gr_rds_decoder_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_complex_to_real_0_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.wxgui_fftsink2_0_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.wxgui_fftsink2_0_0_0_1_0_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_2, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.audio_sink_0, 1)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_mpsk_receiver_cc_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Stereo FM receiver and RDS Decoder") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1000000 self.bb_decim = bb_decim = 4 self.freq_offset = freq_offset = 250000 self.freq = freq = 106.1e6 self.baseband_rate = baseband_rate = samp_rate/bb_decim self.audio_decim = audio_decim = 5 self.xlate_bandwidth = xlate_bandwidth = 100000 self.volume = volume = 0 self.gain = gain = 37.6 self.freq_tune = freq_tune = freq - freq_offset self.audio_rate = audio_rate = 48000 self.audio_decim_rate = audio_decim_rate = baseband_rate/audio_decim ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=-20, maximum=10, num_steps=300, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_volume_sizer, 0, 1, 1, 1) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Demod") self.nb.AddPage(grc_wxgui.Panel(self.nb), "L+R") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Pilot") self.nb.AddPage(grc_wxgui.Panel(self.nb), "DSBSC") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS") self.nb.AddPage(grc_wxgui.Panel(self.nb), "L-R") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS constellation") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Waterfall") self.GridAdd(self.nb, 2, 0, 1, 2) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="RF Gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=49.6, num_steps=124, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_sizer, 0, 0, 1, 1) _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label="Freq", converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=88.1e6, maximum=107.9e6, num_steps=99, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_freq_sizer, 1, 0, 1, 2) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_f( self.nb.GetPage(8).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=baseband_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.nb.GetPage(8).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_1 = scopesink2.scope_sink_c( self.nb.GetPage(7).GetWin(), title="Scope Plot", sample_rate=2375, v_scale=0.4, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(7).Add(self.wxgui_scopesink2_1.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.nb.GetPage(3).GetWin(), title="Pilot", sample_rate=baseband_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(3).Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0_0_0_1_0_1 = fftsink2.fft_sink_c( self.nb.GetPage(5).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=audio_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="RDS", peak_hold=False, ) self.nb.GetPage(5).Add(self.wxgui_fftsink2_0_0_0_1_0_1.win) self.wxgui_fftsink2_0_0_0_1_0_0 = fftsink2.fft_sink_f( self.nb.GetPage(6).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=-50, ref_scale=2.0, sample_rate=baseband_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="L-R", peak_hold=False, ) self.nb.GetPage(6).Add(self.wxgui_fftsink2_0_0_0_1_0_0.win) self.wxgui_fftsink2_0_0_0_1 = fftsink2.fft_sink_f( self.nb.GetPage(4).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=baseband_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="DSBSC Sub-carrier", peak_hold=False, ) self.nb.GetPage(4).Add(self.wxgui_fftsink2_0_0_0_1.win) self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_f( self.nb.GetPage(2).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=audio_decim_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="L+R", peak_hold=False, ) self.nb.GetPage(2).Add(self.wxgui_fftsink2_0_0_0.win) self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_f( self.nb.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=baseband_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.8, title="FM Demod", peak_hold=False, ) self.nb.GetPage(1).Add(self.wxgui_fftsink2_0_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=-30, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.8, title="Baseband", peak_hold=False, ) self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win) 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_tune, 0) self.rtlsdr_source_0.set_freq_corr(0, 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(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.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine( 1, samp_rate/bb_decim/audio_decim, 2375, 1, 100)) self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff( interpolation=audio_rate, decimation=audio_decim_rate, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=audio_rate, decimation=audio_decim_rate, taps=None, fractional_bw=None, ) self.gr_rds_parser_0 = rds.parser(False, True) self.gr_rds_panel_0 = rds.rdsPanel(freq, self.GetWin()) self.Add(self.gr_rds_panel_0.panel) self.gr_rds_decoder_0 = rds.decoder(False, False) self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_fcc(audio_decim, (firdes.low_pass(2500.0,baseband_rate,2.4e3,2e3,firdes.WIN_HAMMING)), 57e3, baseband_rate) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (firdes.low_pass(1, samp_rate, xlate_bandwidth, 100000)), freq_offset, samp_rate) self.fir_filter_xxx_5 = filter.fir_filter_fff(audio_decim, (firdes.low_pass(1.0,baseband_rate,20e3,40e3,firdes.WIN_HAMMING))) self.fir_filter_xxx_5.declare_sample_delay(0) self.fir_filter_xxx_3 = filter.fir_filter_fff(1, (firdes.band_pass(1.0,baseband_rate,38e3-13e3,38e3+13e3,3e3,firdes.WIN_HAMMING))) self.fir_filter_xxx_3.declare_sample_delay(0) self.fir_filter_xxx_2 = filter.fir_filter_fcc(1, (firdes.complex_band_pass(1.0,baseband_rate,19e3-500,19e3+500,1e3,firdes.WIN_HAMMING))) self.fir_filter_xxx_2.declare_sample_delay(0) self.fir_filter_xxx_1 = filter.fir_filter_fff(audio_decim, (firdes.low_pass(1.0,baseband_rate,13e3,3e3,firdes.WIN_HAMMING))) self.fir_filter_xxx_1.declare_sample_delay(0) self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc(2, 0, 1*cmath.pi/100.0, -0.06, 0.06, 0.5, 0.05, samp_rate/bb_decim/audio_decim/ 2375.0, 0.001, 0.005) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((10**(1.*(volume+15)/10), )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10**(1.*(volume+15)/10), )) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_char*1, 2) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=samp_rate, audio_decimation=bb_decim, ) self.analog_pll_refout_cc_0 = analog.pll_refout_cc(0.001, 2 * math.pi * (19000+200) / baseband_rate, 2 * math.pi * (19000-200) / baseband_rate) self.analog_fm_deemph_0_0_0 = analog.fm_deemph(fs=audio_decim_rate, tau=75e-6) self.analog_fm_deemph_0_0 = analog.fm_deemph(fs=audio_decim_rate, tau=75e-6) ################################################## # Connections ################################################## self.connect((self.fir_filter_xxx_1, 0), (self.wxgui_fftsink2_0_0_0, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.fir_filter_xxx_3, 0), (self.wxgui_fftsink2_0_0_0_1, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.fir_filter_xxx_5, 0)) self.connect((self.analog_fm_deemph_0_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.analog_fm_deemph_0_0_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.analog_fm_deemph_0_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_fftsink2_0_0_0_1_0_0, 0)) self.connect((self.fir_filter_xxx_5, 0), (self.blocks_add_xx_0, 1)) self.connect((self.fir_filter_xxx_5, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.fir_filter_xxx_3, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_fm_deemph_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.fir_filter_xxx_1, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.fir_filter_xxx_3, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.fir_filter_xxx_2, 0)) self.connect((self.fir_filter_xxx_2, 0), (self.analog_pll_refout_cc_0, 0)) self.connect((self.analog_pll_refout_cc_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.analog_pll_refout_cc_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_complex_to_imag_0, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_wfm_rcv_0, 0), (self.freq_xlating_fir_filter_xxx_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.wxgui_fftsink2_0_0_0_1_0_1, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_mpsk_receiver_cc_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.gr_rds_decoder_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_null_sink_0, 1)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.gr_rds_decoder_0, "out", self.gr_rds_parser_0, "in") self.msg_connect(self.gr_rds_parser_0, "out", self.gr_rds_panel_0, "in")
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="FMReceiverSignal") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2e6 self.bb_decim = bb_decim = 4 self.freq_offset = freq_offset = 200000 self.freq = freq = 99.5e6 self.baseband_rate = baseband_rate = samp_rate/bb_decim self.audio_decim = audio_decim = 5 self.xlate_bandwidth = xlate_bandwidth = 100000 self.volume = volume = 1 self.gain = gain = 40 self.freq_tune = freq_tune = freq- freq_offset self.audio_rate = audio_rate = 48000 self.audio_decim_rate = audio_decim_rate = baseband_rate/audio_decim ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=0, maximum=10, num_steps=300, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_volume_sizer, 0, 1, 1, 1) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "Demod") self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Waterfall") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS constellation") self.GridAdd(self.nb, 2, 0, 1, 2) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="RF Gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=49.6, num_steps=124, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_sizer, 0, 0, 1, 1) _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label="Freq", converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=88.1e6, maximum=107.9e6, num_steps=99, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_freq_sizer, 1, 0, 1, 2) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_f( self.nb.GetPage(3).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=baseband_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.nb.GetPage(3).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_1 = scopesink2.scope_sink_c( self.nb.GetPage(4).GetWin(), title="Scope Plot", sample_rate=2375, v_scale=0.4, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(4).Add(self.wxgui_scopesink2_1.win) self.wxgui_fftsink2_0_0_0_1_0_1 = fftsink2.fft_sink_c( self.nb.GetPage(2).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=audio_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="RDS", peak_hold=False, ) self.nb.GetPage(2).Add(self.wxgui_fftsink2_0_0_0_1_0_1.win) self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_f( self.nb.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=baseband_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.8, title="FM Demod", peak_hold=False, ) self.nb.GetPage(0).Add(self.wxgui_fftsink2_0_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=-30, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.8, title="Baseband", peak_hold=False, ) self.nb.GetPage(1).Add(self.wxgui_fftsink2_0.win) 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_tune, 0) self.rtlsdr_source_0.set_freq_corr(0, 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(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.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine( 1, samp_rate/bb_decim/audio_decim, 2375, 1, 100)) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=48, decimation=500, taps=None, fractional_bw=None, ) self.gr_rds_parser_0 = rds.parser(True, False, 1) self.gr_rds_panel_0 = rds.rdsPanel(freq, self.GetWin()) self.Add(self.gr_rds_panel_0.panel) self.gr_rds_decoder_0 = rds.decoder(False, False) self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_fcc(audio_decim, (firdes.low_pass(2500.0,baseband_rate,2.4e3,2e3,firdes.WIN_HAMMING)), 57e3, baseband_rate) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (firdes.low_pass(1, samp_rate, xlate_bandwidth, 100000)), freq_offset, samp_rate) self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc(2, 0, 1*cmath.pi/100.0, -0.06, 0.06, 0.5, 0.05, samp_rate/bb_decim/audio_decim/ 2375.0, 0.001, 0.005) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((volume, )) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_char*1, 2) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=samp_rate, audio_decimation=bb_decim, ) ################################################## # Connections ################################################## self.msg_connect((self.gr_rds_decoder_0, 'out'), (self.gr_rds_parser_0, 'in')) self.msg_connect((self.gr_rds_parser_0, 'out'), (self.gr_rds_panel_0, 'in')) self.connect((self.analog_wfm_rcv_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.freq_xlating_fir_filter_xxx_1, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.gr_rds_decoder_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.wxgui_fftsink2_0_0_0_1_0_1, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_mpsk_receiver_cc_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))