def __init__(self, uhd_address, options):

        gr.top_block.__init__(self)

        self.uhd_addr = uhd_address
        self.freq = options.freq
        self.samp_rate = options.samp_rate
        self.gain = options.gain
        self.threshold = options.threshold
        self.trigger = options.trigger

        self.uhd_src = uhd.single_usrp_source(
            device_addr=self.uhd_addr,
            stream_args=uhd.stream_args('fc32'))

        self.uhd_src.set_samp_rate(self.samp_rate)
        self.uhd_src.set_center_freq(self.freq, 0)
        self.uhd_src.set_gain(self.gain, 0)

        taps = firdes.low_pass_2(1, 1, 0.4, 0.1, 60)
        self.chanfilt = filter.fir_filter_ccc(10, taps)
        self.tagger = blocks.burst_tagger(gr.sizeof_gr_complex)

        # Dummy signaler to collect a burst on known periods
        data = 1000*[0,] + 1000*[1,]
        self.signal = blocks.vector_source_s(data, True)

        # Energy detector to get signal burst
        ## use squelch to detect energy
        self.det  = analog.simple_squelch_cc(self.threshold, 0.01)
        ## convert to mag squared (float)
        self.c2m = blocks.complex_to_mag_squared()
        ## average to debounce
        self.avg = filter.single_pole_iir_filter_ff(0.01)
        ## rescale signal for conversion to short
        self.scale = blocks.multiply_const_ff(2**16)
        ## signal input uses shorts
        self.f2s = blocks.float_to_short()

        # Use file sink burst tagger to capture bursts
        self.fsnk = blocks.tagged_file_sink(gr.sizeof_gr_complex, self.samp_rate)


        ##################################################
        # Connections
        ##################################################
        self.connect((self.uhd_src, 0), (self.tagger, 0))
        self.connect((self.tagger, 0), (self.fsnk, 0))

        if self.trigger:
            # Connect a dummy signaler to the burst tagger
            self.connect((self.signal, 0), (self.tagger, 1))

        else:
            # Connect an energy detector signaler to the burst tagger
            self.connect(self.uhd_src, self.det)
            self.connect(self.det, self.c2m, self.avg, self.scale, self.f2s)
            self.connect(self.f2s, (self.tagger, 1))
Beispiel #2
0
    def __init__(self, uhd_address, options):

        gr.top_block.__init__(self)

        self.uhd_addr = uhd_address
        self.freq = options.freq
        self.samp_rate = options.samp_rate
        self.gain = options.gain
        self.threshold = options.threshold
        self.trigger = options.trigger

        self.uhd_src = uhd.single_usrp_source(
            device_addr=self.uhd_addr,
            stream_args=uhd.stream_args('fc32'))

        self.uhd_src.set_samp_rate(self.samp_rate)
        self.uhd_src.set_center_freq(self.freq, 0)
        self.uhd_src.set_gain(self.gain, 0)

        taps = firdes.low_pass_2(1, 1, 0.4, 0.1, 60)
        self.chanfilt = filter.fir_filter_ccc(10, taps)
        self.tagger = blocks.burst_tagger(gr.sizeof_gr_complex)

        # Dummy signaler to collect a burst on known periods
        data = 1000 * [0, ] + 1000 * [1, ]
        self.signal = blocks.vector_source_s(data, True)

        # Energy detector to get signal burst
        # use squelch to detect energy
        self.det = analog.simple_squelch_cc(self.threshold, 0.01)
        # convert to mag squared (float)
        self.c2m = blocks.complex_to_mag_squared()
        # average to debounce
        self.avg = filter.single_pole_iir_filter_ff(0.01)
        # rescale signal for conversion to short
        self.scale = blocks.multiply_const_ff(2**16)
        # signal input uses shorts
        self.f2s = blocks.float_to_short()

        # Use file sink burst tagger to capture bursts
        self.fsnk = blocks.tagged_file_sink(
            gr.sizeof_gr_complex, self.samp_rate)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.uhd_src, 0), (self.tagger, 0))
        self.connect((self.tagger, 0), (self.fsnk, 0))

        if self.trigger:
            # Connect a dummy signaler to the burst tagger
            self.connect((self.signal, 0), (self.tagger, 1))

        else:
            # Connect an energy detector signaler to the burst tagger
            self.connect(self.uhd_src, self.det)
            self.connect(self.det, self.c2m, self.avg, self.scale, self.f2s)
            self.connect(self.f2s, (self.tagger, 1))
Beispiel #3
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.channel_spacing = channel_spacing = 500000
        self.width = width = 40000
        self.tuner = tuner = 868.95e6
        self.squelch = squelch = -25
        self.samp_rate = samp_rate = 1.024e6
        self.freq_offset = freq_offset = (channel_spacing /
                                          2) + (channel_spacing * .1)
        self.demodgain = demodgain = 4
        self.cutoff = cutoff = 200000

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0_1 = osmosdr.source(args="numchan=" + str(1) +
                                                 " " + '')
        self.osmosdr_source_0_1.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_0_1.set_sample_rate(samp_rate)
        self.osmosdr_source_0_1.set_center_freq(tuner + freq_offset, 0)
        self.osmosdr_source_0_1.set_freq_corr(21, 0)
        self.osmosdr_source_0_1.set_gain_mode(False, 0)
        self.osmosdr_source_0_1.set_gain(10, 0)
        self.osmosdr_source_0_1.set_if_gain(24, 0)
        self.osmosdr_source_0_1.set_bb_gain(20, 0)
        self.osmosdr_source_0_1.set_antenna('', 0)
        self.osmosdr_source_0_1.set_bandwidth(0, 0)
        self.freq_xlating_fir_filter_xxx_0_1 = filter.freq_xlating_fir_filter_ccc(
            1,
            firdes.low_pass(1, samp_rate, cutoff, width, firdes.WIN_BLACKMAN,
                            6.76), -freq_offset, samp_rate)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            'capture_' + datetime.today().strftime('%Y%m%d%H%M%S'), False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            demodgain)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.osmosdr_source_0_1, 0),
                     (self.freq_xlating_fir_filter_xxx_0_1, 0))
Beispiel #4
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.channel_spacing = channel_spacing = 200000
        self.width = width = 20000
        self.tuner = tuner = 434e6
        self.squelch = squelch = -25
        self.samp_rate = samp_rate = 1.024e6
        self.freq_offset = freq_offset = (channel_spacing /
                                          2) + (channel_spacing * .1)
        self.demodgain = demodgain = 4
        self.cutoff = cutoff = 134000

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_c_0_1 = osmosdr.source()
        self.osmosdr_source_c_0_1.set_sample_rate(samp_rate)
        self.osmosdr_source_c_0_1.set_center_freq(tuner + freq_offset, 0)
        self.osmosdr_source_c_0_1.set_freq_corr(21, 0)
        self.osmosdr_source_c_0_1.set_iq_balance_mode(0, 0)
        self.osmosdr_source_c_0_1.set_gain_mode(0, 0)
        self.osmosdr_source_c_0_1.set_gain(10, 0)
        self.osmosdr_source_c_0_1.set_if_gain(24, 0)
        self.osmosdr_source_c_0_1.set_bb_gain(20, 0)
        self.osmosdr_source_c_0_1.set_antenna("", 0)
        self.osmosdr_source_c_0_1.set_bandwidth(0, 0)

        self.freq_xlating_fir_filter_xxx_0_1 = filter.freq_xlating_fir_filter_ccc(
            1, (firdes.low_pass(1, samp_rate, cutoff, width,
                                firdes.WIN_BLACKMAN, 6.76)), -freq_offset,
            samp_rate)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   "capture", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            demodgain)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.osmosdr_source_c_0_1, 0),
                     (self.freq_xlating_fir_filter_xxx_0_1, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.digital_binary_slicer_fb_0, 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")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(4e6)
        self.uhd_usrp_source_0.set_center_freq(2426e6, 0)
        self.uhd_usrp_source_0.set_gain(60, 0)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, '/Users/mmohamoud/sdr/ble_dump/squelech_out_file', False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_simple_squelch = analog.simple_squelch_cc(70, 0.1)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_simple_squelch, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.analog_simple_squelch, 0))
Beispiel #6
0
    def __init__(self, squelch_rate, squelch_threshold=-100):
        alpha = 80.0 / squelch_rate

        self.__squelch = analog.simple_squelch_cc(squelch_threshold, alpha)
        self.__probe = analog.probe_avg_mag_sqrd_c(0, alpha=alpha)

        self.squelch_block = gr.hier_block2(
            defaultstr('SquelchMixin bundle'),
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
            gr.io_signature(1, 1, gr.sizeof_gr_complex))
        self.squelch_block.connect(self.squelch_block, self.__squelch,
                                   self.squelch_block)
        self.squelch_block.connect(self.squelch_block, self.__probe)
Beispiel #7
0
    def test_simple_squelch_001(self):
        # Test set/gets

        alpha = 0.0001

        thr1 = 10
        thr2 = 20

        op = analog.simple_squelch_cc(thr1, alpha)

        op.set_threshold(thr2)
        t = op.threshold()
        self.assertEqual(thr2, t)
    def test_simple_squelch_001(self):
        # Test set/gets

        alpha = 0.0001

        thr1 = 10
        thr2 = 20

        op = analog.simple_squelch_cc(thr1, alpha)

        op.set_threshold(thr2)
        t = op.threshold()
        self.assertEqual(thr2, t)
Beispiel #9
0
    def __init__(self, dest, debug, input_rate, deviation, squelch, gain,
                 msgq_id, msg_q):

        gr.hier_block2.__init__(
            self,
            "op25_nbfm_c",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),  # Input signature
            gr.io_signature(0, 0, 0))  # Output signature

        self.debug = debug
        self.msgq_id = msgq_id

        # 'switch' enables the analog decoding to be turned on/off
        self.switch = blocks.copy(gr.sizeof_gr_complex)
        self.switch.set_enabled(False)

        # power squelch
        self.squelch = analog.simple_squelch_cc(squelch, gain)

        # quadrature demod
        fm_demod_gain = input_rate / (4 * pi * deviation)
        self.fm_demod = analog.quadrature_demod_cf(fm_demod_gain)

        # fm deemphasis
        self.deemph = analog.fm_deemph(input_rate, 0.00075)

        # decimate and filter
        audio_decim = input_rate // _PCM_RATE
        lpf_taps = filter.firdes.low_pass(
            1.0,  # gain
            input_rate,  # sampling rate
            3000.0,  # Audio high cutoff (remove aliasing)
            200.0,  # transition
            filter.firdes.WIN_HAMMING)  # filter type
        hpf_taps = filter.firdes.high_pass(
            1.0,  # gain
            _PCM_RATE,  # sampling rate
            200.0,  # Audio low cutoff  (remove sub-audio signaling)
            10.0,  # Sharp transition band
            filter.firdes.WIN_HAMMING)  # filter type
        self.lp_filter = filter.fir_filter_fff(audio_decim, lpf_taps)
        self.hp_filter = filter.fir_filter_fff(1, hpf_taps)

        # analog_udp block converts +/-1.0 float samples to S16LE PCM and sends over UDP
        self.analog_udp = op25_repeater.analog_udp(dest, debug, msgq_id, msg_q)

        self.connect(self, self.switch, self.squelch, self.fm_demod,
                     self.deemph, self.lp_filter, self.hp_filter,
                     self.analog_udp)
        sys.stderr.write("%s [%d] Enabling nbfm analog audio\n" %
                         (log_ts.get(), msgq_id))
Beispiel #10
0
    def __init__(self, rx_callback, tx_status, rx_status):
        gr.hier_block2.__init__(self, "receive_path",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
            gr.io_signature(0, 0, 0))

        ##################################################
        # Variables
        ##################################################
        self.callback = rx_callback

        ##################################################
        # Blocks
        ##################################################
        self.demod = digital.gfsk_demod(
        	samples_per_symbol=4,
        	sensitivity=1.0,
        	gain_mu=0.175,
        	mu=0.5,
        	omega_relative_limit=0.005,
        	freq_error=0.0,
        	verbose=False,
        	log=False,
        )
        self.frame_sync = frame_sync(tx_status, rx_status) # Your custom block!!!

        self.output_unpacked_to_packed = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)

        self.rcvd_pktq = gr.msg_queue()
        self.message_sink = blocks.message_sink(gr.sizeof_char, self.rcvd_pktq, True)

        self.queue_watcher_thread = _queue_watcher_thread(self.rcvd_pktq, self.callback)

        self.blocks_max = blocks.max_ff(1,1)

        #Don't Search if nothing is transmitting
        self.blocks_threshold_ff_0 = blocks.threshold_ff(0.00002, 0.00002, 0)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(-80, 0.55)
        ##################################################
        # Connections
        ##################################################
        #main path
        self.connect(self, self.demod, (self.frame_sync, 0))
        self.connect(self.frame_sync, self.output_unpacked_to_packed, self.message_sink)

        #squelch path
        self.connect(self, (self.analog_simple_squelch_cc_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_max, 0), (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.frame_sync, 1))
Beispiel #11
0
 def __init__(self, squelch_rate, squelch_threshold=-100):
     alpha = 80.0 / squelch_rate
     
     self.__squelch = analog.simple_squelch_cc(squelch_threshold, alpha)
     self.__probe = analog.probe_avg_mag_sqrd_c(0, alpha=alpha)
     
     self.squelch_block = gr.hier_block2(
         defaultstr('SquelchMixin bundle'),
         gr.io_signature(1, 1, gr.sizeof_gr_complex),
         gr.io_signature(1, 1, gr.sizeof_gr_complex))
     self.squelch_block.connect(
         self.squelch_block,
         self.__squelch,
         self.squelch_block)
     self.squelch_block.connect(
         self.squelch_block,
         self.__probe)
Beispiel #12
0
    def __init__(self, system, top_block, block_id):

        gr.hier_block2.__init__(
            self,
            "scanning_receiver",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),  # Input signature
            gr.io_signature(0, 0, 0))  # Output signature

        ##################################################
        # Variables
        ##################################################

        self.hang_time = 0.5
        self.channel_rate = 12500

        self.tb = top_block
        self.block_id = block_id
        self.system = system
        print self.system
        self.system_id = system['id']
        self.channels = system['channels']

        ##################################################
        # Threads
        ##################################################

        receive_engine = threading.Thread(target=self.receive_engine)
        receive_engine.daemon = True
        receive_engine.start()

        ##################################################
        # Blocks
        ##################################################

        self.source = self

        #self.complex_to_mag_squared = blocks.complex_to_mag_squared(1)
        #self.probe = blocks.probe_signal_f()
        self.squelch = analog.simple_squelch_cc(self.system['threshold'], 0.1)
        self.sink = blocks.null_sink(gr.sizeof_gr_complex * 1)

        ##################################################
        # Connections
        ##################################################
        #self.connect(self, self.complex_to_mag_squared, self.probe)
        self.connect(self, self.squelch, self.sink)
Beispiel #13
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.channel_spacing = channel_spacing = 500000
        self.width = width = 40000
        self.tuner = tuner = 868.95e6
        self.squelch = squelch = -25
        self.samp_rate = samp_rate = 1.024e6
        self.freq_offset = freq_offset = (channel_spacing / 2) + (channel_spacing * .1)
        self.demodgain = demodgain = 24
        self.cutoff = cutoff = 200000

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_c_0_1 = osmosdr.source()
        self.osmosdr_source_c_0_1.set_sample_rate(samp_rate)
        self.osmosdr_source_c_0_1.set_center_freq(tuner+freq_offset, 0)
        self.osmosdr_source_c_0_1.set_freq_corr(21, 0)
        self.osmosdr_source_c_0_1.set_iq_balance_mode(0, 0)
        self.osmosdr_source_c_0_1.set_gain_mode(0, 0)
        self.osmosdr_source_c_0_1.set_gain(10, 0)
        self.osmosdr_source_c_0_1.set_if_gain(24, 0)
        self.osmosdr_source_c_0_1.set_bb_gain(20, 0)
        self.osmosdr_source_c_0_1.set_antenna("", 0)
        self.osmosdr_source_c_0_1.set_bandwidth(0, 0)
          
        self.freq_xlating_fir_filter_xxx_0_1 = filter.freq_xlating_fir_filter_ccc(1, (firdes.low_pass(1, samp_rate,cutoff, width,  firdes.WIN_BLACKMAN, 6.76)), -freq_offset, samp_rate)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "capture", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(demodgain)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0), (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.osmosdr_source_c_0_1, 0), (self.freq_xlating_fir_filter_xxx_0_1, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.digital_binary_slicer_fb_0, 0))
    def test_simple_squelch_002(self):
        alpha = 0.0001
        thr = -25

        src_data = map(lambda x: float(x)/10.0, range(1, 40))
        src = blocks.vector_source_c(src_data)
        op = analog.simple_squelch_cc(thr, alpha)
        dst = blocks.vector_sink_c()

        self.tb.connect(src, op)
        self.tb.connect(op, dst)
        self.tb.run()

        expected_result = src_data
        expected_result[0:20] = 20*[0,]

        result_data = dst.data()
        self.assertComplexTuplesAlmostEqual(expected_result, result_data, 4)
