def build_graph(): sample_rate = 8000 scale_factor = 32000 tb = gr.top_block() src = audio.source(sample_rate, "plughw:0,0") src_scale = gr.multiply_const_ff(scale_factor) interp = blks2.rational_resampler_fff(8, 1) f2s = gr.float_to_short() enc = cvsd_vocoder.encode_sb() dec = cvsd_vocoder.decode_bs() s2f = gr.short_to_float() decim = blks2.rational_resampler_fff(1, 8) sink_scale = gr.multiply_const_ff(1.0 / scale_factor) sink = audio.sink(sample_rate, "plughw:0,0") tb.connect(src, src_scale, interp, f2s, enc) tb.connect(enc, dec, s2f, decim, sink_scale, sink) if 0: # debug tb.conect(src, gr.file_sink(gr.sizeof_float, "source.dat")) tb.conect(src_scale, gr.file_sink(gr.sizeof_float, "src_scale.dat")) tb.conect(interp, gr.file_sink(gr.sizeof_float, "interp.dat")) tb.conect(f2s, gr.file_sink(gr.sizeof_short, "f2s.dat")) tb.conect(enc, gr.file_sink(gr.sizeof_char, "enc.dat")) tb.conect(dec, gr.file_sink(gr.sizeof_short, "dec.dat")) tb.conect(s2f, gr.file_sink(gr.sizeof_float, "s2f.dat")) tb.conect(decim, gr.file_sink(gr.sizeof_float, "decim.dat")) tb.conect(sink_scale, gr.file_sink(gr.sizeof_float, "sink_scale.dat")) return tb
def build_graph(): sample_rate = 8000 scale_factor = 32000 tb = gr.top_block() src = audio.source(sample_rate, "plughw:0,0") src_scale = gr.multiply_const_ff(scale_factor) interp = blks2.rational_resampler_fff(8, 1) f2s = gr.float_to_short () enc = vocoder.cvsd_encode_sb() dec = vocoder.cvsd_decode_bs() s2f = gr.short_to_float () decim = blks2.rational_resampler_fff(1, 8) sink_scale = gr.multiply_const_ff(1.0/scale_factor) sink = audio.sink(sample_rate, "plughw:0,0") tb.connect(src, src_scale, interp, f2s, enc) tb.connect(enc, dec, s2f, decim, sink_scale, sink) if 0: # debug tb.conect(src, gr.file_sink(gr.sizeof_float, "source.dat")) tb.conect(src_scale, gr.file_sink(gr.sizeof_float, "src_scale.dat")) tb.conect(interp, gr.file_sink(gr.sizeof_float, "interp.dat")) tb.conect(f2s, gr.file_sink(gr.sizeof_short, "f2s.dat")) tb.conect(enc, gr.file_sink(gr.sizeof_char, "enc.dat")) tb.conect(dec, gr.file_sink(gr.sizeof_short, "dec.dat")) tb.conect(s2f, gr.file_sink(gr.sizeof_float, "s2f.dat")) tb.conect(decim, gr.file_sink(gr.sizeof_float, "decim.dat")) tb.conect(sink_scale, gr.file_sink(gr.sizeof_float, "sink_scale.dat")) return tb
def __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-O", "--audio-output", type="string", default="", help="pcm output device name. E.g., hw:0,0 or /dev/dsp") parser.add_option("-i", "--input-rate", type="eng_float", default=8000, help="set input sample rate to RATE (%default)") parser.add_option("-o", "--output-rate", type="eng_float", default=48000, help="set output sample rate to RATE (%default)") (options, args) = parser.parse_args () if len(args) != 0: parser.print_help() raise SystemExit, 1 input_rate = int(options.input_rate) output_rate = int(options.output_rate) interp = gru.lcm(input_rate, output_rate) / input_rate decim = gru.lcm(input_rate, output_rate) / output_rate print "interp =", interp print "decim =", decim ampl = 0.1 src0 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 650, ampl) rr = blks2.rational_resampler_fff(interp, decim) dst = audio.sink (output_rate, options.audio_output) self.connect (src0, rr, (dst, 0))
def __init__(self, queue, freq=0.0, verbose=False, log=False): gr.hier_block2.__init__(self, "flex_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(0,0,0)) k = 25000/(2*pi*1600) # 4800 Hz max deviation quad = gr.quadrature_demod_cf(k) self.connect(self, quad) rsamp = blks2.rational_resampler_fff(16, 25) self.slicer = pager_swig.slicer_fb(5e-6) # DC removal averaging filter constant self.sync = pager_swig.flex_sync() self.connect(quad, rsamp, self.slicer, self.sync) for i in range(4): self.connect((self.sync, i), pager_swig.flex_deinterleave(), pager_swig.flex_parse(queue, freq)) if log: suffix = '_'+ "%3.3f" % (freq/1e6,) + '.dat' quad_sink = gr.file_sink(gr.sizeof_float, 'quad'+suffix) rsamp_sink = gr.file_sink(gr.sizeof_float, 'rsamp'+suffix) slicer_sink = gr.file_sink(gr.sizeof_char, 'slicer'+suffix) self.connect(rsamp, rsamp_sink) self.connect(quad, quad_sink) self.connect(self.slicer, slicer_sink)
def __init__(self, output_rate): gr.hier_block2.__init__(self, "p25_c4fm_mod_bf", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(1, 1, gr.sizeof_float)) # Output signature symbol_rate = 4800 # P25 baseband symbol rate lcm = gru.lcm(symbol_rate, output_rate) self._interp_factor = int(lcm // symbol_rate) self._decimation = int(lcm // output_rate) self._excess_bw =0.2 mod_map = [1.0/3.0, 1.0, -(1.0/3.0), -1.0] self.C2S = gr.chunks_to_symbols_bf(mod_map) ntaps = 11 * self._interp_factor rrc_taps = gr.firdes.root_raised_cosine( self._interp_factor, # gain (since we're interpolating by sps) lcm, # sampling rate symbol_rate, self._excess_bw, # excess bandwidth (roll-off factor) ntaps) self.rrc_filter = gr.interp_fir_filter_fff(self._interp_factor, rrc_taps) # FM pre-emphasis filter shaping_coeffs = [-0.018, 0.0347, 0.0164, -0.0064, -0.0344, -0.0522, -0.0398, 0.0099, 0.0798, 0.1311, 0.121, 0.0322, -0.113, -0.2499, -0.3007, -0.2137, -0.0043, 0.2825, 0.514, 0.604, 0.514, 0.2825, -0.0043, -0.2137, -0.3007, -0.2499, -0.113, 0.0322, 0.121, 0.1311, 0.0798, 0.0099, -0.0398, -0.0522, -0.0344, -0.0064, 0.0164, 0.0347, -0.018] self.shaping_filter = gr.fir_filter_fff(1, shaping_coeffs) # generate output at appropriate rate self.decimator = blks2.rational_resampler_fff(1, self._decimation) self.connect(self, self.C2S, self.rrc_filter, self.shaping_filter, self.decimator, self)
def __init__(self, queue, freq=0.0, verbose=False, log=False): gr.hier_block2.__init__(self, "flex_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(0, 0, 0)) k = 25000 / (2 * pi * 1600) # 4800 Hz max deviation quad = gr.quadrature_demod_cf(k) self.connect(self, quad) rsamp = blks2.rational_resampler_fff(16, 25) self.slicer = pager_swig.slicer_fb( 5e-6) # DC removal averaging filter constant self.sync = pager_swig.flex_sync() self.connect(quad, rsamp, self.slicer, self.sync) for i in range(4): self.connect((self.sync, i), pager_swig.flex_deinterleave(), pager_swig.flex_parse(queue, freq)) if log: suffix = '_' + "%3.3f" % (freq / 1e6, ) + '.dat' quad_sink = gr.file_sink(gr.sizeof_float, 'quad' + suffix) rsamp_sink = gr.file_sink(gr.sizeof_float, 'rsamp' + suffix) slicer_sink = gr.file_sink(gr.sizeof_char, 'slicer' + suffix) self.connect(rsamp, rsamp_sink) self.connect(quad, quad_sink) self.connect(self.slicer, slicer_sink)
def __init__(self, center_freq, offset_freq, decimate_am=1, play_audio=False): """Configure the RTL-SDR and GNU Radio""" super(rtlsdr_am_stream, self).__init__() audio_rate = 44100 device_rate = audio_rate * 25 output_rate = audio_rate / float(decimate_am) self.rate = output_rate self.osmosdr_source = osmosdr.source_c("") self.osmosdr_source.set_center_freq(freq) self.osmosdr_source.set_sample_rate(device_rate) taps = firdes.low_pass(1, device_rate, 40000, 5000, firdes.WIN_HAMMING, 6.76) self.freq_filter = gr.freq_xlating_fir_filter_ccc(25, taps, -freq_offs, device_rate) self.am_demod = blks2.am_demod_cf( channel_rate=audio_rate, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.resampler = blks2.rational_resampler_fff( interpolation=1, decimation=decimate_am, ) self.sink = gr_queue.queue_sink_f() self.connect(self.osmosdr_source, self.freq_filter, self.am_demod) self.connect(self.am_demod, self.resampler, self.sink) if play_audio: self.audio_sink = audio.sink(audio_rate, "", True) self.connect(self.am_demod, self.audio_sink)
def __init__(self): gr.top_block.__init__(self, "FM Receiver") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 96000 self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate, 48000, 5000, firdes.WIN_HAMMING, 6.76) self.sql_lev = sql_lev = -100 self.rf_gain = rf_gain = 20 self.freq = freq = 144800000 self.af_gain = af_gain = 2 self.sat_file_name = sat_file_name = "Undefined" ################################################## # Blocks ################################################## self.xlating_fir_filter = gr.freq_xlating_fir_filter_ccc(1, (xlate_filter_taps), 0, samp_rate) self.nbfm_normal = blks2.nbfm_rx( audio_rate=48000, quad_rate=96000, tau=75e-6, max_dev=5e3, ) self.low_pass_filter = gr.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, 12500, 1500, firdes.WIN_HAMMING, 6.76)) self.gr_simple_squelch_cc_0 = gr.simple_squelch_cc(sql_lev, 1) self.gr_multiply_const_vxx_1 = gr.multiply_const_vff((af_gain, )) self.fcd_source_c_1 = fcd.source_c("hw:1") self.fcd_source_c_1.set_freq(freq) self.fcd_source_c_1.set_freq_corr(-32) self.audio_sink = audio.sink(48000, "", True) self.wavfile_sink = gr.wavfile_sink(self.sat_file_name, 1, 11025, 16) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=11025, decimation=48000, taps=None, fractional_bw=None, ) ################################################## # Connections ################################################## self.connect((self.xlating_fir_filter, 0), (self.low_pass_filter, 0)) self.connect((self.low_pass_filter, 0), (self.gr_simple_squelch_cc_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.audio_sink, 1)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.audio_sink, 0)) self.connect((self.gr_simple_squelch_cc_0, 0), (self.nbfm_normal, 0)) self.connect((self.nbfm_normal, 0), (self.gr_multiply_const_vxx_1, 0)) self.connect((self.fcd_source_c_1, 0), (self.xlating_fir_filter, 0)) self.connect((self.nbfm_normal, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.wavfile_sink, 0))
def __init__(self): gr.top_block.__init__(self, "CW/SSB Receiver") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 96000 self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate, 48000, 5000, firdes.WIN_HAMMING, 6.76) self.sql_lev = sql_lev = -100 self.rf_gain = rf_gain = 20 self.pass_trans = pass_trans = 600 self.pass_low = pass_low = 300 self.pass_high = pass_high = 1200 self.freq = freq = 144800000 self.af_gain = af_gain = 5 self.sat_file_name = sat_file_name = "Undefined" ################################################## # Blocks ################################################## self.xlating_fir_filter = gr.freq_xlating_fir_filter_ccc(1, (xlate_filter_taps), 0, samp_rate) self.gr_simple_squelch_cc_0 = gr.simple_squelch_cc(sql_lev, 1) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((af_gain, )) self.gr_complex_to_real_0 = gr.complex_to_real(1) self.gr_agc2_xx_0 = gr.agc2_cc(1e-1, 20.8e-6, 0.3, 1.0, 0.0) self.fcd_source_c_1 = fcd.source_c("hw:1") self.fcd_source_c_1.set_freq(freq) self.fcd_source_c_1.set_freq_corr(-10) self.band_pass_filter_0 = gr.fir_filter_ccf(2, firdes.band_pass( 1, samp_rate, pass_low, pass_high, pass_trans, firdes.WIN_HAMMING, 6.76)) self.audio_sink = audio.sink(48000, "", True) self.wavfile_sink = gr.wavfile_sink(self.sat_file_name, 1, 11025, 16) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=11025, decimation=48000, taps=None, fractional_bw=None, ) ################################################## # Connections ################################################## self.connect((self.fcd_source_c_1, 0), (self.xlating_fir_filter, 0)) self.connect((self.xlating_fir_filter, 0), (self.gr_simple_squelch_cc_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.gr_agc2_xx_0, 0)) self.connect((self.gr_complex_to_real_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_agc2_xx_0, 0), (self.gr_complex_to_real_0, 0)) self.connect((self.gr_simple_squelch_cc_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.audio_sink, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.audio_sink, 1)) self.connect((self.gr_complex_to_real_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.wavfile_sink, 0))
def __init__(self): gr.top_block.__init__(self) #build graph now #usrp_source self.usrp = usrp.source_c() adc_rate = self.usrp.adc_rate() #64MHz hw_decim = 16 #so Sample rate into host is 4MHz self.usrp.set_decim_rate(hw_decim) self.subdev = usrp.selected_subdev(self.usrp, usrp.pick_rx_subdevice(self.usrp)) self.usrp.set_mux( usrp.determine_rx_mux_value(self.usrp, usrp.pick_rx_subdevice(self.usrp))) print "Using RX d'board %s" % (self.subdev.side_and_name(), ) self.subdev.set_gain(30) rf_freq = 106800000 # 106.8MHz self.set_freq(rf_freq) print "Freq: ", rf_freq self.subdev.select_rx_antenna("TX/RX") #low pass filter self.sample_rate = adc_rate / hw_decim self.lpf_decim = 20 # so after channel filter, the sample rate is 200KHz self.lp_filter = gr.fir_filter_ccf( self.lpf_decim, gr.firdes.low_pass( 1, self.sample_rate, 100e3, # cut off freq 10e3, # transition band gr.firdes.WIN_BLACKMAN, # Window function 6.76 # not used )) # WBFM receiver quad_rate = self.sample_rate #input rate of demodulator max_dev = 75e3 #max deviation of FM Broadcast fm_demod_gain = quad_rate / (2 * math.pi * max_dev) self.fm_decoder = gr.quadrature_demod_cf(fm_demod_gain) # Rational Resampler self.audio_sample_rate = 96000 self.rational_resampler = blks2.rational_resampler_fff( interpolation=int(self.audio_sample_rate / 1000), decimation=int(self.sample_rate / self.lpf_decim / 1000), taps=None, fractional_bw=None, ) self.audio_sink = audio.sink(int(self.audio_sample_rate), "", True) #connections self.connect(self.usrp, self.lp_filter, self.fm_decoder, self.rational_resampler, self.audio_sink)
def test_101_interp(self): taps = [1, 10, 100, 1000, 10000] src_data = (0, 2, 3, 5, 7, 11, 13, 17) interpolation = 3 xr = (0,0,0,0,2,20,200,2003,20030,300,3005,30050,500,5007,50070,700,7011,70110,1100,11013,110130,1300,13017,130170,1700.0,17000.0,170000.0) expected_result = tuple([float(x) for x in xr]) tb = gr.top_block() src = gr.vector_source_f(src_data) op = blks2.rational_resampler_fff(interpolation, 1, taps=taps) dst = gr.vector_sink_f() tb.connect(src, op) tb.connect(op, dst) tb.run() result_data = dst.data() self.assertEqual(expected_result, result_data)
def __init__(self): gr.top_block.__init__(self) #build graph now #usrp_source self.usrp = usrp.source_c() adc_rate = self.usrp.adc_rate() #64MHz hw_decim = 16 #so Sample rate into host is 4MHz self.usrp.set_decim_rate(hw_decim) self.subdev = usrp.selected_subdev(self.usrp, usrp.pick_rx_subdevice(self.usrp)) self.usrp.set_mux(usrp.determine_rx_mux_value(self.usrp, usrp.pick_rx_subdevice(self.usrp))) print "Using RX d'board %s" % (self.subdev.side_and_name(),) self.subdev.set_gain(30) rf_freq = 106800000 # 106.8MHz self.set_freq(rf_freq) print "Freq: ", rf_freq self.subdev.select_rx_antenna("TX/RX") #low pass filter self.sample_rate = adc_rate / hw_decim self.lpf_decim = 20 # so after channel filter, the sample rate is 200KHz self.lp_filter = gr.fir_filter_ccf( self.lpf_decim, gr.firdes.low_pass ( 1, self.sample_rate, 100e3, # cut off freq 10e3, # transition band gr.firdes.WIN_BLACKMAN, # Window function 6.76 # not used )) # WBFM receiver quad_rate = self.sample_rate #input rate of demodulator max_dev = 75e3 #max deviation of FM Broadcast fm_demod_gain = quad_rate/(2 * math.pi * max_dev) self.fm_decoder = gr.quadrature_demod_cf (fm_demod_gain) # Rational Resampler self.audio_sample_rate = 96000 self.rational_resampler = blks2.rational_resampler_fff ( interpolation = int(self.audio_sample_rate/1000), decimation = int(self.sample_rate/self.lpf_decim/1000), taps = None, fractional_bw = None, ) self.audio_sink = audio.sink (int(self.audio_sample_rate), "", True) #connections self.connect ( self.usrp, self.lp_filter, self.fm_decoder, self.rational_resampler, self.audio_sink )
def __init__(self, output_rate): gr.hier_block2.__init__( self, "p25_c4fm_mod_bf", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(1, 1, gr.sizeof_float)) # Output signature symbol_rate = 4800 # P25 baseband symbol rate lcm = gru.lcm(symbol_rate, output_rate) self._interp_factor = int(lcm // symbol_rate) self._decimation = int(lcm // output_rate) self._excess_bw = 0.2 mod_map = [1.0 / 3.0, 1.0, -(1.0 / 3.0), -1.0] self.C2S = gr.chunks_to_symbols_bf(mod_map) ntaps = 11 * self._interp_factor rrc_taps = gr.firdes.root_raised_cosine( self._interp_factor, # gain (since we're interpolating by sps) lcm, # sampling rate symbol_rate, self._excess_bw, # excess bandwidth (roll-off factor) ntaps) self.rrc_filter = gr.interp_fir_filter_fff(self._interp_factor, rrc_taps) # FM pre-emphasis filter shaping_coeffs = [ -0.018, 0.0347, 0.0164, -0.0064, -0.0344, -0.0522, -0.0398, 0.0099, 0.0798, 0.1311, 0.121, 0.0322, -0.113, -0.2499, -0.3007, -0.2137, -0.0043, 0.2825, 0.514, 0.604, 0.514, 0.2825, -0.0043, -0.2137, -0.3007, -0.2499, -0.113, 0.0322, 0.121, 0.1311, 0.0798, 0.0099, -0.0398, -0.0522, -0.0344, -0.0064, 0.0164, 0.0347, -0.018 ] self.shaping_filter = gr.fir_filter_fff(1, shaping_coeffs) # generate output at appropriate rate self.decimator = blks2.rational_resampler_fff(1, self._decimation) self.connect(self, self.C2S, self.rrc_filter, self.shaping_filter, self.decimator, self)
def __init__(self, center_freq, offset_freq, decimate_am=1, play_audio=False): """Configure the RTL-SDR and GNU Radio""" super(rtlsdr_am_stream, self).__init__() audio_rate = 44100 device_rate = audio_rate * 25 output_rate = audio_rate / float(decimate_am) self.rate = output_rate self.osmosdr_source = osmosdr.source_c("") self.osmosdr_source.set_center_freq(freq) self.osmosdr_source.set_sample_rate(device_rate) taps = firdes.low_pass(1, device_rate, 40000, 5000, firdes.WIN_HAMMING, 6.76) self.freq_filter = gr.freq_xlating_fir_filter_ccc( 25, taps, -freq_offs, device_rate) self.am_demod = blks2.am_demod_cf( channel_rate=audio_rate, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.resampler = blks2.rational_resampler_fff( interpolation=1, decimation=decimate_am, ) self.sink = gr_queue.queue_sink_f() self.connect(self.osmosdr_source, self.freq_filter, self.am_demod) self.connect(self.am_demod, self.resampler, self.sink) if play_audio: self.audio_sink = audio.sink(audio_rate, "", True) self.connect(self.am_demod, self.audio_sink)
def __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-I", "--filename", type="string", help="read input from wav FILE") parser.add_option("-s", "--input-rate", type="eng_float", default="500k", help="set sample rate to RATE (500k)") parser.add_option("-O", "--outname", type="string", help="output to wav file FILE") parser.add_option("-r", "--output-rate", type="eng_float", default="192k", help="set output sample rate to RATE (192k)") parser.add_option("-F", "--filter", action="store_true", default=False, help="filter out audible sounds, retain ultrasonic") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() raise SystemExit, 1 src = gr.wavfile_source (options.filename) input_rate = int(options.input_rate) output_rate = int(options.output_rate) interp = gru.lcm(input_rate, output_rate) / input_rate decim = gru.lcm(input_rate, output_rate) / output_rate dst = gr.wavfile_sink (options.outname, 1, output_rate) rr = blks2.rational_resampler_fff(int(interp), int(decim)) if options.filter: highpass = gr.firdes.high_pass (1, # gain output_rate, # sampling rate 15000, # cutoff freq 2000, # width of trans. band gr.firdes.WIN_HANN) # filter type filt = gr.fir_filter_fff(1,highpass) self.connect (src, rr, filt, dst) else: self.connect (src, rr, dst)
def __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option( "-O", "--audio-output", type="string", default="", help="pcm output device name. E.g., hw:0,0 or /dev/dsp") parser.add_option("-i", "--input-rate", type="eng_float", default=8000, help="set input sample rate to RATE (%default)") parser.add_option("-o", "--output-rate", type="eng_float", default=48000, help="set output sample rate to RATE (%default)") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() raise SystemExit, 1 input_rate = int(options.input_rate) output_rate = int(options.output_rate) interp = gru.lcm(input_rate, output_rate) / input_rate decim = gru.lcm(input_rate, output_rate) / output_rate print "interp =", interp print "decim =", decim ampl = 0.1 src0 = gr.sig_source_f(input_rate, gr.GR_SIN_WAVE, 650, ampl) rr = blks2.rational_resampler_fff(interp, decim) dst = audio.sink(output_rate, options.audio_output) self.connect(src0, rr, (dst, 0))
def __init__(self, frame, panel, vbox, argv): stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) parser = OptionParser(option_class=eng_option) parser.add_option("-T", "--tx-subdev-spec", type="subdev", default=None, help="select USRP Tx side A or B") parser.add_option("-f", "--freq", type="eng_float", default=107.2e6, help="set Tx frequency to FREQ [required]", metavar="FREQ") parser.add_option("--wavfile", type="string", default="", help="read input from FILE") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.usrp_interp = 200 self.u = usrp.sink_c(0, self.usrp_interp) print "USRP Serial: ", self.u.serial_number() self.dac_rate = self.u.dac_rate() # 128 MS/s self.usrp_rate = self.dac_rate / self.usrp_interp # 640 kS/s self.sw_interp = 5 self.audio_rate = self.usrp_rate / self.sw_interp # 128 kS/s # determine the daughterboard subdevice we're using if options.tx_subdev_spec is None: options.tx_subdev_spec = usrp.pick_tx_subdevice(self.u) self.u.set_mux( usrp.determine_tx_mux_value(self.u, options.tx_subdev_spec)) self.subdev = usrp.selected_subdev(self.u, options.tx_subdev_spec) print "Using d'board: ", self.subdev.side_and_name() # set max Tx gain, tune frequency and enable transmitter self.subdev.set_gain(self.subdev.gain_range()[1]) if self.u.tune(self.subdev.which(), self.subdev, options.freq): print "Tuned to", options.freq / 1e6, "MHz" else: sys.exit(1) self.subdev.set_enable(True) # open wav file containing floats in the [-1, 1] range, repeat if options.wavfile is None: print "Please provide a wavfile to transmit! Exiting\n" sys.exit(1) self.src = gr.wavfile_source(options.wavfile, True) nchans = self.src.channels() sample_rate = self.src.sample_rate() bits_per_sample = self.src.bits_per_sample() print nchans, "channels,", sample_rate, "kS/s,", bits_per_sample, "bits/sample" # resample to 128kS/s if sample_rate == 44100: self.resample_left = blks2.rational_resampler_fff(32, 11) self.resample_right = blks2.rational_resampler_fff(32, 11) elif sample_rate == 48000: self.resample_left == blks2.rational_resampler_fff(8, 3) self.resample_right == blks2.rational_resampler_fff(8, 3) elif sample_rate == 8000: self.resample_left == blks2.rational_resampler_fff(16, 1) self.resample_right == blks2.rational_resampler_fff(16, 1) else: print sample_rate, "is an unsupported sample rate" sys.exit(1) self.connect((self.src, 0), self.resample_left) self.connect((self.src, 1), self.resample_right) # create L+R (mono) and L-R (stereo) self.audio_lpr = gr.add_ff() self.audio_lmr = gr.sub_ff() self.connect(self.resample_left, (self.audio_lpr, 0)) self.connect(self.resample_left, (self.audio_lmr, 0)) self.connect(self.resample_right, (self.audio_lpr, 1)) self.connect(self.resample_right, (self.audio_lmr, 1)) # low-pass filter for L+R audio_lpr_taps = gr.firdes.low_pass( 0.3, # gain self.audio_rate, # sampling rate 15e3, # passband cutoff 2e3, # transition width gr.firdes.WIN_HANN) self.audio_lpr_filter = gr.fir_filter_fff(1, audio_lpr_taps) self.connect(self.audio_lpr, self.audio_lpr_filter) # create pilot tone at 19 kHz self.pilot = gr.sig_source_f( self.audio_rate, # sampling freq gr.GR_SIN_WAVE, # waveform 19e3, # frequency 3e-2) # amplitude # create the L-R signal carrier at 38 kHz, high-pass to remove 0Hz tone self.stereo_carrier = gr.multiply_ff() self.connect(self.pilot, (self.stereo_carrier, 0)) self.connect(self.pilot, (self.stereo_carrier, 1)) stereo_carrier_taps = gr.firdes.high_pass( 1, # gain self.audio_rate, # sampling rate 1e4, # cutoff freq 2e3, # transition width gr.firdes.WIN_HANN) self.stereo_carrier_filter = gr.fir_filter_fff(1, stereo_carrier_taps) self.connect(self.stereo_carrier, self.stereo_carrier_filter) # upconvert L-R to 23-53 kHz and band-pass self.mix_stereo = gr.multiply_ff() audio_lmr_taps = gr.firdes.band_pass( 3e3, # gain self.audio_rate, # sampling rate 23e3, # low cutoff 53e3, # high cuttof 2e3, # transition width gr.firdes.WIN_HANN) self.audio_lmr_filter = gr.fir_filter_fff(1, audio_lmr_taps) self.connect(self.audio_lmr, (self.mix_stereo, 0)) self.connect(self.stereo_carrier_filter, (self.mix_stereo, 1)) self.connect(self.mix_stereo, self.audio_lmr_filter) # mix L+R, pilot and L-R self.mixer = gr.add_ff() self.connect(self.audio_lpr_filter, (self.mixer, 0)) self.connect(self.pilot, (self.mixer, 1)) self.connect(self.audio_lmr_filter, (self.mixer, 2)) # interpolation & pre-emphasis interp_taps = gr.firdes.low_pass( self.sw_interp, # gain self.audio_rate, # Fs 60e3, # cutoff freq 5e3, # transition width gr.firdes.WIN_HAMMING) self.interpolator = gr.interp_fir_filter_fff(self.sw_interp, interp_taps) self.pre_emph = blks2.fm_preemph(self.usrp_rate, tau=50e-6) self.connect(self.mixer, self.interpolator, self.pre_emph) # fm modulation, gain & TX max_dev = 100e3 k = 2 * math.pi * max_dev / self.usrp_rate # modulator sensitivity self.modulator = gr.frequency_modulator_fc(k) self.gain = gr.multiply_const_cc(1e3) self.connect(self.pre_emph, self.modulator, self.gain, self.u) # plot an FFT to verify we are sending what we want pre_mod = fftsink2.fft_sink_f(panel, title="Before Interpolation", fft_size=512, sample_rate=self.audio_rate, y_per_div=20, ref_level=20) self.connect(self.mixer, pre_mod) vbox.Add(pre_mod.win, 1, wx.EXPAND)
def __init__(self, gain=0, audio_output="", samp_rate=400e3, address="addr=192.168.10.2", freq=96e6): grc_wxgui.top_block_gui.__init__(self, title="UHD WBFM Receive") ################################################## # Parameters ################################################## self.gain = gain self.audio_output = audio_output self.samp_rate = samp_rate self.address = address self.freq = freq ################################################## # Variables ################################################## self.volume = volume = 1 self.tun_gain = tun_gain = gain self.tun_freq = tun_freq = freq self.fine = fine = 0 self.audio_decim = audio_decim = 10 ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_volume_sizer, 1, 0, 1, 4) _tun_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._tun_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_tun_gain_sizer, value=self.tun_gain, callback=self.set_tun_gain, label="UHD Gain", converter=forms.float_converter(), proportion=0, ) self._tun_gain_slider = forms.slider( parent=self.GetWin(), sizer=_tun_gain_sizer, value=self.tun_gain, callback=self.set_tun_gain, minimum=0, maximum=20, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_tun_gain_sizer) _tun_freq_sizer = wx.BoxSizer(wx.VERTICAL) self._tun_freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_tun_freq_sizer, value=self.tun_freq, callback=self.set_tun_freq, label="Freq (Hz)", converter=forms.float_converter(), proportion=0, ) self._tun_freq_slider = forms.slider( parent=self.GetWin(), sizer=_tun_freq_sizer, value=self.tun_freq, callback=self.set_tun_freq, minimum=87.9e6, maximum=108.1e6, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_tun_freq_sizer) _fine_sizer = wx.BoxSizer(wx.VERTICAL) self._fine_text_box = forms.text_box( parent=self.GetWin(), sizer=_fine_sizer, value=self.fine, callback=self.set_fine, label="Fine Freq (MHz)", converter=forms.float_converter(), proportion=0, ) self._fine_slider = forms.slider( parent=self.GetWin(), sizer=_fine_sizer, value=self.fine, callback=self.set_fine, minimum=-.1, maximum=.1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_fine_sizer, 0, 2, 1, 2) self.wxgui_fftsink2 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=(freq + fine), 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=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.GridAdd(self.wxgui_fftsink2.win, 2, 0, 2, 4) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr=address, 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(tun_freq + fine, 0) self.uhd_usrp_source_0.set_gain(tun_gain, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.low_pass_filter_0 = gr.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 115e3, 30e3, firdes.WIN_HANN, 6.76)) self.gr_multiply_const_vxx = gr.multiply_const_vff((volume, )) self.blks2_wfm_rcv = blks2.wfm_rcv( quad_rate=samp_rate, audio_decimation=audio_decim, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=48, decimation=40, taps=None, fractional_bw=None, ) self.audio_sink = audio.sink(48000, audio_output, True) ################################################## # Connections ################################################## self.connect((self.gr_multiply_const_vxx, 0), (self.audio_sink, 0)) self.connect((self.low_pass_filter_0, 0), (self.blks2_wfm_rcv, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2, 0)) self.connect((self.blks2_wfm_rcv, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_multiply_const_vxx, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Rds Tx") _icon_path = "/home/azimout/.local/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.usrp_interp = usrp_interp = 500 self.dac_rate = dac_rate = 128e6 self.wav_rate = wav_rate = 44100 self.usrp_rate = usrp_rate = int(dac_rate / usrp_interp) self.fm_max_dev = fm_max_dev = 120e3 ################################################## # Blocks ################################################## self.band_pass_filter_0 = gr.interp_fir_filter_fff( 1, firdes.band_pass(1, usrp_rate, 54e3, 60e3, 3e3, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_1 = gr.interp_fir_filter_fff( 1, firdes.band_pass(1, usrp_rate, 23e3, 53e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_fff( interpolation=usrp_rate, decimation=wav_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_1_0 = blks2.rational_resampler_fff( interpolation=usrp_rate, decimation=wav_rate, taps=None, fractional_bw=None, ) self.gr_add_xx_0 = gr.add_vff(1) self.gr_add_xx_1 = gr.add_vff(1) self.gr_char_to_float_0 = gr.char_to_float() self.gr_diff_encoder_bb_0 = gr.diff_encoder_bb(2) self.gr_frequency_modulator_fc_0 = gr.frequency_modulator_fc( 2 * math.pi * fm_max_dev / usrp_rate) self.gr_map_bb_0 = gr.map_bb(([-1, 1])) self.gr_map_bb_1 = gr.map_bb(([1, 2])) self.gr_multiply_xx_0 = gr.multiply_vff(1) self.gr_multiply_xx_1 = gr.multiply_vff(1) self.gr_rds_data_encoder_0 = rds.data_encoder( "/media/dimitris/mywork/gr/dimitris/rds/trunk/src/test/rds_data.xml" ) self.gr_rds_rate_enforcer_0 = rds.rate_enforcer(256000) self.gr_sig_source_x_0 = gr.sig_source_f(usrp_rate, gr.GR_COS_WAVE, 19e3, 0.3, 0) self.gr_sub_xx_0 = gr.sub_ff(1) self.gr_unpack_k_bits_bb_0 = gr.unpack_k_bits_bb(2) self.gr_wavfile_source_0 = gr.wavfile_source( "/media/dimitris/mywork/gr/dimitris/rds/trunk/src/python/limmenso_stereo.wav", True) self.low_pass_filter_0 = gr.interp_fir_filter_fff( 1, firdes.low_pass(1, usrp_rate, 1.5e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = gr.interp_fir_filter_fff( 1, firdes.low_pass(1, usrp_rate, 15e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.usrp_simple_sink_x_0 = grc_usrp.simple_sink_c(which=0, side="A") self.usrp_simple_sink_x_0.set_interp_rate(500) self.usrp_simple_sink_x_0.set_frequency(107.2e6, verbose=True) self.usrp_simple_sink_x_0.set_gain(0) self.usrp_simple_sink_x_0.set_enable(True) self.usrp_simple_sink_x_0.set_auto_tr(True) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.GetWin(), baseband_freq=0, y_per_div=20, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=usrp_rate, fft_size=1024, fft_rate=30, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) ################################################## # Connections ################################################## self.connect((self.gr_sig_source_x_0, 0), (self.gr_rds_rate_enforcer_0, 1)) self.connect((self.gr_char_to_float_0, 0), (self.gr_rds_rate_enforcer_0, 0)) self.connect((self.gr_map_bb_0, 0), (self.gr_char_to_float_0, 0)) self.connect((self.gr_frequency_modulator_fc_0, 0), (self.usrp_simple_sink_x_0, 0)) self.connect((self.gr_add_xx_1, 0), (self.gr_frequency_modulator_fc_0, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_add_xx_1, 1)) self.connect((self.gr_sub_xx_0, 0), (self.gr_multiply_xx_1, 2)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_1, 1)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_1, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 3)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 2)) self.connect((self.blks2_rational_resampler_xxx_1_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_add_xx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1_0, 0), (self.gr_sub_xx_0, 1)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_sub_xx_0, 0)) self.connect((self.gr_wavfile_source_0, 1), (self.blks2_rational_resampler_xxx_1_0, 0)) self.connect((self.gr_wavfile_source_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.gr_rds_data_encoder_0, 0), (self.gr_diff_encoder_bb_0, 0)) self.connect((self.gr_diff_encoder_bb_0, 0), (self.gr_map_bb_1, 0)) self.connect((self.gr_map_bb_1, 0), (self.gr_unpack_k_bits_bb_0, 0)) self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_map_bb_0, 0)) self.connect((self.gr_rds_rate_enforcer_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.gr_add_xx_1, 0)) self.connect((self.gr_multiply_xx_1, 0), (self.band_pass_filter_1, 0)) self.connect((self.band_pass_filter_1, 0), (self.gr_add_xx_1, 3)) self.connect((self.gr_add_xx_1, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_add_xx_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.gr_add_xx_1, 2))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Example bitcpf - FM Rx") _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 = 8e6 self.rx_gain = rx_gain = 15 self.lpf_decim = lpf_decim = 20 self.freq = freq = 106.7e6 self.audio_samp_rate = audio_samp_rate = 96e3 ################################################## # Blocks ################################################## _rx_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._rx_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_rx_gain_sizer, value=self.rx_gain, callback=self.set_rx_gain, label='rx_gain', converter=forms.float_converter(), proportion=0, ) self._rx_gain_slider = forms.slider( parent=self.GetWin(), sizer=_rx_gain_sizer, value=self.rx_gain, callback=self.set_rx_gain, minimum=0, maximum=30, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_rx_gain_sizer) self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RF") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Audio") self.Add(self.notebook_0) 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) self.wxgui_fftsink2_1 = fftsink2.fft_sink_f( self.notebook_0.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate / lpf_decim, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0.win) 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(rx_gain, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.low_pass_filter_0 = gr.fir_filter_ccf( lpf_decim, firdes.low_pass(1, samp_rate, 100e3, 10e3, firdes.WIN_HAMMING, 6.76)) self.gr_wavfile_sink_0 = gr.wavfile_sink("fm_record.wav", 1, int(audio_samp_rate), 8) self.blks2_wfm_rcv_0 = blks2.wfm_rcv( quad_rate=samp_rate / lpf_decim, audio_decimation=1, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=96, decimation=int(samp_rate / lpf_decim / 1000), taps=None, fractional_bw=None, ) self.audio_sink_0 = audio.sink(int(audio_samp_rate), "", True) ################################################## # Connections ################################################## self.connect((self.low_pass_filter_0, 0), (self.blks2_wfm_rcv_0, 0)) self.connect((self.blks2_wfm_rcv_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_wavfile_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_wfm_rcv_0, 0), (self.wxgui_fftsink2_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self, options): gr.top_block.__init__(self) self.options = options (dev_rate, channel_rate, audio_rate, channel_pass, channel_stop, demod) = demod_params[options.modulation] DEV = uhd_src(options.args, # UHD device address options.spec, # device subdev spec options.antenna, # device antenna dev_rate, # device sample rate options.gain, # Receiver gain options.calibration) # Frequency offset DEV.tune(options.frequency) if_rate = DEV.rate() channel_decim = int(if_rate // channel_rate) audio_decim = int(channel_rate // audio_rate) CHAN_taps = optfir.low_pass(1.0, # Filter gain if_rate, # Sample rate channel_pass, # One sided modulation bandwidth channel_stop, # One sided channel bandwidth 0.1, # Passband ripple 60) # Stopband attenuation CHAN = gr.freq_xlating_fir_filter_ccf(channel_decim, # Decimation rate CHAN_taps, # Filter taps 0.0, # Offset frequency if_rate) # Sample rate RFSQL = gr.pwr_squelch_cc(options.rf_squelch, # Power threshold 125.0/channel_rate, # Time constant int(channel_rate/20), # 50ms rise/fall False) # Zero, not gate output AGC = gr.agc_cc(1.0/channel_rate, # Time constant 1.0, # Reference power 1.0, # Initial gain 1.0) # Maximum gain DEMOD = demod(channel_rate, audio_decim) # From RF to audio #self.connect(DEV, CHAN, RFSQL, AGC, DEMOD) self.connect(DEV, CHAN, DEMOD) # Optionally add CTCSS and RSAMP if needed tail = DEMOD if options.ctcss != None and options.ctcss > 60.0: CTCSS = gr.ctcss_squelch_ff(audio_rate, # Sample rate options.ctcss) # Squelch tone self.connect(DEMOD, CTCSS) tail = CTCSS if options.output_rate != audio_rate: out_lcm = gru.lcm(audio_rate, options.output_rate) out_interp = int(out_lcm // audio_rate) out_decim = int(out_lcm // options.output_rate) RSAMP = blks2.rational_resampler_fff(out_interp, out_decim) self.connect(tail, RSAMP) tail = RSAMP # Send to audio output device AUDIO = audio.sink(int(options.output_rate), options.audio_output) self.connect(tail, AUDIO) # Direct asynchronous notifications to callback function if self.options.show_async_msg: self.async_msgq = gr.msg_queue(0) self.async_src = uhd.amsg_source("", self.async_msgq) self.async_rcv = gru.msgq_runner(self.async_msgq, self.async_callback)
def __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-a", "--audio-input", type="string", default="") parser.add_option("-A", "--analog-gain", type="float", default=1.0, help="output gain for analog channel") parser.add_option("-c", "--ctcss-freq", type="float", default=0.0, help="CTCSS tone frequency") parser.add_option("-d", "--debug", type="int", default=0, help="debug level") parser.add_option("-g", "--gain", type="eng_float", default=1, help="adjusts input level for standard data levels") parser.add_option("-H", "--hostname", type="string", default="127.0.0.1", help="asterisk host IP") parser.add_option("-p", "--port", type="int", default=32001, help="chan_usrp UDP port") parser.add_option("-s", "--sample-rate", type="int", default=48000, help="input sample rate") parser.add_option("-S", "--stretch", type="int", default=0) (options, args) = parser.parse_args() sample_rate = options.sample_rate symbol_rate = 4800 symbol_decim = 1 IN = audio.source(sample_rate, options.audio_input) symbol_coeffs = gr.firdes.root_raised_cosine( 1.0, # gain sample_rate, # sampling rate symbol_rate, # symbol rate 0.2, # width of trans. band 500) # filter type SYMBOL_FILTER = gr.fir_filter_fff(symbol_decim, symbol_coeffs) AMP = gr.multiply_const_ff(options.gain) msgq = gr.msg_queue(2) FSK4 = op25.fsk4_demod_ff(msgq, sample_rate, symbol_rate) levels = levels = [-2.0, 0.0, 2.0, 4.0] SLICER = repeater.fsk4_slicer_fb(levels) framer_msgq = gr.msg_queue(2) DECODE = repeater.p25_frame_assembler( '', # udp hostname 0, # udp port no. options.debug, #debug True, # do_imbe True, # do_output False, # do_msgq framer_msgq) IMBE = repeater.vocoder( False, # 0=Decode,True=Encode options.debug, # Verbose flag options.stretch, # flex amount "", # udp ip address 0, # udp port False) # dump raw u vectors CHAN_RPT = repeater.chan_usrp_rx(options.hostname, options.port, options.debug) self.connect(IN, AMP, SYMBOL_FILTER, FSK4, SLICER, DECODE, IMBE, CHAN_RPT) # blocks for second channel (fm rx) output_sample_rate = 8000 decim_amt = sample_rate / output_sample_rate RESAMP = blks2.rational_resampler_fff(1, decim_amt) if options.ctcss_freq > 0: level = 5.0 len = 0 ramp = 0 gate = True CTCSS = repeater.ctcss_squelch_ff(output_sample_rate, options.ctcss_freq, level, len, ramp, gate) AMP2 = gr.multiply_const_ff(32767.0 * options.analog_gain) CVT = gr.float_to_short() CHAN_RPT2 = repeater.chan_usrp_rx(options.hostname, options.port + 1, options.debug) if options.ctcss_freq > 0: self.connect(IN, RESAMP, CTCSS, AMP2, CVT, CHAN_RPT2) else: self.connect(IN, RESAMP, AMP2, CVT, CHAN_RPT2)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Rds Tx") _icon_path = "/home/azimout/.local/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.usrp_interp = usrp_interp = 500 self.dac_rate = dac_rate = 128e6 self.wav_rate = wav_rate = 44100 self.usrp_rate = usrp_rate = int(dac_rate/usrp_interp) self.fm_max_dev = fm_max_dev = 120e3 ################################################## # Blocks ################################################## self.band_pass_filter_0 = gr.interp_fir_filter_fff(1, firdes.band_pass( 1, usrp_rate, 54e3, 60e3, 3e3, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_1 = gr.interp_fir_filter_fff(1, firdes.band_pass( 1, usrp_rate, 23e3, 53e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_fff( interpolation=usrp_rate, decimation=wav_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_1_0 = blks2.rational_resampler_fff( interpolation=usrp_rate, decimation=wav_rate, taps=None, fractional_bw=None, ) self.gr_add_xx_0 = gr.add_vff(1) self.gr_add_xx_1 = gr.add_vff(1) self.gr_char_to_float_0 = gr.char_to_float() self.gr_diff_encoder_bb_0 = gr.diff_encoder_bb(2) self.gr_frequency_modulator_fc_0 = gr.frequency_modulator_fc(2*math.pi*fm_max_dev/usrp_rate) self.gr_map_bb_0 = gr.map_bb(([-1,1])) self.gr_map_bb_1 = gr.map_bb(([1,2])) self.gr_multiply_xx_0 = gr.multiply_vff(1) self.gr_multiply_xx_1 = gr.multiply_vff(1) self.gr_rds_data_encoder_0 = rds.data_encoder("/media/dimitris/mywork/gr/dimitris/rds/trunk/src/test/rds_data.xml") self.gr_rds_rate_enforcer_0 = rds.rate_enforcer(256000) self.gr_sig_source_x_0 = gr.sig_source_f(usrp_rate, gr.GR_COS_WAVE, 19e3, 0.3, 0) self.gr_sub_xx_0 = gr.sub_ff(1) self.gr_unpack_k_bits_bb_0 = gr.unpack_k_bits_bb(2) self.gr_wavfile_source_0 = gr.wavfile_source("/media/dimitris/mywork/gr/dimitris/rds/trunk/src/python/limmenso_stereo.wav", True) self.low_pass_filter_0 = gr.interp_fir_filter_fff(1, firdes.low_pass( 1, usrp_rate, 1.5e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = gr.interp_fir_filter_fff(1, firdes.low_pass( 1, usrp_rate, 15e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.usrp_simple_sink_x_0 = grc_usrp.simple_sink_c(which=0, side="A") self.usrp_simple_sink_x_0.set_interp_rate(500) self.usrp_simple_sink_x_0.set_frequency(107.2e6, verbose=True) self.usrp_simple_sink_x_0.set_gain(0) self.usrp_simple_sink_x_0.set_enable(True) self.usrp_simple_sink_x_0.set_auto_tr(True) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.GetWin(), baseband_freq=0, y_per_div=20, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=usrp_rate, fft_size=1024, fft_rate=30, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) ################################################## # Connections ################################################## self.connect((self.gr_sig_source_x_0, 0), (self.gr_rds_rate_enforcer_0, 1)) self.connect((self.gr_char_to_float_0, 0), (self.gr_rds_rate_enforcer_0, 0)) self.connect((self.gr_map_bb_0, 0), (self.gr_char_to_float_0, 0)) self.connect((self.gr_frequency_modulator_fc_0, 0), (self.usrp_simple_sink_x_0, 0)) self.connect((self.gr_add_xx_1, 0), (self.gr_frequency_modulator_fc_0, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_add_xx_1, 1)) self.connect((self.gr_sub_xx_0, 0), (self.gr_multiply_xx_1, 2)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_1, 1)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_1, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 3)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 2)) self.connect((self.blks2_rational_resampler_xxx_1_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_add_xx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1_0, 0), (self.gr_sub_xx_0, 1)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_sub_xx_0, 0)) self.connect((self.gr_wavfile_source_0, 1), (self.blks2_rational_resampler_xxx_1_0, 0)) self.connect((self.gr_wavfile_source_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.gr_rds_data_encoder_0, 0), (self.gr_diff_encoder_bb_0, 0)) self.connect((self.gr_diff_encoder_bb_0, 0), (self.gr_map_bb_1, 0)) self.connect((self.gr_map_bb_1, 0), (self.gr_unpack_k_bits_bb_0, 0)) self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_map_bb_0, 0)) self.connect((self.gr_rds_rate_enforcer_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.gr_add_xx_1, 0)) self.connect((self.gr_multiply_xx_1, 0), (self.band_pass_filter_1, 0)) self.connect((self.band_pass_filter_1, 0), (self.gr_add_xx_1, 3)) self.connect((self.gr_add_xx_1, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_add_xx_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.gr_add_xx_1, 2))
def __init__(self, antenna="TX/RX", rx_gain=30, vor_samp_rate=250e3, com_freq_1=135.275e6, gain=21, vor_freq_1=115e6): grc_wxgui.top_block_gui.__init__(self, title="Simple Trx") ################################################## # Parameters ################################################## self.antenna = antenna self.rx_gain = rx_gain self.vor_samp_rate = vor_samp_rate self.com_freq_1 = com_freq_1 self.gain = gain self.vor_freq_1 = vor_freq_1 ################################################## # Variables ################################################## self.obs_decimation = obs_decimation = 25 self.ils_decimation = ils_decimation = 50 self.am_sample_rate = am_sample_rate = 12.5e3 self.vor_volume_slider = vor_volume_slider = 5 self.vor_ident = vor_ident = False 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.system_center_freq = system_center_freq = 133.9e6 self.squelch_slider = squelch_slider = -85 self.samp_rate = samp_rate = 250e3 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.correction_gain = correction_gain = 0.8 self.com_volume_slider = com_volume_slider = 1 self.com_freq_entry_1 = com_freq_entry_1 = com_freq_1 self.com_enable = com_enable = True self.audio_select = audio_select = 0 self.audio_sample_rate = audio_sample_rate = 48e3 self.am_decimation = am_decimation = 1 ################################################## # Blocks ################################################## _vor_volume_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._vor_volume_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_vor_volume_slider_sizer, value=self.vor_volume_slider, callback=self.set_vor_volume_slider, label='vor_volume_slider', converter=forms.float_converter(), proportion=0, ) self._vor_volume_slider_slider = forms.slider( parent=self.GetWin(), sizer=_vor_volume_slider_sizer, value=self.vor_volume_slider, callback=self.set_vor_volume_slider, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_vor_volume_slider_sizer, 1, 4, 1, 1) self._vor_ident_check_box = forms.check_box( parent=self.GetWin(), value=self.vor_ident, callback=self.set_vor_ident, label='vor_ident', true=1, false=0, ) self.GridAdd(self._vor_ident_check_box, 0, 3, 1, 1) self._vor_freq_entry_1_text_box = forms.text_box( parent=self.GetWin(), value=self.vor_freq_entry_1, callback=self.set_vor_freq_entry_1, label='vor_freq_entry_1', converter=forms.float_converter(), ) self.GridAdd(self._vor_freq_entry_1_text_box, 0, 1, 1, 1) 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) _com_volume_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._com_volume_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_com_volume_slider_sizer, value=self.com_volume_slider, callback=self.set_com_volume_slider, label='com_volume_slider', converter=forms.float_converter(), proportion=0, ) self._com_volume_slider_slider = forms.slider( parent=self.GetWin(), sizer=_com_volume_slider_sizer, value=self.com_volume_slider, callback=self.set_com_volume_slider, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_com_volume_slider_sizer, 1, 5, 1, 1) self._com_freq_entry_1_text_box = forms.text_box( parent=self.GetWin(), value=self.com_freq_entry_1, callback=self.set_com_freq_entry_1, label='com_freq_entry_1', converter=forms.float_converter(), ) self.GridAdd(self._com_freq_entry_1_text_box, 0, 0, 1, 1) self._com_enable_check_box = forms.check_box( parent=self.GetWin(), value=self.com_enable, callback=self.set_com_enable, label='com_enable', true=1, false=0, ) self.GridAdd(self._com_enable_check_box, 2, 3, 1, 1) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.notebook_0.GetPage(3).GetWin(), title="Scope Plot", sample_rate=12.5e3, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.notebook_0.GetPage(3).Add(self.wxgui_scopesink2_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=-200, maxval=200, factor=1.0, decimal_places=10, ref_level=0, sample_rate=25e3 / 2000, number_rate=15, average=True, avg_alpha=0.02, label="Number Plot", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0_1 = 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=25e3, 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_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(1).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(1).Add(self.wxgui_fftsink2_0.win) 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_clock_source("internal", 0) 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=system_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(vor_freq_entry_1, rf_freq=system_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 1) self.uhd_usrp_source_0.set_gain(rx_gain, 1) self.uhd_usrp_source_0.set_antenna("RX2", 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(com_freq_entry_1, 0) self.uhd_usrp_sink_0.set_gain(25, 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.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.GetWin(), sizer=_squelch_slider_sizer, value=self.squelch_slider, callback=self.set_squelch_slider, minimum=-100, maximum=0, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_squelch_slider_sizer, 1, 0, 1, 1) self.squelch = gr.pwr_squelch_cc(squelch_slider, 0.01, 20, False) self.openavionics_joystick_interface_0 = openavionics.joystick_interface( ) self.openavionics_audio_ptt_0 = openavionics.audio_ptt() self.low_pass_filter_3_0 = filter.fir_filter_fff( 5, firdes.low_pass(1, 25e3, 200, 50, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_3 = filter.fir_filter_fff( 5, firdes.low_pass(1, 25e3, 200, 50, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2 = filter.fir_filter_ccf( 1, firdes.low_pass(1, 25e3, 3e3, 500, 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_0 = filter.fir_filter_ccf( int(250e3 / 25e3), firdes.low_pass(1, vor_samp_rate, 11e3, 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.gr_sig_source_x_0 = gr.sig_source_c(25e3, gr.GR_COS_WAVE, 9960, 1, 0) self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf(1) self.gr_pwr_squelch_xx_0 = gr.pwr_squelch_ff(-50, 0.5, 1, False) self.gr_null_sink_0_0 = gr.null_sink(gr.sizeof_gr_complex * 1) self.gr_multiply_xx_0_0_1 = gr.multiply_vff(1) self.gr_multiply_xx_0_0_0_0 = gr.multiply_vcc(1) self.gr_multiply_xx_0 = gr.multiply_vcc(1) self.gr_float_to_complex_0_0_0 = gr.float_to_complex(1) self.gr_float_to_complex_0 = gr.float_to_complex(1) self.gr_agc2_xx_0_0 = gr.agc2_cc(1, 1, 0.75, 1.0, 0.0) self.gr_agc2_xx_0 = gr.agc2_cc(1, 1, 0.75, 1.0, 0.0) self.gr_add_xx_0_0_0 = gr.add_vff(1) _gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_slider_text_box = forms.text_box( parent=self.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.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.GridAdd(_gain_slider_sizer, 1, 1, 1, 1) self.fft_tone_to_angle_0 = fft_tone_to_angle( fft_bin=12, fft_size=2000, ) self.const_source_x_0_1 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0.450) self.const_source_x_0_0_1 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0.550) self.const_source_x_0_0_0_0 = gr.sig_source_c(0, gr.GR_CONST_WAVE, 0, 0, 0.450) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (180.0 / 3.1415, )) self.blocks_add_xx_0 = blocks.add_vff(1) self.blks2_rational_resampler_xxx_2_0 = blks2.rational_resampler_fff( interpolation=250, decimation=48, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_fff( interpolation=480, decimation=125, taps=None, fractional_bw=None, ) self.blks2_am_demod_cf_0_0 = blks2.am_demod_cf( channel_rate=25e3, audio_decim=am_decimation, audio_pass=11.5e3, audio_stop=12.250e3, ) self.blks2_am_demod_cf_0 = blks2.am_demod_cf( channel_rate=am_sample_rate, audio_decim=am_decimation, audio_pass=3e3, audio_stop=4e3, ) self.band_pass_filter_0 = gr.fir_filter_fff( 2, firdes.band_pass(1, 25000, 980, 1150, 50, firdes.WIN_HAMMING, 6.76)) 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.GridAdd(self._audio_select_chooser, 0, 2, 1, 1) self.analog_sig_source_x_0_0 = analog.sig_source_f( 48000, analog.GR_COS_WAVE, 1000, 1, 0) self.adsf_0 = blocks.multiply_const_vff( (com_enable * com_volume_slider, )) self.adsf = blocks.multiply_const_vff( (vor_ident * vor_volume_slider, )) ################################################## # Connections ################################################## self.connect((self.gr_float_to_complex_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_am_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.gr_null_sink_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.squelch, 0)) self.connect((self.squelch, 0), (self.gr_agc2_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_agc2_xx_0, 0), (self.blks2_am_demod_cf_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.wxgui_fftsink2_0_1, 0)) self.connect((self.gr_agc2_xx_0_0, 0), (self.blks2_am_demod_cf_0_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.low_pass_filter_0_0, 0)) self.connect((self.blks2_am_demod_cf_0_0, 0), (self.gr_float_to_complex_0, 0)) self.connect((self.fft_tone_to_angle_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.fft_tone_to_angle_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.fft_tone_to_angle_0, 2), (self.blocks_null_sink_1, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.gr_agc2_xx_0_0, 0)) self.connect((self.gr_quadrature_demod_cf_0, 0), (self.low_pass_filter_3, 0)) self.connect((self.low_pass_filter_3, 0), (self.fft_tone_to_angle_0, 0)) self.connect((self.low_pass_filter_3_0, 0), (self.fft_tone_to_angle_0, 1)) self.connect((self.blks2_am_demod_cf_0_0, 0), (self.low_pass_filter_3_0, 0)) self.connect((self.blks2_am_demod_cf_0_0, 0), (self.gr_float_to_complex_0, 1)) self.connect((self.gr_multiply_xx_0, 0), (self.low_pass_filter_2, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.low_pass_filter_2, 0), (self.gr_quadrature_demod_cf_0, 0)) self.connect((self.blks2_am_demod_cf_0_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.adsf, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.adsf, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.low_pass_filter_1, 0), (self.adsf_0, 0)) self.connect((self.adsf_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.adsf_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.gr_pwr_squelch_xx_0, 0)) self.connect((self.gr_pwr_squelch_xx_0, 0), (self.adsf, 0)) self.connect((self.const_source_x_0_0_0_0, 0), (self.gr_multiply_xx_0_0_0_0, 1)) self.connect((self.gr_float_to_complex_0_0_0, 0), (self.gr_multiply_xx_0_0_0_0, 0)) self.connect((self.gr_add_xx_0_0_0, 0), (self.gr_float_to_complex_0_0_0, 1)) self.connect((self.gr_add_xx_0_0_0, 0), (self.gr_float_to_complex_0_0_0, 0)) self.connect((self.const_source_x_0_0_1, 0), (self.gr_add_xx_0_0_0, 1)) self.connect((self.gr_multiply_xx_0_0_1, 0), (self.gr_add_xx_0_0_0, 0)) self.connect((self.const_source_x_0_1, 0), (self.gr_multiply_xx_0_0_1, 1)) self.connect((self.gr_multiply_xx_0_0_0_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_2_0, 0), (self.openavionics_audio_ptt_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blks2_rational_resampler_xxx_2_0, 0)) self.connect((self.openavionics_audio_ptt_0, 0), (self.gr_multiply_xx_0_0_1, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.openavionics_joystick_interface_0, "out", self.openavionics_audio_ptt_0, "in2")
def __init__(self, options): gr.top_block.__init__(self) self.options = options (usrp_decim, channel_decim, audio_decim, channel_pass, channel_stop, demod) = demod_params[options.modulation] USRP = usrp_src(options.rx_subdev_spec, # Daugherboard spec usrp_decim, # IF decimation ratio options.gain, # Receiver gain options.calibration) # Frequency offset USRP.tune(options.frequency) if_rate = USRP.rate() channel_rate = if_rate // channel_decim audio_rate = channel_rate // audio_decim CHAN_taps = optfir.low_pass(1.0, # Filter gain if_rate, # Sample rate channel_pass, # One sided modulation bandwidth channel_stop, # One sided channel bandwidth 0.1, # Passband ripple 60) # Stopband attenuation CHAN = gr.freq_xlating_fir_filter_ccf(channel_decim, # Decimation rate CHAN_taps, # Filter taps 0.0, # Offset frequency if_rate) # Sample rate RFSQL = gr.pwr_squelch_cc(options.rf_squelch, # Power threshold 125.0/channel_rate, # Time constant channel_rate/20, # 50ms rise/fall False) # Zero, not gate output AGC = gr.agc_cc(1.0/channel_rate, # Time constant 1.0, # Reference power 1.0, # Initial gain 1.0) # Maximum gain DEMOD = demod(channel_rate, audio_decim) # From RF to audio self.connect(USRP, CHAN, RFSQL, AGC, DEMOD) # Optionally add CTCSS and RSAMP if needed tail = DEMOD if options.ctcss != None and options.ctcss > 60.0: CTCSS = gr.ctcss_squelch_ff(audio_rate, # Sample rate options.ctcss) # Squelch tone self.connect(DEMOD, CTCSS) tail = CTCSS if options.output_rate != audio_rate: out_lcm = gru.lcm(audio_rate, options.output_rate) out_interp = int(out_lcm // audio_rate) out_decim = int(out_lcm // options.output_rate) RSAMP = blks2.rational_resampler_fff(out_interp, out_decim) self.connect(tail, RSAMP) tail = RSAMP # Send to default audio output AUDIO = audio.sink(options.output_rate, "") self.connect(tail, AUDIO)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.variable_slider_0 = variable_slider_0 = 0 self.samp_rate = samp_rate = 500e3 ################################################## # Controls ################################################## _variable_slider_0_sizer = wx.BoxSizer(wx.VERTICAL) self._variable_slider_0_text_box = forms.text_box( parent=self.GetWin(), sizer=_variable_slider_0_sizer, value=self.variable_slider_0, callback=self.set_variable_slider_0, label="Volume", converter=forms.float_converter(), proportion=0, ) self._variable_slider_0_slider = forms.slider( parent=self.GetWin(), sizer=_variable_slider_0_sizer, value=self.variable_slider_0, callback=self.set_variable_slider_0, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_variable_slider_0_sizer) ################################################## # Blocks ################################################## self.audio_sink_0 = audio.sink(48000, "", True) self.blks2_nbfm_rx_0 = blks2.nbfm_rx( audio_rate=25000, quad_rate=100000, tau=75e-6, max_dev=15e3, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=1, decimation=5, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_fff( interpolation=48, decimation=25, taps=None, fractional_bw=None, ) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((variable_slider_0, )) self.gr_multiply_const_vxx_1 = gr.multiply_const_vcc((100e3, )) self.low_pass_filter_0 = gr.fir_filter_ccf(1, firdes.low_pass( 10, samp_rate, 5e3, 10e3, firdes.WIN_HAMMING, 6.76)) self.uhd_single_usrp_source_0 = uhd.single_usrp_source( device_addr="addr=192.168.10.3", io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1, ) self.uhd_single_usrp_source_0.set_samp_rate(samp_rate) self.uhd_single_usrp_source_0.set_center_freq(462.5625e6, 0) self.uhd_single_usrp_source_0.set_gain(45, 0) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, dynamic_range=100, ref_level=50, 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) ################################################## # Connections ################################################## self.connect((self.blks2_nbfm_rx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.blks2_nbfm_rx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.uhd_single_usrp_source_0, 0), (self.gr_multiply_const_vxx_1, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.low_pass_filter_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.wxgui_waterfallsink2_0, 0))
def __init__(self): gr.top_block.__init__ (self) parser=OptionParser(option_class=eng_option) parser.add_option("-H", "--hostname", type="string", default="localhost", help="set hostname of generic sdr") parser.add_option("-P", "--portnum", type="int", default=None, help="set portnum of generic sdr") parser.add_option("-r", "--sdr_rate", type="eng_float", default=250e3, help="set sample rate of generic sdr") parser.add_option("-V", "--volume", type="eng_float", default=None, help="set volume (default is midpoint)") parser.add_option("-O", "--audio-output", type="string", default="plughw:0,0", help="pcm device name (default is plughw:0,0)") # print help when called with wrong arguments (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.vol = options.volume if self.vol is None: self.vol = 0.1 # connect to generic SDR sdr_rate = options.sdr_rate audio_decim = 8 audio_rate = int(sdr_rate/audio_decim) print "audio_rate = ", audio_rate self.interleaved_short_to_complex = gr.interleaved_short_to_complex() self.char_to_short = gr.char_to_short(1) self.sdr_source = grc_blks2.tcp_source( itemsize=gr.sizeof_char*1, addr=options.hostname, port=options.portnum, server=False ) # self.sdr_source = gr.file_source(1, 'sdrs_baseband.dat') # self.throttle = gr.throttle(1, 500e3) # self.connect(self.sdr_source, self.file_sink) self.logger = gr.file_sink(1, 'log.out') self.connect(self.sdr_source, self.logger) # channel filter chan_filter_coeffs = gr.firdes.low_pass( 1.0, # gain sdr_rate, # sampling rate 80e3, # passband cutoff 35e3, # transition width gr.firdes.WIN_HAMMING) self.chan_filter = gr.fir_filter_ccf(1, chan_filter_coeffs) # print "# channel filter:", len(chan_filter_coeffs), "taps" # PLL-based WFM demod fm_alpha = 0.25 * 250e3 * math.pi / sdr_rate # 0.767 fm_beta = fm_alpha * fm_alpha / 4.0 # 0.147 fm_max_freq = 2.0 * math.pi * 90e3 / sdr_rate # 2.209 self.fm_demod = gr.pll_freqdet_cf( 1.0, # Loop BW fm_max_freq, # in radians/sample -fm_max_freq) self.fm_demod.set_alpha(fm_alpha) self.fm_demod.set_beta(fm_beta) self.connect(self.sdr_source, self.char_to_short) self.connect(self.char_to_short, self.interleaved_short_to_complex) self.connect(self.interleaved_short_to_complex, self.chan_filter, self.fm_demod) # L+R, pilot, L-R, RDS filters lpr_filter_coeffs = gr.firdes.low_pass( 1.0, # gain sdr_rate, # sampling rate 15e3, # passband cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.lpr_filter = gr.fir_filter_fff(audio_decim, lpr_filter_coeffs) pilot_filter_coeffs = gr.firdes.band_pass( 1.0, # gain sdr_rate, # sampling rate 19e3-500, # low cutoff 19e3+500, # high cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.pilot_filter = gr.fir_filter_fff(1, pilot_filter_coeffs) dsbsc_filter_coeffs = gr.firdes.band_pass( 1.0, # gain sdr_rate, # sampling rate 38e3-15e3/2, # low cutoff 38e3+15e3/2, # high cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.dsbsc_filter = gr.fir_filter_fff(1, dsbsc_filter_coeffs) rds_filter_coeffs = gr.firdes.band_pass( 1.0, # gain sdr_rate, # sampling rate 57e3-3e3, # low cutoff 57e3+3e3, # high cutoff 3e3, # transition width gr.firdes.WIN_HAMMING) self.rds_filter = gr.fir_filter_fff(1, rds_filter_coeffs) # print "# lpr filter:", len(lpr_filter_coeffs), "taps" # print "# pilot filter:", len(pilot_filter_coeffs), "taps" # print "# dsbsc filter:", len(dsbsc_filter_coeffs), "taps" # print "# rds filter:", len(rds_filter_coeffs), "taps" self.connect(self.fm_demod, self.lpr_filter) self.connect(self.fm_demod, self.pilot_filter) self.connect(self.fm_demod, self.dsbsc_filter) self.connect(self.fm_demod, self.rds_filter) # down-convert L-R, RDS self.stereo_baseband = gr.multiply_ff() self.connect(self.pilot_filter, (self.stereo_baseband, 0)) self.connect(self.pilot_filter, (self.stereo_baseband, 1)) self.connect(self.dsbsc_filter, (self.stereo_baseband, 2)) self.rds_baseband = gr.multiply_ff() self.connect(self.pilot_filter, (self.rds_baseband, 0)) self.connect(self.pilot_filter, (self.rds_baseband, 1)) self.connect(self.pilot_filter, (self.rds_baseband, 2)) self.connect(self.rds_filter, (self.rds_baseband, 3)) # low-pass and downsample L-R lmr_filter_coeffs = gr.firdes.low_pass( 1.0, # gain sdr_rate, # sampling rate 15e3, # passband cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.lmr_filter = gr.fir_filter_fff(audio_decim, lmr_filter_coeffs) self.connect(self.stereo_baseband, self.lmr_filter) # create L, R from L-R, L+R self.left = gr.add_ff() self.right = gr.sub_ff() self.connect(self.lpr_filter, (self.left, 0)) self.connect(self.lmr_filter, (self.left, 1)) self.connect(self.lpr_filter, (self.right, 0)) self.connect(self.lmr_filter, (self.right, 1)) # volume control, complex2flot, audio sink self.volume_control_l = gr.multiply_const_ff(self.vol) self.volume_control_r = gr.multiply_const_ff(self.vol) output_audio_rate = 48000 self.resamp_L = blks2.rational_resampler_fff(interpolation=output_audio_rate,decimation=audio_rate,taps=None,fractional_bw=None,) self.resamp_R = blks2.rational_resampler_fff(interpolation=output_audio_rate,decimation=audio_rate,taps=None,fractional_bw=None,) self.connect(self.left, self.volume_control_l, self.resamp_L) self.connect(self.right, self.volume_control_r, self.resamp_R) # self.audio_sink = audio.sink(int(output_audio_rate), # options.audio_output, False) # self.connect(self.resamp_L, (self.audio_sink, 0)) # self.connect(self.resamp_R, (self.audio_sink, 1)) self.file_sink1 = gr.file_sink(gr.sizeof_float, 'audioL.dat') self.file_sink2 = gr.file_sink(gr.sizeof_float, 'audioR.dat') self.file_sink3 = gr.file_sink(gr.sizeof_float, 'fmDemod.dat') self.connect(self.resamp_L, self.file_sink1) self.connect(self.resamp_R, self.file_sink2) self.connect(self.fm_demod, self.file_sink3) # low-pass the baseband RDS signal at 1.5kHz rds_bb_filter_coeffs = gr.firdes.low_pass( 1, # gain sdr_rate, # sampling rate 1.5e3, # passband cutoff 2e3, # transition width gr.firdes.WIN_HAMMING) self.rds_bb_filter = gr.fir_filter_fff(audio_decim, rds_bb_filter_coeffs) # print "# rds bb filter:", len(rds_bb_filter_coeffs), "taps" self.connect(self.rds_baseband, self.rds_bb_filter) # 1187.5bps = 19kHz/16 self.clock_divider = rds.freq_divider(16) rds_clock_taps = gr.firdes.low_pass( 1, # gain sdr_rate, # sampling rate 1.2e3, # passband cutoff 1.5e3, # transition width gr.firdes.WIN_HAMMING) self.rds_clock = gr.fir_filter_fff(audio_decim, rds_clock_taps) # print "# rds clock filter:", len(rds_clock_taps), "taps" self.connect(self.pilot_filter, self.clock_divider, self.rds_clock) # bpsk_demod, diff_decoder, rds_decoder self.bpsk_demod = rds.bpsk_demod(audio_rate) self.differential_decoder = gr.diff_decoder_bb(2) self.msgq = gr.msg_queue() self.rds_decoder = rds.data_decoder(self.msgq) self.connect(self.rds_bb_filter, (self.bpsk_demod, 0)) self.connect(self.rds_clock, (self.bpsk_demod, 1)) self.connect(self.bpsk_demod, self.differential_decoder) self.connect(self.differential_decoder, self.rds_decoder)
def __init__(self): gr.top_block.__init__ (self) parser=OptionParser(option_class=eng_option) parser.add_option("-H", "--hostname", type="string", default="localhost", help="set hostname of generic sdr") parser.add_option("-P", "--portnum", type="int", default=None, help="set portnum of generic sdr") parser.add_option("-W", "--wsportnum", type="int", default=None, help="set portnum of audio websocket server") parser.add_option("-r", "--sdr_rate", type="eng_float", default=250e3, help="set sample rate of generic sdr") parser.add_option("-V", "--volume", type="eng_float", default=None, help="set volume (default is midpoint)") parser.add_option("-O", "--audio-output", type="string", default="plughw:0,0", help="pcm device name (default is plughw:0,0)") # print help when called with wrong arguments (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.vol = options.volume if self.vol is None: self.vol = 0.1 # connect to generic SDR sdr_rate = options.sdr_rate audio_decim = 8 audio_rate = int(sdr_rate/audio_decim) print "audio_rate = ", audio_rate self.interleaved_short_to_complex = gr.interleaved_short_to_complex() self.char_to_short = gr.char_to_short(1) self.sdr_source = grc_blks2.tcp_source( itemsize=gr.sizeof_char*1, addr=options.hostname, port=options.portnum, server=False ) # self.sdr_source = gr.file_source(1, 'sdrs_baseband.dat') # self.throttle = gr.throttle(1, 500e3) # self.connect(self.sdr_source, self.file_sink) self.logger = gr.file_sink(1, 'log.out') self.connect(self.sdr_source, self.logger) # channel filter chan_filter_coeffs = gr.firdes.low_pass( 1.0, # gain sdr_rate, # sampling rate 80e3, # passband cutoff 35e3, # transition width gr.firdes.WIN_HAMMING) self.chan_filter = gr.fir_filter_ccf(1, chan_filter_coeffs) # print "# channel filter:", len(chan_filter_coeffs), "taps" # PLL-based WFM demod fm_alpha = 0.25 * 250e3 * math.pi / sdr_rate # 0.767 fm_beta = fm_alpha * fm_alpha / 4.0 # 0.147 fm_max_freq = 2.0 * math.pi * 90e3 / sdr_rate # 2.209 self.fm_demod = gr.pll_freqdet_cf( 1.0, # Loop BW fm_max_freq, # in radians/sample -fm_max_freq) self.fm_demod.set_alpha(fm_alpha) self.fm_demod.set_beta(fm_beta) self.connect(self.sdr_source, self.char_to_short) self.connect(self.char_to_short, self.interleaved_short_to_complex) self.connect(self.interleaved_short_to_complex, self.chan_filter, self.fm_demod) # L+R, pilot, L-R, RDS filters lpr_filter_coeffs = gr.firdes.low_pass( 1.0, # gain sdr_rate, # sampling rate 15e3, # passband cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.lpr_filter = gr.fir_filter_fff(audio_decim, lpr_filter_coeffs) pilot_filter_coeffs = gr.firdes.band_pass( 1.0, # gain sdr_rate, # sampling rate 19e3-500, # low cutoff 19e3+500, # high cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.pilot_filter = gr.fir_filter_fff(1, pilot_filter_coeffs) dsbsc_filter_coeffs = gr.firdes.band_pass( 1.0, # gain sdr_rate, # sampling rate 38e3-15e3/2, # low cutoff 38e3+15e3/2, # high cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.dsbsc_filter = gr.fir_filter_fff(1, dsbsc_filter_coeffs) rds_filter_coeffs = gr.firdes.band_pass( 1.0, # gain sdr_rate, # sampling rate 57e3-3e3, # low cutoff 57e3+3e3, # high cutoff 3e3, # transition width gr.firdes.WIN_HAMMING) self.rds_filter = gr.fir_filter_fff(1, rds_filter_coeffs) # print "# lpr filter:", len(lpr_filter_coeffs), "taps" # print "# pilot filter:", len(pilot_filter_coeffs), "taps" # print "# dsbsc filter:", len(dsbsc_filter_coeffs), "taps" # print "# rds filter:", len(rds_filter_coeffs), "taps" self.connect(self.fm_demod, self.lpr_filter) self.connect(self.fm_demod, self.pilot_filter) self.connect(self.fm_demod, self.dsbsc_filter) self.connect(self.fm_demod, self.rds_filter) # down-convert L-R, RDS self.stereo_baseband = gr.multiply_ff() self.connect(self.pilot_filter, (self.stereo_baseband, 0)) self.connect(self.pilot_filter, (self.stereo_baseband, 1)) self.connect(self.dsbsc_filter, (self.stereo_baseband, 2)) self.rds_baseband = gr.multiply_ff() self.connect(self.pilot_filter, (self.rds_baseband, 0)) self.connect(self.pilot_filter, (self.rds_baseband, 1)) self.connect(self.pilot_filter, (self.rds_baseband, 2)) self.connect(self.rds_filter, (self.rds_baseband, 3)) # low-pass and downsample L-R lmr_filter_coeffs = gr.firdes.low_pass( 1.0, # gain sdr_rate, # sampling rate 15e3, # passband cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.lmr_filter = gr.fir_filter_fff(audio_decim, lmr_filter_coeffs) self.connect(self.stereo_baseband, self.lmr_filter) # create L, R from L-R, L+R self.left = gr.add_ff() self.right = gr.sub_ff() self.connect(self.lpr_filter, (self.left, 0)) self.connect(self.lmr_filter, (self.left, 1)) self.connect(self.lpr_filter, (self.right, 0)) self.connect(self.lmr_filter, (self.right, 1)) # volume control, complex2flot, audio sink self.volume_control_l = gr.multiply_const_ff(self.vol) self.volume_control_r = gr.multiply_const_ff(self.vol) output_audio_rate = 48000 self.resamp_L = blks2.rational_resampler_fff(interpolation=output_audio_rate,decimation=audio_rate,taps=None,fractional_bw=None,) self.resamp_R = blks2.rational_resampler_fff(interpolation=output_audio_rate,decimation=audio_rate,taps=None,fractional_bw=None,) self.connect(self.left, self.volume_control_l, self.resamp_L) self.connect(self.right, self.volume_control_r, self.resamp_R) # self.audio_sink = audio.sink(int(output_audio_rate), # options.audio_output, False) # self.connect(self.resamp_L, (self.audio_sink, 0)) # self.connect(self.resamp_R, (self.audio_sink, 1)) # self.file_sink1 = gr.file_sink(gr.sizeof_float, 'audioL.dat') # self.file_sink2 = gr.file_sink(gr.sizeof_float, 'audioR.dat') # self.file_sink3 = gr.file_sink(gr.sizeof_float, 'fmDemod.dat') # self.connect(self.resamp_L, self.file_sink1) # self.connect(self.resamp_R, self.file_sink2) # self.connect(self.fm_demod, self.file_sink3) # Interleave both channels so that we can push over one websocket connection self.audio_interleaver = gr.float_to_complex(1) self.connect(self.resamp_L, (self.audio_interleaver, 0)) self.connect(self.resamp_R, (self.audio_interleaver, 1)) self.ws_audio_server = sdrportal.ws_sink_c(True, options.wsportnum, "FLOAT") self.connect(self.audio_interleaver, self.ws_audio_server) # low-pass the baseband RDS signal at 1.5kHz rds_bb_filter_coeffs = gr.firdes.low_pass( 1, # gain sdr_rate, # sampling rate 1.5e3, # passband cutoff 2e3, # transition width gr.firdes.WIN_HAMMING) self.rds_bb_filter = gr.fir_filter_fff(audio_decim, rds_bb_filter_coeffs) # print "# rds bb filter:", len(rds_bb_filter_coeffs), "taps" self.connect(self.rds_baseband, self.rds_bb_filter) # 1187.5bps = 19kHz/16 self.clock_divider = rds.freq_divider(16) rds_clock_taps = gr.firdes.low_pass( 1, # gain sdr_rate, # sampling rate 1.2e3, # passband cutoff 1.5e3, # transition width gr.firdes.WIN_HAMMING) self.rds_clock = gr.fir_filter_fff(audio_decim, rds_clock_taps) # print "# rds clock filter:", len(rds_clock_taps), "taps" self.connect(self.pilot_filter, self.clock_divider, self.rds_clock) # bpsk_demod, diff_decoder, rds_decoder self.bpsk_demod = rds.bpsk_demod(audio_rate) self.differential_decoder = gr.diff_decoder_bb(2) self.msgq = gr.msg_queue() self.rds_decoder = rds.data_decoder(self.msgq) self.connect(self.rds_bb_filter, (self.bpsk_demod, 0)) self.connect(self.rds_clock, (self.bpsk_demod, 1)) self.connect(self.bpsk_demod, self.differential_decoder) self.connect(self.differential_decoder, self.rds_decoder)
def __init__(self, options): gr.top_block.__init__(self) self.options = options (dev_rate, channel_rate, audio_rate, channel_pass, channel_stop, demod) = demod_params[options.modulation] DEV = uhd_src( options.args, # UHD device address options.spec, # device subdev spec options.antenna, # device antenna dev_rate, # device sample rate options.gain, # Receiver gain options.calibration) # Frequency offset DEV.tune(options.frequency) if_rate = DEV.rate() channel_decim = int(if_rate // channel_rate) audio_decim = int(channel_rate // audio_rate) CHAN_taps = optfir.low_pass( 1.0, # Filter gain if_rate, # Sample rate channel_pass, # One sided modulation bandwidth channel_stop, # One sided channel bandwidth 0.1, # Passband ripple 60) # Stopband attenuation CHAN = gr.freq_xlating_fir_filter_ccf( channel_decim, # Decimation rate CHAN_taps, # Filter taps 0.0, # Offset frequency if_rate) # Sample rate RFSQL = gr.pwr_squelch_cc( options.rf_squelch, # Power threshold 125.0 / channel_rate, # Time constant int(channel_rate / 20), # 50ms rise/fall False) # Zero, not gate output AGC = gr.agc_cc( 1.0 / channel_rate, # Time constant 1.0, # Reference power 1.0, # Initial gain 1.0) # Maximum gain DEMOD = demod(channel_rate, audio_decim) # From RF to audio #self.connect(DEV, CHAN, RFSQL, AGC, DEMOD) self.connect(DEV, CHAN, DEMOD) # Optionally add CTCSS and RSAMP if needed tail = DEMOD if options.ctcss != None and options.ctcss > 60.0: CTCSS = gr.ctcss_squelch_ff( audio_rate, # Sample rate options.ctcss) # Squelch tone self.connect(DEMOD, CTCSS) tail = CTCSS if options.output_rate != audio_rate: out_lcm = gru.lcm(audio_rate, options.output_rate) out_interp = int(out_lcm // audio_rate) out_decim = int(out_lcm // options.output_rate) RSAMP = blks2.rational_resampler_fff(out_interp, out_decim) self.connect(tail, RSAMP) tail = RSAMP # Send to audio output device AUDIO = audio.sink(int(options.output_rate), options.audio_output) self.connect(tail, AUDIO)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Ettus Fm") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 5e6 self.freq = freq = 93.5e6 ################################################## # 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 Spectrum") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Spectrum") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Audio") self.Add(self.notebook_0) 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) self.wxgui_fftsink2_2 = fftsink2.fft_sink_f( self.notebook_0.GetPage(2).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=48e3, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(2).Add(self.wxgui_fftsink2_2.win) self.wxgui_fftsink2_1 = fftsink2.fft_sink_f( self.notebook_0.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=250e3, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0.win) 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(freq, 0) self.uhd_usrp_source_0.set_gain(25, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.uhd_usrp_source_0.set_bandwidth(200e3, 0) self.low_pass_filter_0 = gr.fir_filter_ccf(20, firdes.low_pass( 1, samp_rate, 100e3, 10e3, firdes.WIN_HAMMING, 6.76)) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((5, )) self.blks2_wfm_rcv_0 = blks2.wfm_rcv( quad_rate=250e3, audio_decimation=1, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=48, decimation=250, taps=None, fractional_bw=None, ) self.audio_sink_0 = audio.sink(48000, "", True) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blks2_wfm_rcv_0, 0)) self.connect((self.blks2_wfm_rcv_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_wfm_rcv_0, 0), (self.wxgui_fftsink2_1, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.wxgui_fftsink2_2, 0))
def __init__(self, talkgroup, options): gr.hier_block2.__init__(self, "fsk_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, gr.sizeof_char)) # Output signature #print "Starting log_receiver init()" self.samp_rate = samp_rate = int(options.rate) self.samp_per_sym = samp_per_sym = 5+1 self.decim = decim = 20 self.xlate_bandwidth = xlate_bandwidth = 24260.0 self.xlate_offset = xlate_offset = 0 self.channel_rate = channel_rate = op25.SYMBOL_RATE*samp_per_sym self.audio_mul = audio_mul = 2 self.pre_channel_rate = pre_channel_rate = int(samp_rate/decim) self.auto_tune_offset = auto_tune_offset = 0 self.audiorate = 44100 #options.audiorate self.rate = options.rate self.talkgroup = talkgroup self.directory = options.directory if options.squelch is None: options.squelch = 28 if options.volume is None: options.volume = 3.0 ################################################## # Message Queues ################################################## op25_fsk4_0_msgq_out = baz_message_callback_0_msgq_in = gr.msg_queue(2) op25_decoder_simple_0_msgq_out = op25_traffic_pane_0_msgq_in = gr.msg_queue(2) ################################################## # Blocks ################################################## self.op25_fsk4_0 = op25.op25_fsk4(channel_rate=channel_rate, auto_tune_msgq=op25_fsk4_0_msgq_out,) self.op25_decoder_simple_0 = op25.op25_decoder_simple(key="",traffic_msgq=op25_decoder_simple_0_msgq_out,) self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf((channel_rate/(2.0 * math.pi * op25.SYMBOL_DEVIATION))) self.gr_freq_xlating_fir_filter_xxx_0 = gr.freq_xlating_fir_filter_ccc(decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 4000)), 0, samp_rate) self.gr_fir_filter_xxx_0 = gr.fir_filter_fff(1, ((1.0/samp_per_sym,)*samp_per_sym)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10.**(audio_mul/10.), )) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_ccc( interpolation=channel_rate, decimation=pre_channel_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=self.audiorate, decimation=8000, taps=None, fractional_bw=None, ) self.baz_message_callback_0 = message_callback.message_callback(msgq=baz_message_callback_0_msgq_in, callback=auto_tune_offset , msg_part="arg1", custom_parts="", dummy=False) #here we generate a random filename in the form /tmp/[random].wav, and then use it for the wavstamp block. this avoids collisions later on. remember to clean up these files when deallocating. self.tmpfilename = "/tmp/%s.wav" % ("".join([random.choice(string.letters+string.digits) for x in range(8)])) #if this looks glaringly different, it's because i totally cribbed it from a blog. self.valve = grc_blks2.valve(gr.sizeof_float, bool(1)) #open the logfile for appending self.timestampfilename = "%s/%i.txt" % (self.directory, self.talkgroup) self.timestampfile = open(self.timestampfilename, 'a'); self.filename = "%s/%i.wav" % (self.directory, self.talkgroup) self.audiosink = smartnet.wavsink(self.filename, 1, self.audiorate, 8) #this version allows appending to existing files. self.audio_sink_0 = audio.sink(44100, "", True) self.timestamp = 0.0 #print "Finishing logging receiver init()." self.mute() #start off muted. ################################################## # Connections ################################################## self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_quadrature_demod_cf_0, 0)) self.connect((self.gr_quadrature_demod_cf_0, 0), (self.gr_fir_filter_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.gr_fir_filter_xxx_0, 0), (self.op25_fsk4_0, 0)) self.connect((self.op25_fsk4_0, 0), (self.op25_decoder_simple_0, 0)) self.connect((self.op25_decoder_simple_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) ## Start self.connect(self, (self.gr_freq_xlating_fir_filter_xxx_0, 0)) ## End self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0,0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Fm Rx Example") ################################################## # Variables ################################################## self.usrp_freq = usrp_freq = 96e6 self.samp_rate = samp_rate = 500e3 self.xlate_tune = xlate_tune = 0 self.usrp_decim = usrp_decim = 200 self.rx_freq = rx_freq = usrp_freq self.rf_gain = rf_gain = 15 self.filter_taps = filter_taps = firdes.low_pass( 1, samp_rate, 200e3, 1e3) self.af_gain = af_gain = 3 self.Mult_constant = Mult_constant = 5 ################################################## # Blocks ################################################## _xlate_tune_sizer = wx.BoxSizer(wx.VERTICAL) self._xlate_tune_text_box = forms.text_box( parent=self.GetWin(), sizer=_xlate_tune_sizer, value=self.xlate_tune, callback=self.set_xlate_tune, label='xlate_tune', converter=forms.float_converter(), proportion=0, ) self._xlate_tune_slider = forms.slider( parent=self.GetWin(), sizer=_xlate_tune_sizer, value=self.xlate_tune, callback=self.set_xlate_tune, minimum=-250e3, maximum=250e3, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_xlate_tune_sizer, 7, 0, 1, 5) _usrp_freq_sizer = wx.BoxSizer(wx.VERTICAL) self._usrp_freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_usrp_freq_sizer, value=self.usrp_freq, callback=self.set_usrp_freq, label='usrp_freq', converter=forms.float_converter(), proportion=0, ) self._usrp_freq_slider = forms.slider( parent=self.GetWin(), sizer=_usrp_freq_sizer, value=self.usrp_freq, callback=self.set_usrp_freq, minimum=88e6, maximum=108e6, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_usrp_freq_sizer, 6, 0, 1, 5) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=13.49e3, sample_rate=250e3, fft_size=1024, fft_rate=10, average=True, avg_alpha=500e-3, title="FFT Plot", peak_hold=False, size=(1120, 527), ) self.GridAdd(self.wxgui_fftsink2_0.win, 0, 0, 5, 5) 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(usrp_freq, 0) self.uhd_usrp_source_0.set_gain(15, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self._rx_freq_static_text = forms.static_text( parent=self.GetWin(), value=self.rx_freq, callback=self.set_rx_freq, label='rx_freq', converter=forms.float_converter(), ) self.GridAdd(self._rx_freq_static_text, 5, 3, 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=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_rf_gain_sizer, 8, 0, 1, 2) self.gr_multiply_const_vxx_1 = gr.multiply_const_vff((Mult_constant, )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((Mult_constant, )) self.gr_freq_xlating_fir_filter_xxx_0 = gr.freq_xlating_fir_filter_ccc( 1, (filter_taps), xlate_tune, samp_rate) self.blks2_wfm_rcv_pll_0 = blks2.wfm_rcv_pll( demod_rate=500e3, audio_decimation=10, ) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_fff( interpolation=48, decimation=50, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=48, decimation=50, taps=None, fractional_bw=None, ) self.audio_sink_0 = audio.sink(48000, "", True) _af_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._af_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_af_gain_sizer, value=self.af_gain, callback=self.set_af_gain, label='af_gain', converter=forms.float_converter(), proportion=0, ) self._af_gain_slider = forms.slider( parent=self.GetWin(), sizer=_af_gain_sizer, value=self.af_gain, callback=self.set_af_gain, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_af_gain_sizer, 8, 2, 1, 2) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), (self.gr_freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.blks2_wfm_rcv_pll_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_multiply_const_vxx_1, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.audio_sink_0, 1)) self.connect((self.blks2_wfm_rcv_pll_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_wfm_rcv_pll_0, 1), (self.blks2_rational_resampler_xxx_1, 0))
def __init__(self, frame, panel, vbox, argv): stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) parser=OptionParser(option_class=eng_option) parser.add_option("-a", "--args", type="string", default="", help="UHD device address args [default=%default]") parser.add_option("", "--spec", type="string", default=None, help="Subdevice of UHD device where appropriate") parser.add_option("-A", "--antenna", type="string", default=None, help="select Rx Antenna where appropriate") parser.add_option("-f", "--freq", type="string", default="131725000", help="Frequency in Hz") parser.add_option("-o", "--output", type="string", default="output.txt", help="ACARS log output") parser.add_option("-s", "--samp-rate", type="eng_float", default="250e3", help="set sample rate (bandwidth) [default=%default]") parser.add_option("-d", "--device", type="string", default="", help="PCM device name, e.g. hw:0,0 /dev/dsp pulse etc.") parser.add_option("-w", "--wav-file", type="string", default="", help="WAV file output.") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.frame = frame self.panel = panel self.freq = float(options.freq) usrp_rate = options.samp_rate audio_rate = 48e3 # init USRP source block self.usrp = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) if (options.spec): self.usrp.set_subdev_spec(options.spec, 0) if (options.antenna): self.usrp.set_antenna(options.antenna, 0) self.usrp.set_samp_rate(usrp_rate) self.usrp.set_center_freq(self.freq, 0) # FIR block (5KHz low pass filter) chan_filt_coeffs = gr.firdes.low_pass_2(8, # gain usrp_rate, # sampling rate 5e3, # passband_cutoff 1e2, # transition bw 60) # stopband attenuation self.chan_filt = gr.freq_xlating_fir_filter_ccf(1, # decimation chan_filt_coeffs, # taps 0, # center freq usrp_rate) # samp rate # AM demodulator block self.am_demod = gr.complex_to_mag() # resampler block self.resamp = blks2.rational_resampler_fff(interpolation=int(audio_rate), decimation=int(usrp_rate), taps=None, fractional_bw=None) # acars2 demod/decode blocks self.acars2_demod = acars2.demod(int(audio_rate)) self.acars2_decode = acars2.decode() # file sink self.file_sink = gr.file_sink(gr.sizeof_char, options.output) # build flow graph self.connect(self.usrp, self.chan_filt, self.am_demod, self.resamp, self.acars2_demod, self.acars2_decode, self.file_sink) # add audio sink (optional) if (options.device): print "using audio device %s" % options.device self.audio_sink = audio.sink(int (audio_rate), options.device, True) self.connect(self.resamp, self.audio_sink) # add WAV file sink (optional) if (options.wav_file): print "writing to WAV file %s" % options.wav_file self.wavsink = gr.wavfile_sink(options.wav_file, 1, int(audio_rate), 16) self.connect(self.resamp, self.wavsink) self._build_gui(vbox, usrp_rate, audio_rate) print "built flow graph..."
def __init__(self,frame,panel,vbox,argv): stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) parser=OptionParser(option_class=eng_option) parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, help="select USRP Rx side A or B (default=A)") parser.add_option("-f", "--freq", type="eng_float", default=91.2e6, help="set frequency to FREQ", metavar="FREQ") parser.add_option("-g", "--gain", type="eng_float", default=None, help="set gain in dB") # FIXME add squelch parser.add_option("-s", "--squelch", type="eng_float", default=0, help="set squelch level (default is 0)") parser.add_option("-V", "--volume", type="eng_float", default=None, help="set volume (default is midpoint)") parser.add_option("-O", "--audio-output", type="string", default="plughw:0,0", help="pcm device name (default is plughw:0,0)") # print help when called with wrong arguments (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) # connect to USRP usrp_decim = 250 self.u = usrp.source_c(0, usrp_decim) print "USRP Serial:", self.u.serial_number() usrp_rate = self.u.adc_rate() / usrp_decim # 256 kS/s print "usrp_rate =", usrp_rate audio_decim = 8 audio_rate = usrp_rate / audio_decim # 32 kS/s print "audio_rate =", audio_rate #if options.rx_subdev_spec is None: # options.rx_subdev_spec = usrp.pick_subdev(self.u, dblist) self.u.set_mux(usrp.determine_rx_mux_value(self.u, options.rx_subdev_spec)) self.subdev = usrp.selected_subdev(self.u, options.rx_subdev_spec) print "Using d'board", self.subdev.side_and_name() # gain, volume, frequency self.gain = options.gain if options.gain is None: g = self.subdev.gain_range() self.gain = float(g[0]+g[1])/2 self.vol = options.volume if self.vol is None: g = self.volume_range() self.vol = float(g[0]+g[1])/2 self.freq = options.freq print "Volume:%r, Gain:%r, Freq:%3.1f MHz" % (self.vol, self.gain, self.freq/1e6) # channel filter chan_filter_coeffs = gr.firdes.low_pass( 1.0, # gain usrp_rate, # sampling rate 80e3, # passband cutoff 35e3, # transition width gr.firdes.WIN_HAMMING) self.chan_filter = gr.fir_filter_ccf(1, chan_filter_coeffs) print "# channel filter:", len(chan_filter_coeffs), "taps" # PLL-based WFM demod fm_alpha = 0.25 * 250e3 * math.pi / usrp_rate # 0.767 fm_beta = fm_alpha * fm_alpha / 4.0 # 0.147 fm_max_freq = 2.0 * math.pi * 90e3 / usrp_rate # 2.209 self.fm_demod = gr.pll_freqdet_cf( #fm_alpha, # phase gain #fm_beta, # freq gain 1.0, # Loop BW fm_max_freq, # in radians/sample -fm_max_freq) self.fm_demod.set_alpha(fm_alpha) self.fm_demod.set_beta(fm_beta) self.connect(self.u, self.chan_filter, self.fm_demod) # L+R, pilot, L-R, RDS filters lpr_filter_coeffs = gr.firdes.low_pass( 1.0, # gain usrp_rate, # sampling rate 15e3, # passband cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.lpr_filter = gr.fir_filter_fff(audio_decim, lpr_filter_coeffs) pilot_filter_coeffs = gr.firdes.band_pass( 1.0, # gain usrp_rate, # sampling rate 19e3-500, # low cutoff 19e3+500, # high cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.pilot_filter = gr.fir_filter_fff(1, pilot_filter_coeffs) dsbsc_filter_coeffs = gr.firdes.band_pass( 1.0, # gain usrp_rate, # sampling rate 38e3-15e3/2, # low cutoff 38e3+15e3/2, # high cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.dsbsc_filter = gr.fir_filter_fff(1, dsbsc_filter_coeffs) rds_filter_coeffs = gr.firdes.band_pass( 1.0, # gain usrp_rate, # sampling rate 57e3-3e3, # low cutoff 57e3+3e3, # high cutoff 3e3, # transition width gr.firdes.WIN_HAMMING) self.rds_filter = gr.fir_filter_fff(1, rds_filter_coeffs) print "# lpr filter:", len(lpr_filter_coeffs), "taps" print "# pilot filter:", len(pilot_filter_coeffs), "taps" print "# dsbsc filter:", len(dsbsc_filter_coeffs), "taps" print "# rds filter:", len(rds_filter_coeffs), "taps" self.connect(self.fm_demod, self.lpr_filter) self.connect(self.fm_demod, self.pilot_filter) self.connect(self.fm_demod, self.dsbsc_filter) self.connect(self.fm_demod, self.rds_filter) # down-convert L-R, RDS self.stereo_baseband = gr.multiply_ff() self.connect(self.pilot_filter, (self.stereo_baseband, 0)) self.connect(self.pilot_filter, (self.stereo_baseband, 1)) self.connect(self.dsbsc_filter, (self.stereo_baseband, 2)) self.rds_baseband = gr.multiply_ff() self.connect(self.pilot_filter, (self.rds_baseband, 0)) self.connect(self.pilot_filter, (self.rds_baseband, 1)) self.connect(self.pilot_filter, (self.rds_baseband, 2)) self.connect(self.rds_filter, (self.rds_baseband, 3)) # low-pass and downsample L-R lmr_filter_coeffs = gr.firdes.low_pass( 1.0, # gain usrp_rate, # sampling rate 15e3, # passband cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.lmr_filter = gr.fir_filter_fff(audio_decim, lmr_filter_coeffs) self.connect(self.stereo_baseband, self.lmr_filter) # create L, R from L-R, L+R self.left = gr.add_ff() self.right = gr.sub_ff() self.connect(self.lpr_filter, (self.left, 0)) self.connect(self.lmr_filter, (self.left, 1)) self.connect(self.lpr_filter, (self.right, 0)) self.connect(self.lmr_filter, (self.right, 1)) # volume control, complex2flot, audio sink self.volume_control_l = gr.multiply_const_ff(self.vol) self.volume_control_r = gr.multiply_const_ff(self.vol) output_audio_rate = 48000 self.audio_sink = audio.sink(int(output_audio_rate), options.audio_output, False) #self.connect(self.left, self.volume_control_l, (self.audio_sink, 0)) #self.connect(self.right, self.volume_control_r, (self.audio_sink, 1)) self.resamp_L = blks2.rational_resampler_fff(interpolation=output_audio_rate,decimation=audio_rate,taps=None,fractional_bw=None,) self.resamp_R = blks2.rational_resampler_fff(interpolation=output_audio_rate,decimation=audio_rate,taps=None,fractional_bw=None,) self.connect(self.left, self.volume_control_l, self.resamp_L, (self.audio_sink, 0)) self.connect(self.right, self.volume_control_r, self.resamp_R, (self.audio_sink, 1)) # low-pass the baseband RDS signal at 1.5kHz rds_bb_filter_coeffs = gr.firdes.low_pass( 1, # gain usrp_rate, # sampling rate 1.5e3, # passband cutoff 2e3, # transition width gr.firdes.WIN_HAMMING) self.rds_bb_filter = gr.fir_filter_fff(audio_decim, rds_bb_filter_coeffs) print "# rds bb filter:", len(rds_bb_filter_coeffs), "taps" self.connect(self.rds_baseband, self.rds_bb_filter) # 1187.5bps = 19kHz/16 self.clock_divider = rds.freq_divider(16) rds_clock_taps = gr.firdes.low_pass( 1, # gain usrp_rate, # sampling rate 1.2e3, # passband cutoff 1.5e3, # transition width gr.firdes.WIN_HAMMING) self.rds_clock = gr.fir_filter_fff(audio_decim, rds_clock_taps) print "# rds clock filter:", len(rds_clock_taps), "taps" self.connect(self.pilot_filter, self.clock_divider, self.rds_clock) # bpsk_demod, diff_decoder, rds_decoder self.bpsk_demod = rds.bpsk_demod(audio_rate) self.differential_decoder = gr.diff_decoder_bb(2) self.msgq = gr.msg_queue() self.rds_decoder = rds.data_decoder(self.msgq) self.connect(self.rds_bb_filter, (self.bpsk_demod, 0)) self.connect(self.rds_clock, (self.bpsk_demod, 1)) self.connect(self.bpsk_demod, self.differential_decoder) self.connect(self.differential_decoder, self.rds_decoder) self.frame = frame self.panel = panel self._build_gui(vbox, usrp_rate, audio_rate) self.set_gain(self.gain) self.set_vol(self.vol) if not(self.set_freq(self.freq)): self._set_status_msg("Failed to set initial frequency")
def __init__(self, output_sample_rate=_def_output_sample_rate, excess_bw=_def_excess_bw, reverse=_def_reverse, verbose=_def_verbose, log=_def_log): """ Hierarchical block for RRC-filtered P25 FM modulation. The input is a dibit (P25 symbol) stream (char, not packed) and the output is the float "C4FM" signal at baseband, suitable for application to an FM modulator stage Input is at the base symbol rate (4800), output sample rate is typically either 32000 (USRP TX chain) or 48000 (sound card) @param output_sample_rate: output sample rate @type output_sample_rate: integer @param excess_bw: Root-raised cosine filter excess bandwidth @type excess_bw: float @param reverse: reverse polarity flag @type reverse: bool @param verbose: Print information about modulator? @type verbose: bool @param debug: Print modulation data to files? @type debug: bool """ gr.hier_block2.__init__( self, "p25_c4fm_mod_bf", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(1, 1, gr.sizeof_float)) # Output signature input_sample_rate = 4800 # P25 baseband symbol rate lcm = gru.lcm(input_sample_rate, output_sample_rate) self._interp_factor = int(lcm // input_sample_rate) self._decimation = int(lcm // output_sample_rate) self._excess_bw = excess_bw mod_map = [1.0 / 3.0, 1.0, -(1.0 / 3.0), -1.0] self.C2S = gr.chunks_to_symbols_bf(mod_map) if reverse: self.polarity = gr.multiply_const_ff(-1) else: self.polarity = gr.multiply_const_ff(1) ntaps = 11 * self._interp_factor rrc_taps = gr.firdes.root_raised_cosine( self._interp_factor, # gain (since we're interpolating by sps) lcm, # sampling rate input_sample_rate, # symbol rate self._excess_bw, # excess bandwidth (roll-off factor) ntaps) # rrc_coeffs work slightly differently: each input sample # (from mod_map above) at 4800 rate, then 9 zeros are inserted # to bring to 48000 rate, then this filter is applied: # rrc_filter = gr.fir_filter_fff(1, rrc_coeffs) # FIXME: how to insert the 9 zero samples using gr ? # rrc_coeffs = [0, -0.003, -0.006, -0.009, -0.012, -0.014, -0.014, -0.013, -0.01, -0.006, 0, 0.007, 0.014, 0.02, 0.026, 0.029, 0.029, 0.027, 0.021, 0.012, 0, -0.013, -0.027, -0.039, -0.049, -0.054, -0.055, -0.049, -0.038, -0.021, 0, 0.024, 0.048, 0.071, 0.088, 0.098, 0.099, 0.09, 0.07, 0.039, 0, -0.045, -0.091, -0.134, -0.17, -0.193, -0.199, -0.184, -0.147, -0.085, 0, 0.105, 0.227, 0.36, 0.496, 0.629, 0.751, 0.854, 0.933, 0.983, 1, 0.983, 0.933, 0.854, 0.751, 0.629, 0.496, 0.36, 0.227, 0.105, 0, -0.085, -0.147, -0.184, -0.199, -0.193, -0.17, -0.134, -0.091, -0.045, 0, 0.039, 0.07, 0.09, 0.099, 0.098, 0.088, 0.071, 0.048, 0.024, 0, -0.021, -0.038, -0.049, -0.055, -0.054, -0.049, -0.039, -0.027, -0.013, 0, 0.012, 0.021, 0.027, 0.029, 0.029, 0.026, 0.02, 0.014, 0.007, 0, -0.006, -0.01, -0.013, -0.014, -0.014, -0.012, -0.009, -0.006, -0.003, 0] self.rrc_filter = gr.interp_fir_filter_fff(self._interp_factor, rrc_taps) # FM pre-emphasis filter shaping_coeffs = [ -0.018, 0.0347, 0.0164, -0.0064, -0.0344, -0.0522, -0.0398, 0.0099, 0.0798, 0.1311, 0.121, 0.0322, -0.113, -0.2499, -0.3007, -0.2137, -0.0043, 0.2825, 0.514, 0.604, 0.514, 0.2825, -0.0043, -0.2137, -0.3007, -0.2499, -0.113, 0.0322, 0.121, 0.1311, 0.0798, 0.0099, -0.0398, -0.0522, -0.0344, -0.0064, 0.0164, 0.0347, -0.018 ] self.shaping_filter = gr.fir_filter_fff(1, shaping_coeffs) if verbose: self._print_verbage() if log: self._setup_logging() self.connect(self, self.C2S, self.polarity, self.rrc_filter, self.shaping_filter) if (self._decimation > 1): self.decimator = blks2.rational_resampler_fff(1, self._decimation) self.connect(self.shaping_filter, self.decimator, self) else: self.connect(self.shaping_filter, self)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Fm Rx Example") ################################################## # Variables ################################################## self.usrp_freq = usrp_freq = 96.5e6 self.samp_rate = samp_rate = 500e3 self.xlate_tune = xlate_tune = 0 self.usrp_decim = usrp_decim = 200 self.rx_freq = rx_freq = usrp_freq self.rf_gain = rf_gain = 15 self.filter_taps = filter_taps = firdes.low_pass(1,samp_rate,200e3,1e3) self.af_gain = af_gain = 3 ################################################## # Blocks ################################################## _xlate_tune_sizer = wx.BoxSizer(wx.VERTICAL) self._xlate_tune_text_box = forms.text_box( parent=self.GetWin(), sizer=_xlate_tune_sizer, value=self.xlate_tune, callback=self.set_xlate_tune, label='xlate_tune', converter=forms.float_converter(), proportion=0, ) self._xlate_tune_slider = forms.slider( parent=self.GetWin(), sizer=_xlate_tune_sizer, value=self.xlate_tune, callback=self.set_xlate_tune, minimum=-250e3, maximum=250e3, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_xlate_tune_sizer, 7, 0, 1, 5) _usrp_freq_sizer = wx.BoxSizer(wx.VERTICAL) self._usrp_freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_usrp_freq_sizer, value=self.usrp_freq, callback=self.set_usrp_freq, label='usrp_freq', converter=forms.float_converter(), proportion=0, ) self._usrp_freq_slider = forms.slider( parent=self.GetWin(), sizer=_usrp_freq_sizer, value=self.usrp_freq, callback=self.set_usrp_freq, minimum=88e6, maximum=108e6, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_usrp_freq_sizer, 6, 0, 1, 5) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=13.49e3, sample_rate=250e3, fft_size=1024, fft_rate=10, average=True, avg_alpha=500e-3, title="FFT Plot", peak_hold=False, size=(1120,527), ) self.GridAdd(self.wxgui_fftsink2_0.win, 0, 0, 5, 5) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="addr=192.168.20.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(usrp_freq, 0) self.uhd_usrp_source_0.set_gain(15, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self._rx_freq_static_text = forms.static_text( parent=self.GetWin(), value=self.rx_freq, callback=self.set_rx_freq, label='rx_freq', converter=forms.float_converter(), ) self.GridAdd(self._rx_freq_static_text, 5, 3, 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=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_rf_gain_sizer, 8, 0, 1, 2) self.gr_multiply_const_vxx_1 = gr.multiply_const_vff((3, )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((3, )) self.gr_freq_xlating_fir_filter_xxx_0 = gr.freq_xlating_fir_filter_ccc(1, (filter_taps), xlate_tune, samp_rate) self.blks2_wfm_rcv_pll_0 = blks2.wfm_rcv_pll( demod_rate=500e3, audio_decimation=10, ) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_fff( interpolation=48, decimation=50, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=48, decimation=50, taps=None, fractional_bw=None, ) self.audio_sink_0 = audio.sink(48000, "", True) _af_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._af_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_af_gain_sizer, value=self.af_gain, callback=self.set_af_gain, label='af_gain', converter=forms.float_converter(), proportion=0, ) self._af_gain_slider = forms.slider( parent=self.GetWin(), sizer=_af_gain_sizer, value=self.af_gain, callback=self.set_af_gain, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_af_gain_sizer, 8, 2, 1, 2) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), (self.gr_freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.blks2_wfm_rcv_pll_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_multiply_const_vxx_1, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.audio_sink_0, 1)) self.connect((self.blks2_wfm_rcv_pll_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_wfm_rcv_pll_0, 1), (self.blks2_rational_resampler_xxx_1, 0))
def __init__(self, frame, panel, vbox, argv): stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) parser = OptionParser(option_class=eng_option) parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, help="select USRP Rx side A or B (default=A)") parser.add_option("-f", "--freq", type="eng_float", default=100.1e6, help="set frequency to FREQ", metavar="FREQ") parser.add_option("-g", "--gain", type="eng_float", default=65, help="set gain in dB (default is midpoint)") parser.add_option("-s", "--squelch", type="eng_float", default=0, help="set squelch level (default is 0)") parser.add_option("-V", "--volume", type="eng_float", default=None, help="set volume (default is midpoint)") 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) self.frame = frame self.panel = panel self.vol = 0 self.state = "FREQ" self.freq = 0 # build graph self.u = usrp.source_c() # usrp is data source adc_rate = self.u.adc_rate() # 64 MS/s usrp_decim = 200 self.u.set_decim_rate(usrp_decim) usrp_rate = adc_rate / usrp_decim # 320 kS/s chanfilt_decim = 1 demod_rate = usrp_rate / chanfilt_decim audio_decimation = 10 audio_rate = 3 * demod_rate / audio_decimation / 2 # 48 kHz if options.rx_subdev_spec is None: options.rx_subdev_spec = pick_subdevice(self.u) self.u.set_mux( usrp.determine_rx_mux_value(self.u, options.rx_subdev_spec)) self.subdev = usrp.selected_subdev(self.u, options.rx_subdev_spec) chan_filt_coeffs = gr.firdes.low_pass_2( 1, # gain usrp_rate, # sampling rate 90e3, # passband cutoff 30e3, # transition bandwidth 70, # stopband attenuation gr.firdes.WIN_BLACKMAN) print len(chan_filt_coeffs) chan_filt = gr.fir_filter_ccf(chanfilt_decim, chan_filt_coeffs) self.rchan_sample = blks2.rational_resampler_fff(3, 2) self.lchan_sample = blks2.rational_resampler_fff(3, 2) #self.guts = blks2.wfm_rcv (demod_rate, audio_decimation) self.guts = blks2.wfm_rcv_fmdet(demod_rate, audio_decimation) # FIXME rework {add,multiply}_const_* to handle multiple streams self.volume_control_l = gr.multiply_const_ff(self.vol) self.volume_control_r = gr.multiply_const_ff(self.vol) # sound card as final sink audio_sink = audio.sink(int(audio_rate), options.audio_output, False) # ok_to_block # now wire it all together self.connect(self.u, chan_filt, self.guts) self.connect((self.guts, 0), self.lchan_sample, self.volume_control_l, (audio_sink, 0)) self.connect((self.guts, 1), self.rchan_sample, self.volume_control_r, (audio_sink, 1)) try: self.guts.stereo_carrier_pll_recovery.squelch_enable(True) except: print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet" self._build_gui(vbox, usrp_rate, demod_rate, audio_rate) if options.gain is None: # if no gain was specified, use the mid-point in dB g = self.subdev.gain_range() options.gain = float(g[0] + g[1]) / 2 if options.volume is None: g = self.volume_range() options.volume = float(g[0] + g[1]) / 2 if abs(options.freq) < 1e6: options.freq *= 1e6 # set initial values self.set_gain(options.gain) self.set_vol(options.volume) try: self.guts.stereo_carrier_pll_recovery.set_lock_threshold( options.squelch) except: print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet" if not (self.set_freq(options.freq)): self._set_status_msg("Failed to set initial frequency")
def __init__(self, filepath_in): gr.top_block.__init__(self) #grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 200e3 self.bb_interpolation = bb_interpolation = 100 self.bb_decimation = bb_decimation = 612 self.samples_per_symbol = samples_per_symbol = 4 self.gain_mu = gain_mu = 0.03 self.bb_rate = bb_rate = float( samp_rate) * bb_interpolation / bb_decimation self.bb_filter_freq = bb_filter_freq = 10e3 self.omega = omega = samples_per_symbol self.mu = mu = 0.5 self.gain_omega = gain_omega = 0.25 * gain_mu * gain_mu self.bb_taps = bb_taps = gr.firdes.low_pass(1.0, samp_rate, bb_filter_freq, bb_filter_freq * 0.1) self.baud_rate = baud_rate = bb_rate / samples_per_symbol #self.average = average = 64 ################################################## # Blocks ################################################## # self.wxgui_scopesink2_1_0_0 = scopesink2.scope_sink_f( # self.GetWin(), # title="Scope Plot", # sample_rate=baud_rate, # v_scale=0, # v_offset=0, # t_scale=0, # ac_couple=False, # xy_mode=False, # num_inputs=1, # trig_mode=gr.gr_TRIG_MODE_NORM, # y_axis_label="Counts", # ) # self.Add(self.wxgui_scopesink2_1_0_0.win) #self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (bb_taps), 6e3, samp_rate) self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb( "10101010101010101010101010101", 1) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( omega, gain_omega, mu, gain_mu, 0.0002) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.dc_blocker_xx_0 = filter.dc_blocker_ff(64, True) #self.blocks_uchar_to_float_0_0 = blocks.uchar_to_float() #self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate) #self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/mnt/hgfs/tmp/rf_captures/315.000m_200.000k_20130623_133451_extract_am_2.cfile", True) self.blocks_file_source_0_0 = blocks.file_source( gr.sizeof_gr_complex * 1, filepath_in, False) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=bb_interpolation, decimation=bb_decimation, taps=None, fractional_bw=None, ) # _bb_filter_freq_sizer = wx.BoxSizer(wx.VERTICAL) # self._bb_filter_freq_text_box = forms.text_box( # parent=self.GetWin(), # sizer=_bb_filter_freq_sizer, # value=self.bb_filter_freq, # callback=self.set_bb_filter_freq, # label="BB Freq", # converter=forms.int_converter(), # proportion=0, # ) # self._bb_filter_freq_slider = forms.slider( # parent=self.GetWin(), # sizer=_bb_filter_freq_sizer, # value=self.bb_filter_freq, # callback=self.set_bb_filter_freq, # minimum=5e3, # maximum=30e3, # num_steps=250, # style=wx.SL_HORIZONTAL, # cast=int, # proportion=1, # ) # self.Add(_bb_filter_freq_sizer) # _average_sizer = wx.BoxSizer(wx.VERTICAL) # self._average_text_box = forms.text_box( # parent=self.GetWin(), # sizer=_average_sizer, # value=self.average, # callback=self.set_average, # label="Average Length", # converter=forms.int_converter(), # proportion=0, # ) # self._average_slider = forms.slider( # parent=self.GetWin(), # sizer=_average_sizer, # value=self.average, # callback=self.set_average, # minimum=0, # maximum=256, # num_steps=256, # style=wx.SL_HORIZONTAL, # cast=int, # proportion=1, # ) # self.Add(_average_sizer) ################################################## # Connections ################################################## self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_correlate_access_code_bb_0, 0)) #self.connect((self.digital_correlate_access_code_bb_0, 0), (self.blocks_uchar_to_float_0_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.blocks_complex_to_mag_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) #self.connect((self.blocks_uchar_to_float_0_0, 0), (self.wxgui_scopesink2_1_0_0, 0)) #self.connect((self.blocks_file_source_0_0, 0), (self.blocks_throttle_0, 0)) #self.connect((self.blocks_file_source_0_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.blocks_complex_to_mag_0, 0)) self.packetizer = Packetizer(82) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.packetizer, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__( self, title="Stereo FM receiver and RDS Decoder") ################################################## # Variables ################################################## self.xlate_decim = xlate_decim = 4 self.samp_rate = samp_rate = 1000000 self.freq_offset = freq_offset = 250e3 self.freq = freq = 88.5e6 self.baseband_rate = baseband_rate = samp_rate / xlate_decim self.audio_decim = audio_decim = 4 self.xlate_bandwidth = xlate_bandwidth = 250e3 self.volume = volume = 0 self.loop_bw = loop_bw = 16e3 * 0 + 18e3 * 1 self.gain = gain = 10 self.freq_tune = freq_tune = freq - freq_offset self.audio_rate = audio_rate = 48000 self.audio_decim_rate = audio_decim_rate = baseband_rate / audio_decim self.antenna = antenna = 'TX/RX' ################################################## # Message Queues ################################################## gr_rds_data_decoder_0_msgq_out = gr_rds_panel_0_msgq_in = gr.msg_queue( 2) ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=-20, maximum=10, num_steps=300, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_volume_sizer) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Demod") self.nb.AddPage(grc_wxgui.Panel(self.nb), "L+R") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Pilot") self.nb.AddPage(grc_wxgui.Panel(self.nb), "DSBSC") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS Raw") self.nb.AddPage(grc_wxgui.Panel(self.nb), "L-R") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS") self.Add(self.nb) _loop_bw_sizer = wx.BoxSizer(wx.VERTICAL) self._loop_bw_text_box = forms.text_box( parent=self.GetWin(), sizer=_loop_bw_sizer, value=self.loop_bw, callback=self.set_loop_bw, label="Loop BW", converter=forms.float_converter(), proportion=0, ) self._loop_bw_slider = forms.slider( parent=self.GetWin(), sizer=_loop_bw_sizer, value=self.loop_bw, callback=self.set_loop_bw, minimum=0, maximum=baseband_rate, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_loop_bw_sizer) _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=50, num_steps=50, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_gain_sizer) self._freq_offset_text_box = forms.text_box( parent=self.GetWin(), value=self.freq_offset, callback=self.set_freq_offset, label="Freq Offset", converter=forms.float_converter(), ) self.Add(self._freq_offset_text_box) _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label="Freq", converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=87.5e6, maximum=108e6, num_steps=205, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_sizer) self._antenna_chooser = forms.drop_down( parent=self.GetWin(), value=self.antenna, callback=self.set_antenna, label="Antenna", choices=['TX/RX', 'RX2'], labels=[], ) self.Add(self._antenna_chooser) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.nb.GetPage(3).GetWin(), title="Pilot", sample_rate=baseband_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(3).Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0_0_0_1_0_1 = fftsink2.fft_sink_f( self.nb.GetPage(7).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=-50, ref_scale=2.0, sample_rate=baseband_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="RDS", peak_hold=False, ) self.nb.GetPage(7).Add(self.wxgui_fftsink2_0_0_0_1_0_1.win) self.wxgui_fftsink2_0_0_0_1_0_0 = fftsink2.fft_sink_f( self.nb.GetPage(6).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=-50, ref_scale=2.0, sample_rate=baseband_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="L-R", peak_hold=False, ) self.nb.GetPage(6).Add(self.wxgui_fftsink2_0_0_0_1_0_0.win) self.wxgui_fftsink2_0_0_0_1_0 = fftsink2.fft_sink_f( self.nb.GetPage(5).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=baseband_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="RDS", peak_hold=False, ) self.nb.GetPage(5).Add(self.wxgui_fftsink2_0_0_0_1_0.win) self.wxgui_fftsink2_0_0_0_1 = fftsink2.fft_sink_f( self.nb.GetPage(4).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=baseband_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="DSBSC Sub-carrier", peak_hold=False, ) self.nb.GetPage(4).Add(self.wxgui_fftsink2_0_0_0_1.win) self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_f( self.nb.GetPage(2).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=audio_decim_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="L+R", peak_hold=False, ) self.nb.GetPage(2).Add(self.wxgui_fftsink2_0_0_0.win) self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_f( self.nb.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=baseband_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.8, title="FM Demod", peak_hold=False, ) self.nb.GetPage(1).Add(self.wxgui_fftsink2_0_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=-30, ref_scale=2.0, sample_rate=baseband_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.8, title="Baseband", peak_hold=False, ) self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.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_tune, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna(antenna, 0) self.gr_rds_panel_0 = rds.rdsPanel(gr_rds_panel_0_msgq_in, freq, self.GetWin()) self.Add(self.gr_rds_panel_0) self.gr_rds_freq_divider_0 = rds.freq_divider(16) self.gr_rds_data_decoder_0 = rds.data_decoder( gr_rds_data_decoder_0_msgq_out) self.gr_rds_bpsk_demod_0 = rds.bpsk_demod(audio_decim_rate) self.gr_pll_freqdet_cf_0 = gr.pll_freqdet_cf( 1.0 * 0 + (loop_bw * 2 * math.pi / baseband_rate), +(2.0 * math.pi * 90e3 / baseband_rate), -(2.0 * math.pi * 90e3 / baseband_rate)) self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vff( (10**(1. * volume / 10), )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff( (10**(1. * volume / 10), )) 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.fir_filter_xxx_7 = filter.fir_filter_fff( audio_decim, (firdes.low_pass(1, baseband_rate, 1.2e3, 1.5e3, firdes.WIN_HAMMING))) self.fir_filter_xxx_6 = filter.fir_filter_fff( audio_decim, (firdes.low_pass(1, baseband_rate, 1.5e3, 2e3, firdes.WIN_HAMMING))) self.fir_filter_xxx_5 = filter.fir_filter_fff( audio_decim, (firdes.low_pass(1.0, baseband_rate, 15e3, 1e3, firdes.WIN_HAMMING))) self.fir_filter_xxx_4 = filter.fir_filter_fff( 1, (firdes.band_pass(1.0, baseband_rate, 57e3 - 3e3, 57e3 + 3e3, 3e3, firdes.WIN_HAMMING))) self.fir_filter_xxx_3 = filter.fir_filter_fff( 1, (firdes.band_pass(1.0, baseband_rate, 38e3 - 15e3 / 2, 38e3 + 15e3 / 2, 1e3, firdes.WIN_HAMMING))) self.fir_filter_xxx_2 = filter.fir_filter_fff( 1, (firdes.band_pass(1.0, baseband_rate, 19e3 - 500, 19e3 + 500, 1e3, firdes.WIN_HAMMING))) self.fir_filter_xxx_1 = filter.fir_filter_fff( audio_decim, (firdes.low_pass(1.0, baseband_rate, 15e3, 1e3, firdes.WIN_HAMMING))) self.fir_filter_xxx_0 = filter.fir_filter_ccc(1, (firdes.low_pass( 1.0, baseband_rate, 80e3, 35e3, firdes.WIN_HAMMING))) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blks2_rational_resampler_xxx_0_0 = blks2.rational_resampler_fff( interpolation=audio_rate, decimation=audio_decim_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=audio_rate, decimation=audio_decim_rate, taps=None, fractional_bw=None, ) self.blks2_fm_deemph_0_0_0 = blks2.fm_deemph(fs=baseband_rate, tau=75e-6) self.blks2_fm_deemph_0_0 = blks2.fm_deemph(fs=baseband_rate, tau=75e-6) self.audio_sink_0 = audio.sink(audio_rate, "", True) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.gr_pll_freqdet_cf_0, 0)) self.connect((self.gr_pll_freqdet_cf_0, 0), (self.fir_filter_xxx_1, 0)) self.connect((self.gr_pll_freqdet_cf_0, 0), (self.fir_filter_xxx_2, 0)) self.connect((self.gr_pll_freqdet_cf_0, 0), (self.fir_filter_xxx_4, 0)) self.connect((self.fir_filter_xxx_2, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.fir_filter_xxx_2, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.fir_filter_xxx_2, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.fir_filter_xxx_2, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.fir_filter_xxx_3, 0), (self.blocks_multiply_xx_0, 2)) self.connect((self.fir_filter_xxx_4, 0), (self.blocks_multiply_xx_0_0, 3)) self.connect((self.fir_filter_xxx_2, 0), (self.blocks_multiply_xx_0_0, 2)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.fir_filter_xxx_2, 0), (self.gr_rds_freq_divider_0, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.fir_filter_xxx_5, 0)) self.connect((self.gr_pll_freqdet_cf_0, 0), (self.fir_filter_xxx_3, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0_0, 0), (self.audio_sink_0, 1)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.blks2_rational_resampler_xxx_0_0, 0)) self.connect((self.gr_rds_freq_divider_0, 0), (self.fir_filter_xxx_7, 0)) self.connect((self.fir_filter_xxx_7, 0), (self.gr_rds_bpsk_demod_0, 1)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.gr_rds_data_decoder_0, 0)) self.connect((self.gr_rds_bpsk_demod_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.fir_filter_xxx_6, 0), (self.gr_rds_bpsk_demod_0, 0)) self.connect((self.fir_filter_xxx_2, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.wxgui_fftsink2_0_0_0, 0)) self.connect((self.fir_filter_xxx_3, 0), (self.wxgui_fftsink2_0_0_0_1, 0)) self.connect((self.fir_filter_xxx_4, 0), (self.wxgui_fftsink2_0_0_0_1_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.fir_filter_xxx_6, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_fftsink2_0_0_0_1_0_0, 0)) self.connect((self.fir_filter_xxx_5, 0), (self.blocks_add_xx_0, 1)) self.connect((self.fir_filter_xxx_5, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.wxgui_fftsink2_0_0_0_1_0_1, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blks2_fm_deemph_0_0, 0)) self.connect((self.blks2_fm_deemph_0_0, 0), (self.gr_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blks2_fm_deemph_0_0_0, 0)) self.connect((self.blks2_fm_deemph_0_0_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_pll_freqdet_cf_0, 0), (self.wxgui_fftsink2_0_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Fm Stereo Tx") ################################################## # Variables ################################################## self.st_gain = st_gain = 10 self.samp_rate = samp_rate = 195.312e3 self.pilot_gain = pilot_gain = 80e-3 self.mpx_rate = mpx_rate = 160e3 self.Mono_gain = Mono_gain = 300e-3 self.FM_freq = FM_freq = 96.5e6 ################################################## # Blocks ################################################## _st_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._st_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_st_gain_sizer, value=self.st_gain, callback=self.set_st_gain, label='st_gain', converter=forms.float_converter(), proportion=0, ) self._st_gain_slider = forms.slider( parent=self.GetWin(), sizer=_st_gain_sizer, value=self.st_gain, callback=self.set_st_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_st_gain_sizer) _pilot_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._pilot_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_pilot_gain_sizer, value=self.pilot_gain, callback=self.set_pilot_gain, label='pilot_gain', converter=forms.float_converter(), proportion=0, ) self._pilot_gain_slider = forms.slider( parent=self.GetWin(), sizer=_pilot_gain_sizer, value=self.pilot_gain, callback=self.set_pilot_gain, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_pilot_gain_sizer) self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "FM") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "audio") self.Add(self.notebook_0) _Mono_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._Mono_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_Mono_gain_sizer, value=self.Mono_gain, callback=self.set_Mono_gain, label='Mono_gain', converter=forms.float_converter(), proportion=0, ) self._Mono_gain_slider = forms.slider( parent=self.GetWin(), sizer=_Mono_gain_sizer, value=self.Mono_gain, callback=self.set_Mono_gain, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_Mono_gain_sizer) _FM_freq_sizer = wx.BoxSizer(wx.VERTICAL) self._FM_freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_FM_freq_sizer, value=self.FM_freq, callback=self.set_FM_freq, label='FM_freq', converter=forms.float_converter(), proportion=0, ) self._FM_freq_slider = forms.slider( parent=self.GetWin(), sizer=_FM_freq_sizer, value=self.FM_freq, callback=self.set_FM_freq, minimum=88e6, maximum=108e6, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_FM_freq_sizer) self.wxgui_fftsink2_1 = fftsink2.fft_sink_f( self.notebook_0.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=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=FM_freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="addr=192.168.10.2", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(FM_freq, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.low_pass_filter_0 = gr.fir_filter_fff(1, firdes.low_pass( Mono_gain, mpx_rate, 15000, 2000, firdes.WIN_HAMMING, 6.76)) self.gr_vector_to_streams_0 = gr.vector_to_streams(gr.sizeof_short*1, 2) self.gr_sub_xx_0 = gr.sub_ff(1) self.gr_sig_source_x_1 = gr.sig_source_f(160000, gr.GR_SIN_WAVE, 19000, pilot_gain, 0) self.gr_sig_source_x_0 = gr.sig_source_f(160000, gr.GR_SIN_WAVE, 38000, 30e-3, 0) self.gr_short_to_float_1 = gr.short_to_float(1, 1) self.gr_short_to_float_0 = gr.short_to_float(1, 1) self.gr_multiply_xx_0 = gr.multiply_vff(1) self.gr_multiply_const_vxx_2 = gr.multiply_const_vcc((32.768e3, )) self.gr_multiply_const_vxx_1 = gr.multiply_const_vff((30e-6, )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((30e-6, )) self.gr_frequency_modulator_fc_0 = gr.frequency_modulator_fc(980e-3) self.gr_file_source_0 = gr.file_source(gr.sizeof_short*2, "/home/kranthi/Documents/project/FM Transceiver/FM Transmitter/test.raw", True) self.gr_add_xx_1 = gr.add_vff(1) self.gr_add_xx_0 = gr.add_vff(1) self.blks2_rational_resampler_xxx_2 = blks2.rational_resampler_fff( interpolation=4, decimation=1, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_fff( interpolation=5, decimation=1, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=5, decimation=1, taps=None, fractional_bw=None, ) self.blks2_fm_preemph_0 = blks2.fm_preemph(fs=mpx_rate, tau=50e-6) self.band_pass_filter_0 = gr.fir_filter_fff(1, firdes.band_pass( st_gain, mpx_rate, 23000, 53000, 2000, firdes.WIN_HAMMING, 6.76)) ################################################## # Connections ################################################## self.connect((self.gr_file_source_0, 0), (self.gr_vector_to_streams_0, 0)) self.connect((self.gr_vector_to_streams_0, 0), (self.gr_short_to_float_0, 0)) self.connect((self.gr_vector_to_streams_0, 1), (self.gr_short_to_float_1, 0)) self.connect((self.gr_short_to_float_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_short_to_float_1, 0), (self.gr_multiply_const_vxx_1, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_sub_xx_0, 1)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_sub_xx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_add_xx_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_sub_xx_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_multiply_xx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.gr_sig_source_x_1, 0), (self.gr_add_xx_1, 0)) self.connect((self.band_pass_filter_0, 0), (self.gr_add_xx_1, 1)) self.connect((self.low_pass_filter_0, 0), (self.gr_add_xx_1, 2)) self.connect((self.gr_add_xx_1, 0), (self.blks2_fm_preemph_0, 0)) self.connect((self.blks2_fm_preemph_0, 0), (self.blks2_rational_resampler_xxx_2, 0)) self.connect((self.blks2_rational_resampler_xxx_2, 0), (self.gr_frequency_modulator_fc_0, 0)) self.connect((self.gr_frequency_modulator_fc_0, 0), (self.gr_multiply_const_vxx_2, 0)) self.connect((self.gr_multiply_const_vxx_2, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.gr_multiply_const_vxx_2, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.wxgui_fftsink2_1, 0))
def __init__(self, filepath_in): gr.top_block.__init__(self) #grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 200e3 self.bb_interpolation = bb_interpolation = 100 self.bb_decimation = bb_decimation = 612 self.samples_per_symbol = samples_per_symbol = 4 self.gain_mu = gain_mu = 0.03 self.bb_rate = bb_rate = float(samp_rate) * bb_interpolation / bb_decimation self.bb_filter_freq = bb_filter_freq = 10e3 self.omega = omega = samples_per_symbol self.mu = mu = 0.5 self.gain_omega = gain_omega = 0.25 * gain_mu * gain_mu self.bb_taps = bb_taps = gr.firdes.low_pass(1.0, samp_rate, bb_filter_freq, bb_filter_freq * 0.1) self.baud_rate = baud_rate = bb_rate / samples_per_symbol #self.average = average = 64 ################################################## # Blocks ################################################## # self.wxgui_scopesink2_1_0_0 = scopesink2.scope_sink_f( # self.GetWin(), # title="Scope Plot", # sample_rate=baud_rate, # v_scale=0, # v_offset=0, # t_scale=0, # ac_couple=False, # xy_mode=False, # num_inputs=1, # trig_mode=gr.gr_TRIG_MODE_NORM, # y_axis_label="Counts", # ) # self.Add(self.wxgui_scopesink2_1_0_0.win) #self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (bb_taps), 6e3, samp_rate) self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb("10101010101010101010101010101", 1) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(omega, gain_omega, mu, gain_mu, 0.0002) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.dc_blocker_xx_0 = filter.dc_blocker_ff(64, True) #self.blocks_uchar_to_float_0_0 = blocks.uchar_to_float() #self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate) #self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/mnt/hgfs/tmp/rf_captures/315.000m_200.000k_20130623_133451_extract_am_2.cfile", True) self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_gr_complex*1, filepath_in, False) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=bb_interpolation, decimation=bb_decimation, taps=None, fractional_bw=None, ) # _bb_filter_freq_sizer = wx.BoxSizer(wx.VERTICAL) # self._bb_filter_freq_text_box = forms.text_box( # parent=self.GetWin(), # sizer=_bb_filter_freq_sizer, # value=self.bb_filter_freq, # callback=self.set_bb_filter_freq, # label="BB Freq", # converter=forms.int_converter(), # proportion=0, # ) # self._bb_filter_freq_slider = forms.slider( # parent=self.GetWin(), # sizer=_bb_filter_freq_sizer, # value=self.bb_filter_freq, # callback=self.set_bb_filter_freq, # minimum=5e3, # maximum=30e3, # num_steps=250, # style=wx.SL_HORIZONTAL, # cast=int, # proportion=1, # ) # self.Add(_bb_filter_freq_sizer) # _average_sizer = wx.BoxSizer(wx.VERTICAL) # self._average_text_box = forms.text_box( # parent=self.GetWin(), # sizer=_average_sizer, # value=self.average, # callback=self.set_average, # label="Average Length", # converter=forms.int_converter(), # proportion=0, # ) # self._average_slider = forms.slider( # parent=self.GetWin(), # sizer=_average_sizer, # value=self.average, # callback=self.set_average, # minimum=0, # maximum=256, # num_steps=256, # style=wx.SL_HORIZONTAL, # cast=int, # proportion=1, # ) # self.Add(_average_sizer) ################################################## # Connections ################################################## self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_correlate_access_code_bb_0, 0)) #self.connect((self.digital_correlate_access_code_bb_0, 0), (self.blocks_uchar_to_float_0_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.blocks_complex_to_mag_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) #self.connect((self.blocks_uchar_to_float_0_0, 0), (self.wxgui_scopesink2_1_0_0, 0)) #self.connect((self.blocks_file_source_0_0, 0), (self.blocks_throttle_0, 0)) #self.connect((self.blocks_file_source_0_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.blocks_complex_to_mag_0, 0)) self.packetizer = Packetizer(82) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.packetizer, 0))
def __init__(self, options, queue): gr.top_block.__init__(self, "mhp") self.audio_amps = [] self.converters = [] self.vocoders = [] self.filters = [] self.c4fm = [] self.output_gain = [] input_audio_rate = 8000 output_audio_rate = 48000 c4fm_rate = 96000 if not options.input_files: self.audio_input = audio.source(input_audio_rate, options.audio_input) self.audio_output = audio.sink (output_audio_rate, options.audio_output) for i in range (options.nchannels): if options.input_files: t = gr.file_source(gr.sizeof_char, "baseband-%d.dat" % i, options.repeat) self.vocoders.append(t) else: t = gr.multiply_const_ff(32767 * options.audio_gain) self.audio_amps.append(t) t = gr.float_to_short() self.converters.append(t) t = repeater.vocoder(True, # 0=Decode,True=Encode options.verbose, # Verbose flag options.stretch, # flex amount "", # udp ip address 0, # udp port False) # dump raw u vectors self.vocoders.append(t) t = op25_c4fm_mod.p25_mod(output_sample_rate=c4fm_rate, log=False, verbose=True) self.c4fm.append(t) # FIXME: it would seem as if direct output at 48000 would be the # obvious way to go, but for unknown reasons, it produces hideous # distortion in the output waveform. For the same unknown # reasons, it's clean if we output at 96000 and then decimate # back down to 48k... t = blks2.rational_resampler_fff(1, 2) # 96000 -> 48000 self.filters.append(t) t = gr.multiply_const_ff(options.output_gain) self.output_gain.append(t) for i in range (options.nchannels): if not options.input_files: self.connect(self.audio_amps[i], self.converters[i], self.vocoders[i]) self.connect(self.vocoders[i], self.c4fm[i], self.filters[i], self.output_gain[i]) if options.nchannels == 1: if not options.input_files: self.connect(self.audio_input, self.audio_amps[0]) self.connect(self.output_gain[0], self.audio_output) else: for i in range (options.nchannels): if not options.input_files: self.connect((self.audio_input, i), self.audio_amps[i]) self.connect(self.output_gain[i], (self.audio_output, i))
def __init__(self, talkgroup, options): gr.hier_block2.__init__( self, "fsk_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, gr.sizeof_char)) # Output signature print "Starting log_receiver init()" self.samp_rate = samp_rate = int(options.rate) self.samp_per_sym = samp_per_sym = 10 self.decim = decim = 20 self.xlate_bandwidth = xlate_bandwidth = 24260.0 self.xlate_offset = xlate_offset = 0 self.channel_rate = channel_rate = op25.SYMBOL_RATE * samp_per_sym self.audio_mul = audio_mul = 1 self.pre_channel_rate = pre_channel_rate = int(samp_rate / decim) self.squelch = squelch = -55 self.auto_tune_offset = auto_tune_offset = 0 self.audiorate = 44100 #options.audiorate self.rate = options.rate self.talkgroup = talkgroup self.directory = options.directory if options.squelch is None: options.squelch = 28 if options.volume is None: options.volume = 3.0 ################################################## # Blocks ################################################## print "Setting up Blocks" self.audiotaps = gr.firdes.low_pass(1, samp_rate, 8000, 2000, gr.firdes.WIN_HANN) self.prefilter_decim = int(self.rate / self.audiorate) #the audio prefilter is a channel selection filter. self.audio_prefilter = gr.freq_xlating_fir_filter_ccf( self.prefilter_decim, #decimation self.audiotaps, #taps 0, #freq offset int(samp_rate)) #sampling rate self.audiodemod = blks2.fm_demod_cf( self.rate / self.prefilter_decim, #rate 1, #audio decimation 4000, #deviation 3000, #audio passband 4000, #audio stopband options.volume, #gain 75e-6) #deemphasis constant #the filtering removes FSK data woobling from the subaudible channel self.audiofilttaps = gr.firdes.high_pass(1, self.audiorate, 300, 50, gr.firdes.WIN_HANN) self.audiofilt = gr.fir_filter_fff(1, self.audiofilttaps) self.gr_quadrature_demod_cf_0 = analog.quadrature_demod_cf( 1.6) #(channel_rate/(2.0 * math.pi * op25.SYMBOL_DEVIATION))) self.gr_freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth / 2, 2000)), 0, samp_rate) self.gr_fir_filter_xxx_0 = filter.fir_filter_fff( 1, ((1.0 / samp_per_sym, ) * samp_per_sym)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (10.**(audio_mul / 10.), )) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_ccc( interpolation=channel_rate, decimation=pre_channel_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=self.audiorate, decimation=8000, taps=None, fractional_bw=None, ) #here we generate a random filename in the form /tmp/[random].wav, and then use it for the wavstamp block. this avoids collisions later on. remember to clean up these files when deallocating. self.tmpfilename = "/tmp/%s.wav" % ( "".join([ random.choice(string.letters + string.digits) for x in range(8) ]) ) #if this looks glaringly different, it's because i totally cribbed it from a blog. self.valve = grc_blks2.valve(gr.sizeof_float, bool(1)) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_AUTO_DETECT, dsd.dsd_MOD_AUTO_SELECT, 3, 2, True) #open the logfile for appending self.timestampfilename = "%s/%i.txt" % (self.directory, self.talkgroup) self.timestampfile = open(self.timestampfilename, 'a') self.filename = "%s/%i.wav" % (self.directory, self.talkgroup) self.audiosink = smartnet.wavsink( self.filename, 1, self.audiorate, 8 ) #blocks.wavfile_sink(self.filename, 1, self.audiorate, 8) this version allows appending to existing files. self.audio_sink_0 = audio.sink(44100, "", True) self.timestamp = 0.0 #print "Finishing logging receiver init()." self.mute() #start off muted. print "Connecting blocks" ################################################## # Connections ################################################## self.connect(self.blks2_rational_resampler_xxx_0, self.blocks_multiply_const_vxx_0) self.connect(self.gr_fir_filter_xxx_0, self.valve, self.dsd_block_ff_0) self.connect(self.dsd_block_ff_0, self.blks2_rational_resampler_xxx_0) ## Start self.connect(self, self.gr_freq_xlating_fir_filter_xxx_0, self.blks2_rational_resampler_xxx_1, self.gr_quadrature_demod_cf_0, self.gr_fir_filter_xxx_0) ## End # self.connect(self.blocks_multiply_const_vxx_0, self.audio_sink_0) # Plays the audio self.connect(self.blocks_multiply_const_vxx_0, self.audiosink) # Records the audio
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Fm Stereo Tx") ################################################## # Variables ################################################## self.st_gain = st_gain = 10 self.samp_rate = samp_rate = 195.312e3 self.pilot_gain = pilot_gain = 80e-3 self.mpx_rate = mpx_rate = 160e3 self.Mono_gain = Mono_gain = 300e-3 self.FM_freq = FM_freq = 96.5e6 ################################################## # Blocks ################################################## _st_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._st_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_st_gain_sizer, value=self.st_gain, callback=self.set_st_gain, label='st_gain', converter=forms.float_converter(), proportion=0, ) self._st_gain_slider = forms.slider( parent=self.GetWin(), sizer=_st_gain_sizer, value=self.st_gain, callback=self.set_st_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_st_gain_sizer) _pilot_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._pilot_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_pilot_gain_sizer, value=self.pilot_gain, callback=self.set_pilot_gain, label='pilot_gain', converter=forms.float_converter(), proportion=0, ) self._pilot_gain_slider = forms.slider( parent=self.GetWin(), sizer=_pilot_gain_sizer, value=self.pilot_gain, callback=self.set_pilot_gain, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_pilot_gain_sizer) self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "FM") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "audio") self.Add(self.notebook_0) _Mono_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._Mono_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_Mono_gain_sizer, value=self.Mono_gain, callback=self.set_Mono_gain, label='Mono_gain', converter=forms.float_converter(), proportion=0, ) self._Mono_gain_slider = forms.slider( parent=self.GetWin(), sizer=_Mono_gain_sizer, value=self.Mono_gain, callback=self.set_Mono_gain, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_Mono_gain_sizer) _FM_freq_sizer = wx.BoxSizer(wx.VERTICAL) self._FM_freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_FM_freq_sizer, value=self.FM_freq, callback=self.set_FM_freq, label='FM_freq', converter=forms.float_converter(), proportion=0, ) self._FM_freq_slider = forms.slider( parent=self.GetWin(), sizer=_FM_freq_sizer, value=self.FM_freq, callback=self.set_FM_freq, minimum=88e6, maximum=108e6, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_FM_freq_sizer) self.wxgui_fftsink2_1 = fftsink2.fft_sink_f( self.notebook_0.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=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=FM_freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="addr=192.168.10.2", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(FM_freq, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.low_pass_filter_0 = gr.fir_filter_fff( 1, firdes.low_pass(Mono_gain, mpx_rate, 15000, 2000, firdes.WIN_HAMMING, 6.76)) self.gr_vector_to_streams_0 = gr.vector_to_streams( gr.sizeof_short * 1, 2) self.gr_sub_xx_0 = gr.sub_ff(1) self.gr_sig_source_x_1 = gr.sig_source_f(160000, gr.GR_SIN_WAVE, 19000, pilot_gain, 0) self.gr_sig_source_x_0 = gr.sig_source_f(160000, gr.GR_SIN_WAVE, 38000, 30e-3, 0) self.gr_short_to_float_1 = gr.short_to_float(1, 1) self.gr_short_to_float_0 = gr.short_to_float(1, 1) self.gr_multiply_xx_0 = gr.multiply_vff(1) self.gr_multiply_const_vxx_2 = gr.multiply_const_vcc((32.768e3, )) self.gr_multiply_const_vxx_1 = gr.multiply_const_vff((30e-6, )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((30e-6, )) self.gr_frequency_modulator_fc_0 = gr.frequency_modulator_fc(980e-3) self.gr_file_source_0 = gr.file_source( gr.sizeof_short * 2, "/home/kranthi/Documents/project/FM Transceiver/FM Transmitter/test.raw", True) self.gr_add_xx_1 = gr.add_vff(1) self.gr_add_xx_0 = gr.add_vff(1) self.blks2_rational_resampler_xxx_2 = blks2.rational_resampler_fff( interpolation=4, decimation=1, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_fff( interpolation=5, decimation=1, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=5, decimation=1, taps=None, fractional_bw=None, ) self.blks2_fm_preemph_0 = blks2.fm_preemph(fs=mpx_rate, tau=50e-6) self.band_pass_filter_0 = gr.fir_filter_fff( 1, firdes.band_pass(st_gain, mpx_rate, 23000, 53000, 2000, firdes.WIN_HAMMING, 6.76)) ################################################## # Connections ################################################## self.connect((self.gr_file_source_0, 0), (self.gr_vector_to_streams_0, 0)) self.connect((self.gr_vector_to_streams_0, 0), (self.gr_short_to_float_0, 0)) self.connect((self.gr_vector_to_streams_0, 1), (self.gr_short_to_float_1, 0)) self.connect((self.gr_short_to_float_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_short_to_float_1, 0), (self.gr_multiply_const_vxx_1, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_sub_xx_0, 1)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_sub_xx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_add_xx_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_sub_xx_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_multiply_xx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.gr_sig_source_x_1, 0), (self.gr_add_xx_1, 0)) self.connect((self.band_pass_filter_0, 0), (self.gr_add_xx_1, 1)) self.connect((self.low_pass_filter_0, 0), (self.gr_add_xx_1, 2)) self.connect((self.gr_add_xx_1, 0), (self.blks2_fm_preemph_0, 0)) self.connect((self.blks2_fm_preemph_0, 0), (self.blks2_rational_resampler_xxx_2, 0)) self.connect((self.blks2_rational_resampler_xxx_2, 0), (self.gr_frequency_modulator_fc_0, 0)) self.connect((self.gr_frequency_modulator_fc_0, 0), (self.gr_multiply_const_vxx_2, 0)) self.connect((self.gr_multiply_const_vxx_2, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.gr_multiply_const_vxx_2, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.wxgui_fftsink2_1, 0))
def __init__(self, gain=0, audio_output="", samp_rate=400e3, address="addr=192.168.10.2", freq=96e6): grc_wxgui.top_block_gui.__init__(self, title="UHD WBFM Receive") ################################################## # Parameters ################################################## self.gain = gain self.audio_output = audio_output self.samp_rate = samp_rate self.address = address self.freq = freq ################################################## # Variables ################################################## self.volume = volume = 1 self.tun_gain = tun_gain = gain self.tun_freq = tun_freq = freq self.fine = fine = 0 self.audio_decim = audio_decim = 10 ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_volume_sizer, 1, 0, 1, 4) _tun_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._tun_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_tun_gain_sizer, value=self.tun_gain, callback=self.set_tun_gain, label="UHD Gain", converter=forms.float_converter(), proportion=0, ) self._tun_gain_slider = forms.slider( parent=self.GetWin(), sizer=_tun_gain_sizer, value=self.tun_gain, callback=self.set_tun_gain, minimum=0, maximum=20, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_tun_gain_sizer) _tun_freq_sizer = wx.BoxSizer(wx.VERTICAL) self._tun_freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_tun_freq_sizer, value=self.tun_freq, callback=self.set_tun_freq, label="Freq (Hz)", converter=forms.float_converter(), proportion=0, ) self._tun_freq_slider = forms.slider( parent=self.GetWin(), sizer=_tun_freq_sizer, value=self.tun_freq, callback=self.set_tun_freq, minimum=87.9e6, maximum=108.1e6, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_tun_freq_sizer) _fine_sizer = wx.BoxSizer(wx.VERTICAL) self._fine_text_box = forms.text_box( parent=self.GetWin(), sizer=_fine_sizer, value=self.fine, callback=self.set_fine, label="Fine Freq (MHz)", converter=forms.float_converter(), proportion=0, ) self._fine_slider = forms.slider( parent=self.GetWin(), sizer=_fine_sizer, value=self.fine, callback=self.set_fine, minimum=-.1, maximum=.1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_fine_sizer, 0, 2, 1, 2) self.wxgui_fftsink2 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=(freq+fine), 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=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.GridAdd(self.wxgui_fftsink2.win, 2, 0, 2, 4) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr=address, 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(tun_freq+fine, 0) self.uhd_usrp_source_0.set_gain(tun_gain, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.low_pass_filter_0 = gr.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, 115e3, 30e3, firdes.WIN_HANN, 6.76)) self.gr_multiply_const_vxx = gr.multiply_const_vff((volume, )) self.blks2_wfm_rcv = blks2.wfm_rcv( quad_rate=samp_rate, audio_decimation=audio_decim, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=48, decimation=40, taps=None, fractional_bw=None, ) self.audio_sink = audio.sink(48000, audio_output, True) ################################################## # Connections ################################################## self.connect((self.gr_multiply_const_vxx, 0), (self.audio_sink, 0)) self.connect((self.low_pass_filter_0, 0), (self.blks2_wfm_rcv, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2, 0)) self.connect((self.blks2_wfm_rcv, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_multiply_const_vxx, 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.volume = volume = 0.05 self.samp_rate = samp_rate = 256000 self.resamp_factor = resamp_factor = 4 ################################################## # 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) self.wxgui_scopesink2_1_0 = scopesink2.scope_sink_f( 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=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_1_0.win) self.wxgui_scopesink2_1 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=True, xy_mode=False, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.low_pass_filter_0 = gr.fir_filter_ccf(resamp_factor, firdes.low_pass( 1, samp_rate/resamp_factor, 5000, 100, firdes.WIN_HAMMING, 6.76)) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/Jack_Sparrow/EE304P/Lab04/am_usrp710.dat", True) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=3, decimation=4, taps=None, fractional_bw=None, ) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -80000, 1, 0) ################################################## # Connections ################################################## self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.wxgui_scopesink2_1_0, 0))
def __init__(self, options): gr.top_block.__init__(self) self.rate = options.rate print "Samples per second is %i" % self.rate self._syms_per_sec = 3600; options.audiorate = 44100 options.rate = self.rate options.samples_per_second = self.rate #yeah i know it's on the list options.syms_per_sec = self._syms_per_sec options.gain_mu = 0.01 options.mu=0.5 options.omega_relative_limit = 0.3 options.syms_per_sec = self._syms_per_sec options.offset = options.centerfreq - options.freq print "Tuning channel offset: %f" % options.offset self.freq = options.freq self.samp_rate = samp_rate = self.rate self.samp_per_sym = samp_per_sym = 10 self.decim = decim = 20 self.xlate_bandwidth = 14000 self.pre_channel_rate = pre_channel_rate = int(samp_rate/decim) self.channel_rate = channel_rate = 4800*samp_per_sym self.rtl = osmosdr.source_c( args="nchan=" + str(1) + " " + "" ) self.rtl.set_sample_rate(options.rate) self.rtl.set_center_freq(options.centerfreq, 0) self.rtl.set_freq_corr(options.ppm, 0) #self.rtl.set_gain_mode(1, 0) print "Channel Rate: %d Pre Channel Rate: %d" % (channel_rate, pre_channel_rate) self.centerfreq = options.centerfreq print "Setting center to (With Error): %fMHz" % (self.centerfreq - options.error) if not(self.tune(options.centerfreq - options.error)): print "Failed to set initial frequency" if options.gain is None: options.gain = 14 if options.bbgain is None: options.bbgain = 25 if options.ifgain is None: options.ifgain = 25 print "Setting RF gain to %i" % options.gain print "Setting BB gain to %i" % options.bbgain print "Setting IF gain to %i" % options.ifgain self.rtl.set_gain(options.gain, 0) self.rtl.set_if_gain(options.ifgain,0) self.rtl.set_bb_gain(options.bbgain,0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decim, (firdes.low_pass(1, samp_rate, self.xlate_bandwidth/2, 6000)), -options.offset, samp_rate) self.fir_filter_xxx_0 = filter.fir_filter_fff(1, ((1.0/self.samp_per_sym,)*self.samp_per_sym)) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_AUTO_DETECT,dsd.dsd_MOD_AUTO_SELECT,3,3,True) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_ccc( interpolation=channel_rate, decimation=pre_channel_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=44100, decimation=8000, taps=None, fractional_bw=None, ) self.audio_sink_0 = audio.sink(44100, "", True) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1.6) #self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.dsd_block_ff_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) #self.connect((self.analog_quadrature_demod_cf_0, 0), (self.dsd_block_ff_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.dsd_block_ff_0, 0)) self.connect((self.rtl, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.analog_quadrature_demod_cf_0, 0))
def __init__(self,frame,panel,vbox,argv): stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) parser=OptionParser(option_class=eng_option) parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, help="select USRP Rx side A or B (default=A)") parser.add_option("-f", "--freq", type="eng_float", default=100.1e6, help="set frequency to FREQ", metavar="FREQ") parser.add_option("-g", "--gain", type="eng_float", default=65, help="set gain in dB (default is midpoint)") parser.add_option("-s", "--squelch", type="eng_float", default=0, help="set squelch level (default is 0)") parser.add_option("-V", "--volume", type="eng_float", default=None, help="set volume (default is midpoint)") 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) self.frame = frame self.panel = panel self.vol = 0 self.state = "FREQ" self.freq = 0 # build graph self.u = usrp.source_c() # usrp is data source adc_rate = self.u.adc_rate() # 64 MS/s usrp_decim = 200 self.u.set_decim_rate(usrp_decim) usrp_rate = adc_rate / usrp_decim # 320 kS/s chanfilt_decim = 1 demod_rate = usrp_rate / chanfilt_decim audio_decimation = 10 audio_rate = 3*demod_rate / audio_decimation/2 # 48 kHz if options.rx_subdev_spec is None: options.rx_subdev_spec = pick_subdevice(self.u) self.u.set_mux(usrp.determine_rx_mux_value(self.u, options.rx_subdev_spec)) self.subdev = usrp.selected_subdev(self.u, options.rx_subdev_spec) chan_filt_coeffs = gr.firdes.low_pass_2 (1, # gain usrp_rate, # sampling rate 90e3, # passband cutoff 30e3, # transition bandwidth 70, # stopband attenuation gr.firdes.WIN_BLACKMAN) print len(chan_filt_coeffs) chan_filt = gr.fir_filter_ccf (chanfilt_decim, chan_filt_coeffs) self.rchan_sample = blks2.rational_resampler_fff(3,2) self.lchan_sample = blks2.rational_resampler_fff(3,2) #self.guts = blks2.wfm_rcv (demod_rate, audio_decimation) self.guts = blks2.wfm_rcv_fmdet (demod_rate, audio_decimation) # FIXME rework {add,multiply}_const_* to handle multiple streams self.volume_control_l = gr.multiply_const_ff(self.vol) self.volume_control_r = gr.multiply_const_ff(self.vol) # sound card as final sink audio_sink = audio.sink (int (audio_rate), options.audio_output, False) # ok_to_block # now wire it all together self.connect (self.u, chan_filt, self.guts) self.connect((self.guts, 0), self.lchan_sample,self.volume_control_l,(audio_sink,0)) self.connect((self.guts, 1), self.rchan_sample,self.volume_control_r,(audio_sink,1)) try: self.guts.stereo_carrier_pll_recovery.squelch_enable(True) except: print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet" self._build_gui(vbox, usrp_rate, demod_rate, audio_rate) if options.gain is None: # if no gain was specified, use the mid-point in dB g = self.subdev.gain_range() options.gain = float(g[0]+g[1])/2 if options.volume is None: g = self.volume_range() options.volume = float(g[0]+g[1])/2 if abs(options.freq) < 1e6: options.freq *= 1e6 # set initial values self.set_gain(options.gain) self.set_vol(options.volume) try: self.guts.stereo_carrier_pll_recovery.set_lock_threshold(options.squelch) except: print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet" if not(self.set_freq(options.freq)): self._set_status_msg("Failed to set initial frequency")
def __init__(self, frame, panel, vbox, argv): stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv) parser = OptionParser (option_class=eng_option) parser.add_option("-T", "--tx-subdev-spec", type="subdev", default=None, help="select USRP Tx side A or B") parser.add_option("-f", "--freq", type="eng_float", default=107.2e6, help="set Tx frequency to FREQ [required]", metavar="FREQ") parser.add_option("-i", "--filename", type="string", default="", help="read input from FILE") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.u = usrp.sink_c () self.dac_rate = self.u.dac_rate() # 128 MS/s self.usrp_interp = 400 self.u.set_interp_rate(self.usrp_interp) self.usrp_rate = self.dac_rate / self.usrp_interp # 320 kS/s self.sw_interp = 10 self.audio_rate = self.usrp_rate / self.sw_interp # 32 kS/s # determine the daughterboard subdevice we're using if options.tx_subdev_spec is None: options.tx_subdev_spec = usrp.pick_tx_subdevice(self.u) self.u.set_mux(usrp.determine_tx_mux_value(self.u, options.tx_subdev_spec)) self.subdev = usrp.selected_subdev(self.u, options.tx_subdev_spec) print "Using TX d'board %s" % (self.subdev.side_and_name(),) # set max Tx gain, tune frequency and enable transmitter self.subdev.set_gain(self.subdev.gain_range()[1]) self.u.tune(self.subdev._which, self.subdev, options.freq) self.subdev.set_enable(True) # open file containing floats in the [-1, 1] range, repeat self.src = gr.wavfile_source (options.filename, True) nchans = self.src.channels() sample_rate = self.src.sample_rate() bits_per_sample = self.src.bits_per_sample() print nchans, "channels,", sample_rate, "kS/s,", bits_per_sample, "bits/sample" # resample to 32kS/s if sample_rate == 44100: self.resample = blks2.rational_resampler_fff(8,11) elif sample_rate == 48000: self.resample == blks2.rational_resampler_fff(2,3) else: print sample_rate, "is an unsupported sample rate" exit() # interpolation, preemphasis, fm modulation & gain self.fmtx = blks2.wfm_tx (self.audio_rate, self.usrp_rate, tau=75e-6, max_dev=15e3) self.gain = gr.multiply_const_cc (4e3) # connect it all self.connect (self.src, self.resample, self.fmtx, self.gain, self.u) # plot an FFT to verify we are sending what we want pre_mod = fftsink2.fft_sink_f(panel, title="Pre-Modulation", fft_size=512, sample_rate=self.usrp_rate, y_per_div=10, ref_level=0) self.connect (self.emph, pre_mod) vbox.Add (pre_mod.win, 1, wx.EXPAND)
def __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-a", "--audio-input", type="string", default="") parser.add_option("-A", "--analog-gain", type="float", default=1.0, help="output gain for analog channel") parser.add_option("-c", "--ctcss-freq", type="float", default=0.0, help="CTCSS tone frequency") parser.add_option("-d", "--debug", type="int", default=0, help="debug level") parser.add_option("-g", "--gain", type="eng_float", default=1, help="adjusts input level for standard data levels") parser.add_option("-H", "--hostname", type="string", default="127.0.0.1", help="asterisk host IP") parser.add_option("-p", "--port", type="int", default=32001, help="chan_usrp UDP port") parser.add_option("-s", "--sample-rate", type="int", default=48000, help="input sample rate") parser.add_option("-S", "--stretch", type="int", default=0) (options, args) = parser.parse_args() sample_rate = options.sample_rate symbol_rate = 4800 symbol_decim = 1 IN = audio.source(sample_rate, options.audio_input) symbol_coeffs = gr.firdes.root_raised_cosine(1.0, # gain sample_rate , # sampling rate symbol_rate, # symbol rate 0.2, # width of trans. band 500) # filter type SYMBOL_FILTER = gr.fir_filter_fff (symbol_decim, symbol_coeffs) AMP = gr.multiply_const_ff(options.gain) msgq = gr.msg_queue(2) FSK4 = fsk4.demod_ff(msgq, sample_rate, symbol_rate) levels = levels = [-2.0, 0.0, 2.0, 4.0] SLICER = repeater.fsk4_slicer_fb(levels) framer_msgq = gr.msg_queue(2) DECODE = repeater.p25_frame_assembler('', # udp hostname 0, # udp port no. options.debug, #debug True, # do_imbe True, # do_output False, # do_msgq framer_msgq) IMBE = repeater.vocoder(False, # 0=Decode,True=Encode options.debug, # Verbose flag options.stretch, # flex amount "", # udp ip address 0, # udp port False) # dump raw u vectors CHAN_RPT = repeater.chan_usrp_rx(options.hostname, options.port, options.debug) self.connect(IN, AMP, SYMBOL_FILTER, FSK4, SLICER, DECODE, IMBE, CHAN_RPT) # blocks for second channel (fm rx) output_sample_rate = 8000 decim_amt = sample_rate / output_sample_rate RESAMP = blks2.rational_resampler_fff(1, decim_amt) if options.ctcss_freq > 0: level = 5.0 len = 0 ramp = 0 gate = True CTCSS = repeater.ctcss_squelch_ff(output_sample_rate, options.ctcss_freq, level, len, ramp, gate) AMP2 = gr.multiply_const_ff(32767.0 * options.analog_gain) CVT = gr.float_to_short() CHAN_RPT2 = repeater.chan_usrp_rx(options.hostname, options.port+1, options.debug) if options.ctcss_freq > 0: self.connect(IN, RESAMP, CTCSS, AMP2, CVT, CHAN_RPT2) else: self.connect(IN, RESAMP, AMP2, CVT, CHAN_RPT2)
def __init__(self, frame, panel, vbox, argv): stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) self.frame = frame self.panel = panel parser = OptionParser(option_class=eng_option) parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=(0, 0), help="select USRP Rx side A or B (default=A)") parser.add_option( "-d", "--decim", type="int", default=16, help="set fgpa decimation rate to DECIM [default=%default]") parser.add_option("-f", "--freq", type="eng_float", default=None, help="set frequency to FREQ", metavar="FREQ") parser.add_option("-Q", "--observing", type="eng_float", default=0.0, help="set observing frequency to FREQ") parser.add_option("-a", "--avg", type="eng_float", default=1.0, help="set spectral averaging alpha") parser.add_option("-V", "--favg", type="eng_float", default=2.0, help="set folder averaging alpha") parser.add_option("-g", "--gain", type="eng_float", default=None, help="set gain in dB (default is midpoint)") parser.add_option("-l", "--reflevel", type="eng_float", default=30.0, help="Set pulse display reference level") parser.add_option("-L", "--lowest", type="eng_float", default=1.5, help="Lowest valid frequency bin") parser.add_option("-e", "--longitude", type="eng_float", default=-76.02, help="Set Observer Longitude") parser.add_option("-c", "--latitude", type="eng_float", default=44.85, help="Set Observer Latitude") parser.add_option("-F", "--fft_size", type="eng_float", default=1024, help="Size of FFT") parser.add_option("-t", "--threshold", type="eng_float", default=2.5, help="pulsar threshold") parser.add_option("-p", "--lowpass", type="eng_float", default=100, help="Pulse spectra cutoff freq") parser.add_option("-P", "--prefix", default="./", help="File prefix") parser.add_option("-u", "--pulsefreq", type="eng_float", default=0.748, help="Observation pulse rate") parser.add_option("-D", "--dm", type="eng_float", default=1.0e-5, help="Dispersion Measure") parser.add_option("-O", "--doppler", type="eng_float", default=1.0, help="Doppler ratio") parser.add_option("-B", "--divbase", type="eng_float", default=20, help="Y/Div menu base") parser.add_option("-I", "--division", type="eng_float", default=100, help="Y/Div") parser.add_option("-A", "--audio_source", default="plughw:0,0", help="Audio input device spec") parser.add_option("-N", "--num_pulses", default=1, type="eng_float", help="Number of display pulses") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.show_debug_info = True self.reflevel = options.reflevel self.divbase = options.divbase self.division = options.division self.audiodev = options.audio_source self.mult = int(options.num_pulses) # Low-pass cutoff for post-detector filter # Set to 100Hz usually, since lots of pulsars fit in this # range self.lowpass = options.lowpass # What is lowest valid frequency bin in post-detector FFT? # There's some pollution very close to DC self.lowest_freq = options.lowest # What (dB) threshold to use in determining spectral candidates self.threshold = options.threshold # Filename prefix for recording file self.prefix = options.prefix # Dispersion Measure (DM) self.dm = options.dm # Doppler shift, as a ratio # 1.0 == no doppler shift # 1.005 == a little negative shift # 0.995 == a little positive shift self.doppler = options.doppler # # Input frequency and observing frequency--not necessarily the # same thing, if we're looking at the IF of some downconverter # that's ahead of the USRP and daughtercard. This distinction # is important in computing the correct de-dispersion filter. # self.frequency = options.freq if options.observing <= 0: self.observing_freq = options.freq else: self.observing_freq = options.observing # build the graph self.u = usrp.source_c(decim_rate=options.decim) self.u.set_mux( usrp.determine_rx_mux_value(self.u, options.rx_subdev_spec)) # # Recording file, in case we ever need to record baseband data # self.recording = gr.file_sink(gr.sizeof_char, "/dev/null") self.recording_state = False self.pulse_recording = gr.file_sink(gr.sizeof_short, "/dev/null") self.pulse_recording_state = False # # We come up with recording turned off, but the user may # request recording later on self.recording.close() self.pulse_recording.close() # # Need these two for converting 12-bit baseband signals to 8-bit # self.tofloat = gr.complex_to_float() self.tochar = gr.float_to_char() # Need this for recording pulses (post-detector) self.toshort = gr.float_to_short() # # The spectral measurer sets this when it has a valid # average spectral peak-to-peak distance # We can then use this to program the parameters for the epoch folder # # We set a sentimental value here self.pulse_freq = options.pulsefreq # Folder runs at this raw sample rate self.folder_input_rate = 20000 # Each pulse in the epoch folder is sampled at 128 times the nominal # pulse rate self.folding = 128 # # Try to find candidate parameters for rational resampler # save_i = 0 candidates = [] for i in range(20, 300): input_rate = self.folder_input_rate output_rate = int(self.pulse_freq * i) interp = gru.lcm(input_rate, output_rate) / input_rate decim = gru.lcm(input_rate, output_rate) / output_rate if (interp < 500 and decim < 250000): candidates.append(i) # We didn't find anything, bail! if (len(candidates) < 1): print "Couldn't converge on resampler parameters" sys.exit(1) # # Now try to find candidate with the least sampling error # mindiff = 999.999 for i in candidates: diff = self.pulse_freq * i diff = diff - int(diff) if (diff < mindiff): mindiff = diff save_i = i # Recompute rates input_rate = self.folder_input_rate output_rate = int(self.pulse_freq * save_i) # Compute new interp and decim, based on best candidate interp = gru.lcm(input_rate, output_rate) / input_rate decim = gru.lcm(input_rate, output_rate) / output_rate # Save optimized folding parameters, used later self.folding = save_i self.interp = int(interp) self.decim = int(decim) # So that we can view N pulses in the pulse viewer window FOLD_MULT = self.mult # determine the daughterboard subdevice we're using self.subdev = usrp.selected_subdev(self.u, options.rx_subdev_spec) self.cardtype = self.u.daughterboard_id(0) # Compute raw input rate input_rate = self.u.adc_freq() / self.u.decim_rate() # BW==input_rate for complex data self.bw = input_rate # # Set baseband filter bandwidth if DBS_RX: # if self.cardtype == usrp_dbid.DBS_RX: lbw = input_rate / 2 if lbw < 1.0e6: lbw = 1.0e6 self.subdev.set_bw(lbw) # # We use this as a crude volume control for the audio output # #self.volume = gr.multiply_const_ff(10**(-1)) # # Create location data for ephem package # self.locality = ephem.Observer() self.locality.long = str(options.longitude) self.locality.lat = str(options.latitude) # # What is the post-detector LPF cutoff for the FFT? # PULSAR_MAX_FREQ = int(options.lowpass) # First low-pass filters down to input_rate/FIRST_FACTOR # and decimates appropriately FIRST_FACTOR = int(input_rate / (self.folder_input_rate / 2)) first_filter = gr.firdes.low_pass(1.0, input_rate, input_rate / FIRST_FACTOR, input_rate / (FIRST_FACTOR * 20), gr.firdes.WIN_HAMMING) # Second filter runs at the output rate of the first filter, # And low-pass filters down to PULSAR_MAX_FREQ*10 # second_input_rate = int(input_rate / (FIRST_FACTOR / 2)) second_filter = gr.firdes.band_pass(1.0, second_input_rate, 0.10, PULSAR_MAX_FREQ * 10, PULSAR_MAX_FREQ * 1.5, gr.firdes.WIN_HAMMING) # Third filter runs at PULSAR_MAX_FREQ*20 # and filters down to PULSAR_MAX_FREQ # third_input_rate = PULSAR_MAX_FREQ * 20 third_filter = gr.firdes_band_pass(1.0, third_input_rate, 0.10, PULSAR_MAX_FREQ, PULSAR_MAX_FREQ / 10.0, gr.firdes.WIN_HAMMING) # # Create the appropriate FFT scope # self.scope = ra_fftsink.ra_fft_sink_f(panel, fft_size=int(options.fft_size), sample_rate=PULSAR_MAX_FREQ * 2, title="Post-detector spectrum", ofunc=self.pulsarfunc, xydfunc=self.xydfunc, fft_rate=200) # # Tell scope we're looking from DC to PULSAR_MAX_FREQ # self.scope.set_baseband_freq(0.0) # # Setup stripchart for showing pulse profiles # hz = "%5.3fHz " % self.pulse_freq per = "(%5.3f sec)" % (1.0 / self.pulse_freq) sr = "%d sps" % (int(self.pulse_freq * self.folding)) times = " %d Pulse Intervals" % self.mult self.chart = ra_stripchartsink.stripchart_sink_f( panel, sample_rate=1, stripsize=self.folding * FOLD_MULT, parallel=True, title="Pulse Profiles: " + hz + per + times, xlabel="Seconds @ " + sr, ylabel="Level", autoscale=True, divbase=self.divbase, scaling=1.0 / (self.folding * self.pulse_freq)) self.chart.set_ref_level(self.reflevel) self.chart.set_y_per_div(self.division) # De-dispersion filter setup # # Do this here, just before creating the filter # that will use the taps. # ntaps = self.compute_disp_ntaps(self.dm, self.bw, self.observing_freq) # Taps for the de-dispersion filter self.disp_taps = Numeric.zeros(ntaps, Numeric.Complex64) # Compute the de-dispersion filter now self.compute_dispfilter(self.dm, self.doppler, self.bw, self.observing_freq) # # Call constructors for receive chains # # # Now create the FFT filter using the computed taps self.dispfilt = gr.fft_filter_ccc(1, self.disp_taps) # # Audio sink # #print "input_rate ", second_input_rate, "audiodev ", self.audiodev #self.audio = audio.sink(second_input_rate, self.audiodev) # # The three post-detector filters # Done this way to allow an audio path (up to 10Khz) # ...and also because going from xMhz down to ~100Hz # In a single filter doesn't seem to work. # self.first = gr.fir_filter_fff(FIRST_FACTOR / 2, first_filter) p = second_input_rate / (PULSAR_MAX_FREQ * 20) self.second = gr.fir_filter_fff(int(p), second_filter) self.third = gr.fir_filter_fff(10, third_filter) # Detector self.detector = gr.complex_to_mag_squared() self.enable_comb_filter = False # Epoch folder comb filter if self.enable_comb_filter == True: bogtaps = Numeric.zeros(512, Numeric.Float64) self.folder_comb = gr.fft_filter_ccc(1, bogtaps) # Rational resampler self.folder_rr = blks2.rational_resampler_fff(self.interp, self.decim) # Epoch folder bandpass bogtaps = Numeric.zeros(1, Numeric.Float64) self.folder_bandpass = gr.fir_filter_fff(1, bogtaps) # Epoch folder F2C/C2F self.folder_f2c = gr.float_to_complex() self.folder_c2f = gr.complex_to_float() # Epoch folder S2P self.folder_s2p = gr.serial_to_parallel(gr.sizeof_float, self.folding * FOLD_MULT) # Epoch folder IIR Filter (produces average pulse profiles) self.folder_iir = gr.single_pole_iir_filter_ff( 1.0 / options.favg, self.folding * FOLD_MULT) # # Set all the epoch-folder goop up # self.set_folding_params() # # Start connecting configured modules in the receive chain # # Connect raw USRP to de-dispersion filter, detector self.connect(self.u, self.dispfilt, self.detector) # Connect detector output to FIR LPF # in two stages, followed by the FFT scope self.connect(self.detector, self.first, self.second, self.third, self.scope) # Connect audio output #self.connect(self.first, self.volume) #self.connect(self.volume, (self.audio, 0)) #self.connect(self.volume, (self.audio, 1)) # Connect epoch folder if self.enable_comb_filter == True: self.connect(self.first, self.folder_bandpass, self.folder_rr, self.folder_f2c, self.folder_comb, self.folder_c2f, self.folder_s2p, self.folder_iir, self.chart) else: self.connect(self.first, self.folder_bandpass, self.folder_rr, self.folder_s2p, self.folder_iir, self.chart) # Connect baseband recording file (initially /dev/null) self.connect(self.u, self.tofloat, self.tochar, self.recording) # Connect pulse recording file (initially /dev/null) self.connect(self.first, self.toshort, self.pulse_recording) # # Build the GUI elements # self._build_gui(vbox) # Make GUI agree with command-line self.myform['average'].set_value(int(options.avg)) self.myform['foldavg'].set_value(int(options.favg)) # Make spectral averager agree with command line if options.avg != 1.0: self.scope.set_avg_alpha(float(1.0 / options.avg)) self.scope.set_average(True) # set initial values if options.gain is None: # if no gain was specified, use the mid-point in dB g = self.subdev.gain_range() options.gain = float(g[0] + g[1]) / 2 if options.freq is None: # if no freq was specified, use the mid-point r = self.subdev.freq_range() options.freq = float(r[0] + r[1]) / 2 self.set_gain(options.gain) #self.set_volume(-10.0) if not (self.set_freq(options.freq)): self._set_status_msg("Failed to set initial frequency") self.myform['decim'].set_value(self.u.decim_rate()) self.myform['fs@usb'].set_value(self.u.adc_freq() / self.u.decim_rate()) self.myform['dbname'].set_value(self.subdev.name()) self.myform['DM'].set_value(self.dm) self.myform['Doppler'].set_value(self.doppler) # # Start the timer that shows current LMST on the GUI # self.lmst_timer.Start(1000)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="rtl-sdr") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.xlate_tune = xlate_tune = 0 self.samp_rate = samp_rate = 1024000 self.noxon_central_freq = noxon_central_freq = 103e6 self.rx_freq = rx_freq = noxon_central_freq+xlate_tune self.filter_taps = filter_taps = firdes.low_pass(1,samp_rate,100e3,1e3) self.af_gain = af_gain = 3 ################################################## # Blocks ################################################## _xlate_tune_sizer = wx.BoxSizer(wx.VERTICAL) self._xlate_tune_text_box = forms.text_box( parent=self.GetWin(), sizer=_xlate_tune_sizer, value=self.xlate_tune, callback=self.set_xlate_tune, label="xlate tune", converter=forms.float_converter(), proportion=0, ) self._xlate_tune_slider = forms.slider( parent=self.GetWin(), sizer=_xlate_tune_sizer, value=self.xlate_tune, callback=self.set_xlate_tune, minimum=-500e3, maximum=+500e3, num_steps=500, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_xlate_tune_sizer, 0, 0, 1, 1) self._noxon_central_freq_static_text = forms.static_text( parent=self.GetWin(), value=self.noxon_central_freq, callback=self.set_noxon_central_freq, label="Noxon central frequency ", converter=forms.float_converter(), ) self.GridAdd(self._noxon_central_freq_static_text, 1, 0, 1, 1) _af_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._af_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_af_gain_sizer, value=self.af_gain, callback=self.set_af_gain, label="AF gain", converter=forms.float_converter(), proportion=0, ) self._af_gain_slider = forms.slider( parent=self.GetWin(), sizer=_af_gain_sizer, value=self.af_gain, callback=self.set_af_gain, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_af_gain_sizer, 0, 2, 1, 1) self.xlating_fir_filter = gr.freq_xlating_fir_filter_ccc(4, (filter_taps), -xlate_tune, samp_rate) self.wfm_rcv = blks2.wfm_rcv( quad_rate=samp_rate/4, audio_decimation=5, ) self._rx_freq_static_text = forms.static_text( parent=self.GetWin(), value=self.rx_freq, callback=self.set_rx_freq, label="rx frequency ", converter=forms.float_converter(), ) self.GridAdd(self._rx_freq_static_text, 1, 3, 1, 1) self.rtl2832_source_0 = baz.rtl_source_c(defer_creation=True) self.rtl2832_source_0.set_verbose(True) self.rtl2832_source_0.set_vid(0x0) self.rtl2832_source_0.set_pid(0x0) self.rtl2832_source_0.set_tuner_name("") self.rtl2832_source_0.set_default_timeout(0) self.rtl2832_source_0.set_use_buffer(True) self.rtl2832_source_0.set_fir_coefficients(([])) if self.rtl2832_source_0.create() == False: raise Exception("Failed to create RTL2832 Source: rtl2832_source_0") self.rtl2832_source_0.set_sample_rate(samp_rate) self.rtl2832_source_0.set_frequency(102722000) self.rtl2832_source_0.set_auto_gain_mode(False) self.rtl2832_source_0.set_relative_gain(True) self.rtl2832_source_0.set_gain(3) self.rr_stereo_right = blks2.rational_resampler_fff( interpolation=48, decimation=50, taps=None, fractional_bw=None, ) self.fftsink_rf_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=noxon_central_freq, y_per_div=5, y_divs=10, ref_level=0, ref_scale=.5, sample_rate=samp_rate, fft_size=1024, fft_rate=10, average=True, avg_alpha=0.25, title="Total bandwidth", peak_hold=False, win=window.blackmanharris, size=(800,200), ) self.Add(self.fftsink_rf_0.win) self.fftsink_rf = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=5, y_divs=10, ref_level=0, ref_scale=.5, sample_rate=samp_rate/4, fft_size=1024, fft_rate=10, average=True, avg_alpha=0.25, title="Baseband", peak_hold=False, size=(800,200), ) self.Add(self.fftsink_rf.win) self.audio_sink = audio.sink(48000, "pulse", True) self.af_gain_stereo_left = gr.multiply_const_vff((af_gain, )) ################################################## # Connections ################################################## self.connect((self.xlating_fir_filter, 0), (self.fftsink_rf, 0)) self.connect((self.af_gain_stereo_left, 0), (self.audio_sink, 0)) self.connect((self.wfm_rcv, 0), (self.rr_stereo_right, 0)) self.connect((self.xlating_fir_filter, 0), (self.wfm_rcv, 0)) self.connect((self.rr_stereo_right, 0), (self.af_gain_stereo_left, 0)) self.connect((self.af_gain_stereo_left, 0), (self.audio_sink, 1)) self.connect((self.xlating_fir_filter, 0), (self.fftsink_rf_0, 0)) self.connect((self.rtl2832_source_0, 0), (self.xlating_fir_filter, 0))
def __init__(self, options, queue): gr.top_block.__init__(self, "mhp") self.audio_amps = [] self.converters = [] self.vocoders = [] self.filters = [] self.c4fm = [] self.output_gain = [] input_audio_rate = 8000 output_audio_rate = 48000 c4fm_rate = 96000 if not options.input_files: self.audio_input = audio.source(input_audio_rate, options.audio_input) self.audio_output = audio.sink(output_audio_rate, options.audio_output) for i in range(options.nchannels): if options.input_files: t = gr.file_source(gr.sizeof_char, "baseband-%d.dat" % i, options.repeat) self.vocoders.append(t) else: t = gr.multiply_const_ff(32767 * options.audio_gain) self.audio_amps.append(t) t = gr.float_to_short() self.converters.append(t) t = repeater.vocoder( True, # 0=Decode,True=Encode options.verbose, # Verbose flag options.stretch, # flex amount "", # udp ip address 0, # udp port False) # dump raw u vectors self.vocoders.append(t) t = op25_c4fm_mod.p25_mod(output_sample_rate=c4fm_rate, log=False, verbose=True) self.c4fm.append(t) # FIXME: it would seem as if direct output at 48000 would be the # obvious way to go, but for unknown reasons, it produces hideous # distortion in the output waveform. For the same unknown # reasons, it's clean if we output at 96000 and then decimate # back down to 48k... t = blks2.rational_resampler_fff(1, 2) # 96000 -> 48000 self.filters.append(t) t = gr.multiply_const_ff(options.output_gain) self.output_gain.append(t) for i in range(options.nchannels): if not options.input_files: self.connect(self.audio_amps[i], self.converters[i], self.vocoders[i]) self.connect(self.vocoders[i], self.c4fm[i], self.filters[i], self.output_gain[i]) if options.nchannels == 1: if not options.input_files: self.connect(self.audio_input, self.audio_amps[0]) self.connect(self.output_gain[0], self.audio_output) else: for i in range(options.nchannels): if not options.input_files: self.connect((self.audio_input, i), self.audio_amps[i]) self.connect(self.output_gain[i], (self.audio_output, i))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Ettus Fm") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 5e6 self.freq = freq = 93.5e6 ################################################## # 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 Spectrum") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Spectrum") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Audio") self.Add(self.notebook_0) 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) self.wxgui_fftsink2_2 = fftsink2.fft_sink_f( self.notebook_0.GetPage(2).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=48e3, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(2).Add(self.wxgui_fftsink2_2.win) self.wxgui_fftsink2_1 = fftsink2.fft_sink_f( self.notebook_0.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=250e3, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0.win) 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(freq, 0) self.uhd_usrp_source_0.set_gain(25, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.uhd_usrp_source_0.set_bandwidth(200e3, 0) self.low_pass_filter_0 = gr.fir_filter_ccf( 20, firdes.low_pass(1, samp_rate, 100e3, 10e3, firdes.WIN_HAMMING, 6.76)) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((5, )) self.blks2_wfm_rcv_0 = blks2.wfm_rcv( quad_rate=250e3, audio_decimation=1, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=48, decimation=250, taps=None, fractional_bw=None, ) self.audio_sink_0 = audio.sink(48000, "", True) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blks2_wfm_rcv_0, 0)) self.connect((self.blks2_wfm_rcv_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_wfm_rcv_0, 0), (self.wxgui_fftsink2_1, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.wxgui_fftsink2_2, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Dsd Grc") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self._config_freq_config = ConfigParser.ConfigParser() self._config_freq_config.read(".grc_op25") try: config_freq = self._config_freq_config.getfloat("main", "freq") except: config_freq = 489900000 self.config_freq = config_freq self.freq = freq = config_freq self._config_xlate_offset_config = ConfigParser.ConfigParser() self._config_xlate_offset_config.read(".grc_op25") try: config_xlate_offset = self._config_xlate_offset_config.getfloat("main", "xlate_offset") except: config_xlate_offset = 0 self.config_xlate_offset = config_xlate_offset self.click_freq = click_freq = freq-config_xlate_offset self.xlate_offset_fine = xlate_offset_fine = 0 self.xlate_offset = xlate_offset = freq-click_freq self.samp_rate = samp_rate = 1000000 self.samp_per_sym = samp_per_sym = 10 self.decim = decim = 20 self._config_xlate_bandwidth_config = ConfigParser.ConfigParser() self._config_xlate_bandwidth_config.read(".grc_op25") try: config_xlate_bandwidth = self._config_xlate_bandwidth_config.getfloat("main", "xlate_bandwidth") except: config_xlate_bandwidth = 24000 self.config_xlate_bandwidth = config_xlate_bandwidth self.auto_tune_offset = auto_tune_offset = 0 self.xlate_bandwidth = xlate_bandwidth = config_xlate_bandwidth self.variable_static_text_0 = variable_static_text_0 = freq+xlate_offset+xlate_offset_fine+auto_tune_offset self.squelch = squelch = -65 self.pre_channel_rate = pre_channel_rate = samp_rate/decim self.gain = gain = 25 self.fine_click_freq = fine_click_freq = 0 self.channel_rate = channel_rate = 4800*samp_per_sym self.audio_mul = audio_mul = 0 ################################################## # Blocks ################################################## _xlate_offset_fine_sizer = wx.BoxSizer(wx.VERTICAL) self._xlate_offset_fine_text_box = forms.text_box( parent=self.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.GetWin(), sizer=_xlate_offset_fine_sizer, value=self.xlate_offset_fine, callback=self.set_xlate_offset_fine, minimum=-10000, maximum=10000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_xlate_offset_fine_sizer) self._xlate_offset_text_box = forms.text_box( parent=self.GetWin(), value=self.xlate_offset, callback=self.set_xlate_offset, label="Xlate Offset", converter=forms.float_converter(), ) self.Add(self._xlate_offset_text_box) _xlate_bandwidth_sizer = wx.BoxSizer(wx.VERTICAL) self._xlate_bandwidth_text_box = forms.text_box( parent=self.GetWin(), sizer=_xlate_bandwidth_sizer, value=self.xlate_bandwidth, callback=self.set_xlate_bandwidth, label="Xlate BW", converter=forms.float_converter(), proportion=0, ) self._xlate_bandwidth_slider = forms.slider( parent=self.GetWin(), sizer=_xlate_bandwidth_sizer, value=self.xlate_bandwidth, callback=self.set_xlate_bandwidth, minimum=5000, maximum=50000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_xlate_bandwidth_sizer) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB-1") self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB-2") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Xlate-1") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Xlate-2") self.nb.AddPage(grc_wxgui.Panel(self.nb), "4FSK") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Dibits") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Traffic") 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="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=100, 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) _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 mul", 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=-30, maximum=10, num_steps=40, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_audio_mul_sizer) self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(3).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=50, ref_scale=2.0, sample_rate=channel_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.nb.GetPage(3).Add(self.wxgui_waterfallsink2_0_0.win) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(1).GetWin(), baseband_freq=freq, dynamic_range=100, ref_level=50, ref_scale=2.0, sample_rate=samp_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_1 = scopesink2.scope_sink_f( self.nb.GetPage(4).GetWin(), title="Scope Plot", sample_rate=channel_rate, v_scale=1.5, v_offset=0, t_scale=0.05, 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_1.win) self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c( self.nb.GetPage(2).GetWin(), baseband_freq=fine_click_freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=channel_rate, fft_size=1024, fft_rate=30, average=True, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.nb.GetPage(2).Add(self.wxgui_fftsink2_0_0.win) def wxgui_fftsink2_0_0_callback(x, y): self.set_fine_click_freq(x) self.wxgui_fftsink2_0_0.set_callback(wxgui_fftsink2_0_0_callback) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=30, average=True, avg_alpha=None, 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_click_freq(x) self.wxgui_fftsink2_0.set_callback(wxgui_fftsink2_0_callback) self._variable_static_text_0_static_text = forms.static_text( parent=self.GetWin(), value=self.variable_static_text_0, callback=self.set_variable_static_text_0, label="Final freq", converter=forms.float_converter(), ) self.Add(self._variable_static_text_0_static_text) _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=-100, maximum=100, num_steps=40, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_squelch_sizer) self.osmosdr_source_c_0 = osmosdr.source_c( args="nchan=" + str(1) + " " + "hackrf=0" ) self.osmosdr_source_c_0.set_sample_rate(samp_rate) self.osmosdr_source_c_0.set_center_freq(freq, 0) self.osmosdr_source_c_0.set_freq_corr(0, 0) self.osmosdr_source_c_0.set_dc_offset_mode(0, 0) self.osmosdr_source_c_0.set_iq_balance_mode(0, 0) self.osmosdr_source_c_0.set_gain_mode(0, 0) self.osmosdr_source_c_0.set_gain(14, 0) self.osmosdr_source_c_0.set_if_gain(gain, 0) self.osmosdr_source_c_0.set_bb_gain(gain, 0) self.osmosdr_source_c_0.set_antenna("", 0) self.osmosdr_source_c_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 6000)), xlate_offset+xlate_offset_fine-fine_click_freq, samp_rate) self.fir_filter_xxx_0 = filter.fir_filter_fff(1, ((1.0/samp_per_sym,)*samp_per_sym)) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_P25_PHASE_1,dsd.dsd_MOD_C4FM,3,3,True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10.**(audio_mul/10.), )) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_ccc( interpolation=channel_rate, decimation=pre_channel_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=44100, decimation=8000, taps=None, fractional_bw=None, ) self.audio_sink_0 = audio.sink(44100, "", True) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1.6) ################################################## # Connections ################################################## self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.wxgui_waterfallsink2_0_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.osmosdr_source_c_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.osmosdr_source_c_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.dsd_block_ff_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.dsd_block_ff_0, 0)) self.connect((self.osmosdr_source_c_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.analog_quadrature_demod_cf_0, 0))
def __init__(self, frame, panel, vbox, argv): stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) self.frame = frame self.panel = panel parser = OptionParser(option_class=eng_option) parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=(0, 0), help="select USRP Rx side A or B (default=A)") parser.add_option("-d", "--decim", type="int", default=16, help="set fgpa decimation rate to DECIM [default=%default]") parser.add_option("-f", "--freq", type="eng_float", default=None, help="set frequency to FREQ", metavar="FREQ") parser.add_option("-Q", "--observing", type="eng_float", default=0.0, help="set observing frequency to FREQ") parser.add_option("-a", "--avg", type="eng_float", default=1.0, help="set spectral averaging alpha") parser.add_option("-V", "--favg", type="eng_float", default=2.0, help="set folder averaging alpha") parser.add_option("-g", "--gain", type="eng_float", default=None, help="set gain in dB (default is midpoint)") parser.add_option("-l", "--reflevel", type="eng_float", default=30.0, help="Set pulse display reference level") parser.add_option("-L", "--lowest", type="eng_float", default=1.5, help="Lowest valid frequency bin") parser.add_option("-e", "--longitude", type="eng_float", default=-76.02, help="Set Observer Longitude") parser.add_option("-c", "--latitude", type="eng_float", default=44.85, help="Set Observer Latitude") parser.add_option("-F", "--fft_size", type="eng_float", default=1024, help="Size of FFT") parser.add_option ("-t", "--threshold", type="eng_float", default=2.5, help="pulsar threshold") parser.add_option("-p", "--lowpass", type="eng_float", default=100, help="Pulse spectra cutoff freq") parser.add_option("-P", "--prefix", default="./", help="File prefix") parser.add_option("-u", "--pulsefreq", type="eng_float", default=0.748, help="Observation pulse rate") parser.add_option("-D", "--dm", type="eng_float", default=1.0e-5, help="Dispersion Measure") parser.add_option("-O", "--doppler", type="eng_float", default=1.0, help="Doppler ratio") parser.add_option("-B", "--divbase", type="eng_float", default=20, help="Y/Div menu base") parser.add_option("-I", "--division", type="eng_float", default=100, help="Y/Div") parser.add_option("-A", "--audio_source", default="plughw:0,0", help="Audio input device spec") parser.add_option("-N", "--num_pulses", default=1, type="eng_float", help="Number of display pulses") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.show_debug_info = True self.reflevel = options.reflevel self.divbase = options.divbase self.division = options.division self.audiodev = options.audio_source self.mult = int(options.num_pulses) # Low-pass cutoff for post-detector filter # Set to 100Hz usually, since lots of pulsars fit in this # range self.lowpass = options.lowpass # What is lowest valid frequency bin in post-detector FFT? # There's some pollution very close to DC self.lowest_freq = options.lowest # What (dB) threshold to use in determining spectral candidates self.threshold = options.threshold # Filename prefix for recording file self.prefix = options.prefix # Dispersion Measure (DM) self.dm = options.dm # Doppler shift, as a ratio # 1.0 == no doppler shift # 1.005 == a little negative shift # 0.995 == a little positive shift self.doppler = options.doppler # # Input frequency and observing frequency--not necessarily the # same thing, if we're looking at the IF of some downconverter # that's ahead of the USRP and daughtercard. This distinction # is important in computing the correct de-dispersion filter. # self.frequency = options.freq if options.observing <= 0: self.observing_freq = options.freq else: self.observing_freq = options.observing # build the graph self.u = usrp.source_c(decim_rate=options.decim) self.u.set_mux(usrp.determine_rx_mux_value(self.u, options.rx_subdev_spec)) # # Recording file, in case we ever need to record baseband data # self.recording = gr.file_sink(gr.sizeof_char, "/dev/null") self.recording_state = False self.pulse_recording = gr.file_sink(gr.sizeof_short, "/dev/null") self.pulse_recording_state = False # # We come up with recording turned off, but the user may # request recording later on self.recording.close() self.pulse_recording.close() # # Need these two for converting 12-bit baseband signals to 8-bit # self.tofloat = gr.complex_to_float() self.tochar = gr.float_to_char() # Need this for recording pulses (post-detector) self.toshort = gr.float_to_short() # # The spectral measurer sets this when it has a valid # average spectral peak-to-peak distance # We can then use this to program the parameters for the epoch folder # # We set a sentimental value here self.pulse_freq = options.pulsefreq # Folder runs at this raw sample rate self.folder_input_rate = 20000 # Each pulse in the epoch folder is sampled at 128 times the nominal # pulse rate self.folding = 128 # # Try to find candidate parameters for rational resampler # save_i = 0 candidates = [] for i in range(20,300): input_rate = self.folder_input_rate output_rate = int(self.pulse_freq * i) interp = gru.lcm(input_rate, output_rate) / input_rate decim = gru.lcm(input_rate, output_rate) / output_rate if (interp < 500 and decim < 250000): candidates.append(i) # We didn't find anything, bail! if (len(candidates) < 1): print "Couldn't converge on resampler parameters" sys.exit(1) # # Now try to find candidate with the least sampling error # mindiff = 999.999 for i in candidates: diff = self.pulse_freq * i diff = diff - int(diff) if (diff < mindiff): mindiff = diff save_i = i # Recompute rates input_rate = self.folder_input_rate output_rate = int(self.pulse_freq * save_i) # Compute new interp and decim, based on best candidate interp = gru.lcm(input_rate, output_rate) / input_rate decim = gru.lcm(input_rate, output_rate) / output_rate # Save optimized folding parameters, used later self.folding = save_i self.interp = int(interp) self.decim = int(decim) # So that we can view N pulses in the pulse viewer window FOLD_MULT=self.mult # determine the daughterboard subdevice we're using self.subdev = usrp.selected_subdev(self.u, options.rx_subdev_spec) self.cardtype = self.u.daughterboard_id(0) # Compute raw input rate input_rate = self.u.adc_freq() / self.u.decim_rate() # BW==input_rate for complex data self.bw = input_rate # # Set baseband filter bandwidth if DBS_RX: # if self.cardtype == usrp_dbid.DBS_RX: lbw = input_rate / 2 if lbw < 1.0e6: lbw = 1.0e6 self.subdev.set_bw(lbw) # # We use this as a crude volume control for the audio output # #self.volume = gr.multiply_const_ff(10**(-1)) # # Create location data for ephem package # self.locality = ephem.Observer() self.locality.long = str(options.longitude) self.locality.lat = str(options.latitude) # # What is the post-detector LPF cutoff for the FFT? # PULSAR_MAX_FREQ=int(options.lowpass) # First low-pass filters down to input_rate/FIRST_FACTOR # and decimates appropriately FIRST_FACTOR=int(input_rate/(self.folder_input_rate/2)) first_filter = gr.firdes.low_pass (1.0, input_rate, input_rate/FIRST_FACTOR, input_rate/(FIRST_FACTOR*20), gr.firdes.WIN_HAMMING) # Second filter runs at the output rate of the first filter, # And low-pass filters down to PULSAR_MAX_FREQ*10 # second_input_rate = int(input_rate/(FIRST_FACTOR/2)) second_filter = gr.firdes.band_pass(1.0, second_input_rate, 0.10, PULSAR_MAX_FREQ*10, PULSAR_MAX_FREQ*1.5, gr.firdes.WIN_HAMMING) # Third filter runs at PULSAR_MAX_FREQ*20 # and filters down to PULSAR_MAX_FREQ # third_input_rate = PULSAR_MAX_FREQ*20 third_filter = gr.firdes_band_pass(1.0, third_input_rate, 0.10, PULSAR_MAX_FREQ, PULSAR_MAX_FREQ/10.0, gr.firdes.WIN_HAMMING) # # Create the appropriate FFT scope # self.scope = ra_fftsink.ra_fft_sink_f (panel, fft_size=int(options.fft_size), sample_rate=PULSAR_MAX_FREQ*2, title="Post-detector spectrum", ofunc=self.pulsarfunc, xydfunc=self.xydfunc, fft_rate=200) # # Tell scope we're looking from DC to PULSAR_MAX_FREQ # self.scope.set_baseband_freq (0.0) # # Setup stripchart for showing pulse profiles # hz = "%5.3fHz " % self.pulse_freq per = "(%5.3f sec)" % (1.0/self.pulse_freq) sr = "%d sps" % (int(self.pulse_freq*self.folding)) times = " %d Pulse Intervals" % self.mult self.chart = ra_stripchartsink.stripchart_sink_f (panel, sample_rate=1, stripsize=self.folding*FOLD_MULT, parallel=True, title="Pulse Profiles: "+hz+per+times, xlabel="Seconds @ "+sr, ylabel="Level", autoscale=True, divbase=self.divbase, scaling=1.0/(self.folding*self.pulse_freq)) self.chart.set_ref_level(self.reflevel) self.chart.set_y_per_div(self.division) # De-dispersion filter setup # # Do this here, just before creating the filter # that will use the taps. # ntaps = self.compute_disp_ntaps(self.dm,self.bw,self.observing_freq) # Taps for the de-dispersion filter self.disp_taps = Numeric.zeros(ntaps,Numeric.Complex64) # Compute the de-dispersion filter now self.compute_dispfilter(self.dm,self.doppler, self.bw,self.observing_freq) # # Call constructors for receive chains # # # Now create the FFT filter using the computed taps self.dispfilt = gr.fft_filter_ccc(1, self.disp_taps) # # Audio sink # #print "input_rate ", second_input_rate, "audiodev ", self.audiodev #self.audio = audio.sink(second_input_rate, self.audiodev) # # The three post-detector filters # Done this way to allow an audio path (up to 10Khz) # ...and also because going from xMhz down to ~100Hz # In a single filter doesn't seem to work. # self.first = gr.fir_filter_fff (FIRST_FACTOR/2, first_filter) p = second_input_rate / (PULSAR_MAX_FREQ*20) self.second = gr.fir_filter_fff (int(p), second_filter) self.third = gr.fir_filter_fff (10, third_filter) # Detector self.detector = gr.complex_to_mag_squared() self.enable_comb_filter = False # Epoch folder comb filter if self.enable_comb_filter == True: bogtaps = Numeric.zeros(512, Numeric.Float64) self.folder_comb = gr.fft_filter_ccc(1,bogtaps) # Rational resampler self.folder_rr = blks2.rational_resampler_fff(self.interp, self.decim) # Epoch folder bandpass bogtaps = Numeric.zeros(1, Numeric.Float64) self.folder_bandpass = gr.fir_filter_fff (1, bogtaps) # Epoch folder F2C/C2F self.folder_f2c = gr.float_to_complex() self.folder_c2f = gr.complex_to_float() # Epoch folder S2P self.folder_s2p = gr.serial_to_parallel (gr.sizeof_float, self.folding*FOLD_MULT) # Epoch folder IIR Filter (produces average pulse profiles) self.folder_iir = gr.single_pole_iir_filter_ff(1.0/options.favg, self.folding*FOLD_MULT) # # Set all the epoch-folder goop up # self.set_folding_params() # # Start connecting configured modules in the receive chain # # Connect raw USRP to de-dispersion filter, detector self.connect(self.u, self.dispfilt, self.detector) # Connect detector output to FIR LPF # in two stages, followed by the FFT scope self.connect(self.detector, self.first, self.second, self.third, self.scope) # Connect audio output #self.connect(self.first, self.volume) #self.connect(self.volume, (self.audio, 0)) #self.connect(self.volume, (self.audio, 1)) # Connect epoch folder if self.enable_comb_filter == True: self.connect (self.first, self.folder_bandpass, self.folder_rr, self.folder_f2c, self.folder_comb, self.folder_c2f, self.folder_s2p, self.folder_iir, self.chart) else: self.connect (self.first, self.folder_bandpass, self.folder_rr, self.folder_s2p, self.folder_iir, self.chart) # Connect baseband recording file (initially /dev/null) self.connect(self.u, self.tofloat, self.tochar, self.recording) # Connect pulse recording file (initially /dev/null) self.connect(self.first, self.toshort, self.pulse_recording) # # Build the GUI elements # self._build_gui(vbox) # Make GUI agree with command-line self.myform['average'].set_value(int(options.avg)) self.myform['foldavg'].set_value(int(options.favg)) # Make spectral averager agree with command line if options.avg != 1.0: self.scope.set_avg_alpha(float(1.0/options.avg)) self.scope.set_average(True) # set initial values if options.gain is None: # if no gain was specified, use the mid-point in dB g = self.subdev.gain_range() options.gain = float(g[0]+g[1])/2 if options.freq is None: # if no freq was specified, use the mid-point r = self.subdev.freq_range() options.freq = float(r[0]+r[1])/2 self.set_gain(options.gain) #self.set_volume(-10.0) if not(self.set_freq(options.freq)): self._set_status_msg("Failed to set initial frequency") self.myform['decim'].set_value(self.u.decim_rate()) self.myform['fs@usb'].set_value(self.u.adc_freq() / self.u.decim_rate()) self.myform['dbname'].set_value(self.subdev.name()) self.myform['DM'].set_value(self.dm) self.myform['Doppler'].set_value(self.doppler) # # Start the timer that shows current LMST on the GUI # self.lmst_timer.Start(1000)