def test_pwr_squelch_001(self): # Test set/gets alpha = 0.0001 thr1 = 10 thr2 = 20 ramp = 1 ramp2 = 2 gate = True gate2 = False op = analog.pwr_squelch_cc(thr1, alpha, ramp, gate) op.set_threshold(thr2) t = op.threshold() self.assertEqual(thr2, t) op.set_ramp(ramp2) r = op.ramp() self.assertEqual(ramp2, r) op.set_gate(gate2) g = op.gate() self.assertEqual(gate2, g)
def __init__(self, options, filename): gr.top_block.__init__(self) inf_str = None symbol_rate = 152.34e3 sample_rate = 1e6 #if len(options) != 0: # inf_str = args[0] squelch = analog.pwr_squelch_cc(float(options.squelch), 0.1, 0, True) demod = analog.quadrature_demod_cf(1.0) cr = digital.clock_recovery_mm_ff(sample_rate/symbol_rate, 0.00765625, 0, 0.175, 0.005) slicer = digital.binary_slicer_fb() corr = digital.correlate_access_code_bb(AC, 3) sink = sniffer() if False: print "Reading from: " + inf_str src = blocks.file_source(gr.sizeof_gr_complex, inf_str, False) else: freqs = { 'AA':917.0e6, 'AB':913.0e6, 'AC':914.0e6, 'AD':915.0e6, 'BA':916.0e6, 'BB':919.0e6, 'BC':920.0e6, 'BD':921.0e6, 'CA':922.0e6, 'CB':923.0e6, 'CC':907.0e6, 'CD':908.0e6, 'DA':905.5e6, 'DB':909.0e6, 'DC':911.0e6, 'DD':910.0e6} frequency = freqs[options.channel] print "Channel: " + options.channel + " (" + str(frequency/1e6) + "MHz)" # Create a UHD device source src = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32', "sc16", args="")) # Set the subdevice spec if(options.spec): src.set_subdev_spec(options.spec, 0) # Set the antenna if(options.antenna): src.set_antenna(options.antenna, 0) # Set receiver sample rate src.set_samp_rate(options.samp_rate) # Set receive daughterboard gain if options.gain is None: g = src.get_gain_range() options.gain = float(g.start()+g.stop())/2 print "Using mid-point gain of", options.gain, "(", g.start(), "-", g.stop(), ")" src.set_gain(options.gain) # Set frequency (tune request takes lo_offset) treq = uhd.tune_request(frequency) tr = src.set_center_freq(treq) if tr == None: sys.stderr.write('Failed to set center frequency\n') raise SystemExit, 1 self.connect(src, squelch, demod, cr, slicer, corr, sink)
def __init__(self, chan_rate, threshold, freq): gr.hier_block2.__init__(self, "indri_radio_channel", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_float)) self.chan_rate = chan_rate self.threshold = threshold self.freq = freq self.pwr_squelch = analog.pwr_squelch_cc(self.threshold, 0.001, 0, True) self.nbfm_rx = analog.nbfm_rx( audio_rate=self.chan_rate, quad_rate=self.chan_rate, tau=75e-6, max_dev=6.25e3, ) self.power_probe = analog.probe_avg_mag_sqrd_cf(self.threshold, 0.001) self.null_sink = blocks.null_sink(gr.sizeof_float) self.tg = 0 self.closed_once = False # have we de-squelched since tg assigned? self.power_samples = 0 self.power_total = 0.0 self.connect(self, self.power_probe, self.null_sink) self.connect(self, self.pwr_squelch, self.nbfm_rx, self)
def __init__(self, squelch, quad_rate, audio_rate, max_dev, out_scale, freq, command): gr.hier_block2.__init__(self, "FMtoCommand", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(0, 0, gr.sizeof_gr_complex)) analog_pwr_squelch = analog.pwr_squelch_cc(squelch, 1e-4, 0, True) analog_nbfm_rx = analog.nbfm_rx( audio_rate=audio_rate, quad_rate=quad_rate, tau=75e-6, max_dev=max_dev, ) rational_resampler = filter.rational_resampler_fff( interpolation=441, decimation=500, taps=None, fractional_bw=None, ) blocks_float_to_short = blocks.float_to_short(1, out_scale) self.p = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE) sink = blocks.file_descriptor_sink(gr.sizeof_short * 1, self.p.stdin.fileno()) self.connect(self, (analog_pwr_squelch, 0)) self.connect((analog_pwr_squelch, 0), (analog_nbfm_rx, 0)) self.connect((analog_nbfm_rx, 0), (rational_resampler, 0)) self.connect((rational_resampler, 0), (blocks_float_to_short, 0)) self.connect((blocks_float_to_short, 0), (sink, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Sensado") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.umbral = umbral = 0 self.samp_rate = samp_rate = 44000 self.fc = fc = 0 ################################################## # Blocks ################################################## self.usando_power_squelch = analog.pwr_squelch_cc(umbral, 1, 100, False) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=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(fc, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.sensado_primario = analog.probe_avg_mag_sqrd_c(0, 1) ################################################## # Connections ################################################## self.connect((self.usando_power_squelch, 0), (self.sensado_primario, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.usando_power_squelch, 0))
def __init__(self, squelch, quad_rate, audio_rate, max_dev, out_scale, freq, command): gr.hier_block2.__init__(self, "FMtoCommand", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(0, 0, gr.sizeof_gr_complex)) analog_pwr_squelch = analog.pwr_squelch_cc(squelch, 1e-4, 0, True) analog_nbfm_rx = analog.nbfm_rx( audio_rate = audio_rate, quad_rate = quad_rate, tau = 75e-6, max_dev = max_dev, ) rational_resampler = filter.rational_resampler_fff( interpolation = 441, decimation = 500, taps = None, fractional_bw = None, ) blocks_float_to_short = blocks.float_to_short(1, out_scale) self.p = subprocess.Popen(command, shell = True, stdin = subprocess.PIPE) sink = blocks.file_descriptor_sink(gr.sizeof_short*1, self.p.stdin.fileno()) self.connect(self, (analog_pwr_squelch, 0)) self.connect((analog_pwr_squelch, 0), (analog_nbfm_rx, 0)) self.connect((analog_nbfm_rx, 0), (rational_resampler, 0)) self.connect((rational_resampler, 0), (blocks_float_to_short, 0)) self.connect((blocks_float_to_short, 0), (sink, 0))
def __init__(self, FH_seq): gr.top_block.__init__(self, "Test2") ################################################## # Variables ################################################## self.sql_on = sql_on = 0 self.samp_rate = samp_rate = 2e6 self.curr_chann_idx = 0 self.FH_seq = FH_seq ################################################## # Blocks ################################################## self.analog_pwr_squelch_xx_1 = analog.pwr_squelch_cc(-20, 1, 25, False) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="addr=192.168.10.2", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) def _sql_on_probe(): while True: val = self.analog_pwr_squelch_xx_1.unmuted() try: self.set_sql_on(val) except AttributeError, e: pass time.sleep((0.001))
def __init__(self): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.variable_slider_0 = variable_slider_0 = .846 self.test = test = .005 self.shift = shift = .906 self.samp_rate_0 = samp_rate_0 = 1.2e6 self.samp_rate = samp_rate = 1.2e6/4 self.pows = pows = 1.3 self.lpf = lpf = .724 self.go = go = 0.564 self.gm = gm = 1.61 self.centre_freq = centre_freq = 439.95e6 ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate_0) self.rtlsdr_source_0.set_center_freq(439.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(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(20, 0) self.rtlsdr_source_0.set_if_gain(10, 0) self.rtlsdr_source_0.set_bb_gain(10, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_1 = filter.fir_filter_fff(10, firdes.low_pass( 1, samp_rate, 2.56e3*lpf, (2.56e3/2)*lpf, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(4, (firdes.low_pass_2(1,samp_rate_0,100e3,50e3,40)), 0, samp_rate_0) self.digital_clock_recovery_mm_xx_1 = digital.clock_recovery_mm_ff(11.6439*(1+test), 0.25*0.175*0.175*go, 0.5, 0.175*gm, 0.005*variable_slider_0) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_add_const_vxx_0 = blocks.add_const_vff((-12*shift, )) self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=9000, server=False, ) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(10) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-40*pows, .001, 0, False) ################################################## # Connections ################################################## self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.digital_clock_recovery_mm_xx_1, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blks2_tcp_sink_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_1, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self, FH_seq): gr.top_block.__init__(self, "Test2") ################################################## # Variables ################################################## self.sql_on = sql_on = 0 self.sql_on2 = sql_on2 = 0 self.samp_rate = samp_rate = 2e6 self.curr_chann_idx_0 = 0 self.curr_chann_idx_1 = 0 self.FH_seq = FH_seq ################################################## # Blocks ################################################## self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-25, 1, 25, False) self.analog_pwr_squelch_xx_1 = analog.pwr_squelch_cc(-25, 1, 25, False) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="addr0=192.168.20.2, addr1=192.168.30.2", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_clock_source("mimo", 1) self.uhd_usrp_source_0.set_time_source("mimo", 1) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(2.43064e9, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.uhd_usrp_source_0.set_center_freq(2.43064e9, 1) self.uhd_usrp_source_0.set_gain(0, 1) self.uhd_usrp_source_0.set_antenna("RX2", 1) def _sql_on_probe(): while True: val = self.analog_pwr_squelch_xx_0.unmuted() try: self.set_sql_on(val) except AttributeError, e: pass time.sleep((0.001))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="air band receiver") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.udp_dest_port = udp_dest_port = 8082 self.udp_dest_host = udp_dest_host = "192.168.10.30" self.sql = sql = -10.0 self.samp_rate = samp_rate = 2.4e6 self.rfgain = rfgain = 49.5 self.frq_corr = frq_corr = 30.0 self.device_arg = device_arg = "rtl_tcp=192.168.10.109:1235" self.base_freq = base_freq = 120.5e6 ################################################## # Blocks ################################################## self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + device_arg ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(base_freq, 0) self.osmosdr_source_0.set_freq_corr(frq_corr, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(rfgain, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna('RX', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(50, (firdes.low_pass_2(1,samp_rate,25e3,10e3,40)), 0, samp_rate) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short*1, udp_dest_host, udp_dest_port, 1472, True) self.blocks_float_to_short_0 = blocks.float_to_short(1, 32767) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(sql, 1e-4, 0, False) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=48e3, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0 = analog.agc2_cc(1e-3, 1e-5, 1.0, 0) self.analog_agc2_xx_0.set_max_gain(5) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_float_to_short_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.blocks_float_to_short_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self, FH_seq): gr.top_block.__init__(self, "Test2") ################################################## # Variables ################################################## self.sql_on = sql_on = 0 self.samp_rate = samp_rate = 2e6 self.curr_chann_idx = 0 self.FH_seq = FH_seq ################################################## # Blocks ################################################## #self.analog_noise_source = analog.noise_source_c(analog.GR_GAUSSIAN, 0) self.cosine_source = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0) self.analog_pwr_squelch_xx_1 = analog.pwr_squelch_cc(-30, 1, 25, False) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="addr=192.168.30.2", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_subdev_spec("A:0", 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(2.43665e9, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.uhd_usrp_sink = uhd.usrp_sink( device_addr="addr=192.168.30.2", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink.set_subdev_spec("A:0", 0) self.uhd_usrp_sink.set_samp_rate(samp_rate) self.uhd_usrp_sink.set_center_freq(2.43665e9, 0) self.uhd_usrp_sink.set_gain(31.5, 0) self.uhd_usrp_sink.set_antenna("TX/RX", 0) def _sql_on_probe(): while True: val = self.analog_pwr_squelch_xx_1.unmuted() try: self.set_sql_on(val) except AttributeError, e: pass time.sleep((0.001))
def __init__(self, samp_rate_in, samp_rate_out, center_freq, tune_freq, channel_width, transition_width, threshold, fsk_deviation, fskSquelch, iq_filename, dig_out_filename): gr.top_block.__init__(self) ################################################## # Variables ################################################## self.cutoff_freq = channel_width / 2 self.firdes_taps = firdes.low_pass(1, samp_rate_in, self.cutoff_freq, transition_width) ################################################## # Blocks ################################################## self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, iq_filename, False) self.blocks_tuning_filter_0 = filter.freq_xlating_fir_filter_ccc( int(samp_rate_in / samp_rate_out), (self.firdes_taps), tune_freq - center_freq, samp_rate_in) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc( fskSquelch, 1, 1, False) self.blocks_quadrature_demod_0 = analog.quadrature_demod_cf( samp_rate_out / (2 * pi * fsk_deviation / 2)) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1 * threshold, )) self.blocks_digital_binary_slicer_fb_0 = digital.binary_slicer_fb() # swapped message sink for file sink #self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, dig_out_filename, False) #self.blocks_file_sink_0.set_unbuffered(False) self.sink_queue = gr.msg_queue() self.blocks_message_sink_0 = blocks.message_sink( gr.sizeof_char * 1, self.sink_queue, False) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_tuning_filter_0, 0)) self.connect((self.blocks_tuning_filter_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.blocks_quadrature_demod_0, 0)) self.connect((self.blocks_quadrature_demod_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_digital_binary_slicer_fb_0, 0)) #self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_digital_binary_slicer_fb_0, 0), (self.blocks_message_sink_0, 0))
def __init__(self, f_in, f_out, base_freq, freq_offset, samp_rate, bit_rate): gr.top_block.__init__(self, "Demod Fsk Gen") ################################################## # Variables ################################################## self.samp_rate = samp_rate self.bit_rate = bit_rate self.samp_per_sym = samp_per_sym = int(samp_rate/bit_rate) self.fxff_decimation = fxff_decimation = 1 self.fsk_deviation_hz = fsk_deviation_hz = 160000 self.freq_offset = freq_offset self.base_freq = base_freq if not f_out: f_out = f_in + '.demod' ################################################## # Blocks ################################################## self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, samp_rate/fxff_decimation, bit_rate*0.8, bit_rate*.2, firdes.WIN_BLACKMAN, 6.76)) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(fxff_decimation, (firdes.low_pass(1, samp_rate, bit_rate*1.1, bit_rate*.4, firdes.WIN_BLACKMAN, 6.76)), freq_offset, samp_rate) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate/32,True) 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_file_source_0 = blocks.file_source(gr.sizeof_char*1, f_in, False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, f_out, False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_deinterleave_0 = blocks.deinterleave(gr.sizeof_float*1) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(samp_rate/(2*math.pi*fsk_deviation_hz/8.0)/fxff_decimation) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(30, 0.3, 0, False) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_deinterleave_0, 0)) self.connect((self.blocks_deinterleave_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_deinterleave_0, 1), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_quadrature_demod_cf_0, 0))
def __init__(self, squelch, ch_width, max_dev, out_scale, freq, command, do_audio=False): gr.hier_block2.__init__(self, "FMtoCommand", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(0, 0, gr.sizeof_gr_complex)) self.analog_pwr_squelch = analog.pwr_squelch_cc(squelch, 1e-4, 0, True) self.analog_nbfm_rx = analog.nbfm_rx( audio_rate=ch_width, quad_rate=ch_width, tau=75e-6, max_dev=max_dev, ) self.blocks_float_to_short = blocks.float_to_short(1, out_scale) # OSX: if you get Resource Temporarily Unavailable you probably need to increase maxproc, eg # sudo launchctl limit maxproc 2000 3000 logger.debug("Channel %.3f: Starting %s" % (freq / 1e6, str(command))) self.p = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE) self.sink = blocks.file_descriptor_sink(gr.sizeof_short * 1, self.p.stdin.fileno()) self.connect(self, (self.analog_pwr_squelch, 0)) self.connect((self.analog_pwr_squelch, 0), (self.analog_nbfm_rx, 0)) self.connect((self.analog_nbfm_rx, 0), (self.blocks_float_to_short, 0)) self.connect((self.blocks_float_to_short, 0), (self.sink, 0)) if do_audio: self.resampler = grfilter.rational_resampler_fff( interpolation=441, decimation=425, taps=None, fractional_bw=None) self.mult = blocks.multiply_const_vff((0.2, )) self.audio_sink = audio.sink(22050, '', True) self.connect((self.analog_nbfm_rx, 0), (self.resampler, 0)) self.connect((self.resampler, 0), (self.mult, 0)) self.connect((self.mult, 0), (self.audio_sink, 0))
def test_pwr_squelch_002(self): # Test runtime, gate=True 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.pwr_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 test_pwr_squelch_002(self): # Test runtime, gate=True 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.pwr_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, rf_params, bb_params, working_samp_rate): gr.hier_block2.__init__( self, "RX Demod Block", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), # single in gr.io_signature(1, 1, gr.sizeof_char * 1) # single out ) ################################################## # Parameters ################################################## # ADD VALIDITY CHECKS TO EACH OF THESE self.symbol_time = bb_params.symbol_time self.working_samp_rate = working_samp_rate self.fsk_dev = rf_params.fsk_dev ################################################## # Variables ################################################## self.sps = int(self.symbol_time * self.working_samp_rate) self.sensitivity = 2 * 3.1415 * self.fsk_dev / self.working_samp_rate ################################################## # Blocks ################################################## self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc( rfm.PWR_SQUELCH_DB, 1e-4, 0, False) self.connect((self, 0), (self.analog_pwr_squelch_xx_0, 0)) self.digital_gfsk_demod_0 = digital.gfsk_demod( samples_per_symbol=self.sps, sensitivity=self.sensitivity, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.digital_gfsk_demod_0, 0)) # output from block self.connect((self.digital_gfsk_demod_0, 0), (self, 0))
def __init__(self, frame, panel, vbox, argv): stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) sample_rate = 2e6 center_freq = 300e6 filename = '/home/sdr/Desktop/Lab/Labs/Multicode/multi_code_300MHz_2Mss.raw' fsrc = blocks.file_source(gr.sizeof_gr_complex, filename, True) throt = blocks.throttle(gr.sizeof_gr_complex, sample_rate) c_to_m = blocks.complex_to_mag() #scope = scopesink2.scope_sink_f(panel, sample_rate=sample_rate, size=(1200,800)) rat = filter.fir_filter_ccc(100, filter.firdes.low_pass_2(1, sample_rate, 1000000, 500000, 100)) detector = detect_opener_bits() squelch = analog.pwr_squelch_cc(-60,1,0,False) slicer = digital.binary_slicer_fb() add = blocks.add_const_vff((-.003, )) self.connect(fsrc, throt) self.connect(throt, rat) self.connect(rat, c_to_m) self.connect(c_to_m, add) self.connect(add, slicer) #self.connect(c_to_m, scope) self.connect(slicer, detector)
def __init__(self, FH_seq, start_chann_idx): gr.top_block.__init__(self, "Sequence Follower") ################################################## # Variables ################################################## self.sql_on = sql_on = 0 self.samp_rate = samp_rate = 32000 self.curr_chann_idx = start_chann_idx self.FH_seq = FH_seq ################################################## # Blocks ################################################## self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-10, 1, 25, False) def _sql_on_probe(): while True: val = self.analog_pwr_squelch_xx_0.unmuted() try: self.set_sql_on(val) except AttributeError, e: pass time.sleep(1.0/(100)) _sql_on_thread = threading.Thread(target=_sql_on_probe) _sql_on_thread.daemon = True _sql_on_thread.start() self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccf(64, ( [0.0027054441161453724, 0.002875175094231963, 0.0033175654243677855, 0.004034834913909435, 0.005023509729653597, 0.006274390500038862, 0.007772639859467745, 0.009498009458184242, 0.011425167322158813, 0.013524158857762814, 0.015760963782668114, 0.01809815689921379, 0.020495640113949776, 0.02291143871843815, 0.025302572175860405, 0.027625905349850655, 0.02983906865119934, 0.03190131485462189, 0.03377437964081764, 0.035423289984464645, 0.03681709244847298, 0.03792952373623848, 0.038739532232284546, 0.03923177719116211, 0.039396900683641434, 0.03923177719116211, 0.038739532232284546, 0.03792952373623848, 0.03681709244847298, 0.035423289984464645, 0.03377437964081764, 0.03190131485462189, 0.02983906865119934, 0.027625905349850655, 0.025302572175860405, 0.02291143871843815, 0.020495640113949776, 0.01809815689921379, 0.015760963782668114, 0.013524158857762814, 0.011425167322158813, 0.009498009458184242, 0.007772639859467745, 0.006274390500038862, 0.005023509729653597, 0.004034834913909435, 0.0033175654243677855, 0.002875175094231963, 0.0027054441161453724]), 1000, samp_rate) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/hocheol/GRC/Sample/FHSS_Sig", True) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/hocheol/GRC/Sample/FHSS_Demodulated.cfloat", False) self.blocks_file_sink_0.set_unbuffered(True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.blocks_file_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "NBFM") Qt.QWidget.__init__(self) self.setWindowTitle("NBFM") 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") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.radio_freq = radio_freq = 100 self.volume = volume = 5 self.squelch = squelch = -30 self.samp_rate = samp_rate = 240e4 self.rf_gain = rf_gain = 10 self.freq = freq = radio_freq * 1000000 ################################################## # Blocks ################################################## self._volume_range = Range(0, 10, 1, 5, 200) self._volume_win = RangeWidget(self._volume_range, self.set_volume, "Volume", "counter_slider", float) self.top_layout.addWidget(self._volume_win) self._squelch_range = Range(-70, 0, 10, -30, 200) self._squelch_win = RangeWidget(self._squelch_range, self.set_squelch, "Squelch", "counter_slider", int) self.top_layout.addWidget(self._squelch_win) self._rf_gain_range = Range(0, 50, 1, 10, 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.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(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(rf_gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_1_0 = filter.rational_resampler_fff( interpolation=60, decimation=35, taps=None, fractional_bw=None, ) self._radio_freq_tool_bar = Qt.QToolBar(self) self._radio_freq_tool_bar.addWidget(Qt.QLabel("Frequency (MHz)" + ": ")) self._radio_freq_line_edit = Qt.QLineEdit(str(self.radio_freq)) self._radio_freq_tool_bar.addWidget(self._radio_freq_line_edit) self._radio_freq_line_edit.returnPressed.connect( lambda: self.set_radio_freq( eng_notation.str_to_num( str(self._radio_freq_line_edit.text().toAscii())))) self.top_layout.addWidget(self._radio_freq_tool_bar) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #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 == type(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 freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_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 == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 8, firdes.low_pass(1, samp_rate, 5000, 8000, firdes.WIN_HAMMING, 6.76)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (volume, )) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc( squelch, 1e-4, 0, True) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=30000, quad_rate=300000, tau=75e-6, max_dev=12.5e3, ) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_0, 0), (self.rational_resampler_xxx_1_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.rational_resampler_xxx_1_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Nbfm Wav Out") ################################################## # 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.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_0 = filter.rational_resampler_fff( 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_pwr_squelch_xx_0 = analog.pwr_squelch_cc(squelch*-1, 0.1, 1, False) 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.rational_resampler_xxx_0_0, 0)) self.connect((self.analog_pwr_squelch_xx_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_pwr_squelch_xx_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))
def __init__(self): gr.top_block.__init__(self, "Tetra Rx Multi") options = self.get_options() ################################################## # Variables ################################################## self.srate_rx = srate_rx = options.sample_rate self.channels = srate_rx / 25000 self.srate_channel = 36000 self.afc_period = 5 self.afc_gain = 1. self.afc_channel = options.auto_tune or -1 self.afc_ppm_step = 100 self.debug = options.debug self.last_pwr = -100000 self.sig_det_period = 1 self.sig_det_bw = sig_det_bw = options.sig_detection_bw or srate_rx if self.sig_det_bw <= 1.: self.sig_det_bw *= srate_rx self.sig_det_threshold = options.sig_detection_threshold self.sig_det_channels = [] for ch in range(self.channels): if ch >= self.channels / 2: ch_ = (self.channels - ch - 1) else: ch_ = ch if (float(ch_) / self.channels * 2) <= (self.sig_det_bw / srate_rx): self.sig_det_channels.append(ch) ################################################## # RPC server ################################################## self.xmlrpc_server = SimpleXMLRPCServer.SimpleXMLRPCServer( ("localhost", options.listen_port), allow_none=True) self.xmlrpc_server.register_instance(self) threading.Thread(target=self.xmlrpc_server.serve_forever).start() ################################################## # Rx Blocks and connections ################################################## self.src = osmosdr.source( args=options.args ) self.src.set_sample_rate(srate_rx) self.src.set_center_freq(options.frequency, 0) self.src.set_freq_corr(options.ppm, 0) self.src.set_dc_offset_mode(0, 0) self.src.set_iq_balance_mode(0, 0) if options.gain is not None: self.src.set_gain_mode(False, 0) self.src.set_gain(36, 0) else: self.src.set_gain_mode(True, 0) out_type, dst_path = options.output.split("://", 1) if out_type == "udp": dst_ip, dst_port = dst_path.split(':', 1) self.freq_xlating = freq_xlating_fft_filter_ccc(1, (1, ), 0, srate_rx) self.channelizer = pfb.channelizer_ccf( self.channels, (firdes.root_raised_cosine(1, srate_rx, 18000, 0.35, 1024)), 36./25., 100) self.squelch = [] self.digital_mpsk_receiver_cc = [] self.diff_phasor = [] self.complex_to_arg = [] self.multiply_const = [] self.add_const = [] self.float_to_uchar = [] self.map_bits = [] self.unpack_k_bits = [] self.blocks_sink = [] for ch in range(0, self.channels): squelch = analog.pwr_squelch_cc(0, 0.001, 0, True) mpsk = digital.mpsk_receiver_cc( 4, math.pi/4, math.pi/100.0, -0.5, 0.5, 0.25, 0.001, 2, 0.001, 0.001) diff_phasor = digital.diff_phasor_cc() complex_to_arg = blocks.complex_to_arg(1) multiply_const = blocks.multiply_const_vff((2./math.pi, )) add_const = blocks.add_const_vff((1.5, )) float_to_uchar = blocks.float_to_uchar() map_bits = digital.map_bb(([3, 2, 0, 1, 3])) unpack_k_bits = blocks.unpack_k_bits_bb(2) if out_type == 'udp': sink = blocks.udp_sink(gr.sizeof_gr_char, dst_ip, int(dst_port)+ch, 1472, True) elif out_type == 'file': sink = blocks.file_sink(gr.sizeof_char, dst_path % ch, False) sink.set_unbuffered(True) else: raise ValueError("Invalid output URL '%s'" % options.output) self.connect((self.channelizer, ch), (squelch, 0), (mpsk, 0), (diff_phasor, 0), (complex_to_arg, 0), (multiply_const, 0), (add_const, 0), (float_to_uchar, 0), (map_bits, 0), (unpack_k_bits, 0), (sink, 0)) self.squelch.append(squelch) self.digital_mpsk_receiver_cc.append(mpsk) self.diff_phasor.append(diff_phasor) self.complex_to_arg.append(complex_to_arg) self.multiply_const.append(multiply_const) self.add_const.append(add_const) self.float_to_uchar.append(float_to_uchar) self.map_bits.append(map_bits) self.unpack_k_bits.append(unpack_k_bits) self.blocks_sink.append(sink) self.connect( (self.src, 0), (self.freq_xlating, 0), (self.channelizer, 0)) ################################################## # signal strenght identification ################################################## self.pwr_probes = [] for ch in range(self.channels): pwr_probe = analog.probe_avg_mag_sqrd_c(0, 1./self.srate_channel) self.pwr_probes.append(pwr_probe) self.connect((self.channelizer, ch), (pwr_probe, 0)) def _sig_det_probe(): while True: pwr = [self.pwr_probes[ch].level() for ch in range(self.channels) if ch in self.sig_det_channels] pwr = [10 * math.log10(p) for p in pwr if p > 0.] if not pwr: continue pwr = min(pwr) + self.sig_det_threshold print "Power level for squelch % 5.1f" % pwr if abs(pwr - self.last_pwr) > (self.sig_det_threshold / 2): for s in self.squelch: s.set_threshold(pwr) self.last_pwr = pwr time.sleep(self.sig_det_period) if self.sig_det_threshold is not None: self._sig_det_probe_thread = threading.Thread(target=_sig_det_probe) self._sig_det_probe_thread.daemon = True self._sig_det_probe_thread.start() ################################################## # AFC blocks and connections ################################################## self.afc_selector = grc_blks2.selector( item_size=gr.sizeof_gr_complex, num_inputs=self.channels, num_outputs=1, input_index=0, output_index=0, ) self.afc_demod = analog.quadrature_demod_cf(self.srate_channel/(2*math.pi)) samp_afc = self.srate_channel*self.afc_period / 2 self.afc_avg = blocks.moving_average_ff(samp_afc, 1./samp_afc*self.afc_gain) self.afc_probe = blocks.probe_signal_f() def _afc_probe(): while True: time.sleep(self.afc_period) if self.afc_channel == -1: continue err = self.afc_probe.level() if abs(err) < self.afc_ppm_step: continue freq = self.freq_xlating.center_freq + err * self.afc_gain if self.debug: print "err: %f\tfreq: %f" % (err, freq, ) self.freq_xlating.set_center_freq(freq) self._afc_err_thread = threading.Thread(target=_afc_probe) self._afc_err_thread.daemon = True self._afc_err_thread.start() for ch in range(self.channels): self.connect((self.channelizer, ch), (self.afc_selector, ch)) self.connect( (self.afc_selector, 0), (self.afc_demod, 0), (self.afc_avg, 0), (self.afc_probe, 0)) if self.afc_channel != -1: self.afc_selector.set_input_index(self.afc_channel)
def __init__(self): 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.symbol_rate = symbol_rate = 60000 self.symbol_period = symbol_period = pow(symbol_rate,-1) self.samp_rate = samp_rate = 300e3 self.samp_per_sym = samp_per_sym = 5 self.packet_len = packet_len = 256 self.decimation = decimation = 1 self.bits_per_sym = bits_per_sym = 1 self.Sq_Thresh = Sq_Thresh = -30 self.RF_Gain = RF_Gain = 20 self.Fc = Fc = 175e6 ################################################## # Blocks ################################################## _Sq_Thresh_sizer = wx.BoxSizer(wx.VERTICAL) self._Sq_Thresh_text_box = forms.text_box( parent=self.GetWin(), sizer=_Sq_Thresh_sizer, value=self.Sq_Thresh, callback=self.set_Sq_Thresh, label="Squelch Threshold", converter=forms.float_converter(), proportion=0, ) self._Sq_Thresh_slider = forms.slider( parent=self.GetWin(), sizer=_Sq_Thresh_sizer, value=self.Sq_Thresh, callback=self.set_Sq_Thresh, minimum=-50, maximum=20, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_Sq_Thresh_sizer, 0, 2, 1, 1) _RF_Gain_sizer = wx.BoxSizer(wx.VERTICAL) self._RF_Gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_RF_Gain_sizer, value=self.RF_Gain, callback=self.set_RF_Gain, label="RF Gain", converter=forms.float_converter(), proportion=0, ) self._RF_Gain_slider = forms.slider( parent=self.GetWin(), sizer=_RF_Gain_sizer, value=self.RF_Gain, callback=self.set_RF_Gain, minimum=0, maximum=50, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_RF_Gain_sizer, 0, 0, 1, 1) _Fc_sizer = wx.BoxSizer(wx.VERTICAL) self._Fc_text_box = forms.text_box( parent=self.GetWin(), sizer=_Fc_sizer, value=self.Fc, callback=self.set_Fc, label="Center Frequency", converter=forms.float_converter(), proportion=0, ) self._Fc_slider = forms.slider( parent=self.GetWin(), sizer=_Fc_sizer, value=self.Fc, callback=self.set_Fc, minimum=50e6, maximum=1700e6, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_Fc_sizer, 0, 1, 1, 1) self.osmosdr_source_0_0 = osmosdr.source( args="numchan=" + str(1) + " " + 'rtl_tcp=10.0.0.13:1234' ) self.osmosdr_source_0_0.set_sample_rate(samp_rate) self.osmosdr_source_0_0.set_center_freq(Fc+10e6, 0) self.osmosdr_source_0_0.set_freq_corr(0, 0) self.osmosdr_source_0_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0_0.set_gain_mode(False, 0) self.osmosdr_source_0_0.set_gain(RF_Gain, 0) self.osmosdr_source_0_0.set_if_gain(0, 0) self.osmosdr_source_0_0.set_bb_gain(0, 0) self.osmosdr_source_0_0.set_antenna("", 0) self.osmosdr_source_0_0.set_bandwidth(0, 0) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + 'rtl_tcp=10.0.0.12:1234' ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(Fc, 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(0, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.blocks_skiphead_0_0 = blocks.skiphead(gr.sizeof_gr_complex*1, int(samp_rate)*5) self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex*1, int(samp_rate)*5) self.blocks_pack_k_bits_bb_0_0 = blocks.pack_k_bits_bb(8) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_float_to_char_0_0 = blocks.float_to_char(1, 1) self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) self.blks2_tcp_sink_0_0_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=3493, server=True, ) self.blks2_tcp_sink_0_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=3491, server=True, ) self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc(Sq_Thresh, 0.01, 5, True) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-10, 0.01, 5, True) self.analog_fm_demod_cf_0_0 = analog.fm_demod_cf( channel_rate=samp_rate, audio_decim=decimation, deviation=75e3, audio_pass=120e3, audio_stop=140e3, gain=1.0, tau=75e-6, ) self.analog_fm_demod_cf_0 = analog.fm_demod_cf( channel_rate=samp_rate, audio_decim=decimation, deviation=75e3, audio_pass=120e3, audio_stop=140e3, gain=1.0, tau=75e-6, ) self.RPi_Rx_RPi_Rx_0_0 = RPi_Rx.RPi_Rx(bits_per_sym, samp_per_sym, packet_len, 65) self.RPi_Rx_RPi_Rx_0 = RPi_Rx.RPi_Rx(bits_per_sym, samp_per_sym, packet_len, 65) ################################################## # Connections ################################################## self.connect((self.analog_fm_demod_cf_0, 0), (self.RPi_Rx_RPi_Rx_0, 0)) self.connect((self.RPi_Rx_RPi_Rx_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.RPi_Rx_RPi_Rx_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_fm_demod_cf_0, 0)) self.connect((self.blocks_skiphead_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_skiphead_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blks2_tcp_sink_0_0, 0)) self.connect((self.blocks_float_to_char_0_0, 0), (self.blocks_pack_k_bits_bb_0_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0_0, 0), (self.blks2_tcp_sink_0_0_0, 0)) self.connect((self.analog_fm_demod_cf_0_0, 0), (self.RPi_Rx_RPi_Rx_0_0, 0)) self.connect((self.RPi_Rx_RPi_Rx_0_0, 0), (self.blocks_null_sink_0_0, 0)) self.connect((self.RPi_Rx_RPi_Rx_0_0, 0), (self.blocks_float_to_char_0_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.analog_fm_demod_cf_0_0, 0)) self.connect((self.blocks_skiphead_0_0, 0), (self.analog_pwr_squelch_xx_0_0, 0)) self.connect((self.osmosdr_source_0_0, 0), (self.blocks_skiphead_0_0, 0))
def __init__(self,infile, outfile, input_rate, channel_rate, codec_provoice, codec_p25, sslevel, svlevel): gr.top_block.__init__(self, "Top Block") self.input_rate = input_rate self.channel_rate = channel_rate self.source = blocks.file_source(gr.sizeof_gr_complex*1, infile, False) self.lp1_decim = int(input_rate/(channel_rate*1.6)) print self.lp1_decim self.lp1 = filter.fir_filter_ccc(self.lp1_decim,firdes.low_pass( 1.0, self.input_rate, (self.channel_rate/2), ((self.channel_rate/2)*0.6), firdes.WIN_HAMMING)) #self.audiodemod = gr.quadrature_demod_cf(1) audio_pass = (input_rate/self.lp1_decim)*0.25 audio_stop = audio_pass+2000 self.audiodemod = analog.fm_demod_cf(channel_rate=(input_rate/self.lp1_decim), audio_decim=1, deviation=15000, audio_pass=audio_pass, audio_stop=audio_stop, gain=8, tau=75e-6) self.throttle = blocks.throttle(gr.sizeof_gr_complex*1, self.input_rate) self.signal_squelch = analog.pwr_squelch_cc(sslevel,0.01, 0, True) self.vox_squelch = analog.pwr_squelch_ff(svlevel, 0.0005, 0, True) self.audiosink = blocks.wavfile_sink(outfile, 1, 8000) if codec_provoice: self.dsd = dsd.block_ff(dsd.dsd_FRAME_PROVOICE,dsd.dsd_MOD_AUTO_SELECT,1,0,False) channel_rate = input_rate/self.lp1_decim self.resampler_in = filter.rational_resampler_fff(interpolation=48000, decimation=channel_rate, taps=None, fractional_bw=None, ) output_rate = 8000 resampler = filter.rational_resampler_fff( interpolation=(input_rate/self.lp1_decim), decimation=output_rate, taps=None, fractional_bw=None, ) elif codec_p25: symbol_deviation = 600.0 symbol_rate = 4800 channel_rate = input_rate/self.lp1_decim fm_demod_gain = channel_rate / (2.0 * pi * symbol_deviation) fm_demod = analog.quadrature_demod_cf(fm_demod_gain) symbol_decim = 1 samples_per_symbol = channel_rate // symbol_rate symbol_coeffs = (1.0/samples_per_symbol,) * samples_per_symbol symbol_filter = filter.fir_filter_fff(symbol_decim, symbol_coeffs) autotuneq = gr.msg_queue(2) demod_fsk4 = op25.fsk4_demod_ff(autotuneq, channel_rate, symbol_rate) # symbol slicer levels = [ -2.0, 0.0, 2.0, 4.0 ] slicer = op25.fsk4_slicer_fb(levels) imbe = repeater.vocoder(False, True, 0, "", 0, False) self.decodequeue = decodequeue = gr.msg_queue(10000) decoder = repeater.p25_frame_assembler('', 0, 0, True, True, False, decodequeue) float_conversion = blocks.short_to_float(1, 8192) resampler = filter.rational_resampler_fff( interpolation=8000, decimation=8000, taps=None, fractional_bw=None, ) #Tone squelch, custom GRC block that rips off CTCSS squelch to detect 4800 hz tone and latch squelch after that if not codec_provoice and not codec_p25: #self.tone_squelch = gr.tone_squelch_ff(audiorate, 4800.0, 0.05, 300, 0, True) #tone squelch is EDACS ONLY self.high_pass = filter.fir_filter_fff(1, firdes.high_pass(1, (input_rate/self.lp1_decim), 300, 30, firdes.WIN_HAMMING, 6.76)) #output_rate = channel_rate resampler = filter.rational_resampler_fff( interpolation=8000, decimation=(input_rate/self.lp1_decim), taps=None, fractional_bw=None, ) if(codec_provoice): self.connect(self.source, self.throttle, self.lp1, self.audiodemod, self.resampler_in, self.dsd, self.audiosink) elif(codec_p25): self.connect(self.source, self.throttle, self.lp1, fm_demod, symbol_filter, demod_fsk4, slicer, decoder, imbe, float_conversion, resampler, self.audiosink) else: self.connect(self.source, self.throttle, self.lp1, self.signal_squelch, self.audiodemod, self.high_pass, self.vox_squelch, resampler, self.audiosink) self.time_open = time.time() self.time_tone = 0 self.time_activity = 0
def __init__(self): gr.top_block.__init__(self, "Multimon Flex Rtl Tcp") Qt.QWidget.__init__(self) self.setWindowTitle("Multimon Flex Rtl Tcp") 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", "multimon_flex_rtl_tcp") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2.4e6 self.channel_9 = channel_9 = 931.45e6 self.channel_8 = channel_8 = 931.4e6 self.channel_7 = channel_7 = 931.85e6 self.channel_6 = channel_6 = 931.5e6 self.channel_5 = channel_5 = 929.7e6 self.channel_4 = channel_4 = 929.650e6 self.channel_3 = channel_3 = 929.6e6 self.channel_2 = channel_2 = 929.5e6 self.channel_12 = channel_12 = 929.85e6 self.channel_11 = channel_11 = 929.8e6 self.channel_10 = channel_10 = 929.65e6 self.channel_1 = channel_1 = 929.65e6 self.channel_0 = channel_0 = 929.6e6 self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76) self.variable_qtgui_range_0 = variable_qtgui_range_0 = 50 self.sqlch = sqlch = -50 self.if_gain = if_gain = 40 self.gain = gain = 50 self.firdes_tap = firdes_tap = firdes.low_pass(1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76) self.corr = corr = -13.5 self.channel_13 = channel_13 = 929.625e6 self.center_freq_1 = center_freq_1 = sum([channel_6, channel_7] ) / float(len([channel_6, channel_7])) self.center_freq_0 = center_freq_0 = sum([channel_0, channel_1] ) / float(len([channel_0, channel_1])) self.center_freq = center_freq = sum([channel_0, channel_1, channel_2, channel_3, channel_4, channel_5, channel_6, channel_7, channel_8, channel_9, channel_10, channel_11, channel_12] ) / float(len([channel_0, channel_1, channel_2, channel_3, channel_4, channel_5, channel_6, channel_7, channel_8, channel_9, channel_10, channel_11, channel_12])) self.bb_gain = bb_gain = 40 ################################################## # Blocks ################################################## self._sqlch_range = Range(-150, -20, 500, -50, 200) self._sqlch_win = RangeWidget(self._sqlch_range, self.set_sqlch, "sqlch", "counter_slider", float) self.top_layout.addWidget(self._sqlch_win) self._if_gain_range = Range(0, 60, 100, 40, 200) self._if_gain_win = RangeWidget(self._if_gain_range, self.set_if_gain, "if_gain", "counter", float) self.top_layout.addWidget(self._if_gain_win) self._gain_range = Range(0, 100, 100, 50, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "counter", float) self.top_layout.addWidget(self._gain_win) self._corr_range = Range(-100, 100, 100, -13.5, 200) self._corr_win = RangeWidget(self._corr_range, self.set_corr, "corr", "counter", float) self.top_layout.addWidget(self._corr_win) self._channel_7_tool_bar = Qt.QToolBar(self) self._channel_7_tool_bar.addWidget(Qt.QLabel("channel_7"+": ")) self._channel_7_line_edit = Qt.QLineEdit(str(self.channel_7)) self._channel_7_tool_bar.addWidget(self._channel_7_line_edit) self._channel_7_line_edit.returnPressed.connect( lambda: self.set_channel_7(eng_notation.str_to_num(str(self._channel_7_line_edit.text().toAscii())))) self.top_layout.addWidget(self._channel_7_tool_bar) self._channel_6_tool_bar = Qt.QToolBar(self) self._channel_6_tool_bar.addWidget(Qt.QLabel("channel_6"+": ")) self._channel_6_line_edit = Qt.QLineEdit(str(self.channel_6)) self._channel_6_tool_bar.addWidget(self._channel_6_line_edit) self._channel_6_line_edit.returnPressed.connect( lambda: self.set_channel_6(eng_notation.str_to_num(str(self._channel_6_line_edit.text().toAscii())))) self.top_layout.addWidget(self._channel_6_tool_bar) self._channel_1_tool_bar = Qt.QToolBar(self) self._channel_1_tool_bar.addWidget(Qt.QLabel("channel_1"+": ")) self._channel_1_line_edit = Qt.QLineEdit(str(self.channel_1)) self._channel_1_tool_bar.addWidget(self._channel_1_line_edit) self._channel_1_line_edit.returnPressed.connect( lambda: self.set_channel_1(eng_notation.str_to_num(str(self._channel_1_line_edit.text().toAscii())))) self.top_layout.addWidget(self._channel_1_tool_bar) self._channel_0_tool_bar = Qt.QToolBar(self) self._channel_0_tool_bar.addWidget(Qt.QLabel("channel_0"+": ")) self._channel_0_line_edit = Qt.QLineEdit(str(self.channel_0)) self._channel_0_tool_bar.addWidget(self._channel_0_line_edit) self._channel_0_line_edit.returnPressed.connect( lambda: self.set_channel_0(eng_notation.str_to_num(str(self._channel_0_line_edit.text().toAscii())))) self.top_layout.addWidget(self._channel_0_tool_bar) self._bb_gain_range = Range(0, 100, 100, 40, 200) self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain, "bb_gain", "counter", float) self.top_layout.addWidget(self._bb_gain_win) self._variable_qtgui_range_0_range = Range(0, 100, 1, 50, 200) self._variable_qtgui_range_0_win = RangeWidget(self._variable_qtgui_range_0_range, self.set_variable_qtgui_range_0, "variable_qtgui_range_0", "counter_slider", float) self.top_layout.addWidget(self._variable_qtgui_range_0_win) self.osmosdr_source_0_0 = osmosdr.source( args="numchan=" + str(1) + " " + 'rtl=1' ) self.osmosdr_source_0_0.set_sample_rate(samp_rate) self.osmosdr_source_0_0.set_center_freq(center_freq_1 - 100000, 0) self.osmosdr_source_0_0.set_freq_corr(corr, 0) self.osmosdr_source_0_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0_0.set_gain_mode(True, 0) self.osmosdr_source_0_0.set_gain(gain, 0) self.osmosdr_source_0_0.set_if_gain(if_gain, 0) self.osmosdr_source_0_0.set_bb_gain(bb_gain, 0) self.osmosdr_source_0_0.set_antenna('', 0) self.osmosdr_source_0_0.set_bandwidth(0, 0) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + 'rtl=0' ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(center_freq_0 - 100000, 0) self.osmosdr_source_0.set_freq_corr(corr, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(gain, 0) self.osmosdr_source_0.set_if_gain(if_gain, 0) self.osmosdr_source_0.set_bb_gain(bb_gain, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_0_0_0_0_1 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 48e3, 7.5e3, 5e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0_0_0_0_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 48e3, 7.5e3, 5e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 48e3, 7.5e3, 5e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 48e3, 7.5e3, 5e3, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_xxx_0_0_0_0_1 = filter.freq_xlating_fir_filter_ccc(int(samp_rate / 48000), (firdes_tap), channel_6 - center_freq_1, samp_rate) self.freq_xlating_fir_filter_xxx_0_0_0_0_0_0 = filter.freq_xlating_fir_filter_ccc(int(samp_rate / 48000), (firdes_tap), channel_7 - center_freq_1, samp_rate) self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(int(samp_rate / 48000), (firdes_tap), channel_1 - center_freq_0, samp_rate) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(int(samp_rate / 48000), (firdes_tap), channel_0 - center_freq_0, samp_rate) self._channel_9_tool_bar = Qt.QToolBar(self) self._channel_9_tool_bar.addWidget(Qt.QLabel("channel_9"+": ")) self._channel_9_line_edit = Qt.QLineEdit(str(self.channel_9)) self._channel_9_tool_bar.addWidget(self._channel_9_line_edit) self._channel_9_line_edit.returnPressed.connect( lambda: self.set_channel_9(eng_notation.str_to_num(str(self._channel_9_line_edit.text().toAscii())))) self.top_layout.addWidget(self._channel_9_tool_bar) self._channel_8_tool_bar = Qt.QToolBar(self) self._channel_8_tool_bar.addWidget(Qt.QLabel("channel_8"+": ")) self._channel_8_line_edit = Qt.QLineEdit(str(self.channel_8)) self._channel_8_tool_bar.addWidget(self._channel_8_line_edit) self._channel_8_line_edit.returnPressed.connect( lambda: self.set_channel_8(eng_notation.str_to_num(str(self._channel_8_line_edit.text().toAscii())))) self.top_layout.addWidget(self._channel_8_tool_bar) self._channel_5_tool_bar = Qt.QToolBar(self) self._channel_5_tool_bar.addWidget(Qt.QLabel("channel_5"+": ")) self._channel_5_line_edit = Qt.QLineEdit(str(self.channel_5)) self._channel_5_tool_bar.addWidget(self._channel_5_line_edit) self._channel_5_line_edit.returnPressed.connect( lambda: self.set_channel_5(eng_notation.str_to_num(str(self._channel_5_line_edit.text().toAscii())))) self.top_layout.addWidget(self._channel_5_tool_bar) self._channel_4_tool_bar = Qt.QToolBar(self) self._channel_4_tool_bar.addWidget(Qt.QLabel("channel_4"+": ")) self._channel_4_line_edit = Qt.QLineEdit(str(self.channel_4)) self._channel_4_tool_bar.addWidget(self._channel_4_line_edit) self._channel_4_line_edit.returnPressed.connect( lambda: self.set_channel_4(eng_notation.str_to_num(str(self._channel_4_line_edit.text().toAscii())))) self.top_layout.addWidget(self._channel_4_tool_bar) self._channel_3_tool_bar = Qt.QToolBar(self) self._channel_3_tool_bar.addWidget(Qt.QLabel("channel_3"+": ")) self._channel_3_line_edit = Qt.QLineEdit(str(self.channel_3)) self._channel_3_tool_bar.addWidget(self._channel_3_line_edit) self._channel_3_line_edit.returnPressed.connect( lambda: self.set_channel_3(eng_notation.str_to_num(str(self._channel_3_line_edit.text().toAscii())))) self.top_layout.addWidget(self._channel_3_tool_bar) self._channel_2_tool_bar = Qt.QToolBar(self) self._channel_2_tool_bar.addWidget(Qt.QLabel("channel_2"+": ")) self._channel_2_line_edit = Qt.QLineEdit(str(self.channel_2)) self._channel_2_tool_bar.addWidget(self._channel_2_line_edit) self._channel_2_line_edit.returnPressed.connect( lambda: self.set_channel_2(eng_notation.str_to_num(str(self._channel_2_line_edit.text().toAscii())))) self.top_layout.addWidget(self._channel_2_tool_bar) self._channel_13_tool_bar = Qt.QToolBar(self) self._channel_13_tool_bar.addWidget(Qt.QLabel("channel_13"+": ")) self._channel_13_line_edit = Qt.QLineEdit(str(self.channel_13)) self._channel_13_tool_bar.addWidget(self._channel_13_line_edit) self._channel_13_line_edit.returnPressed.connect( lambda: self.set_channel_13(eng_notation.str_to_num(str(self._channel_13_line_edit.text().toAscii())))) self.top_layout.addWidget(self._channel_13_tool_bar) self._channel_12_tool_bar = Qt.QToolBar(self) self._channel_12_tool_bar.addWidget(Qt.QLabel("channel_12"+": ")) self._channel_12_line_edit = Qt.QLineEdit(str(self.channel_12)) self._channel_12_tool_bar.addWidget(self._channel_12_line_edit) self._channel_12_line_edit.returnPressed.connect( lambda: self.set_channel_12(eng_notation.str_to_num(str(self._channel_12_line_edit.text().toAscii())))) self.top_layout.addWidget(self._channel_12_tool_bar) self._channel_11_tool_bar = Qt.QToolBar(self) self._channel_11_tool_bar.addWidget(Qt.QLabel("channel_11"+": ")) self._channel_11_line_edit = Qt.QLineEdit(str(self.channel_11)) self._channel_11_tool_bar.addWidget(self._channel_11_line_edit) self._channel_11_line_edit.returnPressed.connect( lambda: self.set_channel_11(eng_notation.str_to_num(str(self._channel_11_line_edit.text().toAscii())))) self.top_layout.addWidget(self._channel_11_tool_bar) self._channel_10_tool_bar = Qt.QToolBar(self) self._channel_10_tool_bar.addWidget(Qt.QLabel("channel_10"+": ")) self._channel_10_line_edit = Qt.QLineEdit(str(self.channel_10)) self._channel_10_tool_bar.addWidget(self._channel_10_line_edit) self._channel_10_line_edit.returnPressed.connect( lambda: self.set_channel_10(eng_notation.str_to_num(str(self._channel_10_line_edit.text().toAscii())))) self.top_layout.addWidget(self._channel_10_tool_bar) self.blocks_udp_sink_3_0_1 = blocks.udp_sink(gr.sizeof_short*1, '127.0.0.1', 7306, 1472, True) self.blocks_udp_sink_3_0_0_0 = blocks.udp_sink(gr.sizeof_short*1, '127.0.0.1', 7307, 1472, True) self.blocks_udp_sink_1 = blocks.udp_sink(gr.sizeof_short*1, '127.0.0.1', 7301, 1472, True) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short*1, '127.0.0.1', 7300, 1472, True) self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0_2 = blocks.multiply_const_vff((0.1, )) self.blocks_multiply_const_vxx_0_0_1 = blocks.multiply_const_vff((0.1, )) self.blocks_multiply_const_vxx_0_0_0_0_0_1 = blocks.multiply_const_vff((0.1, )) self.blocks_multiply_const_vxx_0_0_0_0_0_0_0 = blocks.multiply_const_vff((0.1, )) self.blocks_float_to_short_0_1_0_0_1 = blocks.float_to_short(1, 32767) self.blocks_float_to_short_0_1_0_0_0_0 = blocks.float_to_short(1, 32767) self.blocks_float_to_short_0_1 = blocks.float_to_short(1, 32767) self.blocks_float_to_short_0_0 = blocks.float_to_short(1, 32767) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -100000, 1, 0) self.analog_pwr_squelch_xx_0_2 = analog.pwr_squelch_cc(sqlch, 1, 1, True) self.analog_pwr_squelch_xx_0_0_1 = analog.pwr_squelch_cc(sqlch, 1, 1, True) self.analog_pwr_squelch_xx_0_0_0_0_0_1 = analog.pwr_squelch_cc(sqlch, 1, 1, True) self.analog_pwr_squelch_xx_0_0_0_0_0_0_0 = analog.pwr_squelch_cc(sqlch, 1, 1, True) self.analog_nbfm_rx_0_0_0_0_1 = analog.nbfm_rx( audio_rate=48000, quad_rate=48000, tau=75e-6, max_dev=5000, ) self.analog_nbfm_rx_0_0_0_0_0_0 = analog.nbfm_rx( audio_rate=48000, quad_rate=48000, tau=75e-6, max_dev=5000, ) self.analog_nbfm_rx_0_0 = analog.nbfm_rx( audio_rate=48000, quad_rate=48000, tau=75e-6, max_dev=5000, ) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=48000, quad_rate=48000, tau=75e-6, max_dev=5000, ) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_0_2, 0)) self.connect((self.analog_nbfm_rx_0_0, 0), (self.blocks_multiply_const_vxx_0_0_1, 0)) self.connect((self.analog_nbfm_rx_0_0_0_0_0_0, 0), (self.blocks_multiply_const_vxx_0_0_0_0_0_0_0, 0)) self.connect((self.analog_nbfm_rx_0_0_0_0_1, 0), (self.blocks_multiply_const_vxx_0_0_0_0_0_1, 0)) self.connect((self.analog_pwr_squelch_xx_0_0_0_0_0_0_0, 0), (self.low_pass_filter_0_0_0_0_0_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_0_0_0_0_1, 0), (self.low_pass_filter_0_0_0_0_1, 0)) self.connect((self.analog_pwr_squelch_xx_0_0_1, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_2, 0), (self.low_pass_filter_0, 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_0_1, 1)) self.connect((self.blocks_float_to_short_0_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.blocks_float_to_short_0_1, 0), (self.blocks_udp_sink_1, 0)) self.connect((self.blocks_float_to_short_0_1_0_0_0_0, 0), (self.blocks_udp_sink_3_0_0_0, 0)) self.connect((self.blocks_float_to_short_0_1_0_0_1, 0), (self.blocks_udp_sink_3_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_0_0_0_0_0, 0), (self.blocks_float_to_short_0_1_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_0_0_0_1, 0), (self.blocks_float_to_short_0_1_0_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_1, 0), (self.blocks_float_to_short_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.blocks_float_to_short_0_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.freq_xlating_fir_filter_xxx_0_0_0_0_0_0, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.freq_xlating_fir_filter_xxx_0_0_0_0_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_pwr_squelch_xx_0_2, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.analog_pwr_squelch_xx_0_0_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0_0_0, 0), (self.analog_pwr_squelch_xx_0_0_0_0_0_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0_1, 0), (self.analog_pwr_squelch_xx_0_0_0_0_0_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.analog_nbfm_rx_0_0, 0)) self.connect((self.low_pass_filter_0_0_0_0_0_0, 0), (self.analog_nbfm_rx_0_0_0_0_0_0, 0)) self.connect((self.low_pass_filter_0_0_0_0_1, 0), (self.analog_nbfm_rx_0_0_0_0_1, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.osmosdr_source_0_0, 0), (self.blocks_multiply_xx_0_1, 0))
def __init__(self, options, filename): gr.top_block.__init__(self) inf_str = None symbol_rate = 152.34e3 sample_rate = 1e6 #if len(options) != 0: # inf_str = args[0] squelch = analog.pwr_squelch_cc(float(options.squelch), 0.1, 0, True) demod = analog.quadrature_demod_cf(1.0) cr = digital.clock_recovery_mm_ff(sample_rate / symbol_rate, 0.00765625, 0, 0.175, 0.005) slicer = digital.binary_slicer_fb() corr = digital.correlate_access_code_bb(AC, 3) sink = sniffer() if False: print "Reading from: " + inf_str src = blocks.file_source(gr.sizeof_gr_complex, inf_str, False) else: freqs = { 'AA': 917.0e6, 'AB': 913.0e6, 'AC': 914.0e6, 'AD': 915.0e6, 'BA': 916.0e6, 'BB': 919.0e6, 'BC': 920.0e6, 'BD': 921.0e6, 'CA': 922.0e6, 'CB': 923.0e6, 'CC': 907.0e6, 'CD': 908.0e6, 'DA': 905.5e6, 'DB': 909.0e6, 'DC': 911.0e6, 'DD': 910.0e6 } frequency = freqs[options.channel] print "Channel: " + options.channel + " (" + str( frequency / 1e6) + "MHz)" # Create a UHD device source src = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32', "sc16", args="")) # Set the subdevice spec if (options.spec): src.set_subdev_spec(options.spec, 0) # Set the antenna if (options.antenna): src.set_antenna(options.antenna, 0) # Set receiver sample rate src.set_samp_rate(options.samp_rate) # Set receive daughterboard gain if options.gain is None: g = src.get_gain_range() options.gain = float(g.start() + g.stop()) / 2 print "Using mid-point gain of", options.gain, "(", g.start( ), "-", g.stop(), ")" src.set_gain(options.gain) # Set frequency (tune request takes lo_offset) treq = uhd.tune_request(frequency) tr = src.set_center_freq(treq) if tr == None: sys.stderr.write('Failed to set center frequency\n') raise SystemExit, 1 self.connect(src, squelch, demod, cr, slicer, corr, sink)
def __init__(self): gr.top_block.__init__(self, "CP v0.4a") Qt.QWidget.__init__(self) self.setWindowTitle("CP v0.4a") 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", "cp04a") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.radio_freq = radio_freq = 100 self.samp_rate = samp_rate = 2.4e6 self.rf_gain = rf_gain = 10 self.freq = freq = radio_freq * 1000000 self.ch3_volume = ch3_volume = 1 self.ch3_squelch = ch3_squelch = -30 self.ch3_mute = ch3_mute = 1 self.ch3_modulation = ch3_modulation = 0 self.ch3_invert = ch3_invert = 1 self.ch3_freq = ch3_freq = radio_freq self.ch2_volume = ch2_volume = 1 self.ch2_squelch = ch2_squelch = -30 self.ch2_mute = ch2_mute = 1 self.ch2_modulation = ch2_modulation = 0 self.ch2_invert = ch2_invert = 1 self.ch2_freq = ch2_freq = radio_freq self.ch1_volume = ch1_volume = 1 self.ch1_squelch = ch1_squelch = -30 self.ch1_mute = ch1_mute = 1 self.ch1_modulation = ch1_modulation = 0 self.ch1_invert = ch1_invert = 1 self.ch1_freq = ch1_freq = radio_freq ################################################## # Blocks ################################################## self.settings = Qt.QTabWidget() self.settings_widget_0 = Qt.QWidget() self.settings_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.settings_widget_0) self.settings_grid_layout_0 = Qt.QGridLayout() self.settings_layout_0.addLayout(self.settings_grid_layout_0) self.settings.addTab(self.settings_widget_0, "Settings") self.top_grid_layout.addWidget(self.settings, 4,3,2,3) self.tabs = Qt.QTabWidget() self.tabs_widget_0 = Qt.QWidget() self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_0) self.tabs_grid_layout_0 = Qt.QGridLayout() self.tabs_layout_0.addLayout(self.tabs_grid_layout_0) self.tabs.addTab(self.tabs_widget_0, "Ch 1") self.tabs_widget_1 = Qt.QWidget() self.tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_1) self.tabs_grid_layout_1 = Qt.QGridLayout() self.tabs_layout_1.addLayout(self.tabs_grid_layout_1) self.tabs.addTab(self.tabs_widget_1, "Ch 2") self.tabs_widget_2 = Qt.QWidget() self.tabs_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_2) self.tabs_grid_layout_2 = Qt.QGridLayout() self.tabs_layout_2.addLayout(self.tabs_grid_layout_2) self.tabs.addTab(self.tabs_widget_2, "Ch 3") self.top_grid_layout.addWidget(self.tabs, 4,0,2,3) self._rf_gain_range = Range(0, 50, 1, 10, 100) self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, "RF Gain", "counter_slider", float) self.settings_grid_layout_0.addWidget(self._rf_gain_win, 1,0,1,1) self._ch2_volume_range = Range(0, 10, 1, 1, 50) self._ch2_volume_win = RangeWidget(self._ch2_volume_range, self.set_ch2_volume, "Volume", "counter_slider", int) self.top_grid_layout.addWidget(self._ch2_volume_win, 1,2,1,1) self._ch2_squelch_range = Range(-70, 0, 10, -30, 50) self._ch2_squelch_win = RangeWidget(self._ch2_squelch_range, self.set_ch2_squelch, "Squelch", "counter_slider", int) self.top_grid_layout.addWidget(self._ch2_squelch_win, 1,3,1,1) _ch2_mute_check_box = Qt.QCheckBox("Mute") self._ch2_mute_choices = {True: 0, False: 1} self._ch2_mute_choices_inv = dict((v,k) for k,v in self._ch2_mute_choices.iteritems()) self._ch2_mute_callback = lambda i: Qt.QMetaObject.invokeMethod(_ch2_mute_check_box, "setChecked", Qt.Q_ARG("bool", self._ch2_mute_choices_inv[i])) self._ch2_mute_callback(self.ch2_mute) _ch2_mute_check_box.stateChanged.connect(lambda i: self.set_ch2_mute(self._ch2_mute_choices[bool(i)])) self.top_grid_layout.addWidget(_ch2_mute_check_box, 1,5,1,1) self._ch2_modulation_options = (0, 1, 2, ) self._ch2_modulation_labels = ("DMR", "NBFM", "WBFM", ) self._ch2_modulation_tool_bar = Qt.QToolBar(self) self._ch2_modulation_tool_bar.addWidget(Qt.QLabel("Modulation"+": ")) self._ch2_modulation_combo_box = Qt.QComboBox() self._ch2_modulation_tool_bar.addWidget(self._ch2_modulation_combo_box) for label in self._ch2_modulation_labels: self._ch2_modulation_combo_box.addItem(label) self._ch2_modulation_callback = lambda i: Qt.QMetaObject.invokeMethod(self._ch2_modulation_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._ch2_modulation_options.index(i))) self._ch2_modulation_callback(self.ch2_modulation) self._ch2_modulation_combo_box.currentIndexChanged.connect( lambda i: self.set_ch2_modulation(self._ch2_modulation_options[i])) self.top_grid_layout.addWidget(self._ch2_modulation_tool_bar, 1,1,1,1) _ch2_invert_check_box = Qt.QCheckBox("Invert") self._ch2_invert_choices = {True: -1, False: 1} self._ch2_invert_choices_inv = dict((v,k) for k,v in self._ch2_invert_choices.iteritems()) self._ch2_invert_callback = lambda i: Qt.QMetaObject.invokeMethod(_ch2_invert_check_box, "setChecked", Qt.Q_ARG("bool", self._ch2_invert_choices_inv[i])) self._ch2_invert_callback(self.ch2_invert) _ch2_invert_check_box.stateChanged.connect(lambda i: self.set_ch2_invert(self._ch2_invert_choices[bool(i)])) self.top_grid_layout.addWidget(_ch2_invert_check_box, 1,4,1,1) self._ch2_freq_tool_bar = Qt.QToolBar(self) self._ch2_freq_tool_bar.addWidget(Qt.QLabel("Ch2 Freq (MHz)"+": ")) self._ch2_freq_line_edit = Qt.QLineEdit(str(self.ch2_freq)) self._ch2_freq_tool_bar.addWidget(self._ch2_freq_line_edit) self._ch2_freq_line_edit.returnPressed.connect( lambda: self.set_ch2_freq(eng_notation.str_to_num(str(self._ch2_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._ch2_freq_tool_bar, 1,0,1,1) self._ch1_volume_range = Range(0, 10, 1, 1, 100) self._ch1_volume_win = RangeWidget(self._ch1_volume_range, self.set_ch1_volume, "Volume", "counter_slider", int) self.top_grid_layout.addWidget(self._ch1_volume_win, 0,2,1,1) self._ch1_squelch_range = Range(-70, 0, 10, -30, 100) self._ch1_squelch_win = RangeWidget(self._ch1_squelch_range, self.set_ch1_squelch, "Squelch", "counter_slider", int) self.top_grid_layout.addWidget(self._ch1_squelch_win, 0,3,1,1) _ch1_mute_check_box = Qt.QCheckBox("Mute") self._ch1_mute_choices = {True: 0, False: 1} self._ch1_mute_choices_inv = dict((v,k) for k,v in self._ch1_mute_choices.iteritems()) self._ch1_mute_callback = lambda i: Qt.QMetaObject.invokeMethod(_ch1_mute_check_box, "setChecked", Qt.Q_ARG("bool", self._ch1_mute_choices_inv[i])) self._ch1_mute_callback(self.ch1_mute) _ch1_mute_check_box.stateChanged.connect(lambda i: self.set_ch1_mute(self._ch1_mute_choices[bool(i)])) self.top_grid_layout.addWidget(_ch1_mute_check_box, 0,5,1,1) self._ch1_modulation_options = (0, 1, 2, ) self._ch1_modulation_labels = ("DMR", "NBFM", "WBFM", ) self._ch1_modulation_tool_bar = Qt.QToolBar(self) self._ch1_modulation_tool_bar.addWidget(Qt.QLabel("Modulation"+": ")) self._ch1_modulation_combo_box = Qt.QComboBox() self._ch1_modulation_tool_bar.addWidget(self._ch1_modulation_combo_box) for label in self._ch1_modulation_labels: self._ch1_modulation_combo_box.addItem(label) self._ch1_modulation_callback = lambda i: Qt.QMetaObject.invokeMethod(self._ch1_modulation_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._ch1_modulation_options.index(i))) self._ch1_modulation_callback(self.ch1_modulation) self._ch1_modulation_combo_box.currentIndexChanged.connect( lambda i: self.set_ch1_modulation(self._ch1_modulation_options[i])) self.top_grid_layout.addWidget(self._ch1_modulation_tool_bar, 0,1,1,1) _ch1_invert_check_box = Qt.QCheckBox("Invert") self._ch1_invert_choices = {True: -1, False: 1} self._ch1_invert_choices_inv = dict((v,k) for k,v in self._ch1_invert_choices.iteritems()) self._ch1_invert_callback = lambda i: Qt.QMetaObject.invokeMethod(_ch1_invert_check_box, "setChecked", Qt.Q_ARG("bool", self._ch1_invert_choices_inv[i])) self._ch1_invert_callback(self.ch1_invert) _ch1_invert_check_box.stateChanged.connect(lambda i: self.set_ch1_invert(self._ch1_invert_choices[bool(i)])) self.top_grid_layout.addWidget(_ch1_invert_check_box, 0,4,1,1) self._ch1_freq_tool_bar = Qt.QToolBar(self) self._ch1_freq_tool_bar.addWidget(Qt.QLabel("Ch1 Freq (MHz)"+": ")) self._ch1_freq_line_edit = Qt.QLineEdit(str(self.ch1_freq)) self._ch1_freq_tool_bar.addWidget(self._ch1_freq_line_edit) self._ch1_freq_line_edit.returnPressed.connect( lambda: self.set_ch1_freq(eng_notation.str_to_num(str(self._ch1_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._ch1_freq_tool_bar, 0,0,1,1) self.wbfm_chain_0_0 = wbfm_chain() self.wbfm_chain_0 = wbfm_chain() self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(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(rf_gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=400000, decimation=2400000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=400000, decimation=2400000, taps=None, fractional_bw=None, ) self._radio_freq_tool_bar = Qt.QToolBar(self) self._radio_freq_tool_bar.addWidget(Qt.QLabel("Radio Freq (MHz)"+": ")) self._radio_freq_line_edit = Qt.QLineEdit(str(self.radio_freq)) self._radio_freq_tool_bar.addWidget(self._radio_freq_line_edit) self._radio_freq_line_edit.returnPressed.connect( lambda: self.set_radio_freq(eng_notation.str_to_num(str(self._radio_freq_line_edit.text().toAscii())))) self.settings_grid_layout_0.addWidget(self._radio_freq_tool_bar, 0,0,1,1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #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 == type(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_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 10,0,10,6) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 512, #size firdes.WIN_BLACKMAN_hARRIS, #wintype (ch2_freq * 1000000), #fc 400000, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_0_win, 0,0,1,1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 512, #size firdes.WIN_BLACKMAN_hARRIS, #wintype (ch1_freq * 1000000), #fc 400000, #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_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0,0,1,1) self.nbfm_chain_0_0 = nbfm_chain() self.nbfm_chain_0 = nbfm_chain() self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), (ch2_freq * 1000000) - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), (ch1_freq * 1000000) - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.dsd_chain_0_0 = dsd_chain() self.dsd_chain_0 = dsd_chain() self._ch3_volume_range = Range(0, 10, 1, 1, 50) self._ch3_volume_win = RangeWidget(self._ch3_volume_range, self.set_ch3_volume, "Volume", "counter_slider", int) self.top_grid_layout.addWidget(self._ch3_volume_win, 2,2,1,1) self._ch3_squelch_range = Range(-70, 0, 10, -30, 50) self._ch3_squelch_win = RangeWidget(self._ch3_squelch_range, self.set_ch3_squelch, "Squelch", "counter_slider", int) self.top_grid_layout.addWidget(self._ch3_squelch_win, 2,3,1,1) _ch3_mute_check_box = Qt.QCheckBox("Mute") self._ch3_mute_choices = {True: 0, False: 1} self._ch3_mute_choices_inv = dict((v,k) for k,v in self._ch3_mute_choices.iteritems()) self._ch3_mute_callback = lambda i: Qt.QMetaObject.invokeMethod(_ch3_mute_check_box, "setChecked", Qt.Q_ARG("bool", self._ch3_mute_choices_inv[i])) self._ch3_mute_callback(self.ch3_mute) _ch3_mute_check_box.stateChanged.connect(lambda i: self.set_ch3_mute(self._ch3_mute_choices[bool(i)])) self.top_grid_layout.addWidget(_ch3_mute_check_box, 2,5,1,1) self._ch3_modulation_options = (0, 1, 2, ) self._ch3_modulation_labels = ("DMR", "NBFM", "WBFM", ) self._ch3_modulation_tool_bar = Qt.QToolBar(self) self._ch3_modulation_tool_bar.addWidget(Qt.QLabel("Modulation"+": ")) self._ch3_modulation_combo_box = Qt.QComboBox() self._ch3_modulation_tool_bar.addWidget(self._ch3_modulation_combo_box) for label in self._ch3_modulation_labels: self._ch3_modulation_combo_box.addItem(label) self._ch3_modulation_callback = lambda i: Qt.QMetaObject.invokeMethod(self._ch3_modulation_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._ch3_modulation_options.index(i))) self._ch3_modulation_callback(self.ch3_modulation) self._ch3_modulation_combo_box.currentIndexChanged.connect( lambda i: self.set_ch3_modulation(self._ch3_modulation_options[i])) self.top_grid_layout.addWidget(self._ch3_modulation_tool_bar, 2,1,1,1) _ch3_invert_check_box = Qt.QCheckBox("Invert") self._ch3_invert_choices = {True: -1, False: 1} self._ch3_invert_choices_inv = dict((v,k) for k,v in self._ch3_invert_choices.iteritems()) self._ch3_invert_callback = lambda i: Qt.QMetaObject.invokeMethod(_ch3_invert_check_box, "setChecked", Qt.Q_ARG("bool", self._ch3_invert_choices_inv[i])) self._ch3_invert_callback(self.ch3_invert) _ch3_invert_check_box.stateChanged.connect(lambda i: self.set_ch3_invert(self._ch3_invert_choices[bool(i)])) self.top_grid_layout.addWidget(_ch3_invert_check_box, 2,4,1,1) self._ch3_freq_tool_bar = Qt.QToolBar(self) self._ch3_freq_tool_bar.addWidget(Qt.QLabel("Ch3 Freq (MHz)"+": ")) self._ch3_freq_line_edit = Qt.QLineEdit(str(self.ch3_freq)) self._ch3_freq_tool_bar.addWidget(self._ch3_freq_line_edit) self._ch3_freq_line_edit.returnPressed.connect( lambda: self.set_ch3_freq(eng_notation.str_to_num(str(self._ch3_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._ch3_freq_tool_bar, 2,0,1,1) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((ch2_invert * ch2_mute, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((ch1_invert * ch1_mute, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((ch2_volume, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((ch1_volume, )) self.blks2_selector_0_1 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=1, num_outputs=3, input_index=0, output_index=ch2_modulation, ) self.blks2_selector_0_0_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=3, num_outputs=1, input_index=ch2_modulation, output_index=0, ) self.blks2_selector_0_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=3, num_outputs=1, input_index=ch1_modulation, output_index=0, ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=1, num_outputs=3, input_index=0, output_index=ch1_modulation, ) self.audio_sink_0_0 = audio.sink(48000, "", True) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_pwr_squelch_xx_0_0_0 = analog.pwr_squelch_cc(ch2_squelch, 1e-4, 0, True) self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc(ch1_squelch, 1e-4, 0, True) ################################################## # Connections ################################################## self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.blks2_selector_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_0_0, 0), (self.blks2_selector_0_1, 0)) self.connect((self.blks2_selector_0, 0), (self.dsd_chain_0, 0)) self.connect((self.blks2_selector_0, 1), (self.nbfm_chain_0, 0)) self.connect((self.blks2_selector_0, 2), (self.wbfm_chain_0, 0)) self.connect((self.blks2_selector_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blks2_selector_0_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blks2_selector_0_1, 0), (self.dsd_chain_0_0, 0)) self.connect((self.blks2_selector_0_1, 1), (self.nbfm_chain_0_0, 0)) self.connect((self.blks2_selector_0_1, 2), (self.wbfm_chain_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.audio_sink_0_0, 0)) self.connect((self.dsd_chain_0, 0), (self.blks2_selector_0_0, 0)) self.connect((self.dsd_chain_0_0, 0), (self.blks2_selector_0_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.analog_pwr_squelch_xx_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.analog_pwr_squelch_xx_0_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.nbfm_chain_0, 0), (self.blks2_selector_0_0, 1)) self.connect((self.nbfm_chain_0_0, 0), (self.blks2_selector_0_0_0, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.wbfm_chain_0, 0), (self.blks2_selector_0_0, 2)) self.connect((self.wbfm_chain_0_0, 0), (self.blks2_selector_0_0_0, 2))
def __init__(self): # Call the initialization method from the parent class gr.top_block.__init__(self) # Setup the parser for command line arguments parser = OptionParser(option_class=eng_option) parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="print settings to stdout") parser.add_option("-a", "--args", type="string", dest="src_args", default='addr=192.168.1.13', help="USRP device address args") parser.add_option("-g", "--gain", type="eng_float", dest="src_gain", default=0, help="USRP gain in dB") parser.add_option("-q", "--squelch", type="eng_float", dest="squelch_thresh", default=-80, help="Squelch threshold in dB") parser.add_option("-s", "--soundrate", type="eng_float", dest="snd_card_rate", default=48000, help="Sound card rate in Hz (must be n*100 Hz)") parser.add_option("-c", "--channels", type="string", dest="channel_file_name", default='channels.txt', help="Text file of EOL delimited channels in Hz") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() raise SystemExit, 1 # Define the user constants src_args = str(options.src_args) src_gain = float(options.src_gain) squelch_thresh = float(options.squelch_thresh) snd_card_rate = int(options.snd_card_rate) channel_file_name = str(options.channel_file_name) # Define other constants (don't mess with these) max_rf_bandwidth = 25E6 # Limited by N210 channel_sample_rate = 20000 nbfm_maxdev = 2.5E3 nbfm_tau = 75E-6 # Open file, split to list, remove empty strings, and convert to float with open(channel_file_name) as chanfile: lines = chanfile.read().splitlines() chanfile.close() lines = __builtin__.filter(None, lines) chanlist = [float(chan) for chan in lines] # Source decimation is first deternmined by the required RF bandwidth rf_bandwidth = max(chanlist) - min(chanlist) + 2*channel_sample_rate src_decimation = int(math.floor(max_rf_bandwidth/rf_bandwidth)) # Check if rf_bandwidth is too wide if rf_bandwidth > max_rf_bandwidth: print 'Error: Channels spaced beyond the \ %f MHz maximum RF bandwidth!' % (max_rf_bandwidth/1E6) sys.exit([1]) else: pass # Don't let the source decimation go above 100 (USRP N210 limit) if src_decimation > 100: src_decimation = 100 # This is a little tricky # Don't want odd values of source decimation greater than 1 # Also want the source sample rate \ # to be an integer multiple of channel sample rate src_sample_rate = max_rf_bandwidth / src_decimation while ((src_decimation%2 != 0) or \ ((max_rf_bandwidth/src_decimation) % channel_sample_rate != 0)) \ and src_decimation > 1: src_decimation = src_decimation - 1 src_sample_rate = max_rf_bandwidth / src_decimation # Calculate the channel decimation for the fxlating filter # (it will be an integer) channel_decimation = int(src_sample_rate / channel_sample_rate) # Calculate center frequency src_center_freq = (max(chanlist) + min(chanlist)) / 2 # Print some info to stdout for verbose option if options.verbose: print 'Source args string "%s" ' % src_args print 'Source center frequency = %f MHz' % (src_center_freq/1E6) print 'Source decimation = %i' % src_decimation print 'Source sample rate = %i Hz' % src_sample_rate print 'Source gain = %i dB' % src_gain print 'Squelch threshold = %i dB' % squelch_thresh print 'Channel decimation = %i' % channel_decimation print 'Channel sample rate = %i Hz' % channel_sample_rate print 'Sound card rate = %i Hz' % snd_card_rate print 'Channel list = %s' % str(chanlist) # Setup the source src = uhd.usrp_source(src_args, uhd.io_type_t.COMPLEX_FLOAT32, 1) src.set_samp_rate(src_sample_rate) src.set_center_freq(src_center_freq, 0) src.set_gain(src_gain, 0) # Get USRP true center frequency # Do nothing with it as it's only a few Hz error #print src.get_center_freq() # Create N channel flows--------------------------------------------- # Design taps for frequency translating FIR filter filter_taps = filter.firdes.low_pass(1.0, src_sample_rate, 8E3, 2E3, filter.firdes.WIN_HAMMING) # N parallel fxlating FIR filter with decimation to channel rate # Note how the tune freq is chan-src_center_freq ; reversed from GR 3.6 fxlate = [filter.freq_xlating_fir_filter_ccc(channel_decimation, filter_taps, chan - src_center_freq, src_sample_rate) for chan in chanlist] # Power squelch (complex, non blocking) prior to NBFM squelch1 = [analog.pwr_squelch_cc(squelch_thresh, 0.1, 1, False) for chan in chanlist] # NBFM receiver nbfm = [analog.nbfm_rx(channel_sample_rate, channel_sample_rate, nbfm_tau, nbfm_maxdev) for chan in chanlist] # Power squelch (float, blocking) prior to wav file resampling squelch2 = [analog.pwr_squelch_ff(squelch_thresh, 0.1, 1, True) for chan in chanlist] # Rational resampler for channel rate to 8 kHz wav file rate resampwav = [filter.rational_resampler_fff(8000, int(channel_sample_rate)) for chan in chanlist] # Wav file sink wavfile = [blocks.wavfile_sink(str(int(chan))+'.wav', 1, 8000, 8) for chan in chanlist] # Connect the blocks for chan in range(len(chanlist)): self.connect(src, fxlate[chan], squelch1[chan], nbfm[chan], squelch2[chan], resampwav[chan], wavfile[chan]) # Adder to sum the nbfm outputs for sound card adder = blocks.add_vff(1) # Rational resampler for channel rate to audio rate resampsc = filter.rational_resampler_fff(int(snd_card_rate), int(channel_sample_rate)) # Sound card sink sndcard = audio.sink(snd_card_rate, "", True) # Connect the blocks for chan in range(len(chanlist)): self.connect(nbfm[chan], (adder, chan)) # Connect the blocks self.connect(adder, resampsc, sndcard)
def __init__(self, center_freq=433920000): gr.top_block.__init__(self, "Rx 2400 R2") ################################################## # Parameters ################################################## self.center_freq = center_freq ################################################## # Variables ################################################## self.sps = sps = 10 self.baud_rate = baud_rate = 2530 self.samp_rate_tx = samp_rate_tx = 400000 self.samp_rate = samp_rate = baud_rate * sps self.rx_vga_gain = rx_vga_gain = 35 self.rx_lna_gain = rx_lna_gain = 6 self.quad_gain = quad_gain = 8 self.freq = freq = 433920000 self._fft_size_config = ConfigParser.ConfigParser() self._fft_size_config.read('default') try: fft_size = self._fft_size_config.getint('main', 'key') except: fft_size = 2048 self.fft_size = fft_size ################################################## # Blocks ################################################## self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + 'bladerf=0') self.osmosdr_source_0.set_sample_rate(samp_rate_tx) self.osmosdr_source_0.set_center_freq(freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(1, 0) self.osmosdr_source_0.set_iq_balance_mode(1, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(rx_lna_gain, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(rx_vga_gain, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(1500000, 0) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate_tx, 6000, 6000, firdes.WIN_HAMMING, 6.76)) self.logpwrfft_x_0 = logpwrfft.logpwrfft_c( sample_rate=samp_rate_tx, fft_size=fft_size, ref_scale=2, frame_rate=1, avg_alpha=1.0, average=False, ) self.fir_filter_xxx_0 = filter.fir_filter_fff(16, (firdes.low_pass( 1.0, baud_rate * sps, baud_rate, 0.25 * baud_rate))) self.fir_filter_xxx_0.declare_sample_delay(0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_fff( sps, 2 * 3.14159265 / 100, (firdes.low_pass( 1.0, baud_rate * sps, baud_rate, 0.25 * baud_rate)), 32, 16, 1.5, 1) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_float * fft_size, 1) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char * 1, '_out.bin', False) self.blocks_file_sink_0_0.set_unbuffered(True) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float * fft_size, 'log_power_fft_data.bin', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_add_const_vxx_0 = blocks.add_const_vff((0, )) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( quad_gain) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc( -70, 1e-4, 0, True) ################################################## # Connections ################################################## self.connect((self.analog_pwr_squelch_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.logpwrfft_x_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.logpwrfft_x_0, 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 = 1000000 self.deviation = deviation = 180000 self.baud_rate = baud_rate = 49260 self.sps = sps = ((float)(samp_rate)/(float)(baud_rate)) self.modulation_index = modulation_index = (float)(deviation) / ((float)(baud_rate) / 2) self.Threshold = Threshold = -60 self.Freq = Freq = 434000000 ################################################## # Blocks ################################################## _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=430000000, maximum=440000000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_Freq_sizer) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(Freq, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.uhd_usrp_source_0.set_bandwidth(samp_rate, 0) self.low_pass_filter_0_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, samp_rate, 100e3, 100e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, 200e3, 100e3, firdes.WIN_HAMMING, 6.76)) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(sps*(1+0.0), 0.1, 0, 0.1, 0.01) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/augusto/Documents/RXDigital.dat", False) self.blocks_file_sink_0.set_unbuffered(False) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf((float)(sps)/(math.pi * modulation_index)) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(Threshold, 1, 0, False) ################################################## # Connections ################################################## self.connect((self.analog_pwr_squelch_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.digital_binary_slicer_fb_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)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.analog_pwr_squelch_xx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="CP v0.3a") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.freq = freq = 92.9e6 self.samp_rate = samp_rate = 2.4e6 self.ch3_volume = ch3_volume = 1 self.ch3_squelch = ch3_squelch = -30 self.ch3_mute = ch3_mute = 1 self.ch3_modulation = ch3_modulation = 0 self.ch3_invert = ch3_invert = 1 self.ch3_freq = ch3_freq = freq self.ch2_volume = ch2_volume = 1 self.ch2_squelch = ch2_squelch = -30 self.ch2_mute = ch2_mute = 1 self.ch2_modulation = ch2_modulation = 0 self.ch2_invert = ch2_invert = 1 self.ch2_freq = ch2_freq = freq self.ch1_volume = ch1_volume = 1 self.ch1_squelch = ch1_squelch = -30 self.ch1_mute = ch1_mute = 1 self.ch1_modulation = ch1_modulation = 0 self.ch1_invert = ch1_invert = 1 self.ch1_freq = ch1_freq = freq ################################################## # Blocks ################################################## self.tab = self.tab = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.tab.AddPage(grc_wxgui.Panel(self.tab), "Ch 1") self.tab.AddPage(grc_wxgui.Panel(self.tab), "Ch 2") self.tab.AddPage(grc_wxgui.Panel(self.tab), "Ch 3") self.GridAdd(self.tab, 5, 0, 1, 7) self._freq_text_box = forms.text_box( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Radio Center Freq", converter=forms.float_converter(), ) self.GridAdd(self._freq_text_box, 21, 0, 1, 10) _ch3_volume_sizer = wx.BoxSizer(wx.VERTICAL) self._ch3_volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch3_volume_sizer, value=self.ch3_volume, callback=self.set_ch3_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._ch3_volume_slider = forms.slider( parent=self.GetWin(), sizer=_ch3_volume_sizer, value=self.ch3_volume, callback=self.set_ch3_volume, minimum=0, maximum=10, num_steps=20, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ch3_volume_sizer, 4, 2, 1, 1) _ch3_squelch_sizer = wx.BoxSizer(wx.VERTICAL) self._ch3_squelch_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch3_squelch_sizer, value=self.ch3_squelch, callback=self.set_ch3_squelch, label="Squelch", converter=forms.float_converter(), proportion=0, ) self._ch3_squelch_slider = forms.slider( parent=self.GetWin(), sizer=_ch3_squelch_sizer, value=self.ch3_squelch, callback=self.set_ch3_squelch, minimum=-70, maximum=0, num_steps=14, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ch3_squelch_sizer, 4, 3, 1, 1) self._ch3_mute_check_box = forms.check_box( parent=self.GetWin(), value=self.ch3_mute, callback=self.set_ch3_mute, label="Mute", true=0, false=1, ) self.GridAdd(self._ch3_mute_check_box, 4, 5, 1, 1) self._ch3_modulation_chooser = forms.drop_down( parent=self.GetWin(), value=self.ch3_modulation, callback=self.set_ch3_modulation, label="Modulation", choices=[0, 1,2], labels=["DMR","NBFM","WBFM"], ) self.GridAdd(self._ch3_modulation_chooser, 4, 1, 1, 1) self._ch3_invert_check_box = forms.check_box( parent=self.GetWin(), value=self.ch3_invert, callback=self.set_ch3_invert, label="Invert", true=-1, false=1, ) self.GridAdd(self._ch3_invert_check_box, 4, 4, 1, 1) self._ch3_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.ch3_freq, callback=self.set_ch3_freq, label="Ch3 Freq", converter=forms.float_converter(), ) self.GridAdd(self._ch3_freq_text_box, 4, 0, 1, 1) _ch2_volume_sizer = wx.BoxSizer(wx.VERTICAL) self._ch2_volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch2_volume_sizer, value=self.ch2_volume, callback=self.set_ch2_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._ch2_volume_slider = forms.slider( parent=self.GetWin(), sizer=_ch2_volume_sizer, value=self.ch2_volume, callback=self.set_ch2_volume, minimum=0, maximum=10, num_steps=20, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ch2_volume_sizer, 2, 2, 1, 1) _ch2_squelch_sizer = wx.BoxSizer(wx.VERTICAL) self._ch2_squelch_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch2_squelch_sizer, value=self.ch2_squelch, callback=self.set_ch2_squelch, label="Squelch", converter=forms.float_converter(), proportion=0, ) self._ch2_squelch_slider = forms.slider( parent=self.GetWin(), sizer=_ch2_squelch_sizer, value=self.ch2_squelch, callback=self.set_ch2_squelch, minimum=-70, maximum=0, num_steps=14, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ch2_squelch_sizer, 2, 3, 1, 1) self._ch2_mute_check_box = forms.check_box( parent=self.GetWin(), value=self.ch2_mute, callback=self.set_ch2_mute, label="Mute", true=0, false=1, ) self.GridAdd(self._ch2_mute_check_box, 2, 5, 1, 1) self._ch2_modulation_chooser = forms.drop_down( parent=self.GetWin(), value=self.ch2_modulation, callback=self.set_ch2_modulation, label="Modulation", choices=[0, 1,2], labels=["DMR","NBFM","WBFM"], ) self.GridAdd(self._ch2_modulation_chooser, 2, 1, 1, 1) self._ch2_invert_check_box = forms.check_box( parent=self.GetWin(), value=self.ch2_invert, callback=self.set_ch2_invert, label="Invert", true=-1, false=1, ) self.GridAdd(self._ch2_invert_check_box, 2, 4, 1, 1) self._ch2_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.ch2_freq, callback=self.set_ch2_freq, label="Ch2 Freq", converter=forms.float_converter(), ) self.GridAdd(self._ch2_freq_text_box, 2, 0, 1, 1) _ch1_volume_sizer = wx.BoxSizer(wx.VERTICAL) self._ch1_volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch1_volume_sizer, value=self.ch1_volume, callback=self.set_ch1_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._ch1_volume_slider = forms.slider( parent=self.GetWin(), sizer=_ch1_volume_sizer, value=self.ch1_volume, callback=self.set_ch1_volume, minimum=0, maximum=10, num_steps=40, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ch1_volume_sizer, 0, 2, 1, 1) _ch1_squelch_sizer = wx.BoxSizer(wx.VERTICAL) self._ch1_squelch_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch1_squelch_sizer, value=self.ch1_squelch, callback=self.set_ch1_squelch, label="Squelch", converter=forms.float_converter(), proportion=0, ) self._ch1_squelch_slider = forms.slider( parent=self.GetWin(), sizer=_ch1_squelch_sizer, value=self.ch1_squelch, callback=self.set_ch1_squelch, minimum=-70, maximum=0, num_steps=14, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ch1_squelch_sizer, 0, 3, 1, 1) self._ch1_mute_check_box = forms.check_box( parent=self.GetWin(), value=self.ch1_mute, callback=self.set_ch1_mute, label="Mute", true=0, false=1, ) self.GridAdd(self._ch1_mute_check_box, 0, 5, 1, 1) self._ch1_modulation_chooser = forms.drop_down( parent=self.GetWin(), value=self.ch1_modulation, callback=self.set_ch1_modulation, label="Modulation", choices=[0, 1,2], labels=["DMR","NBFM","WBFM"], ) self.GridAdd(self._ch1_modulation_chooser, 0, 1, 1, 1) self._ch1_invert_check_box = forms.check_box( parent=self.GetWin(), value=self.ch1_invert, callback=self.set_ch1_invert, label="Invert", true=-1, false=1, ) self.GridAdd(self._ch1_invert_check_box, 0, 4, 1, 1) self._ch1_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.ch1_freq, callback=self.set_ch1_freq, label="Ch1 Freq", converter=forms.float_converter(), ) self.GridAdd(self._ch1_freq_text_box, 0, 0, 1, 1) self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, 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.GridAdd(self.wxgui_waterfallsink2_1.win, 6, 0, 15, 10) self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_c( self.tab.GetPage(2).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=True, avg_alpha=0.1333, title="Channel 3", peak_hold=False, ) self.tab.GetPage(2).GridAdd(self.wxgui_fftsink2_0_0_0.win, 0, 0, 12, 7) self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c( self.tab.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=True, avg_alpha=0.1333, title="Channel 2", peak_hold=False, ) self.tab.GetPage(1).GridAdd(self.wxgui_fftsink2_0_0.win, 0, 0, 12, 7) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.tab.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=True, avg_alpha=0.1333, title="Channel 1", peak_hold=False, ) self.tab.GetPage(0).GridAdd(self.wxgui_fftsink2_0.win, 0, 0, 12, 7) self.wbfm_chain_0_0_0 = wbfm_chain() self.wbfm_chain_0_0 = wbfm_chain() self.wbfm_chain_0 = wbfm_chain() self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(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.nbfm_chain_1_0 = nbfm_chain() self.nbfm_chain_1 = nbfm_chain() self.nbfm_chain_0 = nbfm_chain() self.freq_xlating_fft_filter_ccc_0_0_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), ch3_freq - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0_0_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), ch2_freq - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), ch1_freq - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.dsd_chain_1_0 = dsd_chain() self.dsd_chain_1 = dsd_chain() self.dsd_chain_0 = dsd_chain() self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vff((ch3_invert * ch3_mute, )) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((ch2_invert * ch2_mute, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((ch1_invert * ch1_mute, )) self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_vff((ch3_volume, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((ch2_volume, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((ch1_volume, )) self.blks2_selector_0_1_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=1, num_outputs=3, input_index=0, output_index=ch3_modulation, ) self.blks2_selector_0_1 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=1, num_outputs=3, input_index=0, output_index=ch2_modulation, ) self.blks2_selector_0_0_0_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=3, num_outputs=1, input_index=ch3_modulation, output_index=0, ) self.blks2_selector_0_0_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=3, num_outputs=1, input_index=ch2_modulation, output_index=0, ) self.blks2_selector_0_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=3, num_outputs=1, input_index=ch1_modulation, output_index=0, ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=1, num_outputs=3, input_index=0, output_index=ch1_modulation, ) self.audio_sink_0_0_0 = audio.sink(48000, "", True) self.audio_sink_0_0 = audio.sink(48000, "", True) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_pwr_squelch_xx_0_0_0_0 = analog.pwr_squelch_cc(ch3_squelch, 1e-4, 0, True) self.analog_pwr_squelch_xx_0_0_0 = analog.pwr_squelch_cc(ch2_squelch, 1e-4, 0, True) self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc(ch1_squelch, 1e-4, 0, True) ################################################## # Connections ################################################## self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.blks2_selector_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_0_0, 0), (self.blks2_selector_0_1, 0)) self.connect((self.analog_pwr_squelch_xx_0_0_0_0, 0), (self.blks2_selector_0_1_0, 0)) self.connect((self.blks2_selector_0, 0), (self.dsd_chain_0, 0)) self.connect((self.blks2_selector_0, 1), (self.nbfm_chain_0, 0)) self.connect((self.blks2_selector_0, 2), (self.wbfm_chain_0, 0)) self.connect((self.blks2_selector_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blks2_selector_0_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blks2_selector_0_0_0_0, 0), (self.blocks_multiply_const_vxx_0_0_0, 0)) self.connect((self.blks2_selector_0_1, 0), (self.dsd_chain_1, 0)) self.connect((self.blks2_selector_0_1, 1), (self.nbfm_chain_1, 0)) self.connect((self.blks2_selector_0_1, 2), (self.wbfm_chain_0_0, 0)) self.connect((self.blks2_selector_0_1_0, 0), (self.dsd_chain_1_0, 0)) self.connect((self.blks2_selector_0_1_0, 1), (self.nbfm_chain_1_0, 0)) self.connect((self.blks2_selector_0_1_0, 2), (self.wbfm_chain_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.blocks_multiply_const_vxx_2_0, 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.audio_sink_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.audio_sink_0_0_0, 0)) self.connect((self.dsd_chain_0, 0), (self.blks2_selector_0_0, 0)) self.connect((self.dsd_chain_1, 0), (self.blks2_selector_0_0_0, 0)) self.connect((self.dsd_chain_1_0, 0), (self.blks2_selector_0_0_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.analog_pwr_squelch_xx_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.analog_pwr_squelch_xx_0_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0_0, 0), (self.analog_pwr_squelch_xx_0_0_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0_0, 0), (self.wxgui_fftsink2_0_0_0, 0)) self.connect((self.nbfm_chain_0, 0), (self.blks2_selector_0_0, 1)) self.connect((self.nbfm_chain_1, 0), (self.blks2_selector_0_0_0, 1)) self.connect((self.nbfm_chain_1_0, 0), (self.blks2_selector_0_0_0_0, 1)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.wxgui_waterfallsink2_1, 0)) self.connect((self.wbfm_chain_0, 0), (self.blks2_selector_0_0, 2)) self.connect((self.wbfm_chain_0_0, 0), (self.blks2_selector_0_0_0, 2)) self.connect((self.wbfm_chain_0_0_0, 0), (self.blks2_selector_0_0_0_0, 2))
def __init__(self, principal_gui, rx_callback, options): gr.hier_block2.__init__(self, "receive_path", gr.io_signature(0,0,0), # the 1,1 indicate the minimum, maximum stream in input gr.io_signature(0,0,0)) # the 0,0 indicate the minimum, maximum stream in output #local setup usrp source creat self.usrp source self._setup_usrp_source(options) options = copy.copy(options) # Make copy of the received options self._verbose = options.verbose self._bitrate = options.data_rate # The bit rate transmission self._samples_per_symbol= options.samples_per_symbol # samples/sample self._rx_callback = rx_callback #This callback is fired (declanche) when there's packet is available self.demodulator = bpsk_demodulator(principal_gui, options) #The demodulator used #Designe filter to get actual channel we want sw_decim = 1 #Create the low pass filter chan_coeffs = filter.firdes.low_pass (1.0, #gain sw_decim * self._samples_per_symbol, #sampling rate 1.0, #midpoint of trans band 0.5, #width of trans band filter.firdes.WIN_HAMMING) #filter type self.channel_filter = filter.fft_filter_ccc(sw_decim, chan_coeffs) self.packet_receiver = ieee_pkt_receiver.ieee_pkt_receiver_868_915(self, gui = principal_gui, demodulator = self.demodulator, callback = rx_callback, sps = self._samples_per_symbol, symbol_rate = self._bitrate, threshold = -1) #Carrier Sensing Block (ecoute du canal) alpha = 0.001 # Carrier Sensing with dB, will have to adjust thresh = 30 #construct analyser of carrier (c'est un sink) # self.probe = gr.probe_avg_mag_sqrd_c(thresh, alpha) #display information about the setup if self._verbose: self._print_verbage() #self.squelch = gr.pwr_squelch_cc(50, 1, 0, True) #connect the input block to channel filter #connect the blocks with usrp, the self.usrp is created in _setup_usrp_source self.squelch = analog.pwr_squelch_cc(50, 1, 0, True) # self.wxgui_constellationsink2_0_0 = constsink_gl.const_sink_c( # principal_gui.GetWin(), # title="Constellation Plot", # sample_rate= options.samp_rate, # frame_rate=5, # const_size=2048, # M=2, # theta=0, # loop_bw=6.28/100.0, # fmax=0.05, # mu=0.5, # gain_mu=0.001, # symbol_rate=options.samp_rate/options.samples_per_symbol, # omega_limit=0.0001, # ) # principal_gui.Add(self.wxgui_constellationsink2_0_0.win) '''For stream of bits''' # self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( # principal_gui.GetWin(), # baseband_freq=options.freq, # y_per_div=10, # y_divs=10, # ref_level=10, # ref_scale=2.0, # sample_rate= 0.5e6, # fft_size=1024, # fft_rate=30, # average=False, # avg_alpha=None, # title="FFT Plot", # peak_hold=False, # ) # principal_gui.Add(self.wxgui_fftsink2_0.win) #self.connect(self.u, self.demodulator, self.wxgui_fftsink2_0) '''End for stream of bits''' #Reception of packets self.connect(self.u, self.packet_receiver)
def __init__(self, argv): gr.top_block.__init__(self) parser=OptionParser(option_class=eng_option) parser.add_option("-a", "--args", type="string", default="", help="UHD device address args [default=%default]") parser.add_option("", "--dev", type="string", default=0, help="Device (rtl=0 or something") parser.add_option("-f", "--freqset", type="string", default="", help="Frequency set key=freq,key=freq,... in kHz") parser.add_option("-m", "--mode", type="string", default="fm", help="Mode (am or fm)") parser.add_option("-g", "--gain", type="eng_float", default=30.0, help="set gain in dB (default is maximum)") parser.add_option("-V", "--volume", type="eng_float", default=1.0, help="set volume (default is midpoint)") parser.add_option("-i", "--icecast", type="string", default="", help="Icecast host:port") parser.add_option("-p", "--icepw", type="string", default="127.0.0.1:8000", help="Icecast source password") parser.add_option("-O", "--audio-output", type="string", default="", help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) if options.volume is None: options.volume = 0.8 self.vol = options.volume self.freqs = self.parse_freqset(options.freqset) self.freq_corr = 0 self.rf_gain = options.gain # around 20 self.if_gain = 7 self.bb_gain = 10.0 self.bandwidth = 2400000 self.channel_bw = 10000 freq_min = min(self.freqs.values()) freq_max = max(self.freqs.values()) print "Frequencies:" for k in self.freqs: print " %s: %.3f MHz" % (k, self.freqs[k]/1000000.0) required_bw = freq_max - freq_min print "Required bandwidth: %.3f MHz" % (required_bw/1000000.0) if required_bw > self.bandwidth: print "Required bandwidth %.3f MHz larger than maximum BW %.3f MHz" % (required_bw/1000000, self.bandwidth/100000) return None # offset center frequency so that it's not on a monitored frequency self.center_freq = freq_min + (required_bw/2) for f in self.freqs.values(): if abs(f - self.center_freq) < self.channel_bw: self.center_freq += self.channel_bw print "Center frequency: %.3f MHz" % self.center_freq print "" # build graph arg_s = options.dev #"rtl=%d" % options.dev u = self.u = osmosdr.source(args=arg_s) u.set_center_freq(self.center_freq, 0) u.set_freq_corr(self.freq_corr, 0) u.set_dc_offset_mode(0, 0) # 0-2: Off-Manual-Automatic u.set_iq_balance_mode(0, 0) # 0-2: Off-Manual-Automatic u.set_gain_mode(False, 0) # 0-1: Manual, Automatic u.set_gain(self.rf_gain, 0) u.set_if_gain(self.if_gain, 0) u.set_bb_gain(self.bb_gain, 0) u.set_antenna("all", 0) u.set_sample_rate(1024e3*2) u.set_bandwidth(self.bandwidth, 0) dev_rate = self.u.get_sample_rate() demod_rate = 64e3 audio_rate = 32e3 chanfilt_decim = int(dev_rate // demod_rate) audio_decim = int(demod_rate // audio_rate) print "Device rate %d, bandwidth %.3f MHz" % (dev_rate, self.bandwidth / 1000000.0) print "Demod rate %d, audio rate %d" % (demod_rate, audio_rate) if options.mode == 'am': chan_filt_coeffs = filter.firdes.low_pass_2(1, # gain dev_rate, # sampling rate 8e3, # passband cutoff 2e3, # transition bw 60) # stopband attenuation else: print "FM filter" chan_filt_coeffs = filter.firdes.low_pass_2(1, # gain dev_rate, # sampling rate 16e3, # passband cutoff 3e3, # transition bw 60) # stopband attenuation audio_filt_coeffs = filter.firdes.low_pass_2(1, # gain demod_rate, # sampling rate 7e3, # passband cutoff 2e3, # transition bw 60) # stopband attenuation demodulators = [] for k in self.freqs: f = self.freqs[k] print "Setting up %s: %.3f MHz" % (k, f / 1000000.0) if_freq = f - self.center_freq chan_filt = filter.freq_xlating_fir_filter_ccf(chanfilt_decim, chan_filt_coeffs, if_freq, dev_rate) agc = analog.agc_cc(0.1, 1, 1) if options.mode == 'am': demod = blocks.complex_to_mag() squelch = analog.standard_squelch(dev_rate/10) sq_range = squelch.squelch_range() sq = (sq_range[0] + sq_range[1])/2 sq = 0.7 print "Squelch: range %.1f ... %.1f, using %.2f" % (sq_range[0], sq_range[1], sq) squelch.set_threshold(sq) audio_filt = filter.fir_filter_fff(audio_decim, audio_filt_coeffs) self.connect(chan_filt, agc, demod, squelch, audio_filt) last_block = audio_filt else: print "FM demod" demod = analog.demod_20k0f3e_cf(demod_rate, audio_decim) squelch = analog.pwr_squelch_cc(-50.0, # Power threshold 125.0/demod_rate, # Time constant int(demod_rate/20), # 50ms rise/fall False) # Zero, not gate output self.connect(chan_filt, squelch, agc, demod) last_block = demod demodulators.append([chan_filt, last_block]) if options.icecast: # set up a file sink fname = self.setup_upstream_pipe(k, options) float_to_int = blocks.float_to_short(scale=7500.0) file_sink = blocks.file_sink(gr.sizeof_short, fname, append=True) self.connect(last_block, float_to_int, file_sink) self.adder = None if options.audio_output != "": self.volume_control = blocks.multiply_const_ff(self.vol) self.adder = blocks.add_ff(1) # sound card as final sink self.audio_sink = audio.sink(int (audio_rate), options.audio_output, False) # ok_to_block # now wire it all together ch = 0 for d in demodulators: self.connect(self.u, d[0]) if self.adder: self.connect(d[1], (self.adder, ch)) ch += 1 if self.adder: self.connect(self.adder, self.volume_control, self.audio_sink) if options.gain is None: g = self.u.get_gain_range() # if no gain was specified, use the mid gain options.gain = (g.start() + g.stop())/2.0
def __init__(self, samp_rate=4E6, audio_rate=8000, record=True): gr.hier_block2.__init__(self, "TunerDemodNBFM", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_float)) # Default values self.center_freq = 0 squelch_db = -60 self.quad_demod_gain = 0.050 self.file_name = "/dev/null" self.record = record # Decimation values for four stages of decimation decims = (5, int(samp_rate/1E6)) # Low pass filter taps for decimation by 5 low_pass_filter_taps_0 = \ grfilter.firdes_low_pass(1, 1, 0.090, 0.010, grfilter.firdes.WIN_HAMMING) # Frequency translating FIR filter decimating by 5 self.freq_xlating_fir_filter_ccc = \ grfilter.freq_xlating_fir_filter_ccc(decims[0], low_pass_filter_taps_0, self.center_freq, samp_rate) # FIR filter decimating by 5 fir_filter_ccc_0 = grfilter.fir_filter_ccc(decims[0], low_pass_filter_taps_0) # Low pass filter taps for decimation from samp_rate/25 to 40-79.9 ksps # In other words, decimation by int(samp_rate/1E6) # 12.5 kHz cutoff for NBFM channel bandwidth low_pass_filter_taps_1 = grfilter.firdes_low_pass( 1, samp_rate/decims[0]**2, 12.5E3, 1E3, grfilter.firdes.WIN_HAMMING) # FIR filter decimation by int(samp_rate/1E6) fir_filter_ccc_1 = grfilter.fir_filter_ccc(decims[1], low_pass_filter_taps_1) # Non blocking power squelch self.analog_pwr_squelch_cc = analog.pwr_squelch_cc(squelch_db, 1e-1, 0, False) # Quadrature demod with gain set for decent audio # The gain will be later multiplied by the 0 dB normalized volume self.analog_quadrature_demod_cf = \ analog.quadrature_demod_cf(self.quad_demod_gain) # 3.5 kHz cutoff for audio bandwidth low_pass_filter_taps_2 = grfilter.firdes_low_pass(1,\ samp_rate/(decims[1] * decims[0]**2),\ 3.5E3, 500, grfilter.firdes.WIN_HAMMING) # FIR filter decimating by 5 from 40-79.9 ksps to 8-15.98 ksps fir_filter_fff_0 = grfilter.fir_filter_fff(decims[0], low_pass_filter_taps_2) # Polyphase resampler allows arbitary RF sample rates # Takes 8-15.98 ksps to a constant 8 ksps for audio pfb_resamp = audio_rate/float(samp_rate/(decims[1] * decims[0]**3)) pfb_arb_resampler_fff = pfb.arb_resampler_fff(pfb_resamp, taps=None, flt_size=32) # Connect the blocks for the demod self.connect(self, self.freq_xlating_fir_filter_ccc) self.connect(self.freq_xlating_fir_filter_ccc, fir_filter_ccc_0) self.connect(fir_filter_ccc_0, fir_filter_ccc_1) self.connect(fir_filter_ccc_1, self.analog_pwr_squelch_cc) self.connect(self.analog_pwr_squelch_cc, self.analog_quadrature_demod_cf) self.connect(self.analog_quadrature_demod_cf, fir_filter_fff_0) self.connect(fir_filter_fff_0, pfb_arb_resampler_fff) self.connect(pfb_arb_resampler_fff, self) # Need to set this to a very low value of -200 since it is after demod # Only want it to gate when the previuos squelch has gone to zero analog_pwr_squelch_ff = analog.pwr_squelch_ff(-200, 1e-1, 0, True) # File sink with single channel and 8 bits/sample self.blocks_wavfile_sink = blocks.wavfile_sink(self.file_name, 1, audio_rate, 8) # Connect the blocks for recording self.connect(pfb_arb_resampler_fff, analog_pwr_squelch_ff) self.connect(analog_pwr_squelch_ff, self.blocks_wavfile_sink)
def __init__(self, samp_rate=4E6, audio_rate=8000, record=True): gr.hier_block2.__init__(self, "TunerDemod", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_float)) # Default values self.center_freq = 0 squelch_db = -60 self.quad_demod_gain = 0.050 self.file_name = "/dev/null" self.record = record # Decimation values for four stages of decimation decims = (5, int(samp_rate / 1E6)) # Low pass filter taps for decimation by 5 low_pass_filter_taps_0 = \ grfilter.firdes_low_pass(1, 1, 0.090, 0.010, grfilter.firdes.WIN_HAMMING) # Frequency translating FIR filter decimating by 5 self.freq_xlating_fir_filter_ccc = \ grfilter.freq_xlating_fir_filter_ccc(decims[0], low_pass_filter_taps_0, self.center_freq, samp_rate) # FIR filter decimating by 5 fir_filter_ccc_0 = grfilter.fir_filter_ccc(decims[0], low_pass_filter_taps_0) # Low pass filter taps for decimation from samp_rate/25 to 40-79.9 ksps # In other words, decimation by int(samp_rate/1E6) # 12.5 kHz cutoff for NBFM channel bandwidth low_pass_filter_taps_1 = grfilter.firdes_low_pass( 1, samp_rate / decims[0]**2, 12.5E3, 1E3, grfilter.firdes.WIN_HAMMING) # FIR filter decimation by int(samp_rate/1E6) fir_filter_ccc_1 = grfilter.fir_filter_ccc(decims[1], low_pass_filter_taps_1) # Non blocking power squelch self.analog_pwr_squelch_cc = analog.pwr_squelch_cc( squelch_db, 1e-1, 0, False) # Quadrature demod with gain set for decent audio # This will be later multiplied by the volume self.analog_quadrature_demod_cf = \ analog.quadrature_demod_cf(self.quad_demod_gain) # 3.5 kHz cutoff for audio bandwidth low_pass_filter_taps_2 = grfilter.firdes_low_pass(1,\ samp_rate/(decims[1] * decims[0]**2),\ 3.5E3, 500, grfilter.firdes.WIN_HAMMING) # FIR filter decimating by 5 from 40-79.9 ksps to 8-15.98 ksps fir_filter_fff_0 = grfilter.fir_filter_fff(decims[0], low_pass_filter_taps_2) # Polyphase resampler allows arbitary RF sample rates # Takes 8-15.98 ksps to a constant 8 ksps for audio pfb_resamp = audio_rate / float(samp_rate / (decims[1] * decims[0]**3)) pfb_arb_resampler_fff = pfb.arb_resampler_fff(pfb_resamp, taps=None, flt_size=32) # Connect the blocks for the demod self.connect(self, self.freq_xlating_fir_filter_ccc) self.connect(self.freq_xlating_fir_filter_ccc, fir_filter_ccc_0) self.connect(fir_filter_ccc_0, fir_filter_ccc_1) self.connect(fir_filter_ccc_1, self.analog_pwr_squelch_cc) self.connect(self.analog_pwr_squelch_cc, self.analog_quadrature_demod_cf) self.connect(self.analog_quadrature_demod_cf, fir_filter_fff_0) self.connect(fir_filter_fff_0, pfb_arb_resampler_fff) self.connect(pfb_arb_resampler_fff, self) # Need to set this to a very low value of -200 since it is after demod # Only want it to gate when the previuos squelch has gone to zero analog_pwr_squelch_ff = analog.pwr_squelch_ff(-200, 1e-1, 0, True) # File sink with single channel and 8 bits/sample self.blocks_wavfile_sink = blocks.wavfile_sink(self.file_name, 1, audio_rate, 8) # Connect the blocks for recording self.connect(pfb_arb_resampler_fff, analog_pwr_squelch_ff) self.connect(analog_pwr_squelch_ff, self.blocks_wavfile_sink)
def __init__(self): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.audio_rate = audio_rate = int(48e3) self.rtl_rate = rtl_rate = int(240e3) self.out_intermediary_rate = out_intermediary_rate = audio_rate*4 self.out_gain = out_gain = .25 self.out_frequency_offset = out_frequency_offset = -50e3 self.out_frequency = out_frequency = 145.521e6 self.out_audio_inverted = out_audio_inverted = True self.in_frequency_offset = in_frequency_offset = 0 self.in_frequency = in_frequency = 145.551e6 self.in_final_gain = in_final_gain = 0.5 self.in_decimation_factor = in_decimation_factor = 8 self.in_audio_inverted = in_audio_inverted = True self.hackrf_rate = hackrf_rate = 2e6 self.dstar_bandwidth = dstar_bandwidth = 6.5e3 ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(rtl_rate) self.rtlsdr_source_0.set_center_freq(in_frequency+in_frequency_offset, 0) self.rtlsdr_source_0.set_freq_corr(69, 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.rational_resampler_xxx_3 = filter.rational_resampler_ccc( interpolation=int(hackrf_rate), decimation=out_intermediary_rate, taps=None, fractional_bw=None, ) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" ) self.osmosdr_sink_0.set_sample_rate(hackrf_rate) self.osmosdr_sink_0.set_center_freq(out_frequency-out_frequency_offset, 0) self.osmosdr_sink_0.set_freq_corr(4, 0) self.osmosdr_sink_0.set_gain(14, 0) self.osmosdr_sink_0.set_if_gain(0, 0) self.osmosdr_sink_0.set_bb_gain(0, 0) self.osmosdr_sink_0.set_antenna("0", 0) self.osmosdr_sink_0.set_bandwidth(100e3, 0) self.low_pass_filter_1 = filter.fir_filter_ccf(5, firdes.low_pass( 1, rtl_rate, dstar_bandwidth*2, 500, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, audio_rate, dstar_bandwidth*2, 200, firdes.WIN_KAISER, 6.76)) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(1, (1, ), 0-out_frequency_offset, out_intermediary_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.dc_blocker_xx_0 = filter.dc_blocker_ff(128, True) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff(((-1 if out_audio_inverted else 1)*out_gain, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((0-in_final_gain if in_audio_inverted else in_final_gain, )) self.audio_source_0 = audio.source(audio_rate, "hw:10,1", True) self.audio_sink_1 = audio.sink(audio_rate, "plughw:11,0", True) self.analog_pwr_squelch_xx_1 = analog.pwr_squelch_cc(-30, 1, 1, False) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_ff(-60, 1, 1, True) self.analog_nbfm_tx_0 = analog.nbfm_tx( audio_rate=int(audio_rate), quad_rate=int(out_intermediary_rate), tau=0, max_dev=dstar_bandwidth, ) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=audio_rate, quad_rate=audio_rate, tau=0.000000000000000000001, max_dev=dstar_bandwidth*2, ) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.analog_nbfm_tx_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.analog_pwr_squelch_xx_1, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.audio_source_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.audio_sink_1, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.low_pass_filter_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.rational_resampler_xxx_3, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_nbfm_tx_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.analog_pwr_squelch_xx_1, 0)) self.connect((self.rational_resampler_xxx_3, 0), (self.osmosdr_sink_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_1, 0))
def __init__(self): gr.top_block.__init__(self, "Lang Rx") ################################################## # Variables ################################################## plutoip = os.environ.get('PLUTO_IP') if plutoip == None: plutoip = 'pluto.local' plutoip = 'ip:' + plutoip self.SQL = SQL = 50 self.RxOffset = RxOffset = 0 self.Mute = Mute = False self.Mode = Mode = 3 self.Filt_Low = Filt_Low = 300 self.Filt_High = Filt_High = 3000 self.FFTEn = FFTEn = 0 self.AFGain = AFGain = 20 ################################################## # Blocks ################################################## self.pluto_source_0 = iio.pluto_source(plutoip, 1000000000, 528000, 2000000, 0x800, True, True, True, "slow_attack", 64.0, '', True) self.logpwrfft_x_0 = logpwrfft.logpwrfft_c( sample_rate=48000, fft_size=512, ref_scale=2, frame_rate=15, avg_alpha=0.9, average=True, ) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 11, (firdes.low_pass(1, 529200, 23000, 2000)), RxOffset, 528000) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_float * 512, '127.0.0.1', 7373, 1472, False) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 512) self.blocks_multiply_const_vxx_2_1_0 = blocks.multiply_const_vff( (1.0 + (Mode == 5), )) self.blocks_multiply_const_vxx_2_1 = blocks.multiply_const_vff( (Mode == 5, )) self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vff( ((Mode == 4) * 0.2, )) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff( (Mode < 4, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff( ((AFGain / 100.0) * (not Mute), )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_add_xx_1_0 = blocks.add_vff(1) self.blocks_add_xx_1 = blocks.add_vff(1) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_float * 512, num_inputs=1, num_outputs=2, input_index=0, output_index=FFTEn, ) self.band_pass_filter_0 = filter.fir_filter_ccc( 1, firdes.complex_band_pass(1, 48000, Filt_Low, Filt_High, 100, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0 = audio.sink(48000, "hw:CARD=Device,DEV=0", False) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc( SQL - 100, 0.001, 0, False) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=48000, quad_rate=48000, tau=75e-6, max_dev=5e3, ) self.analog_agc3_xx_0 = analog.agc3_cc(1e-2, 5e-7, 0.1, 1.0, 1) self.analog_agc3_xx_0.set_max_gain(1000) ################################################## # Connections ################################################## self.connect((self.analog_agc3_xx_0, 0), (self.blocks_complex_to_real_0_0, 0)) self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_2_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blks2_selector_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blks2_selector_0, 1), (self.blocks_udp_sink_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_add_xx_1_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_multiply_const_vxx_2_1, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.blocks_complex_to_real_0_0, 0), (self.blocks_multiply_const_vxx_2_1_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.analog_agc3_xx_0, 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, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_multiply_const_vxx_2_1, 0), (self.blocks_add_xx_1_0, 1)) self.connect((self.blocks_multiply_const_vxx_2_1_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.logpwrfft_x_0, 0)) self.connect((self.logpwrfft_x_0, 0), (self.blks2_selector_0, 0)) self.connect((self.pluto_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Lab 4 1") _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 = 250e3 self.gain = gain = 40 self.freq = freq = 98e6 self.deviation = deviation = 30e3*0 + 5e3 self.audio_rate = audio_rate = int(48e3) ################################################## # Blocks ################################################## self._samp_rate_text_box = forms.text_box( parent=self.GetWin(), value=self.samp_rate, callback=self.set_samp_rate, label="Sample Rate", converter=forms.float_converter(), ) self.Add(self._samp_rate_text_box) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="Gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=90, num_steps=90, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_gain_sizer) self._freq_text_box = forms.text_box( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Frequency", converter=forms.float_converter(), ) self.Add(self._freq_text_box) self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=audio_rate, v_scale=0.25, 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.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna('TX/RX', 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=audio_rate, decimation=int(samp_rate), taps=None, fractional_bw=None, ) self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, audio_rate, 3.5e3, 0.5e3, firdes.WIN_HAMMING, 6.76)) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.audio_sink_0 = audio.sink(audio_rate, "", True) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf((audio_rate/(2*math.pi*deviation))* 0 + ((2*math.pi*deviation)/audio_rate)) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-80, 1e-3, 0, False) ################################################## # Connections ################################################## self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.audio_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.rational_resampler_xxx_0, 0))
def __init__(self, samp_rate=4E6, audio_rate=8000, record=True): gr.hier_block2.__init__(self, "TunerDemodAM", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_float)) # Default values self.center_freq = 0 squelch_db = -60 self.agc_ref = 0.1 self.file_name = "/dev/null" self.record = record # Decimation values for four stages of decimation decims = (5, int(samp_rate/1E6)) # Low pass filter taps for decimation by 5 low_pass_filter_taps_0 = \ grfilter.firdes_low_pass(1, 1, 0.090, 0.010, grfilter.firdes.WIN_HAMMING) # Frequency translating FIR filter decimating by 5 self.freq_xlating_fir_filter_ccc = \ grfilter.freq_xlating_fir_filter_ccc(decims[0], low_pass_filter_taps_0, self.center_freq, samp_rate) # FIR filter decimating by 5 fir_filter_ccc_0 = grfilter.fir_filter_ccc(decims[0], low_pass_filter_taps_0) # Low pass filter taps for decimation from samp_rate/25 to 40-79.9 ksps # In other words, decimation by int(samp_rate/1E6) # 12.5 kHz cutoff for NBFM channel bandwidth low_pass_filter_taps_1 = grfilter.firdes_low_pass( 1, samp_rate/decims[0]**2, 12.5E3, 1E3, grfilter.firdes.WIN_HAMMING) # FIR filter decimation by int(samp_rate/1E6) fir_filter_ccc_1 = grfilter.fir_filter_ccc(decims[1], low_pass_filter_taps_1) # Non blocking power squelch # Squelch level needs to be lower than NBFM or else choppy AM demod self.analog_pwr_squelch_cc = analog.pwr_squelch_cc(squelch_db, 1e-1, 0, False) # AGC with reference set for nomninal 0 dB volume # Paramaters tweaked to prevent impulse during squelching self.agc3_cc = analog.agc3_cc(1.0, 1E-4, self.agc_ref, 10, 1) self.agc3_cc.set_max_gain(65536) # AM demod with complex_to_mag() # Can't use analog.am_demod_cf() since it won't work with N>2 demods am_demod_cf = blocks.complex_to_mag(1) # 3.5 kHz cutoff for audio bandwidth low_pass_filter_taps_2 = grfilter.firdes_low_pass(1,\ samp_rate/(decims[1] * decims[0]**2),\ 3.5E3, 500, grfilter.firdes.WIN_HAMMING) # FIR filter decimating by 5 from 40-79.9 ksps to 8-15.98 ksps fir_filter_fff_0 = grfilter.fir_filter_fff(decims[0], low_pass_filter_taps_2) # Polyphase resampler allows arbitary RF sample rates # Takes 8-15.98 ksps to a constant 8 ksps for audio pfb_resamp = audio_rate/float(samp_rate/(decims[1] * decims[0]**3)) pfb_arb_resampler_fff = pfb.arb_resampler_fff(pfb_resamp, taps=None, flt_size=32) # Connect the blocks for the demod self.connect(self, self.freq_xlating_fir_filter_ccc) self.connect(self.freq_xlating_fir_filter_ccc, fir_filter_ccc_0) self.connect(fir_filter_ccc_0, fir_filter_ccc_1) self.connect(fir_filter_ccc_1, self.analog_pwr_squelch_cc) self.connect(self.analog_pwr_squelch_cc, self.agc3_cc) self.connect(self.agc3_cc, am_demod_cf) self.connect(am_demod_cf, fir_filter_fff_0) self.connect(fir_filter_fff_0, pfb_arb_resampler_fff) self.connect(pfb_arb_resampler_fff, self) # Need to set this to a very low value of -200 since it is after demod # Only want it to gate when the previuos squelch has gone to zero analog_pwr_squelch_ff = analog.pwr_squelch_ff(-200, 1e-1, 0, True) # File sink with single channel and 8 bits/sample self.blocks_wavfile_sink = blocks.wavfile_sink(self.file_name, 1, audio_rate, 8) # Connect the blocks for recording self.connect(pfb_arb_resampler_fff, analog_pwr_squelch_ff) self.connect(analog_pwr_squelch_ff, self.blocks_wavfile_sink)
def __init__(self): gr.top_block.__init__(self, "Ham2Mon NBFM Receiver Flow Example") Qt.QWidget.__init__(self) self.setWindowTitle("Ham2Mon NBFM Receiver Flow Example") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "nbfm_flow_example") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1E6 self.initial_decim = initial_decim = 5 self.samp_ratio = samp_ratio = samp_rate/1E6 self.final_rate = final_rate = samp_rate/initial_decim**2/int(samp_rate/1E6) self.variable_low_pass_filter_taps_2 = variable_low_pass_filter_taps_2 = firdes.low_pass(1.0, final_rate, 3500, 500, firdes.WIN_HAMMING, 6.76) self.variable_low_pass_filter_taps_1 = variable_low_pass_filter_taps_1 = firdes.low_pass(1.0, samp_rate/25, 12.5E3, 1E3, firdes.WIN_HAMMING, 6.76) self.variable_low_pass_filter_taps_0 = variable_low_pass_filter_taps_0 = firdes.low_pass(1.0, 1, 0.090, 0.010, firdes.WIN_HAMMING, 6.76) self.squelch_dB = squelch_dB = -70 self.gain_db = gain_db = 30 self.final_decim = final_decim = int(samp_rate/1E6) self.file_name = file_name = "test.wav" self.fft_length = fft_length = 256 * int(pow(2, np.ceil(np.log(samp_ratio)/np.log(2)))) self.demod_bb_freq = demod_bb_freq = 390E3 self.center_freq = center_freq = 144E6 ################################################## # Blocks ################################################## self._squelch_dB_range = Range(-100, 0, 5, -70, 200) self._squelch_dB_win = RangeWidget(self._squelch_dB_range, self.set_squelch_dB, "Squelch (dB)", "counter_slider", float) self.top_grid_layout.addWidget(self._squelch_dB_win, 5,1,1,3) self._gain_db_range = Range(0, 70, 1, 30, 200) self._gain_db_win = RangeWidget(self._gain_db_range, self.set_gain_db, "HW Gain (dB)", "counter_slider", float) self.top_grid_layout.addWidget(self._gain_db_win, 4,1,1,3) self._demod_bb_freq_range = Range(-samp_rate/2, samp_rate/2, 5E3, 390E3, 200) self._demod_bb_freq_win = RangeWidget(self._demod_bb_freq_range, self.set_demod_bb_freq, "Demod BB Freq (Hz)", "counter_slider", float) self.top_grid_layout.addWidget(self._demod_bb_freq_win, 3,1,1,3) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( fft_length, #size samp_rate, #samp_rate "Averaged Spectrum", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-60, 40) self.qtgui_time_sink_x_0.set_y_label("Power", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(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, 0,1,3,1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc final_rate, #bw "Decimated Channel", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-200, -60) self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 3,0,3,1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( fft_length, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 144E6, #fc samp_rate, #bw "Spectrum", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-120, -20) 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 == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0,0,3,1) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff( 16E3/float(final_rate/5), taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "uhd" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(center_freq, 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_db, 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(samp_rate*0.8, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(initial_decim, (variable_low_pass_filter_taps_0), demod_bb_freq, samp_rate) self.fir_filter_xxx_0_1 = filter.fir_filter_fff(initial_decim, (variable_low_pass_filter_taps_0)) self.fir_filter_xxx_0_1.declare_sample_delay(0) self.fir_filter_xxx_0_0 = filter.fir_filter_ccc(int(samp_rate/1E6), (variable_low_pass_filter_taps_0)) self.fir_filter_xxx_0_0.declare_sample_delay(0) self.fir_filter_xxx_0 = filter.fir_filter_ccc(initial_decim, (variable_low_pass_filter_taps_0)) self.fir_filter_xxx_0.declare_sample_delay(0) self.fft_vxx_0 = fft.fft_vcc(fft_length, True, (window.blackmanharris(fft_length)), True, 1) self.blocks_wavfile_sink_0 = blocks.wavfile_sink(file_name, 1, 16000, 8) self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, fft_length) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_length) self.blocks_probe_signal_vx_0 = blocks.probe_signal_vf(fft_length) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, fft_length, 0) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_gr_complex*fft_length, int(round(samp_rate/fft_length/1000))) self.blocks_integrate_xx_0 = blocks.integrate_ff(100, fft_length) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(fft_length) self.audio_sink_0 = audio.sink(16000, "", True) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(0.050) self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_ff(-200, 0.1, 0, True) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(squelch_dB, 0.1, 0, False) ################################################## # Connections ################################################## self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.fir_filter_xxx_0_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_integrate_xx_0, 0)) self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_probe_signal_vx_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.fir_filter_xxx_0_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.fir_filter_xxx_0_1, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.analog_pwr_squelch_xx_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.audio_sink_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="APRS Receiver") ################################################## # Variables ################################################## self.space = space = 1200 self.mark = mark = 2200 self.xlate_decim = xlate_decim = 8 self.xlate_bandwidth = xlate_bandwidth = 1200*6 self.sym_dev = sym_dev = (mark-space)/2 self.samp_rate = samp_rate = 1e6 self.quad_rate = quad_rate = 96000 self.gain = gain = 10 self.freq_offset = freq_offset = 390e3 self.freq = freq = 144e6 self.baud = baud = 1200 self.audio_rate = audio_rate = 48000 self.audio_mul = audio_mul = 1 self.aprs_rate = aprs_rate = 12000 self.ant = ant = 'TX/RX' ################################################## # Message Queues ################################################## ax25_hdlc_framer_b_0_msgq_out = ax25_print_frame_0_msgq_in = gr.msg_queue(2) ################################################## # Blocks ################################################## self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "Baseband") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Waterfall") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Signal") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Slicer") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Eye") self.Add(self.nb) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="RF Gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=50, num_steps=50, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_gain_sizer) _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=-500e3, maximum=500e3, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_offset_sizer) self._freq_text_box = forms.text_box( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Freq", converter=forms.float_converter(), ) self.Add(self._freq_text_box) _audio_mul_sizer = wx.BoxSizer(wx.VERTICAL) self._audio_mul_text_box = forms.text_box( parent=self.GetWin(), sizer=_audio_mul_sizer, value=self.audio_mul, callback=self.set_audio_mul, label="Audio", converter=forms.float_converter(), proportion=0, ) self._audio_mul_slider = forms.slider( parent=self.GetWin(), sizer=_audio_mul_sizer, value=self.audio_mul, callback=self.set_audio_mul, minimum=0, maximum=10, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_audio_mul_sizer) self._ant_chooser = forms.drop_down( parent=self.GetWin(), value=self.ant, callback=self.set_ant, label="Antenna", choices=['TX/RX', 'RX2'], labels=[], ) self.Add(self._ant_chooser) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(1).GetWin(), baseband_freq=0, dynamic_range=50, ref_level=-65, ref_scale=2.0, sample_rate=aprs_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.nb.GetPage(1).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_0_0_0 = scopesink2.scope_sink_f( self.nb.GetPage(4).GetWin(), title="Scope Plot", sample_rate=aprs_rate/10, v_scale=0.5, v_offset=0, t_scale=0.002, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(4).Add(self.wxgui_scopesink2_0_0_0.win) self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_f( self.nb.GetPage(3).GetWin(), title="Scope Plot", sample_rate=aprs_rate, v_scale=0.5, v_offset=0, t_scale=0.002, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(3).Add(self.wxgui_scopesink2_0_0.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.nb.GetPage(2).GetWin(), title="Scope Plot", sample_rate=aprs_rate, v_scale=0.05, v_offset=0, t_scale=0.002, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(2).Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=-20, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.5, title="FFT Plot", peak_hold=False, ) self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win) def wxgui_fftsink2_0_callback(x, y): self.set_freq_offset(x) self.wxgui_fftsink2_0.set_callback(wxgui_fftsink2_0_callback) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna(ant, 0) self.low_pass_filter_0 = gr.fir_filter_ccf(1, firdes.low_pass( 1, aprs_rate, 2e3, 600, firdes.WIN_HAMMING, 6.76)) self.gr_single_pole_iir_filter_xx_0 = gr.single_pole_iir_filter_ff(0.0001, 1) self.gr_null_sink_0 = gr.null_sink(gr.sizeof_float*1) self.gr_multiply_xx_0 = gr.multiply_vcc(1) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((audio_mul, )) self.gr_agc_xx_1 = gr.agc_ff(1e-3, 0.8, 0.1, 10.0) 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)), freq_offset, samp_rate) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(10, .25 * (0.05)**2, 0.5, 0.005, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blks2_rational_resampler_xxx_0_0 = blks2.rational_resampler_ccc( interpolation=quad_rate, decimation=int(samp_rate/xlate_decim), taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=aprs_rate, decimation=quad_rate, taps=None, fractional_bw=None, ) self.blks2_nbfm_rx_0_0 = blks2.nbfm_rx( audio_rate=audio_rate, quad_rate=quad_rate, tau=75e-6, max_dev=25000, ) self.blks2_nbfm_rx_0 = blks2.nbfm_rx( audio_rate=aprs_rate, quad_rate=quad_rate, tau=75e-6, max_dev=3e3, ) self.ax25_print_frame_0 = packetradio.queue_watcher_thread(ax25_print_frame_0_msgq_in) self.ax25_hdlc_framer_b_0 = packetradio.hdlc_framer(ax25_hdlc_framer_b_0_msgq_out, False) self.analog_sig_source_x_0 = analog.sig_source_c(aprs_rate, analog.GR_SIN_WAVE, -(min(mark,space)+sym_dev), 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(aprs_rate/(2*math.pi*sym_dev)) self.analog_pwr_squelch_xx_0_0_0 = analog.pwr_squelch_cc(-70, 1e-1, 0, False) self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc(-70, 1e-1, 0, False) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blks2_rational_resampler_xxx_0_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.gr_single_pole_iir_filter_xx_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.gr_single_pole_iir_filter_xx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.blks2_nbfm_rx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blks2_nbfm_rx_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.wxgui_scopesink2_0_0_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.ax25_hdlc_framer_b_0, 0)) self.connect((self.blks2_nbfm_rx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0_0, 0), (self.analog_pwr_squelch_xx_0_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_0_0, 0), (self.blks2_nbfm_rx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0_0, 0), (self.analog_pwr_squelch_xx_0_0_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.wxgui_scopesink2_0_0, 0)) self.connect((self.blks2_nbfm_rx_0_0, 0), (self.gr_agc_xx_1, 0)) self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.blks2_nbfm_rx_0_0, 0)) self.connect((self.gr_agc_xx_1, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_null_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Ham2Mon Receiver Flow Example") Qt.QWidget.__init__(self) self.setWindowTitle("Ham2Mon Receiver Flow Example") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "flow_example") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1E6 self.initial_decim = initial_decim = 5 self.samp_ratio = samp_ratio = samp_rate / 1E6 self.final_rate = final_rate = samp_rate / initial_decim**2 / int( samp_rate / 1E6) self.variable_low_pass_filter_taps_2 = variable_low_pass_filter_taps_2 = firdes.low_pass( 1.0, final_rate, 3500, 500, firdes.WIN_HAMMING, 6.76) self.variable_low_pass_filter_taps_1 = variable_low_pass_filter_taps_1 = firdes.low_pass( 1.0, samp_rate / 25, 12.5E3, 1E3, firdes.WIN_HAMMING, 6.76) self.variable_low_pass_filter_taps_0 = variable_low_pass_filter_taps_0 = firdes.low_pass( 1.0, 1, 0.090, 0.010, firdes.WIN_HAMMING, 6.76) self.squelch_dB = squelch_dB = -70 self.gain_db = gain_db = 30 self.final_decim = final_decim = int(samp_rate / 1E6) self.file_name = file_name = "test.wav" self.fft_length = fft_length = 256 * int( pow(2, np.ceil(np.log(samp_ratio) / np.log(2)))) self.demod_bb_freq = demod_bb_freq = 390E3 self.center_freq = center_freq = 144E6 ################################################## # Blocks ################################################## self._squelch_dB_range = Range(-100, 0, 5, -70, 200) self._squelch_dB_win = RangeWidget(self._squelch_dB_range, self.set_squelch_dB, "Squelch (dB)", "counter_slider", float) self.top_grid_layout.addWidget(self._squelch_dB_win, 5, 1, 1, 3) self._gain_db_range = Range(0, 70, 1, 30, 200) self._gain_db_win = RangeWidget(self._gain_db_range, self.set_gain_db, "HW Gain (dB)", "counter_slider", float) self.top_grid_layout.addWidget(self._gain_db_win, 4, 1, 1, 3) self._demod_bb_freq_range = Range(-samp_rate / 2, samp_rate / 2, 5E3, 390E3, 200) self._demod_bb_freq_win = RangeWidget(self._demod_bb_freq_range, self.set_demod_bb_freq, "Demod BB Freq (Hz)", "counter_slider", float) self.top_grid_layout.addWidget(self._demod_bb_freq_win, 3, 1, 1, 3) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( fft_length, #size samp_rate, #samp_rate "Averaged Spectrum", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-60, 40) self.qtgui_time_sink_x_0.set_y_label("Power", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(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, 0, 1, 3, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc final_rate, #bw "Decimated Channel", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-200, -60) self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 3, 0, 3, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( fft_length, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 144E6, #fc samp_rate, #bw "Spectrum", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-120, -20) 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 == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 3, 1) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff( 16E3 / float(final_rate / 5), taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "uhd") self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(center_freq, 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_db, 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(samp_rate * 0.8, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( initial_decim, (variable_low_pass_filter_taps_0), demod_bb_freq, samp_rate) self.fir_filter_xxx_0_1 = filter.fir_filter_fff( initial_decim, (variable_low_pass_filter_taps_0)) self.fir_filter_xxx_0_1.declare_sample_delay(0) self.fir_filter_xxx_0_0 = filter.fir_filter_ccc( int(samp_rate / 1E6), (variable_low_pass_filter_taps_0)) self.fir_filter_xxx_0_0.declare_sample_delay(0) self.fir_filter_xxx_0 = filter.fir_filter_ccc( initial_decim, (variable_low_pass_filter_taps_0)) self.fir_filter_xxx_0.declare_sample_delay(0) self.fft_vxx_0 = fft.fft_vcc(fft_length, True, (window.blackmanharris(fft_length)), True, 1) self.blocks_wavfile_sink_0 = blocks.wavfile_sink( file_name, 1, 16000, 8) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_float * 1, fft_length) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, fft_length) self.blocks_probe_signal_vx_0 = blocks.probe_signal_vf(fft_length) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, fft_length, 0) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_gr_complex * fft_length, int(round(samp_rate / fft_length / 1000))) self.blocks_integrate_xx_0 = blocks.integrate_ff(100, fft_length) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared( fft_length) self.audio_sink_0 = audio.sink(16000, "", True) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(0.050) self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_ff( -200, 0.1, 0, True) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc( squelch_dB, 0.1, 0, False) ################################################## # Connections ################################################## self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.fir_filter_xxx_0_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_integrate_xx_0, 0)) self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_probe_signal_vx_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.fir_filter_xxx_0_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.fir_filter_xxx_0_1, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.analog_pwr_squelch_xx_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.audio_sink_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="NBFM Receiver/Deviation Meter") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.volume = volume = .4 self.thresh = thresh = -24 self.samp_rate = samp_rate = 2.40e6 self.ramp = ramp = 1 self.alpha = alpha = .01 self.RF_Gain = RF_Gain = 50 self.Freq = Freq = 144.39 ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=0, maximum=3, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_volume_sizer, 1, 1, 1, 1) _thresh_sizer = wx.BoxSizer(wx.VERTICAL) self._thresh_text_box = forms.text_box( parent=self.GetWin(), sizer=_thresh_sizer, value=self.thresh, callback=self.set_thresh, label="Squelch", converter=forms.float_converter(), proportion=0, ) self._thresh_slider = forms.slider( parent=self.GetWin(), sizer=_thresh_sizer, value=self.thresh, callback=self.set_thresh, minimum=-70, maximum=0, num_steps=70, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_thresh_sizer, 2, 1, 1, 1) self._ramp_text_box = forms.text_box( parent=self.GetWin(), value=self.ramp, callback=self.set_ramp, label="Ramp", converter=forms.float_converter(), ) self.GridAdd(self._ramp_text_box, 3, 0, 1, 1) self._alpha_text_box = forms.text_box( parent=self.GetWin(), value=self.alpha, callback=self.set_alpha, label="alpha", converter=forms.float_converter(), ) self.GridAdd(self._alpha_text_box, 3, 1, 1, 1) _RF_Gain_sizer = wx.BoxSizer(wx.VERTICAL) self._RF_Gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_RF_Gain_sizer, value=self.RF_Gain, callback=self.set_RF_Gain, label="RF Gain", converter=forms.float_converter(), proportion=0, ) self._RF_Gain_slider = forms.slider( parent=self.GetWin(), sizer=_RF_Gain_sizer, value=self.RF_Gain, callback=self.set_RF_Gain, minimum=0, maximum=50, num_steps=50, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_RF_Gain_sizer, 2, 0, 1, 1) self._Freq_text_box = forms.text_box( parent=self.GetWin(), value=self.Freq, callback=self.set_Freq, label="Frequency (MHz)", converter=forms.float_converter(), ) self.GridAdd(self._Freq_text_box, 1, 0, 1, 1) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=48000, v_scale=2, v_offset=0, t_scale=2e-3, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="KHz Deviation", ) self.GridAdd(self.wxgui_scopesink2_0.win, 0, 0, 1, 1) self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(38.55e-3, 1) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(Freq*1e6, 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(0, 0) self.rtlsdr_source_0.set_gain(RF_Gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(1, 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(50, firdes.low_pass( 1, samp_rate, 7.5e3, 3e3, firdes.WIN_HAMMING, 6.76)) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((6.5, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, )) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(thresh, alpha, ramp, False) self.analog_fm_demod_cf_0 = analog.fm_demod_cf( channel_rate=48000, audio_decim=1, deviation=10000, audio_pass=3500, audio_stop=4000,gnu gain=1.0, tau=1e-6, ) ################################################## # Connections ################################################## self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_fm_demod_cf_0, 0)) self.connect((self.analog_fm_demod_cf_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.analog_fm_demod_cf_0, 0), (self.single_pole_iir_filter_xx_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Multimon Flex Rtl 0") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2.4e6 self.channel_1 = channel_1 = 929.65e6 self.channel_0 = channel_0 = 929.6e6 self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76) self.sqlch = sqlch = -50 self.if_gain = if_gain = -14 self.gain = gain = 50 self.firdes_tap = firdes_tap = firdes.low_pass(1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76) self.corr = corr = -14 self.center_freq_0 = center_freq_0 = sum([channel_0, channel_1] ) / float(len([channel_0, channel_1])) self.bb_gain = bb_gain = 40 ################################################## # Blocks ################################################## self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + 'rtl=0' ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(center_freq_0 - 100000, 0) self.osmosdr_source_0.set_freq_corr(corr, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(gain, 0) self.osmosdr_source_0.set_if_gain(if_gain, 0) self.osmosdr_source_0.set_bb_gain(bb_gain, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 48e3, 6.5e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 48e3, 6.5e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(int(samp_rate / 48000), (firdes_tap), channel_1 - center_freq_0, samp_rate) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(int(samp_rate / 48000), (firdes_tap), channel_0 - center_freq_0, samp_rate) self.blocks_udp_sink_1 = blocks.udp_sink(gr.sizeof_short*1, '127.0.0.1', 7301, 1472, True) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short*1, '127.0.0.1', 7300, 1472, True) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0_2 = blocks.multiply_const_vff((0.1, )) self.blocks_multiply_const_vxx_0_0_1 = blocks.multiply_const_vff((0.1, )) self.blocks_float_to_short_0_1 = blocks.float_to_short(1, 32767) self.blocks_float_to_short_0_0 = blocks.float_to_short(1, 32767) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -100000, 1, 0) self.analog_pwr_squelch_xx_0_2 = analog.pwr_squelch_cc(sqlch, 1, 1, True) self.analog_pwr_squelch_xx_0_0_1 = analog.pwr_squelch_cc(sqlch, 1, 1, True) self.analog_nbfm_rx_0_0 = analog.nbfm_rx( audio_rate=48000, quad_rate=48000, tau=75e-6, max_dev=5000, ) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=48000, quad_rate=48000, tau=75e-6, max_dev=5000, ) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_0_2, 0)) self.connect((self.analog_nbfm_rx_0_0, 0), (self.blocks_multiply_const_vxx_0_0_1, 0)) self.connect((self.analog_pwr_squelch_xx_0_0_1, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_2, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_float_to_short_0_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.blocks_float_to_short_0_1, 0), (self.blocks_udp_sink_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_1, 0), (self.blocks_float_to_short_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.blocks_float_to_short_0_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_pwr_squelch_xx_0_2, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.analog_pwr_squelch_xx_0_0_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.analog_nbfm_rx_0_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "WBFM 2 Channel") Qt.QWidget.__init__(self) self.setWindowTitle("WBFM 2 Channel") 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", "wbfm_2ch") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.radio_freq = radio_freq = 100 self.samp_rate = samp_rate = 240e4 self.rf_gain = rf_gain = 10 self.freq = freq = radio_freq * 1000000 self.ch2volume = ch2volume = 5 self.ch2squelch = ch2squelch = -30 self.ch2mute = ch2mute = 1 self.ch2freq = ch2freq = radio_freq self.ch1volume = ch1volume = 5 self.ch1squelch = ch1squelch = -30 self.ch1mute = ch1mute = 1 self.ch1freq = ch1freq = radio_freq ################################################## # Blocks ################################################## self.ch2 = Qt.QTabWidget() self.ch2_widget_0 = Qt.QWidget() self.ch2_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.ch2_widget_0) self.ch2_grid_layout_0 = Qt.QGridLayout() self.ch2_layout_0.addLayout(self.ch2_grid_layout_0) self.ch2.addTab(self.ch2_widget_0, "Ch 2") self.top_grid_layout.addWidget(self.ch2, 2,1,1,1) self.ch1 = Qt.QTabWidget() self.ch1_widget_0 = Qt.QWidget() self.ch1_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.ch1_widget_0) self.ch1_grid_layout_0 = Qt.QGridLayout() self.ch1_layout_0.addLayout(self.ch1_grid_layout_0) self.ch1.addTab(self.ch1_widget_0, "Ch 1") self.top_grid_layout.addWidget(self.ch1, 2,0,1,1) self._rf_gain_range = Range(0, 50, 1, 10, 200) self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, "RF Gain", "counter_slider", float) self.top_grid_layout.addWidget(self._rf_gain_win, 1,0,1,2) self._ch2volume_range = Range(0, 10, 1, 5, 200) self._ch2volume_win = RangeWidget(self._ch2volume_range, self.set_ch2volume, "Ch2 Volume", "counter_slider", float) self.ch2_grid_layout_0.addWidget(self._ch2volume_win, 1,0,1,2) self._ch2squelch_range = Range(-70, 0, 10, -30, 200) self._ch2squelch_win = RangeWidget(self._ch2squelch_range, self.set_ch2squelch, "Ch2 Squelch", "counter_slider", int) self.ch2_grid_layout_0.addWidget(self._ch2squelch_win, 2,0,1,2) _ch2mute_check_box = Qt.QCheckBox("Mute") self._ch2mute_choices = {True: 0, False: 1} self._ch2mute_choices_inv = dict((v,k) for k,v in self._ch2mute_choices.iteritems()) self._ch2mute_callback = lambda i: Qt.QMetaObject.invokeMethod(_ch2mute_check_box, "setChecked", Qt.Q_ARG("bool", self._ch2mute_choices_inv[i])) self._ch2mute_callback(self.ch2mute) _ch2mute_check_box.stateChanged.connect(lambda i: self.set_ch2mute(self._ch2mute_choices[bool(i)])) self.ch2_grid_layout_0.addWidget(_ch2mute_check_box, 0,1,1,1) self._ch2freq_tool_bar = Qt.QToolBar(self) self._ch2freq_tool_bar.addWidget(Qt.QLabel("Ch2 Freq"+": ")) self._ch2freq_line_edit = Qt.QLineEdit(str(self.ch2freq)) self._ch2freq_tool_bar.addWidget(self._ch2freq_line_edit) self._ch2freq_line_edit.returnPressed.connect( lambda: self.set_ch2freq(eng_notation.str_to_num(str(self._ch2freq_line_edit.text().toAscii())))) self.ch2_grid_layout_0.addWidget(self._ch2freq_tool_bar, 0,0,1,1) self._ch1volume_range = Range(0, 10, 1, 5, 200) self._ch1volume_win = RangeWidget(self._ch1volume_range, self.set_ch1volume, "Ch1 Volume", "counter_slider", float) self.ch1_grid_layout_0.addWidget(self._ch1volume_win, 1,0,1,2) self._ch1squelch_range = Range(-70, 0, 10, -30, 200) self._ch1squelch_win = RangeWidget(self._ch1squelch_range, self.set_ch1squelch, "Ch1 Squelch", "counter_slider", int) self.ch1_grid_layout_0.addWidget(self._ch1squelch_win, 2,0,1,2) _ch1mute_check_box = Qt.QCheckBox("Mute") self._ch1mute_choices = {True: 0, False: 1} self._ch1mute_choices_inv = dict((v,k) for k,v in self._ch1mute_choices.iteritems()) self._ch1mute_callback = lambda i: Qt.QMetaObject.invokeMethod(_ch1mute_check_box, "setChecked", Qt.Q_ARG("bool", self._ch1mute_choices_inv[i])) self._ch1mute_callback(self.ch1mute) _ch1mute_check_box.stateChanged.connect(lambda i: self.set_ch1mute(self._ch1mute_choices[bool(i)])) self.ch1_grid_layout_0.addWidget(_ch1mute_check_box, 0,1,1,1) self._ch1freq_tool_bar = Qt.QToolBar(self) self._ch1freq_tool_bar.addWidget(Qt.QLabel("Ch1 Freq"+": ")) self._ch1freq_line_edit = Qt.QLineEdit(str(self.ch1freq)) self._ch1freq_tool_bar.addWidget(self._ch1freq_line_edit) self._ch1freq_line_edit.returnPressed.connect( lambda: self.set_ch1freq(eng_notation.str_to_num(str(self._ch1freq_line_edit.text().toAscii())))) self.ch1_grid_layout_0.addWidget(self._ch1freq_tool_bar, 0,0,1,1) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(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(rf_gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_2_0 = filter.rational_resampler_ccc( interpolation=400000, decimation=2400000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_2 = filter.rational_resampler_ccc( interpolation=400000, decimation=2400000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1_0 = filter.rational_resampler_fff( interpolation=48, decimation=50, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=48, decimation=50, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=500000, decimation=2400000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=500000, decimation=2400000, taps=None, fractional_bw=None, ) self._radio_freq_tool_bar = Qt.QToolBar(self) self._radio_freq_tool_bar.addWidget(Qt.QLabel("Frequency (MHz)"+": ")) self._radio_freq_line_edit = Qt.QLineEdit(str(self.radio_freq)) self._radio_freq_tool_bar.addWidget(self._radio_freq_line_edit) self._radio_freq_line_edit.returnPressed.connect( lambda: self.set_radio_freq(eng_notation.str_to_num(str(self._radio_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._radio_freq_tool_bar, 0,0,1,2) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #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 == type(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(-100, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 3,0,1,2) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype ch2freq, #fc 400000, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-100, 10) self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.ch2_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 3,0,1,2) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype ch1freq, #fc 400000, #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(-100, 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 False: self.qtgui_freq_sink_x_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.ch1_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 3,0,1,2) self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 500000, 100e3, 8000, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 500000, 100e3, 8000, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), (ch2freq * 1000000) - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), (ch1freq * 1000000) - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((ch2mute, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((ch1mute, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((ch2volume, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((ch1volume, )) self.audio_sink_0_0 = audio.sink(48000, "", True) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_wfm_rcv_0_0 = analog.wfm_rcv( quad_rate=500000, audio_decimation=10, ) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=500000, audio_decimation=10, ) self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc(ch2squelch, 1e-4, 0, True) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(ch1squelch, 1e-4, 0, True) ################################################## # Connections ################################################## self.connect((self.analog_pwr_squelch_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.analog_wfm_rcv_0_0, 0), (self.rational_resampler_xxx_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.audio_sink_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.analog_pwr_squelch_xx_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.rational_resampler_xxx_2_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.analog_wfm_rcv_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rational_resampler_xxx_1_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_2_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self, frame_size=32, puncpat='11'): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.frame_size = frame_size self.puncpat = puncpat ################################################## # Variables ################################################## self.samples_per_symbol = samples_per_symbol = 64 self.rate = rate = 2 self.polys = polys = [79, 109] self.k = k = 7 self.bitrate = bitrate = 9600 self.samp_rate = samp_rate = samples_per_symbol*bitrate self.gain = gain = 50 self.dec_cc = dec_cc = fec.cc_decoder.make(frame_size, k, rate, (polys), 0, -1, fec.CC_STREAMING, False) self.centre_freq = centre_freq = 401e6 self.bandwidth = bandwidth = 200e3 ################################################## # Blocks ################################################## self._gain_range = Range(0, 100, 1, 50, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "counter_slider", float) self.top_layout.addWidget(self._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_time_unknown_pps(uhd.time_spec()) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(centre_freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_bandwidth(bandwidth, 0) self.show_text_0 = display.show_text() self._show_text_0_win = sip.wrapinstance(self.show_text_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._show_text_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 2048, #size bitrate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-128, 128) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(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_layout.addWidget(self._qtgui_time_sink_x_0_win) self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c() self.fosphor_qt_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS) self.fosphor_qt_sink_c_0.set_frequency_range(0, samp_rate) self._fosphor_qt_sink_c_0_win = sip.wrapinstance(self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._fosphor_qt_sink_c_0_win) self.fec_extended_decoder_0 = fec.extended_decoder(decoder_obj_list=dec_cc, threading= None, ann=None, puncpat=puncpat, integration_period=10000) self.digital_map_bb_0 = digital.map_bb(([-1, 1])) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=samples_per_symbol, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.ccsds_asm_deframer_0 = ccsds.asm_deframer(0,1,False,16) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/gs-laptop1/GroundStation/GroundStation/GNURadio/Test Files/Simple GMSK Receive/out.bin", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-40, 1e-4, 0, True) self.ais_invert_0 = ais.invert() ################################################## # Connections ################################################## self.connect((self.ais_invert_0, 0), (self.digital_map_bb_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.digital_gmsk_demod_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.fec_extended_decoder_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.ccsds_asm_deframer_0, 0), (self.show_text_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.ais_invert_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.fec_extended_decoder_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.fec_extended_decoder_0, 0), (self.ccsds_asm_deframer_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.fosphor_qt_sink_c_0, 0))
def __init__(self): gr.top_block.__init__(self, "AM") Qt.QWidget.__init__(self) self.setWindowTitle("AM") 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", "am") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.radio_freq = radio_freq = 100 self.volume = volume = 5 self.squelch = squelch = -30 self.samp_rate = samp_rate = 240e4 self.rf_gain = rf_gain = 10 self.freq = freq = radio_freq * 1000000 ################################################## # Blocks ################################################## self._volume_range = Range(0, 10, 1, 5, 200) self._volume_win = RangeWidget(self._volume_range, self.set_volume, "Volume", "counter_slider", float) self.top_layout.addWidget(self._volume_win) self._squelch_range = Range(-70, 0, 10, -30, 200) self._squelch_win = RangeWidget(self._squelch_range, self.set_squelch, "Squelch", "counter_slider", int) self.top_layout.addWidget(self._squelch_win) self._rf_gain_range = Range(0, 50, 1, 10, 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.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(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(rf_gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=2, decimation=75, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=3, decimation=4, taps=None, fractional_bw=None, ) self._radio_freq_tool_bar = Qt.QToolBar(self) self._radio_freq_tool_bar.addWidget(Qt.QLabel("Frequency (MHz)"+": ")) self._radio_freq_line_edit = Qt.QLineEdit(str(self.radio_freq)) self._radio_freq_tool_bar.addWidget(self._radio_freq_line_edit) self._radio_freq_line_edit.returnPressed.connect( lambda: self.set_radio_freq(eng_notation.str_to_num(str(self._radio_freq_line_edit.text().toAscii())))) self.top_layout.addWidget(self._radio_freq_tool_bar) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #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 == type(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 freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_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 == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 64000, 5000, 100, firdes.WIN_HAMMING, 6.76)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, )) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(squelch, 1e-4, 0, True) self.analog_agc2_xx_0 = analog.agc2_ff(6.25e-4, 1e-5, .2, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.low_pass_filter_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self, FH_seq): #gr.top_block.__init__(self, "Test2") grc_wxgui.top_block_gui.__init__(self, title="Follow_with_single_usrp") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.sql_on = sql_on = 0 self.samp_rate = samp_rate = 2e6 self.curr_chann_idx = 0 self.FH_seq = FH_seq self.inception = 0 self.loop_bw_carriertracking = math.pi / 200.0 self.maxf_carriertracking = 0.5 self.minf_carriertracking = -0.5 ################################################## # Blocks ################################################## self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.pll_carriertracker = analog.pll_carriertracking_cc( self.loop_bw_carriertracking, self.maxf_carriertracking, self.minf_carriertracking) self.analog_pwr_squelch_xx_1 = analog.pwr_squelch_cc(-25, 1, 25, False) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="addr=192.168.10.2", stream_args=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(2.43064e9, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) def _sql_on_probe(): while True: val = self.analog_pwr_squelch_xx_1.unmuted() try: self.set_sql_on(val) except AttributeError, e: pass time.sleep((0.001))
def __init__(self, antenna="TX/RX", vor_freq_1=111e6, com_freq_1=135.275e6, vor_freq_2=111e6, rx_gain=30, gain=20): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Parameters ################################################## self.antenna = antenna self.vor_freq_1 = vor_freq_1 self.com_freq_1 = com_freq_1 self.vor_freq_2 = vor_freq_2 self.rx_gain = rx_gain self.gain = gain ################################################## # Variables ################################################## self.obs_decimation = obs_decimation = 25 self.ils_decimation = ils_decimation = 50 self.am_sample_rate = am_sample_rate = 12.5e3 self.vor_samp_rate = vor_samp_rate = 250e3 self.vor_freq_entry_2 = vor_freq_entry_2 = vor_freq_2 self.vor_freq_entry_1 = vor_freq_entry_1 = vor_freq_1 self.vor_center_freq_0 = vor_center_freq_0 = (117.95e6-108.00e6)/2+117.95e6 self.vor_center_freq = vor_center_freq = (117.95e6-108.00e6)/2+117.95e6 self.squelch_slider = squelch_slider = -110 self.rxgain = rxgain = 15 self.phase_correction = phase_correction = 5 self.obs_sample_rate = obs_sample_rate = am_sample_rate/obs_decimation self.ils_sample_rate = ils_sample_rate = am_sample_rate/ils_decimation self.gain_slider = gain_slider = gain self.com_freq_entry_1 = com_freq_entry_1 = com_freq_1 self.band_center_freq = band_center_freq = (136.975e6-108.0e6)/2+108.0e6 self.audio_select = audio_select = 0 self.audio_sample_rate = audio_sample_rate = 48e3 self.am_decimation = am_decimation = 1 ################################################## # Blocks ################################################## self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RF Analyzer") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Channel FFT") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Audio FFT") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Ref and Phase Scope") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Manipulated Ref and Phase") self.Add(self.notebook_0) self._vor_freq_entry_1_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), value=self.vor_freq_entry_1, callback=self.set_vor_freq_entry_1, label='vor_freq_entry_1', converter=forms.float_converter(), ) self.notebook_0.GetPage(0).Add(self._vor_freq_entry_1_text_box) _gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_slider_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, label='gain_slider', converter=forms.float_converter(), proportion=0, ) self._gain_slider_slider = forms.slider( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, minimum=0, maximum=30, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.notebook_0.GetPage(0).Add(_gain_slider_sizer) self._com_freq_entry_1_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), value=self.com_freq_entry_1, callback=self.set_com_freq_entry_1, label='com_freq_entry_1', converter=forms.float_converter(), ) self.notebook_0.GetPage(0).Add(self._com_freq_entry_1_text_box) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.notebook_0.GetPage(1).GetWin(), title="Scope Plot", sample_rate=10e3, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.notebook_0.GetPage(1).Add(self.wxgui_scopesink2_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=-100, maxval=100, factor=1.0, decimal_places=10, ref_level=0, sample_rate=10, number_rate=15, average=False, avg_alpha=None, label="Number Plot", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=12.5e3, fft_size=1024, fft_rate=5, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0.win) self._vor_freq_entry_2_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), value=self.vor_freq_entry_2, callback=self.set_vor_freq_entry_2, label='vor_freq_entry_2', converter=forms.float_converter(), ) self.notebook_0.GetPage(0).Add(self._vor_freq_entry_2_text_box) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_subdev_spec("A:0 A:0", 0) self.uhd_usrp_source_0.set_samp_rate(vor_samp_rate) self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(com_freq_entry_1,rf_freq=band_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_gain(gain_slider, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(vor_freq_entry_1, rf_freq=band_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 1) self.uhd_usrp_source_0.set_gain(gain_slider, 1) self.uhd_usrp_source_0.set_antenna("TX/RX", 1) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(250e3) self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(com_freq_entry_1,20e6), 0) self.uhd_usrp_sink_0.set_gain(15, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) _squelch_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._squelch_slider_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_squelch_slider_sizer, value=self.squelch_slider, callback=self.set_squelch_slider, label='squelch_slider', converter=forms.float_converter(), proportion=0, ) self._squelch_slider_slider = forms.slider( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_squelch_slider_sizer, value=self.squelch_slider, callback=self.set_squelch_slider, minimum=-110, maximum=0, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.notebook_0.GetPage(0).Add(_squelch_slider_sizer) self.squelch = analog.pwr_squelch_cc(squelch_slider, 0.01, 20, True) self.rational_resampler_xxx_2 = filter.rational_resampler_fff( interpolation=250, decimation=48, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=480, decimation=125, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=4, decimation=5, taps=None, fractional_bw=None, ) self.openavionics_joystick_interface_0 = openavionics.joystick_interface() self.openavionics_audio_ptt_0 = openavionics.audio_ptt() self.null_sink_0_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.multiply_xx_0_0_0 = blocks.multiply_vcc(1) self.multiply_xx_0_0 = blocks.multiply_vff(1) self.low_pass_filter_3 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 10e3, 1, 2, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2_0_0 = filter.fir_filter_ccf(5, firdes.low_pass( 1, 40e3, 2e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2_0 = filter.fir_filter_ccf(5, firdes.low_pass( 1, 40e3, 2e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2 = filter.fir_filter_ccf(5, firdes.low_pass( 1, vor_samp_rate, 15e3, 5e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = filter.interp_fir_filter_fff(1, firdes.low_pass( 1, 12.5e3, 3e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(int(250e3/12.5e3), firdes.low_pass( 1, vor_samp_rate, 10e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.goertzel_fc_0_0 = fft.goertzel_fc(10000, 1000, 30) self.goertzel_fc_0 = fft.goertzel_fc(40000, 4000, 30) self.float_to_complex_0_0 = blocks.float_to_complex(1) self.const_source_x_0_0_0 = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, 0.450) self.const_source_x_0_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0.550) self.const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0.450) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-87.2665e-3, )) self.band_pass_filter_0_0 = filter.fir_filter_fff(4, firdes.band_pass( 1, 40e3, 20, 40, 20, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_fff(1, firdes.band_pass( 1, 10e3, 20, 40, 20, firdes.WIN_HAMMING, 6.76)) self.audio_source_0 = audio.source(48000, "", True) self.audio_sink_0 = audio.sink(int(audio_sample_rate), "", True) self._audio_select_chooser = forms.drop_down( parent=self.GetWin(), value=self.audio_select, callback=self.set_audio_select, label='audio_select', choices=[0, 1], labels=['AM Voice','VOR Subcarrier'], ) self.Add(self._audio_select_chooser) self.analog_sig_source_x_0 = analog.sig_source_c(40e3, analog.GR_COS_WAVE, -9.96e3, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=40e3, audio_decim=4, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0_1_0 = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_1_0.set_max_gain(100) self.analog_agc2_xx_0_1 = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_1.set_max_gain(100) self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_0.set_max_gain(100) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(100) self.am_demod_cf_0 = analog.am_demod_cf( channel_rate=am_sample_rate, audio_decim=am_decimation, audio_pass=3e3, audio_stop=4e3, ) self.agc2_xx_0 = analog.agc2_cc(1, 1, 0.75, 1.0) self.agc2_xx_0.set_max_gain(0.0) self.add_xx_0_0 = blocks.add_vff(1) ################################################## # Connections ################################################## self.connect((self.agc2_xx_0, 0), (self.am_demod_cf_0, 0)) self.connect((self.am_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.agc2_xx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.multiply_xx_0_0, 0), (self.add_xx_0_0, 0)) self.connect((self.const_source_x_0, 0), (self.multiply_xx_0_0, 1)) self.connect((self.const_source_x_0_0, 0), (self.add_xx_0_0, 1)) self.connect((self.multiply_xx_0_0_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.add_xx_0_0, 0), (self.float_to_complex_0_0, 0)) self.connect((self.add_xx_0_0, 0), (self.float_to_complex_0_0, 1)) self.connect((self.float_to_complex_0_0, 0), (self.multiply_xx_0_0_0, 0)) self.connect((self.const_source_x_0_0_0, 0), (self.multiply_xx_0_0_0, 1)) self.connect((self.uhd_usrp_source_0, 0), (self.null_sink_0_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.analog_agc2_xx_0_1_0, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.analog_agc2_xx_0_1, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_agc2_xx_0_1, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.analog_agc2_xx_0_1_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.goertzel_fc_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.low_pass_filter_3, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.low_pass_filter_3, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.analog_agc2_xx_0_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.goertzel_fc_0_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.goertzel_fc_0_0, 0)) self.connect((self.goertzel_fc_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.low_pass_filter_2_0_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_2_0_0, 0)) self.connect((self.low_pass_filter_2_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_2_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.null_sink_0_0, 0)) self.connect((self.low_pass_filter_2, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.audio_source_0, 0), (self.openavionics_audio_ptt_0, 0)) self.connect((self.openavionics_audio_ptt_0, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.multiply_xx_0_0, 0)) self.connect((self.squelch, 0), (self.agc2_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.squelch, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_2, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.openavionics_joystick_interface_0, "out", self.openavionics_audio_ptt_0, "in2")
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="air band receiver") _icon_path = "C:\Program Files\GNURadio-3.7\share\icons\hicolor\scalable/apps\gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.volume = volume = 1 self.sql = sql = 0 self.samp_rate = samp_rate = 2.4e6 self.rfgain = rfgain = 50 self.frq_corr = frq_corr = 30 self.base_freq = base_freq = 120.5e6 ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label='Volume', converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_volume_sizer) _sql_sizer = wx.BoxSizer(wx.VERTICAL) self._sql_text_box = forms.text_box( parent=self.GetWin(), sizer=_sql_sizer, value=self.sql, callback=self.set_sql, label='Squelch', converter=forms.float_converter(), proportion=0, ) self._sql_slider = forms.slider( parent=self.GetWin(), sizer=_sql_sizer, value=self.sql, callback=self.set_sql, minimum=-100, maximum=100, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_sql_sizer) _rfgain_sizer = wx.BoxSizer(wx.VERTICAL) self._rfgain_text_box = forms.text_box( parent=self.GetWin(), sizer=_rfgain_sizer, value=self.rfgain, callback=self.set_rfgain, label='RF_Gain', converter=forms.float_converter(), proportion=0, ) self._rfgain_slider = forms.slider( parent=self.GetWin(), sizer=_rfgain_sizer, value=self.rfgain, callback=self.set_rfgain, minimum=0, maximum=50, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_rfgain_sizer) _frq_corr_sizer = wx.BoxSizer(wx.VERTICAL) self._frq_corr_text_box = forms.text_box( parent=self.GetWin(), sizer=_frq_corr_sizer, value=self.frq_corr, callback=self.set_frq_corr, label='freq_correction(ppm)', converter=forms.float_converter(), proportion=0, ) self._frq_corr_slider = forms.slider( parent=self.GetWin(), sizer=_frq_corr_sizer, value=self.frq_corr, callback=self.set_frq_corr, minimum=-127, maximum=127, num_steps=254, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_frq_corr_sizer) self.wxgui_fftsink2_0_0_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 / 50, fft_size=512, fft_rate=5, average=False, avg_alpha=None, title='FFT Plot', peak_hold=False, ) self.Add(self.wxgui_fftsink2_0_0_0.win) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + 'rtl_tcp=192.168.10.109:1235') self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(base_freq, 0) self.osmosdr_source_0.set_freq_corr(frq_corr, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(rfgain, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna('RX', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 50, (firdes.low_pass_2(1, samp_rate, 25e3, 10e3, 40)), 0, samp_rate) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short * 1, '192.168.10.30', 8082, 1472, True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (volume, )) self.blocks_float_to_short_0 = blocks.float_to_short(1, 32767) self.audio_sink_0 = audio.sink(48000, '', True) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc( sql, 1e-4, 0, False) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=48e3, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0 = analog.agc2_cc(1e-3, 1e-5, 1.0, 0) self.analog_agc2_xx_0.set_max_gain(5) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.wxgui_fftsink2_0_0_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_float_to_short_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.blocks_float_to_short_0, 0), (self.blocks_udp_sink_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_agc2_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="air band receiver") ################################################## # Variables ################################################## self.sql = sql = option.squelch self.samp_rate = samp_rate = 2.4e6 self.rfgain = rfgain = option.gain self.frq_corr = frq_corr = option.correct self.device_arg = device_arg = "rtl_tcp={0}:{1}".format(option.host, option.port) self.base_freq = base_freq = option.freq ################################################## # Blocks ################################################## self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + device_arg ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(base_freq, 0) self.osmosdr_source_0.set_freq_corr(frq_corr, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(rfgain, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna('RX', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(50, (firdes.low_pass_2(1,samp_rate,25e3,10e3,40)), 0, samp_rate) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short*1, option.desthost, option.destport, 1472, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.5, )) self.blocks_float_to_short_0 = blocks.float_to_short(1, 32767) self.audio_sink_0 = audio.sink(48000, '', True) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(sql, 1e-4, 0, False) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=48e3, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0 = analog.agc2_cc(1e-3, 1e-5, 1.0, 0) self.analog_agc2_xx_0.set_max_gain(5) # dc_blocker not use # self.dc_blocker_xx_0 = filter.dc_blocker_ff(32,True) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.blocks_float_to_short_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_throttle_0, 0)) # bypass dc blocker # self.connect((self.analog_am_demod_cf_0, 0), (self.dc_blocker_xx_0, 0)) # self.connect((self.dc_blocker_xx_0, 0), (self.blocks_float_to_short_0, 0)) # self.connect((self.dc_blocker_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_float_to_short_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self, sample_rate, freq_offset, sys_id, chan, group_id, save_dir): gr.hier_block2.__init__( self, "SmartZone Audio Channel", gr.io_signature(1, 1, gr.sizeof_gr_complex), # input signature gr.io_signature(0, 0, 0), # output signature ) # audio constants self._audio_sample_rate = 8000 self._audio_passband = 3.6e3 self._audio_stopband = 4e3 self._audio_gain = 1.0 # fm constants self._deviation = 2.5e3 self._fm_passband = self._audio_stopband + self._deviation self._fm_stopband = self._fm_passband + 8e3 # 3 * audio_bw # fm channel values desired_channel_rate = 40e3 channel_decimation = int(round(sample_rate / desired_channel_rate)) channel_rate = sample_rate / channel_decimation # audio channel values desired_audio_rate = 8e3 audio_decimation = int(round(channel_rate / desired_audio_rate)) audio_rate = channel_rate / audio_decimation # translate desired fm audio frequency to baseband; decimate to channel rate channel_taps = optfir.low_pass(1, sample_rate, self._fm_passband, self._fm_stopband, 0.1, 60) channel_filter = filter.freq_xlating_fir_filter_ccf( channel_decimation, optfir.low_pass(1, sample_rate, self._fm_passband, self._fm_stopband, 0.1, 60), freq_offset, sample_rate, ) # power squelch squelch = analog.pwr_squelch_cc(-50, alpha=1, ramp=0, gate=True) # fm demodulation audio_demod = analog.fm_demod_cf( channel_rate, audio_decimation, self._deviation, self._audio_passband, self._audio_stopband, self._audio_gain, 75e-6, ) # remove sub-audible data XXX demodulate sa_filter = filter.fir_filter_fff(1, firdes.band_pass(1, audio_rate, 400, 3900, 100, filter.firdes.WIN_HANN)) # audio output # ensure directory exists create_directory(save_dir, sys_id) # asink = audio.sink(audio_rate) wavfile_sink = blocks.wavfile_sink( "%s/%x/%s" % (save_dir, sys_id, audio_name(group_id, chan)), 1, int(round(audio_rate)), 8 ) self.connect(self, channel_filter, squelch, audio_demod, sa_filter, wavfile_sink)
def __init__(self): grc_wxgui.top_block_gui.__init__(self) _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.base_freq = base_freq = 121250000 self.t = 0 self.volume_min = 0.001 self.volume = volume = self.volume_min self.volume_max = 0.6 self.squelch = squelch = -26 self.samp_rate = samp_rate = 2400000 self.freq_corr = freq_corr = 31 self.freq = freq = base_freq self.frq_choices = [ 121250000, 121500000, 122200000, 123450000, 124175000, 124925000, 125450000, 130875000, 132700000, 134225000, 134925000, 136050000, 136575000, 169000000 ] # EPSD Port 122700000 EP Przelotowa 124500000 Air-To-Air 2 136975000 #self.frq_choices = [134225000] self.frq_labels = [ 'EPSC TWR', 'EP EMRG', 'EPSD Kwadrat', 'Air-To-Air', 'Mueritz EDWW Radar', 'B FIR Warszawa', 'EPWW Radar 2', 'EPWW Radar 3', 'EPWW Radar 4', 'D FIR Warszawa', 'EPWW Radar', 'Mark EDWW Radar', 'E FIR Warszawa', 'Lotnicze Pogotowie Ratunkowe' ] #self.frq_labels = ['D FIR Warszawa'] self.j = 0 ################################################## # 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(freq, 0) self.rtlsdr_source_0.set_freq_corr(freq_corr, 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(False, 0) self.rtlsdr_source_0.set_gain(49.6, 0) self.rtlsdr_source_0.set_if_gain(1, 0) self.rtlsdr_source_0.set_bb_gain(1, 0) self.rtlsdr_source_0.set_antenna("RX", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.signal_probe = blocks.probe_signal_c() #self.signal_probe = analog.probe_avg_mag_sqrd_c(0, 1) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 50, (firdes.low_pass_2(1, samp_rate, 25e3, 10e3, 40)), 0, samp_rate) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (volume, )) self.audio_sink_0 = audio.sink(48000, "hw:0,1", True) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc( squelch, 0.1, 0, False) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=48000, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 0.1e-4, 1.0, 0) self.analog_agc2_xx_0.set_max_gain(5) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.signal_probe, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_agc2_xx_0, 0))
def build_blocks(self,config): if not self.device_found: return self.error = False fft_size = self.main.fft_size_control.get_value() frame_rate = self.main.framerate_control.get_value() average = self.main.average_control.get_value() ssb_lo = self.ssb_lo ssb_hi = self.ssb_hi USB = self.mode == self.main.MODE_USB or self.mode == self.main.MODE_CW_USB self.audio_dec_nrw = 1 self.dec_nrw, self.interp_nrw = self.compute_dec_interp(self.sample_rate,self.audio_rate) self.audio_dec_wid = self.if_sample_rate / self.audio_rate self.dec_wid, self.interp_wid = self.compute_dec_interp(self.sample_rate,self.if_sample_rate) volume = .1 self.configure_source_controls() self.create_update_freq_xlating_fir_filter() self.analog_agc_cc = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc_cc.set_max_gain(1) self.analog_agc_ff = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0) self.analog_agc_ff.set_max_gain(1) self.rational_resampler_wid = filter.rational_resampler_ccc( decimation=int(self.dec_wid), interpolation=int(self.interp_wid), taps=None, fractional_bw=None, ) self.rational_resampler_nrw = filter.rational_resampler_ccc( decimation=int(self.dec_nrw), interpolation=int(self.interp_nrw), taps=None, fractional_bw=None, ) self.analog_pwr_squelch = analog.pwr_squelch_cc(self.squelch_level, 1e-4, 0, True) self.analog_pwr_squelch_ssb = analog.pwr_squelch_ff(self.squelch_level, 1e-4, 0, True) self.blocks_multiply = blocks.multiply_vcc(1) self.blocks_complex_to_real = blocks.complex_to_real(1) #self.rebuild_filters(config) self.blocks_complex_to_mag_am = blocks.complex_to_mag(1) self.analog_nbfm_rcv = analog.nbfm_rx( audio_rate=self.audio_rate, quad_rate=self.audio_rate, tau=75e-6, max_dev=6e3, ) self.analog_wfm_rcv = analog.wfm_rcv( quad_rate=self.if_sample_rate, audio_decimation=self.audio_dec_wid, ) self.hilbert_fc_2 = filter.hilbert_fc(self.hilbert_taps_ssb, firdes.WIN_HAMMING, 6.76) self.hilbert_fc_1 = filter.hilbert_fc(self.hilbert_taps_ssb, firdes.WIN_HAMMING, 6.76) self.blocks_multiply_ssb = blocks.multiply_vcc(1) self.blocks_complex_to_float_ssb = blocks.complex_to_float(1) self.create_usb_lsb_switch() self.blocks_add = blocks.add_vff(1) self.blocks_complex_to_real = blocks.complex_to_real(1) self.blocks_complex_to_imag = blocks.complex_to_imag(1) # this is the source for the FFT display's data self.logpwrfft = logpwrfft.logpwrfft_c( sample_rate=self.sample_rate, fft_size=fft_size, ref_scale=2, frame_rate=frame_rate, avg_alpha=average, average=(average != 1), ) # this is the main FFT display self.fft_vector_sink = MyVectorSink(self.main,fft_size) self.blocks_multiply_const_volume = blocks.multiply_const_vff((volume, )) # only create this once if self.audio_sink == None: try: self.audio_sink = audio.sink(self.audio_rate, config['audio_device'], True) except Exception as e: self.main.message_dialog("Audio Error","A problem has come up while accessing the audio system: %s" % e) self.error = True self.audio_sink = None self.main.af_gain_control.set_value()
def __init__(self, antenna="TX/RX", vor_freq_1=111e6, com_freq_1=135.275e6, vor_freq_2=111e6, rx_gain=30, gain=20): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Parameters ################################################## self.antenna = antenna self.vor_freq_1 = vor_freq_1 self.com_freq_1 = com_freq_1 self.vor_freq_2 = vor_freq_2 self.rx_gain = rx_gain self.gain = gain ################################################## # Variables ################################################## self.obs_decimation = obs_decimation = 25 self.ils_decimation = ils_decimation = 50 self.am_sample_rate = am_sample_rate = 12.5e3 self.vor_samp_rate = vor_samp_rate = 250e3 self.vor_freq_entry_2 = vor_freq_entry_2 = vor_freq_2 self.vor_freq_entry_1 = vor_freq_entry_1 = vor_freq_1 self.vor_center_freq_0 = vor_center_freq_0 = (117.95e6 - 108.00e6) / 2 + 117.95e6 self.vor_center_freq = vor_center_freq = (117.95e6 - 108.00e6) / 2 + 117.95e6 self.squelch_slider = squelch_slider = -110 self.rxgain = rxgain = 15 self.phase_correction = phase_correction = 5 self.obs_sample_rate = obs_sample_rate = am_sample_rate / obs_decimation self.ils_sample_rate = ils_sample_rate = am_sample_rate / ils_decimation self.gain_slider = gain_slider = gain self.com_freq_entry_1 = com_freq_entry_1 = com_freq_1 self.band_center_freq = band_center_freq = (136.975e6 - 108.0e6) / 2 + 108.0e6 self.audio_select = audio_select = 0 self.audio_sample_rate = audio_sample_rate = 48e3 self.am_decimation = am_decimation = 1 ################################################## # Blocks ################################################## self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RF Analyzer") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Channel FFT") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Audio FFT") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Ref and Phase Scope") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Manipulated Ref and Phase") self.Add(self.notebook_0) self._vor_freq_entry_1_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), value=self.vor_freq_entry_1, callback=self.set_vor_freq_entry_1, label='vor_freq_entry_1', converter=forms.float_converter(), ) self.notebook_0.GetPage(0).Add(self._vor_freq_entry_1_text_box) _gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_slider_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, label='gain_slider', converter=forms.float_converter(), proportion=0, ) self._gain_slider_slider = forms.slider( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, minimum=0, maximum=30, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.notebook_0.GetPage(0).Add(_gain_slider_sizer) self._com_freq_entry_1_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), value=self.com_freq_entry_1, callback=self.set_com_freq_entry_1, label='com_freq_entry_1', converter=forms.float_converter(), ) self.notebook_0.GetPage(0).Add(self._com_freq_entry_1_text_box) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.notebook_0.GetPage(1).GetWin(), title="Scope Plot", sample_rate=10e3, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.notebook_0.GetPage(1).Add(self.wxgui_scopesink2_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=-100, maxval=100, factor=1.0, decimal_places=10, ref_level=0, sample_rate=10, number_rate=15, average=False, avg_alpha=None, label="Number Plot", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=12.5e3, fft_size=1024, fft_rate=5, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0.win) self._vor_freq_entry_2_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), value=self.vor_freq_entry_2, callback=self.set_vor_freq_entry_2, label='vor_freq_entry_2', converter=forms.float_converter(), ) self.notebook_0.GetPage(0).Add(self._vor_freq_entry_2_text_box) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_subdev_spec("A:0 A:0", 0) self.uhd_usrp_source_0.set_samp_rate(vor_samp_rate) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(com_freq_entry_1, rf_freq=band_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_gain(gain_slider, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(vor_freq_entry_1, rf_freq=band_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 1) self.uhd_usrp_source_0.set_gain(gain_slider, 1) self.uhd_usrp_source_0.set_antenna("TX/RX", 1) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(250e3) self.uhd_usrp_sink_0.set_center_freq( uhd.tune_request(com_freq_entry_1, 20e6), 0) self.uhd_usrp_sink_0.set_gain(15, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) _squelch_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._squelch_slider_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_squelch_slider_sizer, value=self.squelch_slider, callback=self.set_squelch_slider, label='squelch_slider', converter=forms.float_converter(), proportion=0, ) self._squelch_slider_slider = forms.slider( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_squelch_slider_sizer, value=self.squelch_slider, callback=self.set_squelch_slider, minimum=-110, maximum=0, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.notebook_0.GetPage(0).Add(_squelch_slider_sizer) self.squelch = analog.pwr_squelch_cc(squelch_slider, 0.01, 20, True) self.rational_resampler_xxx_2 = filter.rational_resampler_fff( interpolation=250, decimation=48, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=480, decimation=125, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=4, decimation=5, taps=None, fractional_bw=None, ) self.openavionics_joystick_interface_0 = openavionics.joystick_interface( ) self.openavionics_audio_ptt_0 = openavionics.audio_ptt() self.null_sink_0_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.multiply_xx_0_0_0 = blocks.multiply_vcc(1) self.multiply_xx_0_0 = blocks.multiply_vff(1) self.low_pass_filter_3 = filter.fir_filter_ccf( 1, firdes.low_pass(1, 10e3, 1, 2, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2_0_0 = filter.fir_filter_ccf( 5, firdes.low_pass(1, 40e3, 2e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2_0 = filter.fir_filter_ccf( 5, firdes.low_pass(1, 40e3, 2e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2 = filter.fir_filter_ccf( 5, firdes.low_pass(1, vor_samp_rate, 15e3, 5e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = filter.interp_fir_filter_fff( 1, firdes.low_pass(1, 12.5e3, 3e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( int(250e3 / 12.5e3), firdes.low_pass(1, vor_samp_rate, 10e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.goertzel_fc_0_0 = fft.goertzel_fc(10000, 1000, 30) self.goertzel_fc_0 = fft.goertzel_fc(40000, 4000, 30) self.float_to_complex_0_0 = blocks.float_to_complex(1) self.const_source_x_0_0_0 = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, 0.450) self.const_source_x_0_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0.550) self.const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0.450) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-87.2665e-3, )) self.band_pass_filter_0_0 = filter.fir_filter_fff( 4, firdes.band_pass(1, 40e3, 20, 40, 20, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_fff( 1, firdes.band_pass(1, 10e3, 20, 40, 20, firdes.WIN_HAMMING, 6.76)) self.audio_source_0 = audio.source(48000, "", True) self.audio_sink_0 = audio.sink(int(audio_sample_rate), "", True) self._audio_select_chooser = forms.drop_down( parent=self.GetWin(), value=self.audio_select, callback=self.set_audio_select, label='audio_select', choices=[0, 1], labels=['AM Voice', 'VOR Subcarrier'], ) self.Add(self._audio_select_chooser) self.analog_sig_source_x_0 = analog.sig_source_c( 40e3, analog.GR_COS_WAVE, -9.96e3, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=40e3, audio_decim=4, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0_1_0 = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_1_0.set_max_gain(100) self.analog_agc2_xx_0_1 = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_1.set_max_gain(100) self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_0.set_max_gain(100) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(100) self.am_demod_cf_0 = analog.am_demod_cf( channel_rate=am_sample_rate, audio_decim=am_decimation, audio_pass=3e3, audio_stop=4e3, ) self.agc2_xx_0 = analog.agc2_cc(1, 1, 0.75, 1.0) self.agc2_xx_0.set_max_gain(0.0) self.add_xx_0_0 = blocks.add_vff(1) ################################################## # Connections ################################################## self.connect((self.agc2_xx_0, 0), (self.am_demod_cf_0, 0)) self.connect((self.am_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.agc2_xx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.multiply_xx_0_0, 0), (self.add_xx_0_0, 0)) self.connect((self.const_source_x_0, 0), (self.multiply_xx_0_0, 1)) self.connect((self.const_source_x_0_0, 0), (self.add_xx_0_0, 1)) self.connect((self.multiply_xx_0_0_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.add_xx_0_0, 0), (self.float_to_complex_0_0, 0)) self.connect((self.add_xx_0_0, 0), (self.float_to_complex_0_0, 1)) self.connect((self.float_to_complex_0_0, 0), (self.multiply_xx_0_0_0, 0)) self.connect((self.const_source_x_0_0_0, 0), (self.multiply_xx_0_0_0, 1)) self.connect((self.uhd_usrp_source_0, 0), (self.null_sink_0_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.analog_agc2_xx_0_1_0, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.analog_agc2_xx_0_1, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_agc2_xx_0_1, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.analog_agc2_xx_0_1_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.goertzel_fc_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.low_pass_filter_3, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.low_pass_filter_3, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.analog_agc2_xx_0_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.goertzel_fc_0_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.goertzel_fc_0_0, 0)) self.connect((self.goertzel_fc_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.low_pass_filter_2_0_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_2_0_0, 0)) self.connect((self.low_pass_filter_2_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_2_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.null_sink_0_0, 0)) self.connect((self.low_pass_filter_2, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.audio_source_0, 0), (self.openavionics_audio_ptt_0, 0)) self.connect((self.openavionics_audio_ptt_0, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.multiply_xx_0_0, 0)) self.connect((self.squelch, 0), (self.agc2_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.squelch, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_2, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.openavionics_joystick_interface_0, "out", self.openavionics_audio_ptt_0, "in2")
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="NBFM Receiver") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 125e6 ################################################## # Blocks ################################################## self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=450e6, 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_0.win) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=3, decimation=125, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=48, decimation=30, taps=None, fractional_bw=None, ) self.low_pass_filter_0 = filter.fir_filter_ccf(10, firdes.low_pass( 1, 3e6, 5e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10, )) self.blocks_interleaved_short_to_complex_0 = blocks.interleaved_short_to_complex(False, False) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_short*1, "/dev/langford", True) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_pwr_squelch_xx_1 = analog.pwr_squelch_cc(-80, 1, 0, False) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=30000, quad_rate=300000, tau=75e-6, max_dev=5e3, ) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_interleaved_short_to_complex_0, 0)) self.connect((self.low_pass_filter_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.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_nbfm_rx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_interleaved_short_to_complex_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.blocks_interleaved_short_to_complex_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.analog_pwr_squelch_xx_1, 0)) self.connect((self.analog_pwr_squelch_xx_1, 0), (self.low_pass_filter_0, 0))