Beispiel #15
0
    def test_simple_squelch_002(self):
        alpha = 0.0001
        thr = -25

        src_data = [float(x) / 10.0 for x in range(1, 40)]
        src = blocks.vector_source_c(src_data)
        op = analog.simple_squelch_cc(thr, alpha)
        dst = blocks.vector_sink_c()

        self.tb.connect(src, op)
        self.tb.connect(op, dst)
        self.tb.run()

        expected_result = src_data
        expected_result[0:20] = 20*[0,]

        result_data = dst.data()
        self.assertComplexTuplesAlmostEqual(expected_result, result_data, 4)
    def __init__(self):

        gr.top_block.__init__(self, "Top Block")
        self.receive = osmosdr.source(args="numchan" + str(1) + "" + "")

        self.receive.set_sample_rate(1e6)
        self.receive.set_center_freq(90e6)
        self.receive.set_freq_corr(0, 0)
        self.receive.set_gain_mode(False, 0)
        self.receive.set_gain(10, 0)
        self.receive.set_if_gain(20, 0)
        self.receive.set_bb_gain(20, 0)
        self.receive.set_antenna("", 0)
        self.receive.set_bandwidth(0, 0)

        self.detect = analog.simple_squelch_cc(-24.5, 100e-6)
        self.comptomag = blocks.complex_to_mag(1)

        self.probe = blocks.probe_signal_f()

        #connection
        self.connect((self.receive, 0), (self.detect, 0))
        self.connect((self.detect, 0), (self.comptomag, 0))
        self.connect((self.comptomag, 0), (self.probe, 0))
Beispiel #17
0
    def __init__(self):
        gr.top_block.__init__(self, "Ssb Trx")

        ##################################################
        # Variables
        ##################################################
        self.BaseFreq = BaseFreq = 1296250000
        self.USB = USB = True
        self.TxOffset = TxOffset = 0
        self.TxLO = TxLO = BaseFreq-10000
        self.SQL = SQL = 20
        self.RxOffset = RxOffset = 0
        self.PTT = PTT = False
        self.NCW = NCW = False
        self.MicGain = MicGain = 5.0
        self.MON = MON = False
        self.KEY = KEY = False
        self.FMMIC = FMMIC = 50
        self.FM = FM = True
        self.CW = CW = False
        self.AFGain = AFGain = 20

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=12,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.pluto_source_0 = iio.pluto_source('ip:192.168.2.1', BaseFreq, 529200, 2000000, 0x800, True, True, True, "slow_attack", 64.0, '', True)
        self.pluto_sink_0 = iio.pluto_sink('ip:192.168.2.1', TxLO, 529200, 2000000, 0x800, False, 0, '', True)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(12, (firdes.low_pass(1,529200,12000,6000)), RxOffset, 529200)
        self.blocks_mute_xx_0_0 = blocks.mute_cc(bool(not PTT))
        self.blocks_mute_xx_0 = blocks.mute_ff(bool(PTT and (not MON)))
        self.blocks_multiply_xx_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_4 = blocks.multiply_const_vcc((not FM, ))
        self.blocks_multiply_const_vxx_3 = blocks.multiply_const_vcc((FM, ))
        self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vff((int(FM) *0.1, ))
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((not FM, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((AFGain/10.0, ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((FMMIC/10.0, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(((MicGain/10.0)*(not CW), ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_add_xx_2 = blocks.add_vcc(1)
        self.blocks_add_xx_1 = blocks.add_vff(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.band_pass_filter_1 = filter.fir_filter_fff(1, firdes.band_pass(
        	1, 44100, 200, 3000, 100, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.band_pass(
        	1, 44100, -3000+USB*3300+10000, -300+USB*3300+10000, 100, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0 = filter.fir_filter_ccc(1, firdes.complex_band_pass(
        	1, 44100, -3000+USB*3300+NCW*CW*250, -300+USB*3300-NCW*CW*1950, 100, firdes.WIN_HAMMING, 6.76))
        self.audio_source_0 = audio.source(44100, "hw:CARD=Device,DEV=0", True)
        self.audio_sink_0 = audio.sink(44100, "hw:CARD=Device,DEV=0", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(-60+SQL, 1)
        self.analog_sig_source_x_1_0 = analog.sig_source_f(44100, analog.GR_COS_WAVE, 800, int(CW and KEY), 0)
        self.analog_sig_source_x_1 = analog.sig_source_c(529200, analog.GR_COS_WAVE, TxOffset, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(44100, analog.GR_COS_WAVE, 10000, 1, 0)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
        	audio_rate=44100,
        	quad_rate=44100,
        	tau=75e-6,
        	max_dev=5e3,
        	fh=-1,
                )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=44100,
        	quad_rate=44100,
        	tau=75e-6,
        	max_dev=5e3,
          )
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_2_0, 0))
        self.connect((self.analog_nbfm_tx_0, 0), (self.blocks_multiply_xx_2, 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), (self.blocks_multiply_xx_2, 1))
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.analog_sig_source_x_1_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_nbfm_rx_0, 0))
        self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.band_pass_filter_0_0, 0), (self.blocks_multiply_const_vxx_4, 0))
        self.connect((self.band_pass_filter_1, 0), (self.analog_nbfm_tx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.blocks_mute_xx_0, 0))
        self.connect((self.blocks_add_xx_2, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.band_pass_filter_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.blocks_add_xx_1, 1))
        self.connect((self.blocks_multiply_const_vxx_3, 0), (self.blocks_add_xx_2, 0))
        self.connect((self.blocks_multiply_const_vxx_4, 0), (self.blocks_add_xx_2, 1))
        self.connect((self.blocks_multiply_xx_0, 0), (self.band_pass_filter_0_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_mute_xx_0_0, 0))
        self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_multiply_const_vxx_3, 0))
        self.connect((self.blocks_mute_xx_0, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_mute_xx_0_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.band_pass_filter_0, 0))
        self.connect((self.pluto_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_1, 0))
Beispiel #18
0
    def __init__(self):
        gr.top_block.__init__(self, "RTTY_receive", catch_exceptions=True)
        Qt.QWidget.__init__(self)
        self.setWindowTitle("RTTY_receive")
        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", "RTTY_receive")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(
                    self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.sq_lvl = sq_lvl = -70
        self.samp_rate = samp_rate = 48000
        self.reverse = reverse = 1
        self.fsk_deviation = fsk_deviation = 170
        self.decim = decim = 50
        self.center = center = 2210
        self.baud = baud = 1 / 0.022

        ##################################################
        # Blocks
        ##################################################
        self._sq_lvl_range = Range(-100, 0, 5, -70, 200)
        self._sq_lvl_win = RangeWidget(self._sq_lvl_range, self.set_sq_lvl,
                                       'Squelch', "counter_slider", float,
                                       QtCore.Qt.Horizontal)
        self.top_grid_layout.addWidget(self._sq_lvl_win)
        # Create the options list
        self._reverse_options = (
            1,
            -1,
        )
        # Create the labels list
        self._reverse_labels = (
            'Normal',
            'Reverse',
        )
        # Create the combo box
        # Create the radio buttons
        self._reverse_group_box = Qt.QGroupBox('reverse' + ": ")
        self._reverse_box = Qt.QVBoxLayout()

        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)

            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)

        self._reverse_button_group = variable_chooser_button_group()
        self._reverse_group_box.setLayout(self._reverse_box)
        for i, _label in enumerate(self._reverse_labels):
            radio_button = Qt.QRadioButton(_label)
            self._reverse_box.addWidget(radio_button)
            self._reverse_button_group.addButton(radio_button, i)
        self._reverse_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._reverse_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._reverse_options.index(i)))
        self._reverse_callback(self.reverse)
        self._reverse_button_group.buttonClicked[int].connect(
            lambda i: self.set_reverse(self._reverse_options[i]))
        self.top_grid_layout.addWidget(self._reverse_group_box)
        self.zeromq_push_msg_sink_0 = zeromq.push_msg_sink(
            'tcp://127.0.0.1:50252', 100, True)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
            interpolation=500, decimation=960, taps=None, fractional_bw=None)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            128,  #size
            960,  #samp_rate
            "",  #name
            1,  #number of inputs
            None  # parent
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(0, 1)

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

        self.qtgui_time_sink_x_0.enable_tags(True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_NORM,
                                                  qtgui.TRIG_SLOPE_NEG, 0.5, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        labels = [
            'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5',
            'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10'
        ]
        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]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]

        for i in range(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.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            center,  #fc
            1024,  #bw
            "",  #name
            1,
            None  # parent
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.05)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)
        self.qtgui_freq_sink_x_0.set_fft_window_normalized(False)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcf(
            50, firdes.low_pass(1.0, samp_rate, 1000, 400), center, samp_rate)
        self.epy_block_0 = epy_block_0.my_sync_block()
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(reverse)
        self.audio_source_0 = audio.source(samp_rate, '', True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(sq_lvl, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1.0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.epy_block_0, 'msg_out'),
                         (self.zeromq_push_msg_sink_0, 'in'))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.audio_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.epy_block_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
Beispiel #19
0
    def __init__(self):
        gr.top_block.__init__(self, "OPS-SAT UHF RX")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("OPS-SAT UHF RX")
        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", "os_uhf_rx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.signal_freq = signal_freq = 437.2e6
        self.true_freq = true_freq = signal_freq
        self.samp_rate = samp_rate = 200e3
        self.offset_freq = offset_freq = -40e3
        self.doppler_freq = doppler_freq = true_freq - signal_freq

        self.variable_low_pass_filter_taps_0 = variable_low_pass_filter_taps_0 = firdes.low_pass(
            1.0, samp_rate, 25000, 1000, firdes.WIN_HAMMING, 6.76)

        self.samp_rate_down = samp_rate_down = 57.6e3
        self.freq_tuned = freq_tuned = offset_freq - doppler_freq
        self.Squelch = Squelch = -130

        ##################################################
        # Blocks
        ##################################################
        self._Squelch_range = Range(-180, -50, 1, -130, 200)
        self._Squelch_win = RangeWidget(self._Squelch_range, self.set_Squelch,
                                        "Squelch", "counter_slider", float)
        self.top_grid_layout.addWidget(self._Squelch_win)
        self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_gr_complex, 1,
                                                 'tcp://127.0.0.1:5555', 100,
                                                 False, -1)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=int(samp_rate_down),
            decimation=int(samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            2  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.1)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.gpredict_doppler_1 = gpredict.doppler(self.set_true_freq,
                                                   "localhost", 4532, False)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (variable_low_pass_filter_taps_0), -freq_tuned, samp_rate)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/home/osops/tom/dev/workspace/osat_437.16M_200k_beacon_mode6.cf32',
            True)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(Squelch, 1)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -freq_tuned, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.zeromq_pub_sink_0, 0))
Beispiel #20
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2E6

        ##################################################
        # Blocks
        ##################################################
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              "")
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(131.550E6, 0)
        self.rtlsdr_source_0.set_freq_corr(50, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(2, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(2, 0)
        self.rtlsdr_source_0.set_gain_mode(True, 0)
        self.rtlsdr_source_0.set_gain(50, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(3E3, 0)

        self.rational_resampler_xxx_1 = filter.rational_resampler_fff(
            interpolation=1,
            decimation=10,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=480000,
            decimation=200000,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)

        if not True:
            self.qtgui_waterfall_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        labels = ["", "", "", "", "", "", "", "", "", ""]
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_f(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_1.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_1.enable_autoscale(False)
        self.qtgui_freq_sink_x_1.enable_grid(False)
        self.qtgui_freq_sink_x_1.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_1.disable_legend()

        if "float" == "float" or "float" == "msg_float":
            self.qtgui_freq_sink_x_1.set_plot_pos_half(not True)

        labels = ["", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_1_win)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            10,
            firdes.low_pass(1, samp_rate, 3E3, 25E3, firdes.WIN_HAMMING, 6.76))
        self.blocks_wavfile_sink_0_0 = blocks.wavfile_sink(
            "/home/chris/Desktop/filteredAcarsNew", 1, 48000, 8)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.audio_sink_1 = audio.sink(48000, "", True)
        self.analog_simple_squelch_cc_1 = analog.simple_squelch_cc(-25, 0.001)
        self.analog_rail_ff_0 = analog.rail_ff(0, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_rail_ff_0, 0), (self.audio_sink_1, 0))
        self.connect((self.analog_rail_ff_0, 0),
                     (self.blocks_wavfile_sink_0_0, 0))
        self.connect((self.analog_rail_ff_0, 0), (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.analog_simple_squelch_cc_1, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_simple_squelch_cc_1, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.analog_rail_ff_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0))
    def __init__(self, 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))
Beispiel #22
0
 def __init__(self, squelch_rate, squelch_threshold=-100):
     alpha = 80.0 / squelch_rate
     self.rf_squelch_block = analog.simple_squelch_cc(squelch_threshold, alpha)
     self.rf_probe_block = analog.probe_avg_mag_sqrd_c(0, alpha=alpha)
Beispiel #23
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(
            self, title="narrow fm demod on high freq police radio bands")
        _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 = 2400000
        self.rx_freq = rx_freq = 854.388e6
        self.rx_fine = rx_fine = 0
        self.rx_coarse = rx_coarse = 0
        self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(
            1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76)
        self.width = width = 12500
        self.variable_chooser_1 = variable_chooser_1 = 1
        self.tv_freq = tv_freq = 500.25e6
        self.trans = trans = 25000
        self.squelch = squelch = -55
        self.sql_lev = sql_lev = -20
        self.rx_freq_val = rx_freq_val = rx_freq + (rx_coarse + rx_fine)
        self.freq = freq = 155e6
        self.dev = dev = 7500
        self.decimation = decimation = 50
        self.af_gain = af_gain = 1

        ##################################################
        # Blocks
        ##################################################
        _width_sizer = wx.BoxSizer(wx.VERTICAL)
        self._width_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_width_sizer,
            value=self.width,
            callback=self.set_width,
            label="LP Filter",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._width_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_width_sizer,
            value=self.width,
            callback=self.set_width,
            minimum=2000,
            maximum=40000,
            num_steps=760,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_width_sizer, 2, 4, 1, 4)
        _trans_sizer = wx.BoxSizer(wx.VERTICAL)
        self._trans_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_trans_sizer,
            value=self.trans,
            callback=self.set_trans,
            label="LP Trans",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._trans_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_trans_sizer,
            value=self.trans,
            callback=self.set_trans,
            minimum=500,
            maximum=50000,
            num_steps=900,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_trans_sizer, 2, 8, 1, 4)
        _squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._squelch_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_squelch_sizer,
            value=self.squelch,
            callback=self.set_squelch,
            label="squelch level",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._squelch_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_squelch_sizer,
            value=self.squelch,
            callback=self.set_squelch,
            minimum=-100,
            maximum=0,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_squelch_sizer)
        _rx_freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_freq_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rx_freq_sizer,
            value=self.rx_freq,
            callback=self.set_rx_freq,
            label="RX Center ",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rx_freq_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rx_freq_sizer,
            value=self.rx_freq,
            callback=self.set_rx_freq,
            minimum=840000000,
            maximum=860000000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_rx_freq_sizer, 0, 0, 1, 16)
        _rx_fine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_fine_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rx_fine_sizer,
            value=self.rx_fine,
            callback=self.set_rx_fine,
            label="RX Fine",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rx_fine_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rx_fine_sizer,
            value=self.rx_fine,
            callback=self.set_rx_fine,
            minimum=0,
            maximum=10000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_rx_fine_sizer, 1, 4, 1, 4)
        _rx_coarse_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_coarse_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rx_coarse_sizer,
            value=self.rx_coarse,
            callback=self.set_rx_coarse,
            label="RX Offset",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rx_coarse_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rx_coarse_sizer,
            value=self.rx_coarse,
            callback=self.set_rx_coarse,
            minimum=0,
            maximum=1e6,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_rx_coarse_sizer, 1, 0, 1, 4)
        _dev_sizer = wx.BoxSizer(wx.VERTICAL)
        self._dev_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_dev_sizer,
            value=self.dev,
            callback=self.set_dev,
            label="NBFM deviation",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._dev_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_dev_sizer,
            value=self.dev,
            callback=self.set_dev,
            minimum=4000,
            maximum=16000,
            num_steps=24,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_dev_sizer)
        self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c(
            self.GetWin(),
            baseband_freq=rx_freq + rx_coarse + rx_fine,
            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.Add(self.wxgui_waterfallsink2_1.win)
        self._variable_chooser_1_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.variable_chooser_1,
            callback=self.set_variable_chooser_1,
            label='variable_chooser_1',
            choices=[1, 2, 3],
            labels=[],
        )
        self.Add(self._variable_chooser_1_chooser)
        _sql_lev_sizer = wx.BoxSizer(wx.VERTICAL)
        self._sql_lev_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_sql_lev_sizer,
            value=self.sql_lev,
            callback=self.set_sql_lev,
            label="SQL",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._sql_lev_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_sql_lev_sizer,
            value=self.sql_lev,
            callback=self.set_sql_lev,
            minimum=-100,
            maximum=100,
            num_steps=200,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_sql_lev_sizer, 1, 12, 1, 4)
        self._rx_freq_val_static_text = forms.static_text(
            parent=self.GetWin(),
            value=self.rx_freq_val,
            callback=self.set_rx_freq_val,
            label="Receive",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._rx_freq_val_static_text, 0, 16, 1, 1)
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              "")
        self.rtlsdr_source_0.set_time_now(osmosdr.time_spec_t(time.time()),
                                          osmosdr.ALL_MBOARDS)
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(rx_freq, 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(10, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        self.low_pass_filter_0 = filter.fir_filter_ccf(
            decimation,
            firdes.low_pass(1, samp_rate, width, trans, firdes.WIN_HAMMING,
                            6.76))
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=48000,
            quad_rate=48000,
            tau=50e-6,
            max_dev=dev,
        )
        _af_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._af_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_af_gain_sizer,
            value=self.af_gain,
            callback=self.set_af_gain,
            label="VOL",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._af_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_af_gain_sizer,
            value=self.af_gain,
            callback=self.set_af_gain,
            minimum=0,
            maximum=5,
            num_steps=50,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_af_gain_sizer, 2, 12, 1, 4)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_nbfm_rx_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.wxgui_waterfallsink2_1, 0))
