def __init__(self, uhd_address, options): gr.top_block.__init__(self) self.uhd_addr = uhd_address self.freq = options.freq self.samp_rate = options.samp_rate self.gain = options.gain self.threshold = options.threshold self.trigger = options.trigger self.uhd_src = uhd.single_usrp_source( device_addr=self.uhd_addr, stream_args=uhd.stream_args('fc32')) self.uhd_src.set_samp_rate(self.samp_rate) self.uhd_src.set_center_freq(self.freq, 0) self.uhd_src.set_gain(self.gain, 0) taps = firdes.low_pass_2(1, 1, 0.4, 0.1, 60) self.chanfilt = gr.fir_filter_ccc(10, taps) self.tagger = gr.burst_tagger(gr.sizeof_gr_complex) # Dummy signaler to collect a burst on known periods data = 1000 * [ 0, ] + 1000 * [ 1, ] self.signal = gr.vector_source_s(data, True) # Energy detector to get signal burst ## use squelch to detect energy self.det = gr.simple_squelch_cc(self.threshold, 0.01) ## convert to mag squared (float) self.c2m = gr.complex_to_mag_squared() ## average to debounce self.avg = gr.single_pole_iir_filter_ff(0.01) ## rescale signal for conversion to short self.scale = gr.multiply_const_ff(2**16) ## signal input uses shorts self.f2s = gr.float_to_short() # Use file sink burst tagger to capture bursts self.fsnk = gr.tagged_file_sink(gr.sizeof_gr_complex, self.samp_rate) ################################################## # Connections ################################################## self.connect((self.uhd_src, 0), (self.tagger, 0)) self.connect((self.tagger, 0), (self.fsnk, 0)) if self.trigger: # Connect a dummy signaler to the burst tagger self.connect((self.signal, 0), (self.tagger, 1)) else: # Connect an energy detector signaler to the burst tagger self.connect(self.uhd_src, self.det) self.connect(self.det, self.c2m, self.avg, self.scale, self.f2s) self.connect(self.f2s, (self.tagger, 1))
def __init__(self, uhd_address, options): gr.top_block.__init__(self) self.uhd_addr = uhd_address self.freq = options.freq self.samp_rate = options.samp_rate self.gain = options.gain self.threshold = options.threshold self.trigger = options.trigger self.uhd_src = uhd.single_usrp_source( device_addr=self.uhd_addr, io_type=uhd.io_type_t.COMPLEX_FLOAT32, num_channels=1, ) self.uhd_src.set_samp_rate(self.samp_rate) self.uhd_src.set_center_freq(self.freq, 0) self.uhd_src.set_gain(self.gain, 0) taps = firdes.low_pass_2(1, 1, 0.4, 0.1, 60) self.chanfilt = gr.fir_filter_ccc(10, taps) self.tagger = gr.burst_tagger(gr.sizeof_gr_complex) # Dummy signaler to collect a burst on known periods data = 1000*[0,] + 1000*[1,] self.signal = gr.vector_source_s(data, True) # Energy detector to get signal burst ## use squelch to detect energy self.det = gr.simple_squelch_cc(self.threshold, 0.01) ## convert to mag squared (float) self.c2m = gr.complex_to_mag_squared() ## average to debounce self.avg = gr.single_pole_iir_filter_ff(0.01) ## rescale signal for conversion to short self.scale = gr.multiply_const_ff(2**16) ## signal input uses shorts self.f2s = gr.float_to_short() # Use file sink burst tagger to capture bursts self.fsnk = gr.tagged_file_sink(gr.sizeof_gr_complex, self.samp_rate) ################################################## # Connections ################################################## self.connect((self.uhd_src, 0), (self.tagger, 0)) self.connect((self.tagger, 0), (self.fsnk, 0)) if self.trigger: # Connect a dummy signaler to the burst tagger self.connect((self.signal, 0), (self.tagger, 1)) else: # Connect an energy detector signaler to the burst tagger self.connect(self.uhd_src, self.det) self.connect(self.det, self.c2m, self.avg, self.scale, self.f2s) self.connect(self.f2s, (self.tagger, 1))
def _setup_top_block(self): self.tb = gr.top_block() samp_rate = 96000 oversample = 10 center_freq = 868.280e6 # Radio receiver, initial downsampling args = str("nchan=1 rtl=%s,buffers=16,offset_tune=1" % self.device) osmosdr_source = osmosdr.source_c(args=args) osmosdr_source.set_sample_rate(samp_rate*oversample) osmosdr_source.set_center_freq(center_freq, 0) osmosdr_source.set_freq_corr(0, 0) osmosdr_source.set_gain_mode(1, 0) osmosdr_source.set_gain(0, 0) low_pass_filter = gr.fir_filter_ccf(oversample, firdes.low_pass(1, samp_rate*oversample, 90e3, 8e3, firdes.WIN_HAMMING, 6.76)) self.tb.connect((osmosdr_source, 0), (low_pass_filter, 0)) # Squelch self.noise_probe = gr.probe_avg_mag_sqrd_c(0, 1.0/samp_rate/1e2) self.squelch = gr.simple_squelch_cc(self.noise_level, 1) noise_probe_thread = threading.Thread(target=self._noise_probe_thread) noise_probe_thread.start() self.threads.append(noise_probe_thread) self.tb.connect((low_pass_filter, 0), (self.noise_probe, 0)) self.tb.connect((low_pass_filter, 0), (self.squelch, 0)) # FM demodulation quadrature_demod = gr.quadrature_demod_cf(1) self.tb.connect((self.squelch, 0), (quadrature_demod, 0)) # Binary slicing, transformation into capture-compatible format add_offset = gr.add_const_vff((-1e-3, )) binary_slicer = digital.binary_slicer_fb() char_to_float = gr.char_to_float(1, 1) multiply_const = gr.multiply_const_vff((255, )) float_to_uchar = gr.float_to_uchar() pipe_sink = gr.file_sink(gr.sizeof_char*1, self.pipe) pipe_sink.set_unbuffered(False) self.tb.connect((quadrature_demod, 0), (add_offset, 0)) self.tb.connect((add_offset, 0), (binary_slicer, 0)) self.tb.connect((binary_slicer, 0), (char_to_float, 0)) self.tb.connect((char_to_float, 0), (multiply_const, 0)) self.tb.connect((multiply_const, 0), (float_to_uchar, 0)) self.tb.connect((float_to_uchar, 0), (pipe_sink, 0))
def __init__(self): 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, "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 ################################################## # 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) ################################################## # 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))
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 ################################################## # 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) ################################################## # 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))
def __init__(self, args, spec, antenna, gain, audio_output): gr.hier_block2.__init__(self, "receive_path", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(0, 0, 0)) # Output signature self.u = uhd.usrp_source(device_addr=args, io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1) self.if_rate = 256e3 self.quad_rate = 64e3 self.audio_rate = 32e3 self.u.set_samp_rate(self.if_rate) dev_rate = self.u.get_samp_rate() # Create filter to get actual channel we want nfilts = 32 chan_coeffs = gr.firdes.low_pass (nfilts, # gain nfilts*dev_rate, # sampling rate 8e3, # low pass cutoff freq 2e3, # width of trans. band gr.firdes.WIN_HANN) # filter type rrate = self.quad_rate / dev_rate self.resamp = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) if USE_SIMPLE_SQUELCH: self.squelch = gr.simple_squelch_cc(20) else: self.squelch = blks2.standard_squelch(self.audio_rate) # instantiate the guts of the single channel receiver self.fmrx = blks2.nbfm_rx(self.audio_rate, self.quad_rate) # audio gain / mute block self._audio_gain = gr.multiply_const_ff(1.0) # sound card as final sink audio_sink = audio.sink (int(self.audio_rate), audio_output) # now wire it all together if USE_SIMPLE_SQUELCH: self.connect (self.u, self.resamp, self.squelch, self.fmrx, self._audio_gain, audio_sink) else: self.connect (self.u, self.resamp, self.fmrx, self.squelch, self._audio_gain, audio_sink) if gain is None: # if no gain was specified, use the mid-point in dB g = self.u.get_gain_range() gain = float(g.start()+g.stop())/2 self.set_gain(gain) v = self.volume_range() self.set_volume((v[0]+v[1])/2) s = self.squelch_range() self.set_squelch((s[0]+s[1])/2) # Set the subdevice spec if(spec): self.u.set_subdev_spec(spec, 0) # Set the antenna if(antenna): self.u.set_antenna(antenna, 0)
def __init__(self, demod_class, rx_callback, options): gr.hier_block2.__init__(self, "receive_path", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(0, 0, 0)) # Output signature options = copy.copy(options) # make a copy so we can destructively modify self._verbose = options.verbose self._rx_freq = options.rx_freq # receiver's center frequency self._rx_gain = options.rx_gain # receiver's gain self._rx_subdev_spec = options.rx_subdev_spec # daughterboard to use self._bitrate = options.bitrate # desired bit rate self._decim = options.decim # Decimating rate for the USRP (prelim) self._samples_per_symbol = options.samples_per_symbol # desired samples/symbol self._fusb_block_size = options.fusb_block_size # usb info for USRP self._fusb_nblocks = options.fusb_nblocks # usb info for USRP self._rx_callback = rx_callback # this callback is fired when there's a packet available self._demod_class = demod_class # the demodulator_class we're using if self._rx_freq is None: sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n") raise SystemExit # Set up USRP source; also adjusts decim, samples_per_symbol, and bitrate self._setup_usrp_source() g = self.subdev.gain_range() if options.show_rx_gain_range: print "Rx Gain Range: minimum = %g, maximum = %g, step size = %g" \ % (g[0], g[1], g[2]) self.set_gain(options.rx_gain) self.set_auto_tr(True) # enable Auto Transmit/Receive switching # Set RF frequency ok = self.set_freq(self._rx_freq) if not ok: print "Failed to set Rx frequency to %s" % (eng_notation.num_to_str(self._rx_freq)) raise ValueError, eng_notation.num_to_str(self._rx_freq) # copy the final answers back into options for use by demodulator options.samples_per_symbol = self._samples_per_symbol options.bitrate = self._bitrate options.decim = self._decim # Get demod_kwargs demod_kwargs = self._demod_class.extract_kwargs_from_options(options) # Design filter to get actual channel we want sw_decim = 1 chan_coeffs = gr.firdes.low_pass (1.0, # gain sw_decim * self._samples_per_symbol, # sampling rate 1.0, # midpoint of trans. band 0.5, # width of trans. band gr.firdes.WIN_HANN) # filter type # Decimating channel filter # complex in and out, float taps self.chan_filt = gr.fft_filter_ccc(sw_decim, chan_coeffs) #self.chan_filt = gr.fir_filter_ccf(sw_decim, chan_coeffs) # receiver self.packet_receiver = \ blks2.demod_pkts(self._demod_class(**demod_kwargs), access_code=None, callback=self._rx_callback, threshold=-1) # Carrier Sensing Blocks alpha = 0.001 thresh = 30 # in dB, will have to adjust self.sequelcher = gr.simple_squelch_cc(45) if options.log_rx_power == True: self.probe = gr.probe_avg_mag_sqrd_cf(thresh,alpha) self.power_sink = gr.file_sink(gr.sizeof_float, "rxpower.dat") self.connect(self.chan_filt, self.probe, self.power_sink) else: self.probe = gr.probe_avg_mag_sqrd_c(thresh,alpha) #self.connect(self.chan_filt, self.sequelcher, self.probe) # Display some information about the setup if self._verbose: self._print_verbage() #filter the noise and pass only the transmitted data #file_source = gr.file_source(gr.sizeof_gr_complex,"modulated_data.dat") #self.connect(self.chan_filt,file_sink) self.connect(self.u, self.chan_filt,self.sequelcher, self.packet_receiver)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Amaviation Agc") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.sql_threshold = sql_threshold = -30 self.samp_rate = samp_rate = 1000000 self.frq_offset = frq_offset = 0 self.base_frq = base_frq = 131725000 ################################################## # Blocks ################################################## _sql_threshold_sizer = wx.BoxSizer(wx.VERTICAL) self._sql_threshold_text_box = forms.text_box( parent=self.GetWin(), sizer=_sql_threshold_sizer, value=self.sql_threshold, callback=self.set_sql_threshold, label="Squelch Threshold", converter=forms.float_converter(), proportion=0, ) self._sql_threshold_slider = forms.slider( parent=self.GetWin(), sizer=_sql_threshold_sizer, value=self.sql_threshold, callback=self.set_sql_threshold, minimum=-100, maximum=0, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_sql_threshold_sizer) _frq_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._frq_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_frq_offset_sizer, value=self.frq_offset, callback=self.set_frq_offset, label="Frequency Offset", converter=forms.float_converter(), proportion=0, ) self._frq_offset_slider = forms.slider( parent=self.GetWin(), sizer=_frq_offset_sizer, value=self.frq_offset, callback=self.set_frq_offset, minimum=-100000, maximum=100000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_frq_offset_sizer) self._base_frq_text_box = forms.text_box( parent=self.GetWin(), value=self.base_frq, callback=self.set_base_frq, label="Base frequency", converter=forms.float_converter(), ) self.Add(self._base_frq_text_box) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.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_bandwidth(300000) self.rtl2832_source_0.set_sample_rate(samp_rate) self.rtl2832_source_0.set_frequency(base_frq + frq_offset) self.rtl2832_source_0.set_gain_mode("sensitive") self.rtl2832_source_0.set_auto_gain_mode(False) self.rtl2832_source_0.set_relative_gain(True) self.rtl2832_source_0.set_gain(30) self.gr_simple_squelch_cc_0 = gr.simple_squelch_cc( sql_threshold, 0.0001) self.gr_agc2_xx_0 = gr.agc2_cc(100e-3, 200e-3, 1.0, 1.0, 2.0) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=48, decimation=1000, taps=None, fractional_bw=None, ) self.blks2_am_demod_cf_0 = blks2.am_demod_cf( channel_rate=48000, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.audio_sink_0 = audio.sink(48000, "pulse", True) ################################################## # Connections ################################################## self.connect((self.rtl2832_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blks2_am_demod_cf_0, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_simple_squelch_cc_0, 0)) self.connect((self.gr_simple_squelch_cc_0, 0), (self.gr_agc2_xx_0, 0)) self.connect((self.gr_agc2_xx_0, 0), (self.blks2_am_demod_cf_0, 0)) self.connect((self.rtl2832_source_0, 0), (self.blks2_rational_resampler_xxx_0, 0))
def __init__(self, subdev_spec, gain, audio_output): gr.hier_block2.__init__( self, "receive_path", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(0, 0, 0)) # Output signature self.u = usrp.source_c() adc_rate = self.u.adc_rate() self.if_rate = 256e3 # 256 kS/s usrp_decim = int(adc_rate // self.if_rate) if_decim = 4 self.u.set_decim_rate(usrp_decim) self.quad_rate = self.if_rate // if_decim # 64 kS/s audio_decim = 2 self.audio_rate = self.quad_rate // audio_decim # 32 kS/s if subdev_spec is None: subdev_spec = usrp.pick_rx_subdevice(self.u) self.subdev = usrp.selected_subdev(self.u, subdev_spec) print "Using RX d'board %s" % (self.subdev.side_and_name(), ) self.u.set_mux(usrp.determine_rx_mux_value(self.u, subdev_spec)) # Create filter to get actual channel we want chan_coeffs = gr.firdes.low_pass( 1.0, # gain self.if_rate, # sampling rate 8e3, # low pass cutoff freq 2e3, # width of trans. band gr.firdes.WIN_HANN) # filter type print "len(rx_chan_coeffs) =", len(chan_coeffs) # Decimating Channel filter with frequency translation # complex in and out, float taps self.ddc = gr.freq_xlating_fir_filter_ccf( if_decim, # decimation rate chan_coeffs, # taps 0, # frequency translation amount self.if_rate) # input sample rate if USE_SIMPLE_SQUELCH: self.squelch = gr.simple_squelch_cc(20) else: self.squelch = blks2.standard_squelch(self.audio_rate) # instantiate the guts of the single channel receiver self.fmrx = blks2.nbfm_rx(self.audio_rate, self.quad_rate) # audio gain / mute block self._audio_gain = gr.multiply_const_ff(1.0) # sound card as final sink audio_sink = audio.sink(int(self.audio_rate), audio_output) # now wire it all together if USE_SIMPLE_SQUELCH: self.connect(self.u, self.ddc, self.squelch, self.fmrx, self._audio_gain, audio_sink) else: self.connect(self.u, self.ddc, self.fmrx, self.squelch, self._audio_gain, audio_sink) if gain is None: # if no gain was specified, use the mid-point in dB g = self.subdev.gain_range() gain = float(g[0] + g[1]) / 2 self.set_gain(gain) v = self.volume_range() self.set_volume((v[0] + v[1]) / 2) s = self.squelch_range() self.set_squelch((s[0] + s[1]) / 2)
def __init__(self, args, spec, antenna, gain, audio_output): gr.hier_block2.__init__( self, "receive_path", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(0, 0, 0)) # Output signature self.u = uhd.usrp_source(device_addr=args, stream_args=uhd.stream_args('fc32')) self.if_rate = 256e3 self.quad_rate = 64e3 self.audio_rate = 32e3 self.u.set_samp_rate(self.if_rate) dev_rate = self.u.get_samp_rate() # Create filter to get actual channel we want nfilts = 32 chan_coeffs = gr.firdes.low_pass( nfilts, # gain nfilts * dev_rate, # sampling rate 8e3, # low pass cutoff freq 2e3, # width of trans. band gr.firdes.WIN_HANN) # filter type rrate = self.quad_rate / dev_rate self.resamp = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) if USE_SIMPLE_SQUELCH: self.squelch = gr.simple_squelch_cc(20) else: self.squelch = blks2.standard_squelch(self.audio_rate) # instantiate the guts of the single channel receiver self.fmrx = blks2.nbfm_rx(self.audio_rate, self.quad_rate) # audio gain / mute block self._audio_gain = gr.multiply_const_ff(1.0) # sound card as final sink audio_sink = audio.sink(int(self.audio_rate), audio_output) # now wire it all together if USE_SIMPLE_SQUELCH: self.connect(self.u, self.resamp, self.squelch, self.fmrx, self._audio_gain, audio_sink) else: self.connect(self.u, self.resamp, self.fmrx, self.squelch, self._audio_gain, audio_sink) if gain is None: # if no gain was specified, use the mid-point in dB g = self.u.get_gain_range() gain = float(g.start() + g.stop()) / 2 self.set_gain(gain) v = self.volume_range() self.set_volume((v[0] + v[1]) / 2) s = self.squelch_range() self.set_squelch((s[0] + s[1]) / 2) # Set the subdevice spec if (spec): self.u.set_subdev_spec(spec, 0) # Set the antenna if (antenna): self.u.set_antenna(antenna, 0)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Amaviation Agc") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.sql_threshold = sql_threshold = -30 self.samp_rate = samp_rate = 1000000 self.frq_offset = frq_offset = 0 self.base_frq = base_frq = 131725000 ################################################## # Blocks ################################################## _sql_threshold_sizer = wx.BoxSizer(wx.VERTICAL) self._sql_threshold_text_box = forms.text_box( parent=self.GetWin(), sizer=_sql_threshold_sizer, value=self.sql_threshold, callback=self.set_sql_threshold, label="Squelch Threshold", converter=forms.float_converter(), proportion=0, ) self._sql_threshold_slider = forms.slider( parent=self.GetWin(), sizer=_sql_threshold_sizer, value=self.sql_threshold, callback=self.set_sql_threshold, minimum=-100, maximum=0, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_sql_threshold_sizer) _frq_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._frq_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_frq_offset_sizer, value=self.frq_offset, callback=self.set_frq_offset, label="Frequency Offset", converter=forms.float_converter(), proportion=0, ) self._frq_offset_slider = forms.slider( parent=self.GetWin(), sizer=_frq_offset_sizer, value=self.frq_offset, callback=self.set_frq_offset, minimum=-100000, maximum=100000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_frq_offset_sizer) self._base_frq_text_box = forms.text_box( parent=self.GetWin(), value=self.base_frq, callback=self.set_base_frq, label="Base frequency", converter=forms.float_converter(), ) self.Add(self._base_frq_text_box) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.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_bandwidth(300000) self.rtl2832_source_0.set_sample_rate(samp_rate) self.rtl2832_source_0.set_frequency(base_frq+frq_offset) self.rtl2832_source_0.set_gain_mode("sensitive") self.rtl2832_source_0.set_auto_gain_mode(False) self.rtl2832_source_0.set_relative_gain(True) self.rtl2832_source_0.set_gain(30) self.gr_simple_squelch_cc_0 = gr.simple_squelch_cc(sql_threshold, 0.0001) self.gr_agc2_xx_0 = gr.agc2_cc(100e-3, 200e-3, 1.0, 1.0, 2.0) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=48, decimation=1000, taps=None, fractional_bw=None, ) self.blks2_am_demod_cf_0 = blks2.am_demod_cf( channel_rate=48000, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.audio_sink_0 = audio.sink(48000, "pulse", True) ################################################## # Connections ################################################## self.connect((self.rtl2832_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blks2_am_demod_cf_0, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_simple_squelch_cc_0, 0)) self.connect((self.gr_simple_squelch_cc_0, 0), (self.gr_agc2_xx_0, 0)) self.connect((self.gr_agc2_xx_0, 0), (self.blks2_am_demod_cf_0, 0)) self.connect((self.rtl2832_source_0, 0), (self.blks2_rational_resampler_xxx_0, 0))
def __init__(self, subdev_spec, gain, audio_output): gr.hier_block2.__init__(self, "receive_path", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(0, 0, 0)) # Output signature self.u = usrp.source_c () adc_rate = self.u.adc_rate() self.if_rate = 256e3 # 256 kS/s usrp_decim = int(adc_rate // self.if_rate) if_decim = 4 self.u.set_decim_rate(usrp_decim) self.quad_rate = self.if_rate // if_decim # 64 kS/s audio_decim = 2 self.audio_rate = self.quad_rate // audio_decim # 32 kS/s if subdev_spec is None: subdev_spec = usrp.pick_rx_subdevice(self.u) self.subdev = usrp.selected_subdev(self.u, subdev_spec) print "Using RX d'board %s" % (self.subdev.side_and_name(),) self.u.set_mux(usrp.determine_rx_mux_value(self.u, subdev_spec)) # Create filter to get actual channel we want chan_coeffs = gr.firdes.low_pass (1.0, # gain self.if_rate, # sampling rate 8e3, # low pass cutoff freq 2e3, # width of trans. band gr.firdes.WIN_HANN) # filter type print "len(rx_chan_coeffs) =", len(chan_coeffs) # Decimating Channel filter with frequency translation # complex in and out, float taps self.ddc = gr.freq_xlating_fir_filter_ccf(if_decim, # decimation rate chan_coeffs, # taps 0, # frequency translation amount self.if_rate) # input sample rate if USE_SIMPLE_SQUELCH: self.squelch = gr.simple_squelch_cc(20) else: self.squelch = blks2.standard_squelch(self.audio_rate) # instantiate the guts of the single channel receiver self.fmrx = blks2.nbfm_rx(self.audio_rate, self.quad_rate) # audio gain / mute block self._audio_gain = gr.multiply_const_ff(1.0) # sound card as final sink audio_sink = audio.sink (int(self.audio_rate), audio_output) # now wire it all together if USE_SIMPLE_SQUELCH: self.connect (self.u, self.ddc, self.squelch, self.fmrx, self._audio_gain, audio_sink) else: self.connect (self.u, self.ddc, self.fmrx, self.squelch, self._audio_gain, audio_sink) if gain is None: # if no gain was specified, use the mid-point in dB g = self.subdev.gain_range() gain = float(g[0]+g[1])/2 self.set_gain(gain) v = self.volume_range() self.set_volume((v[0]+v[1])/2) s = self.squelch_range() self.set_squelch((s[0]+s[1])/2)