Python gnuradio.filter.fir_filter_ccf() Examples

The following are 3 code examples of gnuradio.filter.fir_filter_ccf(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gnuradio.filter , or try the search function .
Example #1
Source File: doorbell-receiver.py    From so-you-want-to-hack-radios with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
    gr.top_block.__init__(self, name="Doorbell Top Block")

    # RF Config
    self.threshold_min = -60
    self.threshold_max = -50
    self.samp_rate = samp_rate = 100e3
    self.gain = gain = 30
    self.freq = freq = 315e6
    self.decimation = 10

    # USRP
    self.usrp = uhd.usrp_source("", uhd.stream_args("fc32"))
    self.usrp.set_samp_rate(samp_rate)
    self.usrp.set_center_freq(freq, 0)
    self.usrp.set_gain(gain, 0)
    self.usrp.set_antenna("TX/RX", 0)

    # Low Pass Filter
    self.lpf = filter.fir_filter_ccf(self.decimation,
      firdes.low_pass(1, samp_rate, 50e3, 10e3, firdes.WIN_HAMMING, 6.76))

    # Complex to Power (dB)
    self._10log10 = blocks.nlog10_ff(10, 1, 0)
    self.complex_to_mag_squared = blocks.complex_to_mag_squared(1)

    # Threshold
    self.threshold = blocks.threshold_ff(self.threshold_min, self.threshold_max, 0)

    # Framer
    self.framer = doorbell_framer()

    # Connect the blocks
    self.connect((self.usrp, 0), (self.lpf, 0))
    self.connect((self.lpf, 0), (self.complex_to_mag_squared, 0))
    self.connect((self.complex_to_mag_squared, 0), (self._10log10, 0))
    self.connect((self._10log10, 0), (self.threshold, 0))
    self.connect((self.threshold, 0), (self.framer, 0))


# Doorbell Framer 
Example #2
Source File: receive345.py    From decode345 with MIT License 4 votes vote down vote up
def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.trans_width = trans_width = 10e3
        self.samp_rate = samp_rate = 1e6
        self.mult_const = mult_const = 100
        self.lowpass_decimation = lowpass_decimation = 10
        self.freq = freq = 344940000
        self.cutoff_freq = cutoff_freq = 50e3

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(True, 0)
        self.osmosdr_source_0.set_gain(0, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.low_pass_filter_0 = filter.fir_filter_ccf(lowpass_decimation, firdes.low_pass(
        	1, samp_rate, cutoff_freq, trans_width, firdes.WIN_HAMMING, 6.76))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((mult_const, ))
        self.blocks_float_to_uchar_0 = blocks.float_to_uchar()
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char*1, '/tmp/grcfifo', False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_float_to_uchar_0, 0), (self.blocks_file_sink_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_uchar_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.low_pass_filter_0, 0)) 
Example #3
Source File: Radio.py    From PLSDR with GNU General Public License v3.0 4 votes vote down vote up
def rebuild_filters(self,config,value = None):
    if self.cw_base == None:
      return
    if value == None:
      value = config['bw_mode']
      
    am_bw = (8000,3000,2000)[value]
    fm_bw = (8000,6000,4000)[value]
    wfm_bw = (60e3,40e3,20e3)[value]
    ssb_bw = (5000,2400,1800)[value]
    cw_bw = (self.cw_base*2/3,self.cw_base/2,self.cw_base/3)[value]
    
    am_taps = firdes.low_pass(
      1, self.audio_rate, am_bw, 500, firdes.WIN_HAMMING, 6.76)
    fm_taps = firdes.low_pass(
      1, self.audio_rate, fm_bw, 500, firdes.WIN_HAMMING, 6.76)
    wfm_taps = firdes.low_pass(
      1, self.if_sample_rate, wfm_bw, 4e3, firdes.WIN_HAMMING, 6.76)
    ssb_taps = firdes.low_pass(
      1, self.audio_rate, ssb_bw, 100, firdes.WIN_HAMMING, 6.76)
    #print("CW Base: %d - %d - %d" % (self.cw_base-cw_bw,self.cw_base + cw_bw,self.audio_rate))
    cw_taps = firdes.band_pass(
      1, self.audio_rate, self.cw_base-cw_bw,self.cw_base+cw_bw, 100, firdes.WIN_HAMMING, 6.76)
    
    if self.low_pass_filter_am == None:
      self.low_pass_filter_am = filter.fir_filter_ccf(1, am_taps)
    else:
      self.low_pass_filter_am.set_taps(am_taps) 
      
    if self.low_pass_filter_fm == None:
      self.low_pass_filter_fm = filter.fir_filter_ccf(1, fm_taps)
    else:
      self.low_pass_filter_fm.set_taps(fm_taps)
      
    if self.low_pass_filter_wfm == None:
      self.low_pass_filter_wfm = filter.fir_filter_ccf(1, wfm_taps)
    else:
      self.low_pass_filter_wfm.set_taps(wfm_taps)
      
    if self.low_pass_filter_ssb == None:
      self.low_pass_filter_ssb = filter.fir_filter_fff(1, ssb_taps)
    else:
      self.low_pass_filter_ssb.set_taps(ssb_taps)
      
    if self.band_pass_filter_cw == None:
      self.band_pass_filter_cw = filter.fir_filter_fff(1, cw_taps)
    else:
      self.band_pass_filter_cw.set_taps(cw_taps)
      
  # calculate gcd using Euclid's algorithm