Beispiel #24
0
    def __init__(self):
        gr.top_block.__init__(self, "Nbfm Dsd No Gui")

        ##################################################
        # Variables
        ##################################################
        self.decim = decim = 2
        self.adc_rate = adc_rate = 2000000
        self.xlate_offset_fine = xlate_offset_fine = -800
        self.xlate_offset = xlate_offset = 0
        self.xlate_decim = xlate_decim = 4
        self.xlate_bandwidth = xlate_bandwidth = 12500
        self.volume = volume = 2
        self.squelch = squelch = 50
        self.samp_rate = samp_rate = adc_rate/decim
        self.audio_rate = audio_rate = 48000
        self.audio_interp = audio_interp = 4

        ##################################################
        # Blocks
        ##################################################
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(442.574e6, 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(2, 0)
        self.rtlsdr_source_0.set_gain_mode(True, 0)
        self.rtlsdr_source_0.set_gain(50, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
                interpolation=48000,
                decimation=8000,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=audio_rate*audio_interp,
                decimation=samp_rate/xlate_decim,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(xlate_decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 1000)), xlate_offset + xlate_offset_fine, samp_rate)
        self.dsd_block_ff_1 = dsd.block_ff(dsd.dsd_FRAME_AUTO_DETECT,dsd.dsd_MOD_AUTO_SELECT,3,True,2)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, ))
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch*-1, 1)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=audio_rate,
        	quad_rate=audio_rate*audio_interp,
        	tau=75e-6,
        	max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.dsd_block_ff_1, 0))    
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_nbfm_rx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.dsd_block_ff_1, 0), (self.rational_resampler_xxx_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_simple_squelch_cc_0, 0))    
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
Beispiel #25
0
    def __init__(self):
        gr.top_block.__init__(self, "Receive Single FM Station")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Receive Single FM Station")
        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", "rcv_single_fm")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.rf_rate = rf_rate = 20e6
        self.rf_frequency_h = rf_frequency_h = 88.5
        self.fm_taps = fm_taps = firdes.low_pass_2(32., rf_rate, 96e3, 25e3, 50)
        self.audio_rate = audio_rate = 44100
        self.taps_len = taps_len = fm_taps.__len__()
        self.rf_gain = rf_gain = 50
        self.rf_frequency = rf_frequency = 98.1e6
        self.fm_channel_rate = fm_channel_rate = audio_rate*5
        self.channel_number = channel_number = int(10*(rf_frequency_h-98)) /2if rf_frequency_h>=98 else 50 + int(10*(rf_frequency_h-88.1))/2

        ##################################################
        # Blocks
        ##################################################
        self._rf_rate_range = Range(100e3, 20e6, 200e3, 20e6, 200)
        self._rf_rate_win = RangeWidget(self._rf_rate_range, self.set_rf_rate, 'RF sample rate', "counter_slider", float)
        self.top_layout.addWidget(self._rf_rate_win)
        self._rf_gain_range = Range(0, 90, 1, 50, 200)
        self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, 'RF gain', "counter_slider", float)
        self.top_layout.addWidget(self._rf_gain_win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(rf_rate)
        self.uhd_usrp_source_0.set_center_freq(rf_frequency, 0)
        self.uhd_usrp_source_0.set_gain(rf_gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self._rf_frequency_h_range = Range(88.0, 108.0, .2, 88.5, 200)
        self._rf_frequency_h_win = RangeWidget(self._rf_frequency_h_range, self.set_rf_frequency_h, 'RF Frequency', "counter_slider", float)
        self.top_layout.addWidget(self._rf_frequency_h_win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=fm_channel_rate,
                decimation=int(200e3),
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	rf_frequency, #fc
        	rf_rate, #bw
        	"Received Spectrum", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True)
        
        if not True:
          self.qtgui_waterfall_sink_x_0_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True)
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i])
        
        self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-140, 10)
        
        self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_win)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	rf_frequency, #fc
        	fm_channel_rate, #bw
        	"Selected Channel", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)
        
        if not True:
          self.qtgui_waterfall_sink_x_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])
        
        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)
        
        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	1., #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_freq_sink_x_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.pfb_channelizer_ccf_0 = pfb.channelizer_ccf(
        	  100,
        	  (fm_taps),
        	  1.0,
        	  100)
        self.pfb_channelizer_ccf_0.set_channel_map(([channel_number]))
        self.pfb_channelizer_ccf_0.declare_sample_delay(0)
        	
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.audio_sink_0 = audio.sink(audio_rate, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
        	quad_rate=fm_channel_rate,
        	audio_decimation=fm_channel_rate/audio_rate,
        )
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(-20, .1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_wfm_rcv_0, 0))    
        self.connect((self.analog_wfm_rcv_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.pfb_channelizer_ccf_0, 1), (self.blocks_null_sink_0, 0))    
        self.connect((self.pfb_channelizer_ccf_0, 2), (self.blocks_null_sink_0, 1))    
        self.connect((self.pfb_channelizer_ccf_0, 3), (self.blocks_null_sink_0, 2))    
        self.connect((self.pfb_channelizer_ccf_0, 4), (self.blocks_null_sink_0, 3))    
        self.connect((self.pfb_channelizer_ccf_0, 5), (self.blocks_null_sink_0, 4))    
        self.connect((self.pfb_channelizer_ccf_0, 6), (self.blocks_null_sink_0, 5))    
        self.connect((self.pfb_channelizer_ccf_0, 7), (self.blocks_null_sink_0, 6))    
        self.connect((self.pfb_channelizer_ccf_0, 8), (self.blocks_null_sink_0, 7))    
        self.connect((self.pfb_channelizer_ccf_0, 9), (self.blocks_null_sink_0, 8))    
        self.connect((self.pfb_channelizer_ccf_0, 10), (self.blocks_null_sink_0, 9))    
        self.connect((self.pfb_channelizer_ccf_0, 11), (self.blocks_null_sink_0, 10))    
        self.connect((self.pfb_channelizer_ccf_0, 12), (self.blocks_null_sink_0, 11))    
        self.connect((self.pfb_channelizer_ccf_0, 13), (self.blocks_null_sink_0, 12))    
        self.connect((self.pfb_channelizer_ccf_0, 14), (self.blocks_null_sink_0, 13))    
        self.connect((self.pfb_channelizer_ccf_0, 15), (self.blocks_null_sink_0, 14))    
        self.connect((self.pfb_channelizer_ccf_0, 16), (self.blocks_null_sink_0, 15))    
        self.connect((self.pfb_channelizer_ccf_0, 17), (self.blocks_null_sink_0, 16))    
        self.connect((self.pfb_channelizer_ccf_0, 18), (self.blocks_null_sink_0, 17))    
        self.connect((self.pfb_channelizer_ccf_0, 19), (self.blocks_null_sink_0, 18))    
        self.connect((self.pfb_channelizer_ccf_0, 20), (self.blocks_null_sink_0, 19))    
        self.connect((self.pfb_channelizer_ccf_0, 21), (self.blocks_null_sink_0, 20))    
        self.connect((self.pfb_channelizer_ccf_0, 22), (self.blocks_null_sink_0, 21))    
        self.connect((self.pfb_channelizer_ccf_0, 23), (self.blocks_null_sink_0, 22))    
        self.connect((self.pfb_channelizer_ccf_0, 24), (self.blocks_null_sink_0, 23))    
        self.connect((self.pfb_channelizer_ccf_0, 25), (self.blocks_null_sink_0, 24))    
        self.connect((self.pfb_channelizer_ccf_0, 26), (self.blocks_null_sink_0, 25))    
        self.connect((self.pfb_channelizer_ccf_0, 27), (self.blocks_null_sink_0, 26))    
        self.connect((self.pfb_channelizer_ccf_0, 28), (self.blocks_null_sink_0, 27))    
        self.connect((self.pfb_channelizer_ccf_0, 29), (self.blocks_null_sink_0, 28))    
        self.connect((self.pfb_channelizer_ccf_0, 30), (self.blocks_null_sink_0, 29))    
        self.connect((self.pfb_channelizer_ccf_0, 31), (self.blocks_null_sink_0, 30))    
        self.connect((self.pfb_channelizer_ccf_0, 32), (self.blocks_null_sink_0, 31))    
        self.connect((self.pfb_channelizer_ccf_0, 33), (self.blocks_null_sink_0, 32))    
        self.connect((self.pfb_channelizer_ccf_0, 34), (self.blocks_null_sink_0, 33))    
        self.connect((self.pfb_channelizer_ccf_0, 35), (self.blocks_null_sink_0, 34))    
        self.connect((self.pfb_channelizer_ccf_0, 36), (self.blocks_null_sink_0, 35))    
        self.connect((self.pfb_channelizer_ccf_0, 37), (self.blocks_null_sink_0, 36))    
        self.connect((self.pfb_channelizer_ccf_0, 38), (self.blocks_null_sink_0, 37))    
        self.connect((self.pfb_channelizer_ccf_0, 39), (self.blocks_null_sink_0, 38))    
        self.connect((self.pfb_channelizer_ccf_0, 40), (self.blocks_null_sink_0, 39))    
        self.connect((self.pfb_channelizer_ccf_0, 41), (self.blocks_null_sink_0, 40))    
        self.connect((self.pfb_channelizer_ccf_0, 42), (self.blocks_null_sink_0, 41))    
        self.connect((self.pfb_channelizer_ccf_0, 43), (self.blocks_null_sink_0, 42))    
        self.connect((self.pfb_channelizer_ccf_0, 44), (self.blocks_null_sink_0, 43))    
        self.connect((self.pfb_channelizer_ccf_0, 45), (self.blocks_null_sink_0, 44))    
        self.connect((self.pfb_channelizer_ccf_0, 46), (self.blocks_null_sink_0, 45))    
        self.connect((self.pfb_channelizer_ccf_0, 47), (self.blocks_null_sink_0, 46))    
        self.connect((self.pfb_channelizer_ccf_0, 48), (self.blocks_null_sink_0, 47))    
        self.connect((self.pfb_channelizer_ccf_0, 49), (self.blocks_null_sink_0, 48))    
        self.connect((self.pfb_channelizer_ccf_0, 50), (self.blocks_null_sink_0, 49))    
        self.connect((self.pfb_channelizer_ccf_0, 51), (self.blocks_null_sink_0, 50))    
        self.connect((self.pfb_channelizer_ccf_0, 52), (self.blocks_null_sink_0, 51))    
        self.connect((self.pfb_channelizer_ccf_0, 53), (self.blocks_null_sink_0, 52))    
        self.connect((self.pfb_channelizer_ccf_0, 54), (self.blocks_null_sink_0, 53))    
        self.connect((self.pfb_channelizer_ccf_0, 55), (self.blocks_null_sink_0, 54))    
        self.connect((self.pfb_channelizer_ccf_0, 56), (self.blocks_null_sink_0, 55))    
        self.connect((self.pfb_channelizer_ccf_0, 57), (self.blocks_null_sink_0, 56))    
        self.connect((self.pfb_channelizer_ccf_0, 58), (self.blocks_null_sink_0, 57))    
        self.connect((self.pfb_channelizer_ccf_0, 59), (self.blocks_null_sink_0, 58))    
        self.connect((self.pfb_channelizer_ccf_0, 60), (self.blocks_null_sink_0, 59))    
        self.connect((self.pfb_channelizer_ccf_0, 61), (self.blocks_null_sink_0, 60))    
        self.connect((self.pfb_channelizer_ccf_0, 62), (self.blocks_null_sink_0, 61))    
        self.connect((self.pfb_channelizer_ccf_0, 63), (self.blocks_null_sink_0, 62))    
        self.connect((self.pfb_channelizer_ccf_0, 64), (self.blocks_null_sink_0, 63))    
        self.connect((self.pfb_channelizer_ccf_0, 65), (self.blocks_null_sink_0, 64))    
        self.connect((self.pfb_channelizer_ccf_0, 66), (self.blocks_null_sink_0, 65))    
        self.connect((self.pfb_channelizer_ccf_0, 67), (self.blocks_null_sink_0, 66))    
        self.connect((self.pfb_channelizer_ccf_0, 68), (self.blocks_null_sink_0, 67))    
        self.connect((self.pfb_channelizer_ccf_0, 69), (self.blocks_null_sink_0, 68))    
        self.connect((self.pfb_channelizer_ccf_0, 70), (self.blocks_null_sink_0, 69))    
        self.connect((self.pfb_channelizer_ccf_0, 71), (self.blocks_null_sink_0, 70))    
        self.connect((self.pfb_channelizer_ccf_0, 72), (self.blocks_null_sink_0, 71))    
        self.connect((self.pfb_channelizer_ccf_0, 73), (self.blocks_null_sink_0, 72))    
        self.connect((self.pfb_channelizer_ccf_0, 74), (self.blocks_null_sink_0, 73))    
        self.connect((self.pfb_channelizer_ccf_0, 75), (self.blocks_null_sink_0, 74))    
        self.connect((self.pfb_channelizer_ccf_0, 76), (self.blocks_null_sink_0, 75))    
        self.connect((self.pfb_channelizer_ccf_0, 77), (self.blocks_null_sink_0, 76))    
        self.connect((self.pfb_channelizer_ccf_0, 78), (self.blocks_null_sink_0, 77))    
        self.connect((self.pfb_channelizer_ccf_0, 79), (self.blocks_null_sink_0, 78))    
        self.connect((self.pfb_channelizer_ccf_0, 80), (self.blocks_null_sink_0, 79))    
        self.connect((self.pfb_channelizer_ccf_0, 81), (self.blocks_null_sink_0, 80))    
        self.connect((self.pfb_channelizer_ccf_0, 82), (self.blocks_null_sink_0, 81))    
        self.connect((self.pfb_channelizer_ccf_0, 83), (self.blocks_null_sink_0, 82))    
        self.connect((self.pfb_channelizer_ccf_0, 84), (self.blocks_null_sink_0, 83))    
        self.connect((self.pfb_channelizer_ccf_0, 85), (self.blocks_null_sink_0, 84))    
        self.connect((self.pfb_channelizer_ccf_0, 86), (self.blocks_null_sink_0, 85))    
        self.connect((self.pfb_channelizer_ccf_0, 87), (self.blocks_null_sink_0, 86))    
        self.connect((self.pfb_channelizer_ccf_0, 88), (self.blocks_null_sink_0, 87))    
        self.connect((self.pfb_channelizer_ccf_0, 89), (self.blocks_null_sink_0, 88))    
        self.connect((self.pfb_channelizer_ccf_0, 90), (self.blocks_null_sink_0, 89))    
        self.connect((self.pfb_channelizer_ccf_0, 91), (self.blocks_null_sink_0, 90))    
        self.connect((self.pfb_channelizer_ccf_0, 92), (self.blocks_null_sink_0, 91))    
        self.connect((self.pfb_channelizer_ccf_0, 93), (self.blocks_null_sink_0, 92))    
        self.connect((self.pfb_channelizer_ccf_0, 94), (self.blocks_null_sink_0, 93))    
        self.connect((self.pfb_channelizer_ccf_0, 95), (self.blocks_null_sink_0, 94))    
        self.connect((self.pfb_channelizer_ccf_0, 96), (self.blocks_null_sink_0, 95))    
        self.connect((self.pfb_channelizer_ccf_0, 97), (self.blocks_null_sink_0, 96))    
        self.connect((self.pfb_channelizer_ccf_0, 98), (self.blocks_null_sink_0, 97))    
        self.connect((self.pfb_channelizer_ccf_0, 99), (self.blocks_null_sink_0, 98))    
        self.connect((self.pfb_channelizer_ccf_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_simple_squelch_cc_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_waterfall_sink_x_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.pfb_channelizer_ccf_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0))    
