예제 #1
0
	def __init__(self, u, center_freq, hw_dec_rate, downsample_rate, pulse_width, tari, debug_on, output_data):
		gr.top_block.__init__(self)

		# sample_rate = 100e6 / hw_dec_rate
		sample_rate = 2e6

		self.u = u
		# self.u.set_decim(hw_dec_rate)
		g = u.get_gain_range()
		print "-----------"

		self.u.set_gain(float(g.start() + g.stop()) / 4)
		print "Using gain of", float(g.start() + g.stop()) / 4 , "(", g.stop(), "-", g.start(), ")"
		tune_req = uhd.tune_request_t(center_freq,sample_rate)
		# r = rx.set_center_freq(tune_req)
		x = self.u.set_center_freq(tune_req)
		if not x:
			print "Couldn't set rx freq"
            
		self.u.set_samp_rate(sample_rate)
		us_per_sample = 1e6 / sample_rate * downsample_rate
		print "USRP Sample Rate: "+ str(sample_rate) + " us Per Sample: " + str(us_per_sample)

		# 25 Msps is too much to process. But we don't want to decimate at the USRP because we want the full band.
		# We can downsample, because we don't care about aliasing. 
		self.downsample = gr.keep_one_in_n(gr.sizeof_gr_complex, int(downsample_rate))
		self.to_mag = gr.complex_to_mag()
		
		# For TARI = 24, PW == DELIM. So we can't do a matched filter, or everything becomes a delimiter and a zero.
		# PW / 2 smooths reasonably well.
		# self.smooth = gr.moving_average_ff(int(pulse_width / us_per_sample) /2  , int(pulse_width / us_per_sample) /2 ) 
		self.smooth = gr.moving_average_ff(int(1), 1.0) 
		self.rd = rfid.reader_decoder(us_per_sample, tari)

		if(debug_on):
			# fileInfo = "_smooth1_b"
        	# time = strftime("%H_%M_%S", localtime())
        	# threshFileName = "rm_thresh_" + time + fileInfo + ".out"
        	# signalFileName = "rm_signal_" + time + fileInfo + ".out"

			signalFileName = "rm_signal.out"
			threshFileName = "rm_thresh.out"
			self.sink = gr.file_sink(gr.sizeof_float, threshFileName)
			# self.signal_sink = gr.file_sink(gr.sizeof_float, signalFileName)
			# self.connect(self.smooth, self.signal_sink)
		else:
			self.sink = gr.null_sink(gr.sizeof_float)

		self.connect(self.u, self.downsample, self.to_mag, self.smooth, self.rd, self.sink)

		# Change to "gr.sizeof_gr_complex" if "block_x" is "rx" 
		file_rx_sink = gr.file_sink(gr.sizeof_gr_complex, output_data) 
		self.connect(self.u, file_rx_sink)
예제 #2
0
    def __init__(self, u, center_freq, hw_dec_rate, downsample_rate,
                 pulse_width, tari, debug_on):
        gr.top_block.__init__(self)

        self.u = u
        self.u.set_decim(hw_dec_rate)
        g = u.gain_range()
        self.u.set_gain(float(g[0] + g[1]) / 4)
        print "Using gain of", float(g[0] +
                                     g[1]) / 4, "(", g[0], "-", g[1], ")"
        x = self.u.set_center_freq(center_freq)
        if not x:
            print "Couldn't set rx freq"

        sample_rate = self.u.adc_rate() / hw_dec_rate
        us_per_sample = 1e6 / sample_rate * downsample_rate
        print "USRP Sample Rate: " + str(
            sample_rate) + " us Per Sample: " + str(us_per_sample)

        #25 Msps is too much to process. But we don't want to decimate at the USRP because we want the full band.
        # We can downsample, because we don't care about aliasing.
        self.downsample = gr.keep_one_in_n(gr.sizeof_gr_complex,
                                           int(downsample_rate))

        self.to_mag = gr.complex_to_mag()

        #For TARI = 24, PW == DELIM. So we can't do a matched filter, or everything becomes a delimiter and a zero.
        # PW / 2 smooths reasonably well.
        self.smooth = gr.moving_average_ff(
            int(pulse_width / us_per_sample) / 2,
            int(pulse_width / us_per_sample) / 2)

        self.rd = rfid.reader_decoder(us_per_sample, tari)

        if (debug_on):
            self.sink = gr.file_sink(gr.sizeof_float, "rm_thresh.out")
            self.signal_sink = gr.file_sink(gr.sizeof_float, "rm_signal.out")
            self.connect(self.smooth, self.signal_sink)

        else:
            self.sink = gr.null_sink(gr.sizeof_float)

        self.connect(self.u, self.downsample, self.to_mag, self.smooth,
                     self.rd, self.sink)
예제 #3
0
    def __init__(self, u, center_freq, hw_dec_rate, downsample_rate, pulse_width, tari, debug_on):
        gr.top_block.__init__(self)

        self.u = u
        self.u.set_decim(hw_dec_rate)
        g = u.gain_range()
        self.u.set_gain(float(g[0] + g[1]) / 4)
        print "Using gain of", float(g[0] + g[1]) / 4 , "(", g[0], "-", g[1], ")"
        x = self.u.set_center_freq(center_freq)
        if not x:
            print "Couldn't set rx freq"
            
        sample_rate = self.u.adc_rate() / hw_dec_rate
        us_per_sample = 1e6 / sample_rate * downsample_rate
        print "USRP Sample Rate: "+ str(sample_rate) + " us Per Sample: " + str(us_per_sample)

        #25 Msps is too much to process. But we don't want to decimate at the USRP because we want the full band.
        # We can downsample, because we don't care about aliasing. 
        self.downsample = gr.keep_one_in_n(gr.sizeof_gr_complex, int(downsample_rate))

        self.to_mag = gr.complex_to_mag()
        
        #For TARI = 24, PW == DELIM. So we can't do a matched filter, or everything becomes a delimiter and a zero.
        # PW / 2 smooths reasonably well.
        self.smooth = gr.moving_average_ff(int(pulse_width / us_per_sample) /2  , int(pulse_width / us_per_sample) /2 ) 
        
        self.rd = rfid.reader_decoder(us_per_sample, tari)

        if(debug_on):
            self.sink = gr.file_sink(gr.sizeof_float, "rm_thresh.out")
            self.signal_sink = gr.file_sink(gr.sizeof_float, "rm_signal.out")
            self.connect(self.smooth, self.signal_sink)

        else:
            self.sink = gr.null_sink(gr.sizeof_float)
        
        self.connect(self.u, self.downsample, self.to_mag, self.smooth, self.rd, self.sink)