Beispiel #26
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Nbfm")

        ##################################################
        # Variables
        ##################################################
        self.decim = decim = 2
        self.adc_rate = adc_rate = 2000000
        self.xlate_offset_fine = xlate_offset_fine = 4000
        self.xlate_offset = xlate_offset = 0
        self.xlate_decim = xlate_decim = 4
        self.xlate_bandwidth = xlate_bandwidth = 12500
        self.volume = volume = 1
        self.squelch = squelch = 50
        self.samp_rate = samp_rate = adc_rate / decim
        self.main_freq = main_freq = 167.99e6
        self.audio_rate = audio_rate = 48000
        self.audio_interp = audio_interp = 4

        ##################################################
        # Blocks
        ##################################################
        self.main_notebook = self.main_notebook = wx.Notebook(self.GetWin(),
                                                              style=wx.NB_TOP)
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook),
                                   "Baseband")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook),
                                   "Scope")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook),
                                   "Waterfall")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook),
                                   "Quad demod")
        self.Add(self.main_notebook)
        _xlate_offset_fine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_offset_fine_text_box = forms.text_box(
            parent=self.main_notebook.GetPage(0).GetWin(),
            sizer=_xlate_offset_fine_sizer,
            value=self.xlate_offset_fine,
            callback=self.set_xlate_offset_fine,
            label="Fine Offset",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._xlate_offset_fine_slider = forms.slider(
            parent=self.main_notebook.GetPage(0).GetWin(),
            sizer=_xlate_offset_fine_sizer,
            value=self.xlate_offset_fine,
            callback=self.set_xlate_offset_fine,
            minimum=-10000,
            maximum=10000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.main_notebook.GetPage(0).Add(_xlate_offset_fine_sizer)
        self._xlate_offset_text_box = forms.text_box(
            parent=self.main_notebook.GetPage(0).GetWin(),
            value=self.xlate_offset,
            callback=self.set_xlate_offset,
            label="Xlate Offset",
            converter=forms.float_converter(),
        )
        self.main_notebook.GetPage(0).Add(self._xlate_offset_text_box)
        _xlate_bandwidth_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_bandwidth_text_box = forms.text_box(
            parent=self.main_notebook.GetPage(0).GetWin(),
            sizer=_xlate_bandwidth_sizer,
            value=self.xlate_bandwidth,
            callback=self.set_xlate_bandwidth,
            label="Xlate Bandwidth",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._xlate_bandwidth_slider = forms.slider(
            parent=self.main_notebook.GetPage(0).GetWin(),
            sizer=_xlate_bandwidth_sizer,
            value=self.xlate_bandwidth,
            callback=self.set_xlate_bandwidth,
            minimum=2500,
            maximum=250000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.main_notebook.GetPage(0).Add(_xlate_bandwidth_sizer)
        _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=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_volume_sizer)
        _squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._squelch_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_squelch_sizer,
            value=self.squelch,
            callback=self.set_squelch,
            label='squelch',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._squelch_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_squelch_sizer,
            value=self.squelch,
            callback=self.set_squelch,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_squelch_sizer)
        self._main_freq_text_box = forms.text_box(
            parent=self.main_notebook.GetPage(0).GetWin(),
            value=self.main_freq,
            callback=self.set_main_freq,
            label="Main Freq",
            converter=forms.float_converter(),
        )
        self.main_notebook.GetPage(0).Add(self._main_freq_text_box)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
            self.main_notebook.GetPage(2).GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=50,
            ref_scale=2.0,
            sample_rate=samp_rate / xlate_decim,
            fft_size=512,
            fft_rate=30,
            average=False,
            avg_alpha=None,
            title="Waterfall Plot",
        )
        self.main_notebook.GetPage(2).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
            self.main_notebook.GetPage(3).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate / xlate_decim,
            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.main_notebook.GetPage(3).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
            self.main_notebook.GetPage(1).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate / xlate_decim,
            v_scale=10,
            v_offset=0,
            t_scale=10000,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.main_notebook.GetPage(1).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.main_notebook.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=50,
            ref_scale=2.0,
            sample_rate=samp_rate / xlate_decim,
            fft_size=1024,
            fft_rate=30,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.main_notebook.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(main_freq, 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(2, 0)
        self.rtlsdr_source_0.set_gain_mode(True, 0)
        self.rtlsdr_source_0.set_gain(50, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=audio_rate * audio_interp,
            decimation=samp_rate / xlate_decim,
            taps=None,
            fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            xlate_decim,
            (firdes.low_pass(1, samp_rate, xlate_bandwidth / 2, 1000)),
            xlate_offset + xlate_offset_fine, samp_rate)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (volume, ))
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(
            squelch * -1, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=audio_rate,
            quad_rate=audio_rate * audio_interp,
            tau=75e-6,
            max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.wxgui_scopesink2_1, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_nbfm_rx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.rational_resampler_xxx_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.wxgui_scopesink2_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
Beispiel #27
0
    def __init__(self):
        gr.top_block.__init__(self, "Bluetooth LE Receiver")

        ##################################################
        # Variables
        ##################################################
        self.transition_width = transition_width = 300e3
        self.sample_rate = sample_rate = 4e6
        self.data_rate = data_rate = 1e6
        self.cutoff_freq = cutoff_freq = 850e3
        self.ble_channel_spacing = ble_channel_spacing = 2e6
        self.ble_channel = ble_channel = 12
        self.ble_base_freq = ble_base_freq = 2402e6
        self.squelch_threshold = squelch_threshold = -70
        self.rf_gain = rf_gain = 10
        self.lowpass_filter = lowpass_filter = firdes.low_pass(
            1, sample_rate, cutoff_freq, transition_width, firdes.WIN_HAMMING,
            6.76)
        self.gmsk_sps = gmsk_sps = int(sample_rate / data_rate)
        self.gmsk_omega_limit = gmsk_omega_limit = 0.035
        self.gmsk_mu = gmsk_mu = 0.5
        self.gmsk_gain_mu = gmsk_gain_mu = 0.7
        self.freq_offset = freq_offset = 1e6
        self.freq = freq = ble_base_freq + (ble_channel_spacing * ble_channel)

        ##################################################
        # Message Queues
        ##################################################
        self.message_queue = message_queue = gr.msg_queue(2)

        ##################################################
        # Blocks
        ##################################################
        self.unpacked_to_packed = blocks.unpacked_to_packed_bb(
            1, gr.GR_LSB_FIRST)
        self.osmosdr_source = osmosdr.source(args="numchan=" + str(1) + " " +
                                             "")
        self.osmosdr_source.set_sample_rate(sample_rate)
        self.osmosdr_source.set_center_freq(freq + freq_offset, 0)
        self.osmosdr_source.set_freq_corr(0, 0)
        self.osmosdr_source.set_dc_offset_mode(0, 0)
        self.osmosdr_source.set_iq_balance_mode(0, 0)
        self.osmosdr_source.set_gain_mode(False, 0)
        self.osmosdr_source.set_gain(rf_gain, 0)
        self.osmosdr_source.set_if_gain(20, 0)
        self.osmosdr_source.set_bb_gain(20, 0)
        self.osmosdr_source.set_antenna("", 0)
        self.osmosdr_source.set_bandwidth(0, 0)

        self.message_sink = blocks.message_sink(gr.sizeof_char * 1,
                                                message_queue, True)
        self.freq_xlating_fir_filter_lp = filter.freq_xlating_fir_filter_ccc(
            1, (lowpass_filter), -freq_offset, sample_rate)
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
            samples_per_symbol=gmsk_sps,
            gain_mu=gmsk_gain_mu,
            mu=gmsk_mu,
            omega_relative_limit=gmsk_omega_limit,
            freq_error=0.0,
            verbose=False,
            log=False,
        )
        self.analog_simple_squelch = analog.simple_squelch_cc(
            squelch_threshold, 0.1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.freq_xlating_fir_filter_lp, 0),
                     (self.digital_gmsk_demod_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0),
                     (self.unpacked_to_packed, 0))
        self.connect((self.unpacked_to_packed, 0), (self.message_sink, 0))
        self.connect((self.osmosdr_source, 0), (self.analog_simple_squelch, 0))
        self.connect((self.analog_simple_squelch, 0),
                     (self.freq_xlating_fir_filter_lp, 0))
Beispiel #28
0
 def __init__(self, squelch_rate, squelch_threshold=-100):
     alpha = 80.0 / squelch_rate
     self.rf_squelch_block = analog.simple_squelch_cc(
         squelch_threshold, alpha)
     self.rf_probe_block = analog.probe_avg_mag_sqrd_c(0, alpha=alpha)
Beispiel #29
0
	def __init__(self):
		gr.top_block.__init__(self)

		sdr_device = ''

		# Front end
		error_ppm = 40
		freq_c0 = 869000000

		# Modulation parameters
		sample_rate = 1200000
		bit_rate = 50000
		deviation = 25000
		max_freq_error = 50000
		decim = 2
		squelch_threshold = -20

		sync_word = "01010010110111010010" # preamble + 2dd2

		# Source
		self.src = osmosdr.source(sdr_device)
		self.src.set_sample_rate(sample_rate)
		self.src.set_center_freq(freq_c0)
		self.src.set_freq_corr(error_ppm)
		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(20, 0)
		self.src.set_if_gain(20, 0)
		self.src.set_bb_gain(20, 0)

		# Channel filter (bandwidth is relative to centre of channel so /2
		bandwidth = 2. * (deviation + bit_rate / 2)
		filter_taps = gr_filter.firdes.low_pass(1, sample_rate, max_freq_error + bandwidth / 2., bit_rate / 2., gr_filter.firdes.WIN_BLACKMAN, 6.76)
		self.filt = gr_filter.freq_xlating_fir_filter_ccc(decim, filter_taps, 0.0, sample_rate)
		
		# FSK demod
		m = 2. * deviation / bit_rate # Modulation index
		demod_gain = float(sample_rate) / decim / bit_rate / (pi * m)
		squelch = gr_analog.simple_squelch_cc(squelch_threshold, 1.)
		demod = gr_analog.quadrature_demod_cf(demod_gain)

		# AM demod (RSSI)
		ctof = gr_blocks.complex_to_mag()

		# Clock recovery and slicer
		gain_mu = 0.175
		gain_omega = 0.25 * gain_mu * gain_mu
		omega_rel_limit = 0.005
		clock = gr_digital.clock_recovery_mm_ff(sample_rate / decim / bit_rate,
			gain_omega, 0.5, gain_mu, omega_rel_limit)
		slicer = gr_digital.binary_slicer_fb()
		sync = gr_digital.correlate_access_code_bb(sync_word, 0)

		# Sink to queue
		self.queue = gr.msg_queue()
		self.watcher = queue_thread(self.queue, None)
		sink = gr_blocks.message_sink(gr.sizeof_char, self.queue, False)
		
		# GUI elements
		fft = qtgui.freq_sink_c(512, gr_filter.firdes.WIN_BLACKMAN, freq_c0, sample_rate/decim, "Spectrum", 1)
		fft.enable_grid(True)
		fft.set_line_label(0, 'Signal')
		qtfft = sip.wrapinstance(fft.pyqwidget(), Qt.QWidget)
		self.qtwidgets.append(qtfft)
		
		plot = qtgui.time_sink_f(int(0.1 * sample_rate / decim), sample_rate / decim, "Scope", 2)
		plot.enable_grid(True)
		plot.set_update_time(0.1)
		plot.set_y_axis(-2, 2)
		plot.set_line_label(0, 'RSSI')
		plot.set_line_label(1, 'FSK')
		plot.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, 0.1, 0, 0, '')
		qtplot = sip.wrapinstance(plot.pyqwidget(), Qt.QWidget)
		self.qtwidgets.append(qtplot)
		
		plot2 = qtgui.time_sink_f(int(0.005 * sample_rate / decim), sample_rate / decim, "Packet View", 1)
		plot2.enable_grid(True)
		plot2.set_update_time(0.1)
		plot2.set_y_axis(-2, 2)
		plot2.set_line_label(0, 'FSK')
		plot2.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, 0.1, 0, 0, '')
		qtplot2 = sip.wrapinstance(plot2.pyqwidget(), Qt.QWidget)
		self.qtwidgets.append(qtplot2)
		
		# Flowgraph
		self.connect(self.src, self.filt, squelch, demod, clock, slicer, sync, sink)
		self.connect(self.src, fft)
		self.connect(demod, (plot, 0))
		self.connect(self.filt, ctof, (plot, 1))
		self.connect(demod, (plot2, 0))
Beispiel #30
0
    def _setup_top_block(self):

        self.tb = gr.top_block()

        samp_rate = 96000
        oversample = 10

        # Radio receiver, initial downsampling
        args = "rtl=%d,buffers=16" % (self.device,)
        if self.osmosdr_args:
            args += ",%s" % (self.osmosdr_args,)

        osmosdr_source = osmosdr.source(args=args)
        osmosdr_source.set_sample_rate(samp_rate * oversample)
        osmosdr_source.set_center_freq(self.freq, 0)
        osmosdr_source.set_freq_corr(0, 0)
        osmosdr_source.set_gain_mode(1, 0)
        osmosdr_source.set_gain(0, 0)

        taps = filter.firdes.low_pass(1, samp_rate * oversample, 90e3, 8e3, filter.firdes.WIN_HAMMING, 6.76)
        low_pass_filter = filter.fir_filter_ccf(oversample, taps)

        self.tb.connect((osmosdr_source, 0), (low_pass_filter, 0))

        # Squelch
        self.noise_probe = analog.probe_avg_mag_sqrd_c(0, 1.0 / samp_rate / 1e2)
        self.squelch = analog.simple_squelch_cc(self.noise_level, 1)

        noise_probe_thread = threading.Thread(target=self._noise_probe_thread)
        noise_probe_thread.start()
        self.threads.append(noise_probe_thread)

        self.tb.connect((low_pass_filter, 0), (self.noise_probe, 0))
        self.tb.connect((low_pass_filter, 0), (self.squelch, 0))

        # FM demodulation
        quadrature_demod = analog.quadrature_demod_cf(1)

        self.tb.connect((self.squelch, 0), (quadrature_demod, 0))

        # Binary slicing, transformation into capture-compatible format

        add_offset = blocks.add_const_vff((-1e-3,))

        binary_slicer = digital.binary_slicer_fb()

        char_to_float = blocks.char_to_float(1, 1)

        multiply_const = blocks.multiply_const_vff((255,))

        float_to_uchar = blocks.float_to_uchar()

        pipe_sink = blocks.file_sink(gr.sizeof_char * 1, self.pipe)
        pipe_sink.set_unbuffered(False)

        self.tb.connect((quadrature_demod, 0), (add_offset, 0))
        self.tb.connect((add_offset, 0), (binary_slicer, 0))
        self.tb.connect((binary_slicer, 0), (char_to_float, 0))
        self.tb.connect((char_to_float, 0), (multiply_const, 0))
        self.tb.connect((multiply_const, 0), (float_to_uchar, 0))
        self.tb.connect((float_to_uchar, 0), (pipe_sink, 0))
    def __init__(self, args, spec, antenna, gain, audio_output):
	gr.hier_block2.__init__(self, "receive_path",
				gr.io_signature(0, 0, 0), # Input signature
				gr.io_signature(0, 0, 0)) # Output signature

        self.u = uhd.usrp_source(device_addr=args, stream_args=uhd.stream_args('fc32'))

        # Set the subdevice spec
        if(spec):
            self.u.set_subdev_spec(spec, 0)

        # Set the antenna
        if(antenna):
            self.u.set_antenna(antenna, 0)

        self.if_rate    = 256e3
        self.quad_rate  = 64e3
        self.audio_rate = 32e3

        self.u.set_samp_rate(self.if_rate)
        dev_rate = self.u.get_samp_rate()

        # Create filter to get actual channel we want
        nfilts = 32
        chan_coeffs = filter.firdes.low_pass(nfilts,              # gain
                                             nfilts*dev_rate,     # sampling rate
                                             8e3,                 # low pass cutoff freq
                                             2e3,                 # width of trans. band
                                             filter.firdes.WIN_HANN)  # filter type
        rrate = self.quad_rate / dev_rate
        self.resamp = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)

        if USE_SIMPLE_SQUELCH:
            self.squelch = analog.simple_squelch_cc(20)
        else:
            self.squelch = analog.standard_squelch(self.audio_rate)

        # instantiate the guts of the single channel receiver
        self.fmrx = analog.nbfm_rx(self.audio_rate, self.quad_rate)

        # audio gain / mute block
        self._audio_gain = blocks.multiply_const_ff(1.0)

        # sound card as final sink
        audio_sink = audio.sink (int(self.audio_rate), audio_output)

        # now wire it all together
        if USE_SIMPLE_SQUELCH:
            self.connect (self.u, self.resamp, self.squelch, self.fmrx,
                          self._audio_gain, audio_sink)
        else:
            self.connect (self.u, self.resamp, self.fmrx, self.squelch,
                          self._audio_gain, audio_sink)

        if gain is None:
            # if no gain was specified, use the mid-point in dB
            g = self.u.get_gain_range()
            gain = float(g.start()+g.stop())/2

        self.set_gain(gain)

        v = self.volume_range()
        self.set_volume((v[0]+v[1])/2)

        s = self.squelch_range()
        self.set_squelch((s[0]+s[1])/2)
    def __init__(self):
        gr.top_block.__init__(self, "NBFM_transceiver")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("NBFM_transceiver")
        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", "NBFM_transceiver")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48000
        self.rx_freq = rx_freq = 141050000
        self.offset = offset = 5000000
        self.tx_gain = tx_gain = 15
        self.tx_freq = tx_freq = rx_freq - offset
        self.sqch = sqch = -60
        self.sdr_samp_rate = sdr_samp_rate = samp_rate * 12
        self.rx_tx = rx_tx = 0
        self.rx_gain = rx_gain = 10
        self.rx_freq_fine = rx_freq_fine = 0
        self.rx_aud = rx_aud = 0.300

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(0, 90, 1, 15, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        'tx_gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_gain_win, 2, 2, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._sqch_range = Range(-110, -50, 1, -60, 200)
        self._sqch_win = RangeWidget(self._sqch_range, self.set_sqch,
                                     'rx_sqlch', "counter_slider", float)
        self.top_grid_layout.addWidget(self._sqch_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._sdr_samp_rate_range = Range(520833, 61440000, 100000,
                                          samp_rate * 12, 200)
        self._sdr_samp_rate_win = RangeWidget(self._sdr_samp_rate_range,
                                              self.set_sdr_samp_rate,
                                              'sdr_sample_rate',
                                              "counter_slider", float)
        self.top_grid_layout.addWidget(self._sdr_samp_rate_win, 0, 1, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_tx_options = (
            0,
            1,
        )
        self._rx_tx_labels = (
            'RX',
            'TX',
        )
        self._rx_tx_group_box = Qt.QGroupBox('rx_tx_pushbutton')
        self._rx_tx_box = Qt.QHBoxLayout()

        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)

            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)

        self._rx_tx_button_group = variable_chooser_button_group()
        self._rx_tx_group_box.setLayout(self._rx_tx_box)
        for i, label in enumerate(self._rx_tx_labels):
            radio_button = Qt.QRadioButton(label)
            self._rx_tx_box.addWidget(radio_button)
            self._rx_tx_button_group.addButton(radio_button, i)
        self._rx_tx_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._rx_tx_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._rx_tx_options.index(i)))
        self._rx_tx_callback(self.rx_tx)
        self._rx_tx_button_group.buttonClicked[int].connect(
            lambda i: self.set_rx_tx(self._rx_tx_options[i]))
        self.top_grid_layout.addWidget(self._rx_tx_group_box, 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._rx_gain_range = Range(0, 50, 1, 10, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        'rx_gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_gain_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._rx_freq_range = Range(88000000, 174000000, 25000, 141050000, 200)
        self._rx_freq_win = RangeWidget(self._rx_freq_range, self.set_rx_freq,
                                        'rx_freq', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_freq_win, 1, 0, 1, 2)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_aud_range = Range(0, 0.5, 0.05, 0.300, 200)
        self._rx_aud_win = RangeWidget(self._rx_aud_range, self.set_rx_aud,
                                       'rx_audio_gain', "counter_slider",
                                       float)
        self.top_grid_layout.addWidget(self._rx_aud_win, 2, 1, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._offset_options = (
            5000000,
            600000,
        )
        self._offset_labels = (
            '5Mhz',
            '600kHz',
        )
        self._offset_tool_bar = Qt.QToolBar(self)
        self._offset_tool_bar.addWidget(Qt.QLabel('rx_tx_offset' + ": "))
        self._offset_combo_box = Qt.QComboBox()
        self._offset_tool_bar.addWidget(self._offset_combo_box)
        for label in self._offset_labels:
            self._offset_combo_box.addItem(label)
        self._offset_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._offset_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._offset_options.index(i)))
        self._offset_callback(self.offset)
        self._offset_combo_box.currentIndexChanged.connect(
            lambda i: self.set_offset(self._offset_options[i]))
        self.top_grid_layout.addWidget(self._offset_tool_bar, 0, 2, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._tx_freq_tool_bar = Qt.QToolBar(self)

        if None:
            self._tx_freq_formatter = None
        else:
            self._tx_freq_formatter = lambda x: eng_notation.num_to_str(x)

        self._tx_freq_tool_bar.addWidget(Qt.QLabel('tx_freq' + ": "))
        self._tx_freq_label = Qt.QLabel(
            str(self._tx_freq_formatter(self.tx_freq)))
        self._tx_freq_tool_bar.addWidget(self._tx_freq_label)
        self.top_grid_layout.addWidget(self._tx_freq_tool_bar, 1, 2, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_freq_fine_range = Range(-10000, 10000, 100, 0, 200)
        self._rx_freq_fine_win = RangeWidget(self._rx_freq_fine_range,
                                             self.set_rx_freq_fine,
                                             'rx_freq_fine', "counter_slider",
                                             float)
        self.top_grid_layout.addWidget(self._rx_freq_fine_win, 3, 1, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.rational_resampler_xxx_0_1 = filter.rational_resampler_ccf(
            interpolation=samp_rate,
            decimation=sdr_samp_rate,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=samp_rate,
            decimation=sdr_samp_rate,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=sdr_samp_rate,
            decimation=samp_rate,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_sink_x_0 = qtgui.sink_c(
            256,  #fftsize
            firdes.WIN_HAMMING,  #wintype
            rx_freq,  #fc
            25000,  #bw
            "",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            False,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win, 4, 0, 6, 3)
        for r in range(4, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 3):
            self.top_grid_layout.setColumnStretch(c, 1)

        self.qtgui_sink_x_0.enable_rf_freq(True)

        self.pluto_source_0 = iio.pluto_source('', rx_freq, sdr_samp_rate,
                                               15000, 0x4000, True, True, True,
                                               "manual",
                                               rx_gain * ((-rx_tx) + 1), '',
                                               True)
        self.pluto_sink_0 = iio.pluto_sink('192.168.2.1', rx_freq - offset,
                                           sdr_samp_rate, 5000, 0x4000, False,
                                           -tx_gain * (rx_tx), '', True)
        self.low_pass_filter_1 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, 20000, 500, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 10e3, 2e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 16000, 200, firdes.WIN_HAMMING,
                            6.76))
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (rx_aud * (-(rx_tx) + 1), ))
        self.audio_sink_0 = audio.sink(48000,
                                       "Speakers (Conexant SmartAudio HD)",
                                       True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(sqch, 1)
        self.analog_sig_source_x_0_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 0, 1, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(
            sdr_samp_rate, analog.GR_COS_WAVE, 0, 1, 0)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
            audio_rate=samp_rate,
            quad_rate=samp_rate,
            tau=75e-6,
            max_dev=5e3,
            fh=-1.0,
        )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=48000,
            quad_rate=48000,
            tau=50e-6,
            max_dev=12.5e3,
        )
        self.Internal_Microphone = audio.source(48000, '', True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Internal_Microphone, 0),
                     (self.low_pass_filter_1, 0))
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_nbfm_tx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_0_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_nbfm_rx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.rational_resampler_xxx_0_1, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.analog_nbfm_tx_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.low_pass_filter_1, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.pluto_source_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.pluto_sink_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_1, 0),
                     (self.qtgui_sink_x_0, 0))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="B200 VHF NBFM transceiver")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.tx_rx_choice = tx_rx_choice = 1
        self.tx_gain = tx_gain = .615
        self.tune_minus_20 = tune_minus_20 = 0
        self.tune_minus_10 = tune_minus_10 = 0
        self.tune_20 = tune_20 = 0
        self.tune_10 = tune_10 = 0
        self.tone = tone = 100
        self.squelch = squelch = -70.32
        self.samp_rate = samp_rate = 4000000
        self.rx_offset = rx_offset = 0
        self.rit_tune = rit_tune = 0
        self.offset = offset = 600000
        self.chooser_fm = chooser_fm = 147.34e6
        self.audio_gain = audio_gain = .7

        ##################################################
        # Blocks
        ##################################################
        self._tx_rx_choice_chooser = forms.button(
        	parent=self.GetWin(),
        	value=self.tx_rx_choice,
        	callback=self.set_tx_rx_choice,
        	label="TX-RX",
        	choices=[0, 1],
        	labels=['TX', 'RX'],
        )
        self.GridAdd(self._tx_rx_choice_chooser, 0, 3, 1, 1)
        _tx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	label="TX Gain: 144= .6, 220= .70, 440= .72",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._tx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	minimum=.6,
        	maximum=.75,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_tx_gain_sizer)
        self._tune_minus_20_chooser = forms.button(
        	parent=self.GetWin(),
        	value=self.tune_minus_20,
        	callback=self.set_tune_minus_20,
        	label="-20 Tune",
        	choices=[0, 20e3, 40e3, 60e3, 80e3, 100e3, 120e3, 140e3, 0],
        	labels=[0, -20, -40, -60, -80, -100, -120, -140, 0],
        )
        self.GridAdd(self._tune_minus_20_chooser, 0, 1, 1, 1)
        self._tune_minus_10_chooser = forms.button(
        	parent=self.GetWin(),
        	value=self.tune_minus_10,
        	callback=self.set_tune_minus_10,
        	label="-10 Tune",
        	choices=[0,-10e3, -20e3, -30e3, -40e3,-50e3,0],
        	labels=[0, -10, -20, -30, -40,-50,0],
        )
        self.GridAdd(self._tune_minus_10_chooser, 1, 1, 1, 1)
        self._tune_20_chooser = forms.button(
        	parent=self.GetWin(),
        	value=self.tune_20,
        	callback=self.set_tune_20,
        	label="+20 Tune",
        	choices=[0, 20e3, 40e3, 60e3, 80e3, 100e3, 120e3, 140e3,0],
        	labels=[0, '+20', '+40', '+60', '+80', '+100', '+120', '+140','0'],
        )
        self.GridAdd(self._tune_20_chooser, 0, 0, 1, 1)
        self._tune_10_chooser = forms.button(
        	parent=self.GetWin(),
        	value=self.tune_10,
        	callback=self.set_tune_10,
        	label="+10 Tune",
        	choices=[0,10e3, 20e3, 30e3, 40e3,50e3,0],
        	labels=[0,'+10', '+20', '+30', '+40','+50','0'],
        )
        self.GridAdd(self._tune_10_chooser, 1, 0, 1, 1)
        self._tone_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.tone,
        	callback=self.set_tone,
        	label="CTCSS",
        	choices=[100,103.5, 110.9, 118.8, 123.0,127.3,179.5],
        	labels=['100', '103.5', '110.9','118.8', '123.0', '127.3','179.5'],
        	style=wx.RA_HORIZONTAL,
        )
        self.GridAdd(self._tone_chooser, 0, 5, 1, 1)
        _squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._squelch_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_squelch_sizer,
        	value=self.squelch,
        	callback=self.set_squelch,
        	label="Squelch",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._squelch_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_squelch_sizer,
        	value=self.squelch,
        	callback=self.set_squelch,
        	minimum=-95,
        	maximum=-55,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_squelch_sizer, 0, 6, 1, 1)
        self._rx_offset_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.rx_offset,
        	callback=self.set_rx_offset,
        	label="RX offset",
        	choices=[0, 600000, -600000,5e6],
        	labels=['0', '+', '-','+5M'],
        	style=wx.RA_HORIZONTAL,
        )
        self.GridAdd(self._rx_offset_chooser, 1, 6, 1, 1)
        _rit_tune_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rit_tune_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rit_tune_sizer,
        	value=self.rit_tune,
        	callback=self.set_rit_tune,
        	label="RIT",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rit_tune_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rit_tune_sizer,
        	value=self.rit_tune,
        	callback=self.set_rit_tune,
        	minimum=-30e3,
        	maximum=+30e3,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_rit_tune_sizer, 1, 2, 1, 3)
        self._offset_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.offset,
        	callback=self.set_offset,
        	label="TX offset",
        	choices=[600000, -600000, 0,5e6],
        	labels=['+', '-', '0','5MHz'],
        	style=wx.RA_HORIZONTAL,
        )
        self.GridAdd(self._offset_chooser, 0, 4, 1, 1)
        self._chooser_fm_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.chooser_fm,
        	callback=self.set_chooser_fm,
        	label="Preset",
        	choices=[145.13e6,145.33e6, 145.88e6, 146.46e6, 146.49e6, 146.52e6,146.58e6, 146.64e6,146.74e6, 146.82e6, 146.86e6, 146.92e6, 146.96e6, 147.0e6,147.06e6, 147.08e6, 147.20e6, 147.22e6, 147.34e6, 223.5e6,441.825e6, 432.25e6],
        	labels=[145.13,145.33, 145.88, 146.46, 146.49, 146.52, 146.58, 146.64, 146.74, 146.82, 146.860, 146.92, 146.96,  147.00, 147.06, 147.08,147.200, 147.220, 147.34, 223.5,441.825, 432.25],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._chooser_fm_chooser)
        _audio_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._audio_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_audio_gain_sizer,
        	value=self.audio_gain,
        	callback=self.set_audio_gain,
        	label="Audio gain",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._audio_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_audio_gain_sizer,
        	value=self.audio_gain,
        	callback=self.set_audio_gain,
        	minimum=.1,
        	maximum=4,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_audio_gain_sizer, 0, 2, 1, 1)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=(((((chooser_fm+tune_20)-tune_minus_20)+tune_10)+tune_minus_10)+rx_offset),
        	y_per_div=5,
        	y_divs=16,
        	ref_level=-55,
        	ref_scale=2.0,
        	sample_rate=samp_rate/2,
        	fft_size=1024*0+2048*0+4096,
        	fft_rate=12,
        	average=True,
        	avg_alpha=.4,
        	title="RF Bandpass",
        	peak_hold=False,
        )
        self.GridAdd(self.wxgui_fftsink2_0.win, 2, 0, 5, 14)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate((samp_rate))
        self.uhd_usrp_source_0.set_center_freq((((((chooser_fm+tune_20)-tune_minus_20)+tune_10)+tune_minus_10)+rx_offset)-10e3, 0)
        self.uhd_usrp_source_0.set_normalized_gain(.520*.8, 0)
        self.uhd_usrp_source_0.set_antenna("RX2", 0)
        self.uhd_usrp_source_0.set_bandwidth(1.99e6, 0)
        self.uhd_usrp_sink_1 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_1.set_samp_rate(320000)
        self.uhd_usrp_sink_1.set_center_freq((((((chooser_fm+offset)+tune_20)-tune_minus_20)+tune_10)+tune_minus_10)+rit_tune, 0)
        self.uhd_usrp_sink_1.set_normalized_gain((.83*0+.72)*0+tx_gain, 0)
        self.uhd_usrp_sink_1.set_antenna("TX/RX", 0)
        self.uhd_usrp_sink_1.set_bandwidth(200000, 0)
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
                interpolation=32000,
                decimation=40000,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=samp_rate/2,
                decimation=samp_rate,
                taps=None,
                fractional_bw=None,
        )
        self.pfb_decimator_ccf_0 = pfb.decimator_ccf(
        	  2,
        	  (firdes.low_pass(.1, (samp_rate), (samp_rate)/4.05,10e3)),
        	  0,
        	  100,
                  True,
                  True)
        self.pfb_decimator_ccf_0.declare_sample_delay(0)
        	
        self.low_pass_filter_1 = filter.fir_filter_fff(1, firdes.low_pass(
        	1, 32000, 4400, 300, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass(
        	1, 32000, 4500, 600, firdes.WIN_HAMMING, 6.76))
        self.high_pass_filter_0 = filter.fir_filter_fff(1, firdes.high_pass(
        	1, 32000, 300, 100, firdes.WIN_HAMMING, 6.76))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(50, (firdes.low_pass(1,samp_rate/2,18e3,600)), 0+rit_tune+10e3, samp_rate/2)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex*1)
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vcc((.8, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((125, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((audio_gain*tx_rx_choice, ))
        self.blocks_add_xx_1 = blocks.add_vff(1)
        self.blks2_selector_0_1 = grc_blks2.selector(
        	item_size=gr.sizeof_gr_complex*1,
        	num_inputs=2,
        	num_outputs=1,
        	input_index=1+(tx_rx_choice),
        	output_index=0,
        )
        self.audio_source_1 = audio.source(32000, "", True)
        self.audio_sink_0 = audio.sink(32000, "", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, .0001)
        self.analog_sig_source_x_0 = analog.sig_source_f(32000, analog.GR_COS_WAVE, tone, .091, 0)
        self.analog_nbfm_tx_1 = analog.nbfm_tx(
        	audio_rate=32000,
        	quad_rate=320000,
        	tau=(75e-6)*0+90e-6,
        	max_dev=5e3,
                )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=32000,
        	quad_rate=32000,
        	tau=75e-6,
        	max_dev=5e3,
          )
        self.analog_fm_preemph_0 = analog.fm_preemph(fs=32e3, tau=75e-6)
        self.analog_fm_deemph_0 = analog.fm_deemph(fs=32000, tau=75e-6)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_fm_deemph_0, 0), (self.low_pass_filter_1, 0))    
        self.connect((self.analog_fm_preemph_0, 0), (self.blocks_add_xx_1, 0))    
        self.connect((self.analog_nbfm_rx_0, 0), (self.analog_fm_deemph_0, 0))    
        self.connect((self.analog_nbfm_tx_1, 0), (self.blocks_multiply_const_vxx_2, 0))    
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_1, 1))    
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.rational_resampler_xxx_1, 0))    
        self.connect((self.audio_source_1, 0), (self.blocks_multiply_const_vxx_1, 0))    
        self.connect((self.blks2_selector_0_1, 0), (self.uhd_usrp_sink_1, 0))    
        self.connect((self.blocks_add_xx_1, 0), (self.analog_nbfm_tx_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.high_pass_filter_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blks2_selector_0_1, 1))    
        self.connect((self.blocks_null_source_0, 0), (self.blks2_selector_0_1, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_simple_squelch_cc_0, 0))    
        self.connect((self.high_pass_filter_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.analog_fm_preemph_0, 0))    
        self.connect((self.low_pass_filter_1, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.pfb_decimator_ccf_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
        self.connect((self.rational_resampler_xxx_1, 0), (self.analog_nbfm_rx_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.pfb_decimator_ccf_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.rational_resampler_xxx_0, 0))    
Beispiel #34
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2000000
        self.decimation = decimation = 10
        self.symbol_rate = symbol_rate = 38400
        self.input_rate = input_rate = samp_rate / decimation
        self.window_symbols = window_symbols = 1
        self.symbol_taps_length = symbol_taps_length = int(
            (float(input_rate) / symbol_rate))
        self.samples_per_symbol = samples_per_symbol = float(
            input_rate) / symbol_rate
        self.grab_freq = grab_freq = 868200000
        self.symbol_taps = symbol_taps = (1, ) * symbol_taps_length
        self.offset_sign2 = offset_sign2 = (-34780 * grab_freq) / 868200000
        self.offset_sign1 = offset_sign1 = (11600 * grab_freq) / 868200000
        self.gain_mu = gain_mu = 0.4 / samples_per_symbol
        self.fsk_deviation_hz = fsk_deviation_hz = 5200
        self.average_window = average_window = int(
            (input_rate * window_symbols / symbol_rate))

        ##################################################
        # Blocks
        ##################################################
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            samples_per_symbol * (1 + 0.0), 0.25 * gain_mu * gain_mu, 0.5,
            gain_mu, 0.02)
        self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb()
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            average_window, 1.0 / average_window, 4000)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1,
                                                       sys.argv[1], False)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/fraschi/gfskQuadDemod.data', False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_deinterleave_0 = blocks.deinterleave(
            gr.sizeof_float * 1, 1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vcc((-128 - 128j, ))
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(40, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)
        self.FXFIR1 = filter.freq_xlating_fir_filter_ccc(
            decimation, (1, ), -14e3, samp_rate)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.FXFIR1, 0), (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_deinterleave_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_deinterleave_0, 1),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_uchar_to_float_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.FXFIR1, 0))
        self.connect((self.blocks_uchar_to_float_0, 0),
                     (self.blocks_deinterleave_0, 0))
        self.connect((self.digital_binary_slicer_fb_0_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0_0, 0))
Beispiel #35
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="narrow fm demod on high freq police radio bands")
        _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 = 2400000
        self.rx_freq = rx_freq = 854.388e6
        self.rx_fine = rx_fine = 0
        self.rx_coarse = rx_coarse = 0
        self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76)
        self.width = width = 12500
        self.variable_chooser_1 = variable_chooser_1 = 1
        self.tv_freq = tv_freq = 500.25e6
        self.trans = trans = 25000
        self.squelch = squelch = -55
        self.sql_lev = sql_lev = -20
        self.rx_freq_val = rx_freq_val = rx_freq+(rx_coarse+rx_fine)
        self.freq = freq = 155e6
        self.dev = dev = 7500
        self.decimation = decimation = 50
        self.af_gain = af_gain = 1

        ##################################################
        # Blocks
        ##################################################
        _width_sizer = wx.BoxSizer(wx.VERTICAL)
        self._width_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_width_sizer,
        	value=self.width,
        	callback=self.set_width,
        	label="LP Filter",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._width_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_width_sizer,
        	value=self.width,
        	callback=self.set_width,
        	minimum=2000,
        	maximum=40000,
        	num_steps=760,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_width_sizer, 2, 4, 1, 4)
        _trans_sizer = wx.BoxSizer(wx.VERTICAL)
        self._trans_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_trans_sizer,
        	value=self.trans,
        	callback=self.set_trans,
        	label="LP Trans",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._trans_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_trans_sizer,
        	value=self.trans,
        	callback=self.set_trans,
        	minimum=500,
        	maximum=50000,
        	num_steps=900,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_trans_sizer, 2, 8, 1, 4)
        _squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._squelch_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_squelch_sizer,
        	value=self.squelch,
        	callback=self.set_squelch,
        	label="squelch level",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._squelch_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_squelch_sizer,
        	value=self.squelch,
        	callback=self.set_squelch,
        	minimum=-100,
        	maximum=0,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_squelch_sizer)
        _rx_freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rx_freq_sizer,
        	value=self.rx_freq,
        	callback=self.set_rx_freq,
        	label="RX Center ",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rx_freq_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rx_freq_sizer,
        	value=self.rx_freq,
        	callback=self.set_rx_freq,
        	minimum=840000000,
        	maximum=860000000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_rx_freq_sizer, 0, 0, 1, 16)
        _rx_fine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_fine_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rx_fine_sizer,
        	value=self.rx_fine,
        	callback=self.set_rx_fine,
        	label="RX Fine",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rx_fine_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rx_fine_sizer,
        	value=self.rx_fine,
        	callback=self.set_rx_fine,
        	minimum=0,
        	maximum=10000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_rx_fine_sizer, 1, 4, 1, 4)
        _rx_coarse_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_coarse_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rx_coarse_sizer,
        	value=self.rx_coarse,
        	callback=self.set_rx_coarse,
        	label="RX Offset",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rx_coarse_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rx_coarse_sizer,
        	value=self.rx_coarse,
        	callback=self.set_rx_coarse,
        	minimum=0,
        	maximum=1e6,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_rx_coarse_sizer, 1, 0, 1, 4)
        _dev_sizer = wx.BoxSizer(wx.VERTICAL)
        self._dev_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_dev_sizer,
        	value=self.dev,
        	callback=self.set_dev,
        	label="NBFM deviation",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._dev_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_dev_sizer,
        	value=self.dev,
        	callback=self.set_dev,
        	minimum=4000,
        	maximum=16000,
        	num_steps=24,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_dev_sizer)
        self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=rx_freq + rx_coarse + rx_fine,
        	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.Add(self.wxgui_waterfallsink2_1.win)
        self._variable_chooser_1_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.variable_chooser_1,
        	callback=self.set_variable_chooser_1,
        	label='variable_chooser_1',
        	choices=[1, 2, 3],
        	labels=[],
        )
        self.Add(self._variable_chooser_1_chooser)
        _sql_lev_sizer = wx.BoxSizer(wx.VERTICAL)
        self._sql_lev_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_sql_lev_sizer,
        	value=self.sql_lev,
        	callback=self.set_sql_lev,
        	label="SQL",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._sql_lev_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_sql_lev_sizer,
        	value=self.sql_lev,
        	callback=self.set_sql_lev,
        	minimum=-100,
        	maximum=100,
        	num_steps=200,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_sql_lev_sizer, 1, 12, 1, 4)
        self._rx_freq_val_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.rx_freq_val,
        	callback=self.set_rx_freq_val,
        	label="Receive",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._rx_freq_val_static_text, 0, 16, 1, 1)
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.rtlsdr_source_0.set_time_now(osmosdr.time_spec_t(time.time()), osmosdr.ALL_MBOARDS)
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(rx_freq, 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(10, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.low_pass_filter_0 = filter.fir_filter_ccf(decimation, firdes.low_pass(
        	1, samp_rate, width, trans, firdes.WIN_HAMMING, 6.76))
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=48000,
        	quad_rate=48000,
        	tau=50e-6,
        	max_dev=dev,
        )
        _af_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._af_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_af_gain_sizer,
        	value=self.af_gain,
        	callback=self.set_af_gain,
        	label="VOL",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._af_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_af_gain_sizer,
        	value=self.af_gain,
        	callback=self.set_af_gain,
        	minimum=0,
        	maximum=5,
        	num_steps=50,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_af_gain_sizer, 2, 12, 1, 4)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_nbfm_rx_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.analog_simple_squelch_cc_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_waterfallsink2_1, 0))    
Beispiel #36
0
    def __init__(self, channel=908.4e6, gain=40):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Parameters
        ##################################################
        self.channel = channel
        self.gain = gain

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 800000
        self.taps = taps = firdes.low_pass(1, samp_rate, 150e3, 50e3,
                                           firdes.WIN_HAMMING)
        self.seuil = seuil = -40

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(
            ('localhost', 8080), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        self.xmlrpc_server_0_thread = threading.Thread(
            target=self.xmlrpc_server_0.serve_forever)
        self.xmlrpc_server_0_thread.daemon = True
        self.xmlrpc_server_0_thread.start()
        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(channel + 200e3, 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.low_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, 40e3, 10e3, firdes.WIN_HAMMING,
                            6.76))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (taps), -200e3, samp_rate)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            20, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_CLIENT",
                                                       '127.0.0.1', '52002',
                                                       10000, False)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(seuil, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            2 * (samp_rate) / (2 * math.pi * 20e3 / 8.0))
        self.Zwave_packet_sink_0 = Zwave.packet_sink()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.Zwave_packet_sink_0, 'out'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.Zwave_packet_sink_0, 'out'),
                         (self.blocks_socket_pdu_0_0, 'pdus'))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.Zwave_packet_sink_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
Beispiel #37
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.tuner = tuner = 434e6
        self.freq_offset = freq_offset = -200000
        self.width = width = 10000
        self.variable_static_text_0 = variable_static_text_0 = tuner - freq_offset
        self.squelch = squelch = -30
        self.samp_rate = samp_rate = 1.024e6
        self.demodgain = demodgain = 14
        self.cutoff = cutoff = 110000

        ##################################################
        # Blocks
        ##################################################
        _width_sizer = wx.BoxSizer(wx.VERTICAL)
        self._width_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_width_sizer,
        	value=self.width,
        	callback=self.set_width,
        	label='width',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._width_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_width_sizer,
        	value=self.width,
        	callback=self.set_width,
        	minimum=0,
        	maximum=400000,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_width_sizer, 0, 3, 1, 1)
        _tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_tuner_sizer,
        	value=self.tuner,
        	callback=self.set_tuner,
        	label='tuner',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_tuner_sizer,
        	value=self.tuner,
        	callback=self.set_tuner,
        	minimum=0,
        	maximum=2e9,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_tuner_sizer, 1, 0, 1, 7)
        _squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._squelch_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_squelch_sizer,
        	value=self.squelch,
        	callback=self.set_squelch,
        	label='squelch',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._squelch_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_squelch_sizer,
        	value=self.squelch,
        	callback=self.set_squelch,
        	minimum=-50,
        	maximum=20,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_squelch_sizer, 0, 1, 1, 1)
        self.nbook = self.nbook = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nbook.AddPage(grc_wxgui.Panel(self.nbook), "Scope")
        self.nbook.AddPage(grc_wxgui.Panel(self.nbook), "FSK")
        self.nbook.AddPage(grc_wxgui.Panel(self.nbook), "Waterfall")
        self.GridAdd(self.nbook, 2, 0, 1, 10)
        _freq_offset_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_offset_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_freq_offset_sizer,
        	value=self.freq_offset,
        	callback=self.set_freq_offset,
        	label='freq_offset',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._freq_offset_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_freq_offset_sizer,
        	value=self.freq_offset,
        	callback=self.set_freq_offset,
        	minimum=-1e6,
        	maximum=1e6,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_freq_offset_sizer, 0, 4, 1, 1)
        _demodgain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._demodgain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_demodgain_sizer,
        	value=self.demodgain,
        	callback=self.set_demodgain,
        	label='demodgain',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._demodgain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_demodgain_sizer,
        	value=self.demodgain,
        	callback=self.set_demodgain,
        	minimum=-1,
        	maximum=42,
        	num_steps=44,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.GridAdd(_demodgain_sizer, 0, 0, 1, 1)
        _cutoff_sizer = wx.BoxSizer(wx.VERTICAL)
        self._cutoff_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_cutoff_sizer,
        	value=self.cutoff,
        	callback=self.set_cutoff,
        	label='cutoff',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._cutoff_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_cutoff_sizer,
        	value=self.cutoff,
        	callback=self.set_cutoff,
        	minimum=0,
        	maximum=1000000,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_cutoff_sizer, 0, 2, 1, 1)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.nbook.GetPage(2).GetWin(),
        	baseband_freq=tuner,
        	dynamic_range=60,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        )
        self.nbook.GetPage(2).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_f(
        	self.nbook.GetPage(1).GetWin(),
        	title="Scope Plot 1",
        	sample_rate=samp_rate,
        	v_scale=1,
        	v_offset=0.5,
        	t_scale=0.02,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=2,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.nbook.GetPage(1).Add(self.wxgui_scopesink2_0_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.nbook.GetPage(0).GetWin(),
        	baseband_freq=tuner,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        	win=window.flattop,
        )
        self.nbook.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self._variable_static_text_0_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.variable_static_text_0,
        	callback=self.set_variable_static_text_0,
        	label="Tuned to",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._variable_static_text_0_static_text, 0, 5, 1, 1)
        self.osmosdr_source_c_0_1 = osmosdr.source()
        self.osmosdr_source_c_0_1.set_sample_rate(samp_rate)
        self.osmosdr_source_c_0_1.set_center_freq(tuner+freq_offset, 0)
        self.osmosdr_source_c_0_1.set_freq_corr(21, 0)
        self.osmosdr_source_c_0_1.set_iq_balance_mode(0, 0)
        self.osmosdr_source_c_0_1.set_gain_mode(0, 0)
        self.osmosdr_source_c_0_1.set_gain(demodgain, 0)
        self.osmosdr_source_c_0_1.set_if_gain(24, 0)
        self.osmosdr_source_c_0_1.set_bb_gain(20, 0)
        self.osmosdr_source_c_0_1.set_antenna("", 0)
        self.osmosdr_source_c_0_1.set_bandwidth(0, 0)
          
        self.freq_xlating_fir_filter_xxx_0_1 = filter.freq_xlating_fir_filter_ccc(1, (firdes.low_pass(1, samp_rate,cutoff, width,  firdes.WIN_BLACKMAN, 6.76)), -freq_offset, samp_rate)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "capture", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(demodgain)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0), (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.osmosdr_source_c_0_1, 0), (self.freq_xlating_fir_filter_xxx_0_1, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_uchar_to_float_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_uchar_to_float_0, 0), (self.wxgui_scopesink2_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0), (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.wxgui_scopesink2_0_0, 1))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Fm Tuner")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.tuning_frequency = tuning_frequency = 90.5e6
        self.volume = volume = 1
        self.transition = transition = 500000
        self.samp_rate = samp_rate = 2000000
        self.quadrature = quadrature = 500000
        self.low_cutoff = low_cutoff = tuning_frequency-0.1e6
        self.high_cutoff = high_cutoff = tuning_frequency+0.1e6
        self.frequency = frequency = tuning_frequency
        self.cutoff = cutoff = 100000
        self.center_freq_probe = center_freq_probe = 0
        self.ave_mag_probe = ave_mag_probe = 0
        self.audio_decimation = audio_decimation = 10

        ##################################################
        # Blocks
        ##################################################
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(tuning_frequency, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(2, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(1, 0)
        self.rtlsdr_source_0.set_gain(25, 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.analog_probe_avg_mag_sqrd_x_0 = analog.probe_avg_mag_sqrd_c(0, 1)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=4,
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate, cutoff, transition, firdes.WIN_HAMMING, 6.76))
        _frequency_sizer = wx.BoxSizer(wx.VERTICAL)
        self._frequency_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_frequency_sizer,
        	value=self.frequency,
        	callback=self.set_frequency,
        	label='frequency',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._frequency_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_frequency_sizer,
        	value=self.frequency,
        	callback=self.set_frequency,
        	minimum=88e6,
        	maximum=110e6,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_frequency_sizer)
        def _center_freq_probe_probe():
        	while True:
        		val = self.rtlsdr_source_0.get_center_freq()
        		try: self.set_center_freq_probe(val)
        		except AttributeError, e: pass
        		time.sleep(1.0/(10))
        _center_freq_probe_thread = threading.Thread(target=_center_freq_probe_probe)
        _center_freq_probe_thread.daemon = True
        _center_freq_probe_thread.start()
        def _ave_mag_probe_probe():
        	while True:
        		val = self.analog_probe_avg_mag_sqrd_x_0.level()
        		try: self.set_ave_mag_probe(val)
        		except AttributeError, e: pass
        		time.sleep(1.0/(10))
        _ave_mag_probe_thread = threading.Thread(target=_ave_mag_probe_probe)
        _ave_mag_probe_thread.daemon = True
        _ave_mag_probe_thread.start()
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(-60, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_probe_avg_mag_sqrd_x_0, 0))
Beispiel #39
0
    def __init__(self):
        gr.top_block.__init__(self, "Bluetooth LE Receiver")

        ##################################################
        # Variables
        ##################################################
        self.transition_width = transition_width = 300e3
        self.sample_rate = sample_rate = 4e6
        self.data_rate = data_rate = 1e6
        self.cutoff_freq = cutoff_freq = 850e3
        self.ble_channel_spacing = ble_channel_spacing = 2e6
        self.ble_channel = ble_channel = 12
        self.ble_base_freq = ble_base_freq = 2402e6
        self.squelch_threshold = squelch_threshold = -70
        self.rf_gain = rf_gain = 10
        self.lowpass_filter = lowpass_filter = firdes.low_pass(1, sample_rate, cutoff_freq, transition_width, firdes.WIN_HAMMING, 6.76)
        self.gmsk_sps = gmsk_sps = int(sample_rate / data_rate)
        self.gmsk_omega_limit = gmsk_omega_limit = 0.035
        self.gmsk_mu = gmsk_mu = 0.5
        self.gmsk_gain_mu = gmsk_gain_mu = 0.7
        self.freq_offset = freq_offset = 1e6
        self.freq = freq = ble_base_freq+(ble_channel_spacing * ble_channel)

        ##################################################
        # Message Queues
        ##################################################
        self.message_queue = message_queue = gr.msg_queue(2)

        ##################################################
        # Blocks
        ##################################################
        self.unpacked_to_packed = blocks.unpacked_to_packed_bb(1, gr.GR_LSB_FIRST)
        self.osmosdr_source = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_source.set_sample_rate(sample_rate)
        self.osmosdr_source.set_center_freq(freq+freq_offset, 0)
        self.osmosdr_source.set_freq_corr(0, 0)
        self.osmosdr_source.set_dc_offset_mode(0, 0)
        self.osmosdr_source.set_iq_balance_mode(0, 0)
        self.osmosdr_source.set_gain_mode(False, 0)
        self.osmosdr_source.set_gain(rf_gain, 0)
        self.osmosdr_source.set_if_gain(20, 0)
        self.osmosdr_source.set_bb_gain(20, 0)
        self.osmosdr_source.set_antenna("", 0)
        self.osmosdr_source.set_bandwidth(0, 0)
          
        self.message_sink = blocks.message_sink(gr.sizeof_char*1, message_queue, True)
        self.freq_xlating_fir_filter_lp = filter.freq_xlating_fir_filter_ccc(1, (lowpass_filter), -freq_offset, sample_rate)
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
        	samples_per_symbol=gmsk_sps,
        	gain_mu=gmsk_gain_mu,
        	mu=gmsk_mu,
        	omega_relative_limit=gmsk_omega_limit,
        	freq_error=0.0,
        	verbose=False,
        	log=False,
        )
        self.analog_simple_squelch = analog.simple_squelch_cc(squelch_threshold, 0.1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.freq_xlating_fir_filter_lp, 0), (self.digital_gmsk_demod_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0), (self.unpacked_to_packed, 0))
        self.connect((self.unpacked_to_packed, 0), (self.message_sink, 0))
        self.connect((self.osmosdr_source, 0), (self.analog_simple_squelch, 0))
        self.connect((self.analog_simple_squelch, 0), (self.freq_xlating_fir_filter_lp, 0))
Beispiel #40
0
    def __init__(self):
        gr.top_block.__init__(self, "FCD FM Receiver")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("FCD FM 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", "fcd_nfm_rx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 96000
        self.offset_fine = offset_fine = 0
        self.offset_coarse = offset_coarse = 0
        self.freq = freq = 144.47e6
        self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(
            1, samp_rate, 48000, 5000, firdes.WIN_HAMMING, 6.76)
        self.width = width = 10000
        self.trans = trans = 1500
        self.sql_lev = sql_lev = -100
        self.rx_freq = rx_freq = freq + (offset_coarse + offset_fine)
        self.rf_gain = rf_gain = 20
        self.display_selector = display_selector = 0
        self.af_gain = af_gain = 1

        ##################################################
        # Blocks
        ##################################################
        self._width_range = Range(2000, 40000, 100, 10000, 200)
        self._width_win = RangeWidget(self._width_range, self.set_width,
                                      "Filter", "counter", float)
        self.top_grid_layout.addWidget(self._width_win, 7, 0, 1, 1)
        self._trans_range = Range(500, 5000, 1, 1500, 200)
        self._trans_win = RangeWidget(self._trans_range, self.set_trans,
                                      "Trans", "counter", float)
        self.top_grid_layout.addWidget(self._trans_win, 8, 0, 1, 1)
        self._sql_lev_range = Range(-100, 0, 1, -100, 200)
        self._sql_lev_win = RangeWidget(self._sql_lev_range, self.set_sql_lev,
                                        "SQL", "counter", float)
        self.top_grid_layout.addWidget(self._sql_lev_win, 7, 2, 1, 1)
        self._rx_freq_tool_bar = Qt.QToolBar(self)

        if None:
            self._rx_freq_formatter = None
        else:
            self._rx_freq_formatter = lambda x: x

        self._rx_freq_tool_bar.addWidget(Qt.QLabel("Receive" + ": "))
        self._rx_freq_label = Qt.QLabel(
            str(self._rx_freq_formatter(self.rx_freq)))
        self._rx_freq_tool_bar.addWidget(self._rx_freq_label)
        self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 4, 3, 1, 1)

        self._offset_fine_range = Range(-1000, 1000, 1, 0, 200)
        self._offset_fine_win = RangeWidget(self._offset_fine_range,
                                            self.set_offset_fine, "Fine Tune",
                                            "counter", float)
        self.top_grid_layout.addWidget(self._offset_fine_win, 6, 0, 1, 2)
        self._offset_coarse_range = Range(-48000, 48000, 100, 0, 200)
        self._offset_coarse_win = RangeWidget(self._offset_coarse_range,
                                              self.set_offset_coarse,
                                              "Coarse Tune", "counter", float)
        self.top_grid_layout.addWidget(self._offset_coarse_win, 6, 2, 1, 2)
        self._display_selector_options = [0, 1]
        self._display_selector_labels = ['Baseband', 'RF']
        self._display_selector_tool_bar = Qt.QToolBar(self)
        self._display_selector_tool_bar.addWidget(Qt.QLabel("Spectrum" + ": "))
        self._display_selector_combo_box = Qt.QComboBox()
        self._display_selector_tool_bar.addWidget(
            self._display_selector_combo_box)
        for label in self._display_selector_labels:
            self._display_selector_combo_box.addItem(label)
        self._display_selector_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._display_selector_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._display_selector_options.index(i)))
        self._display_selector_callback(self.display_selector)
        self._display_selector_combo_box.currentIndexChanged.connect(
            lambda i: self.set_display_selector(self._display_selector_options[
                i]))
        self.top_grid_layout.addWidget(self._display_selector_tool_bar, 5, 0,
                                       1, 1)
        self._af_gain_range = Range(0, 5, 0.1, 1, 200)
        self._af_gain_win = RangeWidget(self._af_gain_range, self.set_af_gain,
                                        "VOL", "counter", float)
        self.top_grid_layout.addWidget(self._af_gain_win, 8, 1, 1, 1)
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              "")
        self.rtlsdr_source_0.set_time_now(osmosdr.time_spec_t(time.time()),
                                          osmosdr.ALL_MBOARDS)
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(107.9e6, 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(10, 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(3000, 0)

        self._rf_gain_range = Range(-5, 30, 1, 20, 200)
        self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain,
                                        "RF", "counter", float)
        self.top_grid_layout.addWidget(self._rf_gain_win, 7, 1, 1, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            512,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            rx_freq * display_selector,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.05)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ["", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 5,
                                       4)
        self.low_pass_filter = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, width / 2, trans, firdes.WIN_HAMMING,
                            6.76))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (xlate_filter_taps), -(offset_coarse + offset_fine), samp_rate)
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel("FCD Freq" + ": "))
        self._freq_line_edit = Qt.QLineEdit(str(self.freq))
        self._freq_tool_bar.addWidget(self._freq_line_edit)
        self._freq_line_edit.returnPressed.connect(lambda: self.set_freq(
            eng_notation.str_to_num(str(self._freq_line_edit.text().toAscii()))
        ))
        self.top_grid_layout.addWidget(self._freq_tool_bar, 5, 1, 1, 1)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff(
            (af_gain, ))
        self.audio_sink = audio.sink(48000, "", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(sql_lev, 1)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=48000,
            quad_rate=96000,
            tau=75e-6,
            max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_nbfm_rx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.audio_sink, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.audio_sink, 1))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.low_pass_filter, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.low_pass_filter, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
Beispiel #41
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Nbfm")

        ##################################################
        # Variables
        ##################################################
        self.decim = decim = 2
        self.adc_rate = adc_rate = 2000000
        self.xlate_offset_fine = xlate_offset_fine = 4000
        self.xlate_offset = xlate_offset = 0
        self.xlate_decim = xlate_decim = 4
        self.xlate_bandwidth = xlate_bandwidth = 12500
        self.volume = volume = 1
        self.squelch = squelch = 50
        self.samp_rate = samp_rate = adc_rate/decim
        self.main_freq = main_freq = 167.99e6
        self.audio_rate = audio_rate = 48000
        self.audio_interp = audio_interp = 4

        ##################################################
        # Blocks
        ##################################################
        self.main_notebook = self.main_notebook = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Baseband")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Scope")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Waterfall")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Quad demod")
        self.Add(self.main_notebook)
        _xlate_offset_fine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_offset_fine_text_box = forms.text_box(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	sizer=_xlate_offset_fine_sizer,
        	value=self.xlate_offset_fine,
        	callback=self.set_xlate_offset_fine,
        	label="Fine Offset",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._xlate_offset_fine_slider = forms.slider(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	sizer=_xlate_offset_fine_sizer,
        	value=self.xlate_offset_fine,
        	callback=self.set_xlate_offset_fine,
        	minimum=-10000,
        	maximum=10000,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.main_notebook.GetPage(0).Add(_xlate_offset_fine_sizer)
        self._xlate_offset_text_box = forms.text_box(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	value=self.xlate_offset,
        	callback=self.set_xlate_offset,
        	label="Xlate Offset",
        	converter=forms.float_converter(),
        )
        self.main_notebook.GetPage(0).Add(self._xlate_offset_text_box)
        _xlate_bandwidth_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_bandwidth_text_box = forms.text_box(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	sizer=_xlate_bandwidth_sizer,
        	value=self.xlate_bandwidth,
        	callback=self.set_xlate_bandwidth,
        	label="Xlate Bandwidth",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._xlate_bandwidth_slider = forms.slider(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	sizer=_xlate_bandwidth_sizer,
        	value=self.xlate_bandwidth,
        	callback=self.set_xlate_bandwidth,
        	minimum=2500,
        	maximum=250000,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.main_notebook.GetPage(0).Add(_xlate_bandwidth_sizer)
        _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=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_volume_sizer)
        _squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._squelch_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_squelch_sizer,
        	value=self.squelch,
        	callback=self.set_squelch,
        	label='squelch',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._squelch_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_squelch_sizer,
        	value=self.squelch,
        	callback=self.set_squelch,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_squelch_sizer)
        self._main_freq_text_box = forms.text_box(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	value=self.main_freq,
        	callback=self.set_main_freq,
        	label="Main Freq",
        	converter=forms.float_converter(),
        )
        self.main_notebook.GetPage(0).Add(self._main_freq_text_box)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.main_notebook.GetPage(2).GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=50,
        	ref_scale=2.0,
        	sample_rate=samp_rate/xlate_decim,
        	fft_size=512,
        	fft_rate=30,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        )
        self.main_notebook.GetPage(2).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
        	self.main_notebook.GetPage(3).GetWin(),
        	title="Scope Plot",
        	sample_rate=samp_rate/xlate_decim,
        	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.main_notebook.GetPage(3).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
        	self.main_notebook.GetPage(1).GetWin(),
        	title="Scope Plot",
        	sample_rate=samp_rate/xlate_decim,
        	v_scale=10,
        	v_offset=0,
        	t_scale=10000,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.main_notebook.GetPage(1).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.main_notebook.GetPage(0).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=50,
        	ref_scale=2.0,
        	sample_rate=samp_rate/xlate_decim,
        	fft_size=1024,
        	fft_rate=30,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.main_notebook.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(main_freq, 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(2, 0)
        self.rtlsdr_source_0.set_gain_mode(True, 0)
        self.rtlsdr_source_0.set_gain(50, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=audio_rate*audio_interp,
                decimation=samp_rate/xlate_decim,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(xlate_decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 1000)), xlate_offset + xlate_offset_fine, samp_rate)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, ))
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch*-1, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=audio_rate,
        	quad_rate=audio_rate*audio_interp,
        	tau=75e-6,
        	max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.wxgui_scopesink2_1, 0))    
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_nbfm_rx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.rational_resampler_xxx_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.wxgui_scopesink2_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_waterfallsink2_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_simple_squelch_cc_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
Beispiel #42
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _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 = 1024e3
        self.data_rate = data_rate = 9600
        self.channel_spacing = channel_spacing = 500000
        self.width = width = 150000
        self.tuner = tuner = 430.24e6
        self.squelch = squelch = -25
        self.samp_per_sym = samp_per_sym = int(samp_rate / data_rate)
        self.offset = offset = -0.2
        self.freq_offset = freq_offset = (channel_spacing / 2) + (channel_spacing * .1)
        self.demodgain = demodgain = 4
        self.cutoff = cutoff = 60000

        ##################################################
        # Blocks
        ##################################################
        _width_sizer = wx.BoxSizer(wx.VERTICAL)
        self._width_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_width_sizer,
        	value=self.width,
        	callback=self.set_width,
        	label='width',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._width_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_width_sizer,
        	value=self.width,
        	callback=self.set_width,
        	minimum=0,
        	maximum=400000,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_width_sizer, 1, 6, 1, 1)
        _tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tuner_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_tuner_sizer,
        	value=self.tuner,
        	callback=self.set_tuner,
        	label='tuner',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._tuner_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_tuner_sizer,
        	value=self.tuner,
        	callback=self.set_tuner,
        	minimum=430e6,
        	maximum=440e6,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_tuner_sizer, 1, 1, 1, 1)
        _squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._squelch_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_squelch_sizer,
        	value=self.squelch,
        	callback=self.set_squelch,
        	label='squelch',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._squelch_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_squelch_sizer,
        	value=self.squelch,
        	callback=self.set_squelch,
        	minimum=-50,
        	maximum=20,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_squelch_sizer, 1, 3, 1, 1)
        _demodgain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._demodgain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_demodgain_sizer,
        	value=self.demodgain,
        	callback=self.set_demodgain,
        	label='demodgain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._demodgain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_demodgain_sizer,
        	value=self.demodgain,
        	callback=self.set_demodgain,
        	minimum=-1,
        	maximum=42,
        	num_steps=44,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_demodgain_sizer, 1, 2, 1, 1)
        _cutoff_sizer = wx.BoxSizer(wx.VERTICAL)
        self._cutoff_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_cutoff_sizer,
        	value=self.cutoff,
        	callback=self.set_cutoff,
        	label='cutoff',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._cutoff_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_cutoff_sizer,
        	value=self.cutoff,
        	callback=self.set_cutoff,
        	minimum=0,
        	maximum=400000,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_cutoff_sizer, 1, 5, 1, 1)
        self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_f(
        	self.GetWin(),
        	title="Scope Plot 1",
        	sample_rate=samp_rate,
        	v_scale=1,
        	v_offset=0.5,
        	t_scale=0.02,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=2,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.osmosdr_source_c_0_1 = osmosdr.source()
        self.osmosdr_source_c_0_1.set_sample_rate(samp_rate)
        self.osmosdr_source_c_0_1.set_center_freq(tuner+freq_offset, 0)
        self.osmosdr_source_c_0_1.set_freq_corr(21, 0)
        self.osmosdr_source_c_0_1.set_iq_balance_mode(0, 0)
        self.osmosdr_source_c_0_1.set_gain_mode(0, 0)
        self.osmosdr_source_c_0_1.set_gain(10, 0)
        self.osmosdr_source_c_0_1.set_if_gain(24, 0)
        self.osmosdr_source_c_0_1.set_bb_gain(20, 0)
        self.osmosdr_source_c_0_1.set_antenna("", 0)
        self.osmosdr_source_c_0_1.set_bandwidth(0, 0)
          
        _offset_sizer = wx.BoxSizer(wx.VERTICAL)
        self._offset_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_offset_sizer,
        	value=self.offset,
        	callback=self.set_offset,
        	label='offset',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._offset_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_offset_sizer,
        	value=self.offset,
        	callback=self.set_offset,
        	minimum=-1,
        	maximum=1,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_offset_sizer, 1, 4, 1, 1)
        self.freq_xlating_fir_filter_xxx_0_1 = filter.freq_xlating_fir_filter_ccc(1, (firdes.low_pass(1, samp_rate,cutoff, width,  firdes.WIN_BLACKMAN, 6.76)), -freq_offset, samp_rate)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samp_per_sym*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005)
        self.digital_binary_slicer_fb_1 = digital.binary_slicer_fb()
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(demodgain)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.digital_binary_slicer_fb_1, 0), (self.blocks_char_to_float_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_1, 0))
        self.connect((self.osmosdr_source_c_0_1, 0), (self.freq_xlating_fir_filter_xxx_0_1, 0))
        self.connect((self.blocks_char_to_float_0, 0), (self.wxgui_scopesink2_0_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.wxgui_scopesink2_0_0, 1))
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0), (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0), (self.wxgui_fftsink2_0, 0))
Beispiel #43
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _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 = 4e6
        self.fsk_deviation_hz = fsk_deviation_hz = 186000
        self.channel_freq = channel_freq = 433930000
        self.centre_freq = centre_freq = 432000000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=samp_rate/12,
        	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.Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate/12,
        	fft_size=1024,
        	fft_rate=15,
        	average=True,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=1,
                decimation=2,
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(14, firdes.low_pass(
        	1, samp_rate, 1000e3, 100e3, firdes.WIN_HAMMING, 6.76))
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(1, 2, 0)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, ))
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/x/navtrak/navtrak4339.sink", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(-60, 1)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -930000, 1, 0)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(samp_rate/(2*math.pi*fsk_deviation_hz/8.0))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_threshold_ff_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.analog_simple_squelch_cc_0, 0))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
    def __init__(self, udp_port):
        gr.top_block.__init__(self, "Sigfox Receive Realtime")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 250000
        self.taps = taps = firdes.low_pass(1, samp_rate, 100, 50,
                                           firdes.WIN_HAMMING)
        self.decim_second = decim_second = 250
        self.decim_first = decim_first = 5
        self.udp_port = udp_port

        ##################################################
        # Blocks
        ##################################################
        self.sigfox_packet_sink_scapy_0_1_1_9 = sigfox.packet_sink_scapy()
        self.sigfox_packet_sink_scapy_0_1_1_8 = sigfox.packet_sink_scapy()
        self.sigfox_packet_sink_scapy_0_1_1_7 = sigfox.packet_sink_scapy()
        self.sigfox_Detection_Peak_0 = sigfox.Detection_Peak(
            90, samp_rate / 6.28)
        self.freq_xlating_fir_filter_xxx_0_1_9 = filter.freq_xlating_fir_filter_ccc(
            decim_first, (taps), 0, samp_rate)
        self.freq_xlating_fir_filter_xxx_0_1_8 = filter.freq_xlating_fir_filter_ccc(
            decim_first, (taps), 0, samp_rate)
        self.freq_xlating_fir_filter_xxx_0_1_7 = filter.freq_xlating_fir_filter_ccc(
            decim_first, (taps), 0, samp_rate)
        self.fir_filter_xxx_0_1 = filter.fir_filter_ccc(decim_second, (1, ))
        self.fir_filter_xxx_0_1.declare_sample_delay(0)
        self.fir_filter_xxx_0_0 = filter.fir_filter_ccc(decim_second, (1, ))
        self.fir_filter_xxx_0_0.declare_sample_delay(0)
        self.fir_filter_xxx_0 = filter.fir_filter_ccc(decim_second, (1, ))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.digital_diff_decoder_bb_0_0_0_1_1_9 = digital.diff_decoder_bb(2)
        self.digital_diff_decoder_bb_0_0_0_1_1_8 = digital.diff_decoder_bb(2)
        self.digital_diff_decoder_bb_0_0_0_1_1_7 = digital.diff_decoder_bb(2)
        self.digital_costas_loop_cc_0_0_0_0_0_0_0_1_2_1_1_1_9 = digital.costas_loop_cc(
            6.28 / 100, 2, False)
        self.digital_costas_loop_cc_0_0_0_0_0_0_0_1_2_1_1_1_8 = digital.costas_loop_cc(
            6.28 / 100, 2, False)
        self.digital_costas_loop_cc_0_0_0_0_0_0_0_1_2_1_1_1_7 = digital.costas_loop_cc(
            6.28 / 100, 2, False)
        self.digital_clock_recovery_mm_xx_0_0_1_1_9 = digital.clock_recovery_mm_cc(
            2, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005)
        self.digital_clock_recovery_mm_xx_0_0_1_1_8 = digital.clock_recovery_mm_cc(
            2, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005)
        self.digital_clock_recovery_mm_xx_0_0_1_1_7 = digital.clock_recovery_mm_cc(
            2, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005)
        self.digital_binary_slicer_fb_0_1_1_9 = digital.binary_slicer_fb()
        self.digital_binary_slicer_fb_0_1_1_8 = digital.binary_slicer_fb()
        self.digital_binary_slicer_fb_0_1_1_7 = digital.binary_slicer_fb()
        self.blocks_socket_pdu_0_0_1 = blocks.socket_pdu(
            "UDP_CLIENT", '127.0.0.1', self.udp_port, 10000, False)
        self.blocks_message_debug_0_0_0_1_1 = blocks.message_debug()
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_complex_to_real_0_1_1_9 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0_1_1_8 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0_1_1_7 = blocks.complex_to_real(1)
        self.analog_simple_squelch_cc_1_1_0 = analog.simple_squelch_cc(-20, 1)
        self.analog_pll_freqdet_cf_0 = analog.pll_freqdet_cf(
            6.28 / 100, 6.28 * 110e3 / samp_rate, -6.28 * 110e3 / samp_rate)
        self.analog_const_source_x_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.sigfox_Detection_Peak_0, 'out0'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.sigfox_Detection_Peak_0, 'out1'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.sigfox_Detection_Peak_0, 'out2'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.sigfox_Detection_Peak_0, 'out0'),
                         (self.freq_xlating_fir_filter_xxx_0_1_7, 'freq'))
        self.msg_connect((self.sigfox_Detection_Peak_0, 'out1'),
                         (self.freq_xlating_fir_filter_xxx_0_1_8, 'freq'))
        self.msg_connect((self.sigfox_Detection_Peak_0, 'out2'),
                         (self.freq_xlating_fir_filter_xxx_0_1_9, 'freq'))
        self.msg_connect((self.sigfox_packet_sink_scapy_0_1_1_7, 'out'),
                         (self.blocks_message_debug_0_0_0_1_1, 'print'))
        self.msg_connect((self.sigfox_packet_sink_scapy_0_1_1_7, 'out'),
                         (self.blocks_socket_pdu_0_0_1, 'pdus'))
        self.msg_connect((self.sigfox_packet_sink_scapy_0_1_1_8, 'out'),
                         (self.blocks_message_debug_0_0_0_1_1, 'print'))
        self.msg_connect((self.sigfox_packet_sink_scapy_0_1_1_8, 'out'),
                         (self.blocks_socket_pdu_0_0_1, 'pdus'))
        self.msg_connect((self.sigfox_packet_sink_scapy_0_1_1_9, 'out'),
                         (self.blocks_message_debug_0_0_0_1_1, 'print'))
        self.msg_connect((self.sigfox_packet_sink_scapy_0_1_1_9, 'out'),
                         (self.blocks_socket_pdu_0_0_1, 'pdus'))
        self.connect((self.analog_const_source_x_0, 0),
                     (self.analog_simple_squelch_cc_1_1_0, 0))
        self.connect((self.analog_pll_freqdet_cf_0, 0),
                     (self.sigfox_Detection_Peak_0, 0))
        self.connect((self.analog_simple_squelch_cc_1_1_0, 0),
                     (self.analog_pll_freqdet_cf_0, 0))
        self.connect((self.analog_simple_squelch_cc_1_1_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0_1_7, 0))
        self.connect((self.analog_simple_squelch_cc_1_1_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0_1_8, 0))
        self.connect((self.analog_simple_squelch_cc_1_1_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0_1_9, 0))
        self.connect((self.blocks_complex_to_real_0_1_1_7, 0),
                     (self.digital_binary_slicer_fb_0_1_1_7, 0))
        self.connect((self.blocks_complex_to_real_0_1_1_8, 0),
                     (self.digital_binary_slicer_fb_0_1_1_8, 0))
        self.connect((self.blocks_complex_to_real_0_1_1_9, 0),
                     (self.digital_binary_slicer_fb_0_1_1_9, 0))
        self.connect((self.digital_binary_slicer_fb_0_1_1_7, 0),
                     (self.digital_diff_decoder_bb_0_0_0_1_1_7, 0))
        self.connect((self.digital_binary_slicer_fb_0_1_1_8, 0),
                     (self.digital_diff_decoder_bb_0_0_0_1_1_8, 0))
        self.connect((self.digital_binary_slicer_fb_0_1_1_9, 0),
                     (self.digital_diff_decoder_bb_0_0_0_1_1_9, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0_0_1_1_7, 0),
                     (self.blocks_complex_to_real_0_1_1_7, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0_0_1_1_8, 0),
                     (self.blocks_complex_to_real_0_1_1_8, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0_0_1_1_9, 0),
                     (self.blocks_complex_to_real_0_1_1_9, 0))
        self.connect(
            (self.digital_costas_loop_cc_0_0_0_0_0_0_0_1_2_1_1_1_7, 0),
            (self.fir_filter_xxx_0, 0))
        self.connect(
            (self.digital_costas_loop_cc_0_0_0_0_0_0_0_1_2_1_1_1_8, 0),
            (self.fir_filter_xxx_0_0, 0))
        self.connect(
            (self.digital_costas_loop_cc_0_0_0_0_0_0_0_1_2_1_1_1_9, 0),
            (self.fir_filter_xxx_0_1, 0))
        self.connect((self.digital_diff_decoder_bb_0_0_0_1_1_7, 0),
                     (self.sigfox_packet_sink_scapy_0_1_1_7, 0))
        self.connect((self.digital_diff_decoder_bb_0_0_0_1_1_8, 0),
                     (self.sigfox_packet_sink_scapy_0_1_1_8, 0))
        self.connect((self.digital_diff_decoder_bb_0_0_0_1_1_9, 0),
                     (self.sigfox_packet_sink_scapy_0_1_1_9, 0))
        self.connect((self.fir_filter_xxx_0, 0),
                     (self.digital_clock_recovery_mm_xx_0_0_1_1_7, 0))
        self.connect((self.fir_filter_xxx_0_0, 0),
                     (self.digital_clock_recovery_mm_xx_0_0_1_1_8, 0))
        self.connect((self.fir_filter_xxx_0_1, 0),
                     (self.digital_clock_recovery_mm_xx_0_0_1_1_9, 0))
        self.connect(
            (self.freq_xlating_fir_filter_xxx_0_1_7, 0),
            (self.digital_costas_loop_cc_0_0_0_0_0_0_0_1_2_1_1_1_7, 0))
        self.connect(
            (self.freq_xlating_fir_filter_xxx_0_1_8, 0),
            (self.digital_costas_loop_cc_0_0_0_0_0_0_0_1_2_1_1_1_8, 0))
        self.connect(
            (self.freq_xlating_fir_filter_xxx_0_1_9, 0),
            (self.digital_costas_loop_cc_0_0_0_0_0_0_0_1_2_1_1_1_9, 0))
Beispiel #45
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1024000
        self.decimation = decimation = 10
        self.symbol_rate = symbol_rate = 38400
        self.input_rate = input_rate = samp_rate / decimation
        self.window_symbols = window_symbols = 1
        self.symbol_taps_length = symbol_taps_length = int(
            (float(input_rate) / symbol_rate))
        self.samples_per_symbol = samples_per_symbol = float(
            input_rate) / symbol_rate
        self.grab_freq = grab_freq = 868200000
        self.symbol_taps = symbol_taps = (1, ) * symbol_taps_length
        self.offset_sign2 = offset_sign2 = (-34780 * grab_freq) / 868200000
        self.offset_sign1 = offset_sign1 = (11600 * grab_freq) / 868200000
        self.gain_mu = gain_mu = 0.4 / samples_per_symbol
        self.fsk_deviation_hz = fsk_deviation_hz = 5200
        self.average_window = average_window = int(
            (input_rate * window_symbols / symbol_rate))

        ##################################################
        # Blocks
        ##################################################
        self.urmetEasyRead_urmetEasyRead_0 = urmetEasyRead.urmetEasyRead()
        self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb(
            '11010011100100011101001110010001', 1)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            samples_per_symbol, 0.25 * gain_mu * gain_mu, 0.5, gain_mu, 0.02)
        self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb()
        self.cc1111_cc1111_packet_decoder_0 = cc1111.cc1111_packet_decoder(
            gr.msg_queue(1), False, True, True, True)
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        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_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1,
                                                       sys.argv[1], False)
        self.blocks_deinterleave_0 = blocks.deinterleave(
            gr.sizeof_float * 1, 1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vcc((-128 - 128j, ))
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(40, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)
        self.FXFIR1 = filter.freq_xlating_fir_filter_ccc(
            decimation, (1, ), -14e3, samp_rate)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.FXFIR1, 0), (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_deinterleave_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_deinterleave_0, 1),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_uchar_to_float_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.FXFIR1, 0))
        self.connect((self.blocks_uchar_to_float_0, 0),
                     (self.blocks_deinterleave_0, 0))
        self.connect((self.cc1111_cc1111_packet_decoder_0, 0),
                     (self.urmetEasyRead_urmetEasyRead_0, 0))
        self.connect((self.digital_binary_slicer_fb_0_0, 0),
                     (self.digital_correlate_access_code_bb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0_0, 0))
        self.connect((self.digital_correlate_access_code_bb_0, 0),
                     (self.cc1111_cc1111_packet_decoder_0, 0))
        self.connect((self.urmetEasyRead_urmetEasyRead_0, 0),
                     (self.blocks_null_sink_1, 0))
Beispiel #46
0
Datei: ec3k.py Projekt: zejn/ec3k
    def _setup_top_block(self):

        self.tb = gr.top_block()

        samp_rate = 96000
        oversample = 10

        # Radio receiver, initial downsampling
        args = "rtl=%d,buffers=16" % (self.device, )
        if self.osmosdr_args:
            args += ",%s" % (self.osmosdr_args, )

        osmosdr_source = osmosdr.source(args=args)
        osmosdr_source.set_sample_rate(samp_rate * oversample)
        osmosdr_source.set_center_freq(self.freq, 0)
        osmosdr_source.set_freq_corr(0, 0)
        osmosdr_source.set_gain_mode(True, 0)
        osmosdr_source.set_gain(0, 0)

        taps = filter.firdes.low_pass(1, samp_rate * oversample, 90e3, 8e3,
                                      filter.firdes.WIN_HAMMING, 6.76)
        low_pass_filter = filter.fir_filter_ccf(oversample, taps)

        self.tb.connect((osmosdr_source, 0), (low_pass_filter, 0))

        # Squelch
        self.noise_probe = analog.probe_avg_mag_sqrd_c(0,
                                                       1.0 / samp_rate / 1e2)
        self.squelch = analog.simple_squelch_cc(self.noise_level, 1)

        noise_probe_thread = threading.Thread(target=self._noise_probe_thread)
        noise_probe_thread.start()
        self.threads.append(noise_probe_thread)

        self.tb.connect((low_pass_filter, 0), (self.noise_probe, 0))
        self.tb.connect((low_pass_filter, 0), (self.squelch, 0))

        # FM demodulation
        quadrature_demod = analog.quadrature_demod_cf(1)

        self.tb.connect((self.squelch, 0), (quadrature_demod, 0))

        # Binary slicing, transformation into capture-compatible format

        add_offset = blocks.add_const_vff((-1e-3, ))

        binary_slicer = digital.binary_slicer_fb()

        char_to_float = blocks.char_to_float(1, 1)

        multiply_const = blocks.multiply_const_vff((255, ))

        float_to_uchar = blocks.float_to_uchar()

        pipe_sink = blocks.file_sink(gr.sizeof_char * 1, self.pipe)
        pipe_sink.set_unbuffered(False)

        self.tb.connect((quadrature_demod, 0), (add_offset, 0))
        self.tb.connect((add_offset, 0), (binary_slicer, 0))
        self.tb.connect((binary_slicer, 0), (char_to_float, 0))
        self.tb.connect((char_to_float, 0), (multiply_const, 0))
        self.tb.connect((multiply_const, 0), (float_to_uchar, 0))
        self.tb.connect((float_to_uchar, 0), (pipe_sink, 0))
Beispiel #47
0
    def __init__(self, args, spec, antenna, gain, audio_output):
        gr.hier_block2.__init__(
            self,
            "receive_path",
            gr.io_signature(0, 0, 0),  # Input signature
            gr.io_signature(0, 0, 0))  # Output signature

        self.u = uhd.usrp_source(device_addr=args,
                                 stream_args=uhd.stream_args('fc32'))

        # Set the subdevice spec
        if (spec):
            self.u.set_subdev_spec(spec, 0)

    # Set the antenna
        if (antenna):
            self.u.set_antenna(antenna, 0)

        self.if_rate = 256e3
        self.quad_rate = 64e3
        self.audio_rate = 32e3

        self.u.set_samp_rate(self.if_rate)
        dev_rate = self.u.get_samp_rate()

        # Create filter to get actual channel we want
        nfilts = 32
        chan_coeffs = filter.firdes.low_pass(
            nfilts,  # gain
            nfilts * dev_rate,  # sampling rate
            8e3,  # low pass cutoff freq
            2e3,  # width of trans. band
            filter.firdes.WIN_HANN)  # filter type
        rrate = self.quad_rate / dev_rate
        self.resamp = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)

        if USE_SIMPLE_SQUELCH:
            self.squelch = analog.simple_squelch_cc(20)
        else:
            self.squelch = analog.standard_squelch(self.audio_rate)

    # instantiate the guts of the single channel receiver
        self.fmrx = analog.nbfm_rx(self.audio_rate, self.quad_rate)

        # audio gain / mute block
        self._audio_gain = blocks.multiply_const_ff(1.0)

        # sound card as final sink
        audio_sink = audio.sink(int(self.audio_rate), audio_output)

        # now wire it all together
        if USE_SIMPLE_SQUELCH:
            self.connect(self.u, self.resamp, self.squelch, self.fmrx,
                         self._audio_gain, audio_sink)
        else:
            self.connect(self.u, self.resamp, self.fmrx, self.squelch,
                         self._audio_gain, audio_sink)

        if gain is None:
            # if no gain was specified, use the mid-point in dB
            g = self.u.get_gain_range()
            gain = float(g.start() + g.stop()) / 2

        self.set_gain(gain)

        v = self.volume_range()
        self.set_volume((v[0] + v[1]) / 2)

        s = self.squelch_range()
        self.set_squelch((s[0] + s[1]) / 2)
    def __init__(self):
        gr.top_block.__init__(self, "Key")

        # super(Key, self).__init__()

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2016000  #1920000#2000000
        self.offset_freq_keyboard = offset_freq_keyboard = 27195000
        self.offset_freq = offset_freq = 27175000
        self.center_freq = center_freq = 28000000
        self.target_rate = target_rate = 48000#16000#96000
        self.offset_keyboard = offset_keyboard = offset_freq_keyboard - center_freq
        self.offset = offset = offset_freq - center_freq
        #self.firdes_tap_overall = firdes_tap_overall = firdes.low_pass(1, samp_rate, 50000, 0100, firdes.WIN_HAMMING,
        #                                                               6.76)
        self.firdes_tap_keyboard = firdes_tap_keyboard = firdes.low_pass(1, samp_rate, 20000, 0100,#5000, 5000, #20000, 10000,
                                                                         firdes.WIN_HAMMING,
                                                                         6.76)

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_c_0 = osmosdr.source_c(args="nchan=" + str(1) + " " + "")
        self.osmosdr_source_c_0.set_sample_rate(samp_rate)
        self.osmosdr_source_c_0.set_center_freq(center_freq, 0)
        self.osmosdr_source_c_0.set_freq_corr(0, 0)
        self.osmosdr_source_c_0.set_dc_offset_mode(1, 0)
        self.osmosdr_source_c_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_c_0.set_gain_mode(0, 0)
        self.osmosdr_source_c_0.set_gain(01, 0)
        self.osmosdr_source_c_0.set_if_gain(20, 0)
        self.osmosdr_source_c_0.set_bb_gain(20, 0)
        self.osmosdr_source_c_0.set_antenna("", 0)
        self.osmosdr_source_c_0.set_bandwidth(0, 0)

        self.low_pass_filter_0 = gr.fir_filter_fff(1, firdes.low_pass(
            1, target_rate, 5e3, 01e3, firdes.WIN_HAMMING, 6.76))
        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(int(samp_rate / target_rate),
                                                                                  (firdes_tap_keyboard),
                                                                                  offset_keyboard, samp_rate)
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink("/root/sdr/keyboard/44.1Ks_27Mf_quad3_keyboard.wav", 1,
                                                         target_rate, 8)

        #ACL
        #self.blocks_file_source_0 = blocks.file_source(gr.sizeof_float * 1, "/root/sdr/keyboard/96k_27M_float", False)
        #self.blocks_file_sink_2 = blocks.file_sink(gr.sizeof_float * 1, "/root/sdr/keyboard/96k_27M_float")
        #self.blocks_file_sink_2.set_unbuffered(False)
        self.sink = gr_queue.queue_sink_f()


        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(-5, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(2)


        ##################################################
        # Connections
        ##################################################
        self.connect((self.osmosdr_source_c_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.blocks_wavfile_sink_0, 0))
        self.connect((self.low_pass_filter_0, 0), self.sink)