def __init__(self):
       		gr.top_block.__init__(self)
		

           
		amplitude = 30000   # 1  2150 10000
		
		rx_out = gr.file_sink(gr.sizeof_gr_complex, "./rx.out")
		

		interp_rate = 128  # tx_samprate = 1M
#		dec_rate = 8       # rx_samprate = 8M

		dec_rate = 16     #16 # rx_samprate = 4M
		sw_dec = 4       #2

#		num_taps = int(64000 / ( (dec_rate * 4) * 40 )) #Filter matched to 1/4 of the 40 kHz tag cycle
		num_taps = int(64000 / ( (dec_rate * 4) * 256 )) #Filter matched to 1/4 of the 256 kHz tag cycle

		taps = [complex(1,1)] * num_taps
		
		matched_filt = gr.fir_filter_ccc(sw_dec, taps);
		  
		to_mag = gr.complex_to_mag()
		center = rfid.center_ff(4)

		mm = rfid.clock_recovery_zc_ff(4,1);
		self.reader = rfid.reader_f(int(128e6/interp_rate)); 
		
		tag_decoder = rfid.tag_decoder_f()

		command_gate = rfid.command_gate_cc(12, 60, 64000000 / dec_rate / sw_dec)
		

	       
	       
		to_complex = gr.float_to_complex()
		amp = gr.multiply_const_ff(amplitude)
		
		##################################################
		# Blocks
		##################################################
		freq = 915e6 #915e6 
		rx_gain = 24 #xjtu

		tx = uhd.usrp_sink(
			device_addr="",
			io_type=uhd.io_type.COMPLEX_FLOAT32,
			num_channels=1,
		)
		
		tx.set_samp_rate(128e6/interp_rate)
		
		p = tx.get_gain_range()
		tx.set_gain(float(p.start() + p.stop()) / 4)

		#r = tx.set_center_freq(freq, 0)	
		t = tx.set_samp_rate(64e6/dec_rate)
		tune_req_tx = uhd.tune_request_t(freq,128e6/interp_rate/2)
		tt = tx.set_center_freq(tune_req_tx)

		rx = uhd.usrp_source(
			options.args,
			io_type=uhd.io_type.COMPLEX_FLOAT32,
			num_channels=1,
		)
		r = rx.set_samp_rate(64e6/dec_rate)
		tune_req = uhd.tune_request_t(freq,64e6/dec_rate)
		x = rx.set_center_freq(tune_req)
		if not x:
            	    print "Couldn't set rx freq"
		#g = rx.get_gain_range()
		rx.set_gain(rx_gain)
		
		print "***************Info******************"
		print "-----tx: get sample rate:"
		print (tx.get_samp_rate())
		print "tx: get freq:"
		print (tx.get_center_freq())	

		print "-----rx.detail"
		print rx.detail()
		print "rx: get samp rate"
		print (rx.get_samp_rate())		
		print "rx: get freq "
		print (rx.get_center_freq())
		print "rx: get gain "
		print (rx.get_gain())		
		print "***************END******************"

		command_gate.set_ctrl_out(self.reader.ctrl_q())
		tag_decoder.set_ctrl_out(self.reader.ctrl_q())

	#########Build Graph
		self.connect(rx, matched_filt)		
		self.connect(matched_filt, command_gate)


		self.connect(command_gate, to_mag)
		#self.connect(command_gate, agc)
		#self.connect(agc, to_mag) 

		self.connect(to_mag, center, mm, tag_decoder)
		#self.connect(to_mag, center, matched_filt_tag_decode, tag_decoder)
		self.connect(tag_decoder, self.reader)
		self.connect(self.reader, amp)	
		self.connect(amp, to_complex)
		self.connect(to_complex, tx)

	#################
		#self.connect(command_gate, commandGate_out)	
		self.connect(rx, rx_out)
示例#2
0
    def __init__(self):
        gr.top_block.__init__(self)
           
        amplitude = 30000

        filt_out = gr.file_sink(gr.sizeof_gr_complex, "./filt.out")
        filt2_out = gr.file_sink(gr.sizeof_gr_complex, "./filt2.out")
        ffilt_out = gr.file_sink(gr.sizeof_float, "./ffilt.out")
        ffilt2_out = gr.file_sink(gr.sizeof_float, "./ffilt2.out")

        interp_rate = 128
        dec_rate = 8
        sw_dec = 4

        num_taps = int(64000 / ( (dec_rate * 4) * 256 )) #Filter matched to 1/4 of the 256 kHz tag cycle
        taps = [complex(1,1)] * num_taps
        
        matched_filt = gr.fir_filter_ccc(sw_dec, taps);  
          
        agc = gr.agc2_cc(0.3, 1e-3, 1, 1, 100) 
     
        to_mag = gr.complex_to_mag()

        center = rfid.center_ff(4)

        omega = 2
        mu = 0.25
        gain_mu = 0.25
        gain_omega = .25 * gain_mu * gain_mu
        omega_relative_limit = .05

        mm = gr.clock_recovery_mm_ff(omega, gain_omega, mu, gain_mu, omega_relative_limit)


        self.reader = rfid.reader_f(int(128e6/interp_rate)); 
        
        tag_decoder = rfid.tag_decoder_f()
        
        command_gate = rfid.command_gate_cc(12, 60, 64000000 / dec_rate / sw_dec)
        

       
       
        to_complex = gr.float_to_complex()
        amp = gr.multiply_const_ff(amplitude)
        
        f_sink = gr.file_sink(gr.sizeof_gr_complex, 'f_sink.out');
        f_sink2 = gr.file_sink(gr.sizeof_gr_complex, 'f_sink2.out');


            #TX
      


        freq = 915e6
        rx_gain = 20  
    
        tx = usrp.sink_c(fusb_block_size = 1024, fusb_nblocks=8)
        tx.set_interp_rate(interp_rate)
        tx_subdev = (0,0)
        tx.set_mux(usrp.determine_tx_mux_value(tx, tx_subdev))
        subdev = usrp.selected_subdev(tx, tx_subdev)
        subdev.set_enable(True)
        subdev.set_gain(subdev.gain_range()[2])
        t = tx.tune(subdev.which(), subdev, freq)
        if not t:
            print "Couldn't set tx freq"
#End TX
             
#RX
        rx = usrp.source_c(0, dec_rate, fusb_block_size = 512 * 4, fusb_nblocks = 16)
        rx_subdev_spec = (1,0)
        rx.set_mux(usrp.determine_rx_mux_value(rx, rx_subdev_spec))
        rx_subdev = usrp.selected_subdev(rx, rx_subdev_spec)
        rx_subdev.set_gain(rx_gain)
        rx_subdev.set_auto_tr(False)
        rx_subdev.set_enable(True)
        
        r = usrp.tune(rx, 0, rx_subdev, freq)

        self.rx = rx
        if not r:
            print "Couldn't set rx freq"

#End RX

        command_gate.set_ctrl_out(self.reader.ctrl_q())
        tag_decoder.set_ctrl_out(self.reader.ctrl_q())
        agc2 = gr.agc2_ff(0.3, 1e-3, 1, 1, 100) 


#########Build Graph
        self.connect(rx, matched_filt)
        self.connect(matched_filt, command_gate)
        self.connect(command_gate, agc)
        self.connect(agc, to_mag) 
        self.connect(to_mag, center, agc2, mm, tag_decoder)
        self.connect(tag_decoder, self.reader, amp, to_complex, tx);
#################

        
        self.connect(matched_filt, filt_out)
示例#3
0
    def __init__(self):
        # GUI setup
        grc_wxgui.top_block_gui.__init__(self, title="Grc Wisp Reader")

        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.GetWin(),
            title="Scope Plot",
            sample_rate=1e6,
            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_0.win)

        # Constants
        amplitude = 1
        interp_rate = 128
        dec_rate = 16  #		dec_rate = 8
        sw_dec = 2  #	sw_dec = 4

        num_taps = int(64000 / ((
                                dec_rate * 4) * 256 ))  #Filter matched to 1/4 of the 256 kHz tag cycle  #		num_taps = int(64000 / ( (dec_rate * 4) * 40 )) #Filter matched to 1/4 of the 40 kHz tag cycle

        #---------------------------
        #num_taps==3
        #taps =[complex(1,1)] * num_taps = [(1+1j)]*3 = [(1+1j),(1+1j),(1+1j)]
        #
        #"complex" creates complex numbers
        # complex(x,y) = x+yj (x are the real part of the number and y are the complex part of the number)
        #
        #[complex(x,y)]*size = size tells how many complex numbers will be created
        #[complex(1,1)]*3 = [(1+1j),(1+1j),(1+1j)]
        #---------------------------
        taps = [complex(1, 1)] * num_taps

        matched_filt = gr.fir_filter_ccc(sw_dec, taps);

        to_mag = gr.complex_to_mag()

        center = rfid.center_ff(4)  #		center = rfid.center_ff(10)

        mm = rfid.clock_recovery_zc_ff(4, 1);
        self.reader = rfid.reader_f(int(128e6 / interp_rate));

        tag_decoder = rfid.tag_decoder_f()

        command_gate = rfid.command_gate_cc(12, 60,
                                            64000000 / dec_rate / sw_dec)  #		command_gate = rfid.command_gate_cc(12, 250, 64000000 / dec_rate / sw_dec)

        to_complex = gr.float_to_complex()
        amp = gr.multiply_const_ff(amplitude)

        ##################################################
        # Blocks
        ##################################################
        freq = 915e6
        rx_gain = 1

        # Transmitter setup
        tx = uhd.usrp_sink(
            device_addr="",
            io_type=uhd.io_type.COMPLEX_FLOAT32,
            num_channels=1,
        )
        tx.set_samp_rate(128e6 / interp_rate)
        tx.set_center_freq(freq, 0)

        # Receiver setup
        rx = uhd.usrp_source(
            device_addr="",
            io_type=uhd.io_type.COMPLEX_FLOAT32,
            num_channels=1,
        )
        rx.set_samp_rate(64e6 / dec_rate)
        rx.set_center_freq(freq, 0)
        rx.set_gain(rx_gain, 0)

        # Command gate
        command_gate.set_ctrl_out(self.reader.ctrl_q())

        # Tag decoder
        tag_decoder.set_ctrl_out(self.reader.ctrl_q())

        #########Build Graph
        self.connect(rx, matched_filt)
        self.connect(matched_filt, command_gate)

        self.connect(command_gate, to_mag)
        #		self.connect(command_gate, agc)         #		agc = gr.agc2_cc(0.3, 1e-3, 1, 1, 100)
        #		self.connect(agc, to_mag)

        self.connect(to_mag, center, mm, tag_decoder)
        #		self.connect(to_mag, center, matched_filt_tag_decode, tag_decoder)
        self.connect(tag_decoder, self.reader)
        self.connect(self.reader, amp)
        self.connect(amp, to_complex)
        self.connect(to_complex, tx)
示例#4
0
	def __init__(self):
		grc_wxgui.top_block_gui.__init__(self, title="Grc Wisp Reader")
		_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))
		
		self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
			self.GetWin(),
			title="Scope Plot",
			sample_rate=1e6,
			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_0.win)
           
		amplitude = 1


		interp_rate = 128
#		dec_rate = 8
#		sw_dec = 4
		dec_rate = 16
		sw_dec = 2

#		num_taps = int(64000 / ( (dec_rate * 4) * 40 )) #Filter matched to 1/4 of the 40 kHz tag cycle
		num_taps = int(64000 / ( (dec_rate * 4) * 256 )) #Filter matched to 1/4 of the 256 kHz tag cycle

		taps = [complex(1,1)] * num_taps
		
		matched_filt = gr.fir_filter_ccc(sw_dec, taps);
		  
		agc = gr.agc2_cc(0.3, 1e-3, 1, 1, 100) 
	     
		to_mag = gr.complex_to_mag()
#		center = rfid.center_ff(10)
		center = rfid.center_ff(4)

		omega = 5
		mu = 0.25
		gain_mu = 0.25
		gain_omega = .25 * gain_mu * gain_mu
		omega_relative_limit = .05

#		mm = digital.clock_recovery_mm_ff(omega, gain_omega, mu, gain_mu, omega_relative_limit)
		mm = rfid.clock_recovery_zc_ff(4,1);
		self.reader = rfid.reader_f(int(128e6/interp_rate)); 
		
		tag_decoder = rfid.tag_decoder_f()
		
#		command_gate = rfid.command_gate_cc(12, 250, 64000000 / dec_rate / sw_dec)
		command_gate = rfid.command_gate_cc(12, 60, 64000000 / dec_rate / sw_dec)
		

	       
	       
		to_complex = gr.float_to_complex()
		amp = gr.multiply_const_ff(amplitude)
		
		##################################################
		# Blocks
		##################################################
		freq = 915e6
		rx_gain = 1

		tx = uhd.usrp_sink(
			device_addr="",
			io_type=uhd.io_type.COMPLEX_FLOAT32,
			num_channels=1,
		)
		print "tx: get sample rate:"
		print (tx.get_samp_rate())
		tx.set_samp_rate(128e6/interp_rate)
		print "tx: get sample rate:"
		print (tx.get_samp_rate())
		
		r = tx.set_center_freq(freq, 0)
		
		rx = uhd.usrp_source(
			device_addr="",
			io_type=uhd.io_type.COMPLEX_FLOAT32,
			num_channels=1,
		)
		print "rx: get samp rate"
		print (rx.get_samp_rate())		
		r = rx.set_samp_rate(64e6/dec_rate)
		print "rx: get samp rate"
		print (rx.get_samp_rate())		

		r = rx.set_center_freq(freq, 0)
		
		print "rx: get gain "
		print (rx.get_gain_range())		
		r = rx.set_gain(rx_gain, 0)
		print "rx: get gain "
		print (rx.get_gain())		


		command_gate.set_ctrl_out(self.reader.ctrl_q())
		tag_decoder.set_ctrl_out(self.reader.ctrl_q())

	#########Build Graph
		self.connect(rx, matched_filt)		
		self.connect(matched_filt, command_gate)


		self.connect(command_gate, to_mag)
#		self.connect(command_gate, agc)
#		self.connect(agc, to_mag) 

		self.connect(to_mag, center, mm, tag_decoder)
#		self.connect(to_mag, center, matched_filt_tag_decode, tag_decoder)
		self.connect(tag_decoder, self.reader)
		self.connect(self.reader, amp)	
		self.connect(amp, to_complex)
		self.connect(to_complex, tx)
示例#5
0
    def __init__(self):
        gr.top_block.__init__(self)
           
        amplitude = 5000        
        interp_rate = 256
        dec_rate = 16
        sw_dec = 5

        num_taps = int(64000 / ( (dec_rate * 4) * 40 )) #Filter matched to 1/4 of the 40 kHz tag cycle
        taps = [complex(1,1)] * num_taps
        
        matched_filt = gr.fir_filter_ccc(sw_dec, taps);  
          
        agc = gr.agc2_cc(0.3, 1e-3, 1, 1, 100) 
     
        to_mag = gr.complex_to_mag()

        center = rfid.center_ff(10)

        omega = 5
        mu = 0.25
        gain_mu = 0.25
        gain_omega = .25 * gain_mu * gain_mu
        omega_relative_limit = .05

        mm = gr.clock_recovery_mm_ff(omega, gain_omega, mu, gain_mu, omega_relative_limit)


        self.reader = rfid.reader_f(int(128e6/interp_rate)); 
        
        tag_decoder = rfid.tag_decoder_f()
        
        command_gate = rfid.command_gate_cc(12, 250, 64000000 / dec_rate / sw_dec)
        
        
        to_complex = gr.float_to_complex()
        amp = gr.multiply_const_ff(amplitude)
        
        #output the TX and RX signals only
        f_txout = gr.file_sink(gr.sizeof_gr_complex, 'f_txout.out');
        f_rxout = gr.file_sink(gr.sizeof_gr_complex, 'f_rxout.out');
        
#TX
		# working frequency at 915 MHz by default and RX Gain of 20
        freq = options.center_freq #915e6 
        rx_gain = options.rx_gain #20  
    
        tx = usrp.sink_c(fusb_block_size = 512, fusb_nblocks=4)
        tx.set_interp_rate(256)
        tx_subdev = (0,0)
        tx.set_mux(usrp.determine_tx_mux_value(tx, tx_subdev))
        subdev = usrp.selected_subdev(tx, tx_subdev)
        subdev.set_enable(True)
        subdev.set_gain(subdev.gain_range()[2])
        t = tx.tune(subdev.which(), subdev, freq)
        if not t:
            print "Couldn't set tx freq"
#End TX
             
#RX
        rx = usrp.source_c(0, dec_rate, fusb_block_size = 512, fusb_nblocks = 4)
        rx_subdev_spec = (1,0)
        rx.set_mux(usrp.determine_rx_mux_value(rx, rx_subdev_spec))
        rx_subdev = usrp.selected_subdev(rx, rx_subdev_spec)
        rx_subdev.set_gain(rx_gain)
        rx_subdev.set_auto_tr(False)
        rx_subdev.set_enable(True)
        
        r = usrp.tune(rx, 0, rx_subdev, freq)

        self.rx = rx
        if not r:
            print "Couldn't set rx freq"

#End RX

        command_gate.set_ctrl_out(self.reader.ctrl_q())
        tag_decoder.set_ctrl_out(self.reader.ctrl_q())



#########Build Graph
        self.connect(rx, matched_filt)
        self.connect(matched_filt, command_gate)
        self.connect(command_gate, agc)
        self.connect(agc, to_mag) 
        self.connect(to_mag, center, mm, tag_decoder)
        self.connect(tag_decoder, self.reader, amp, to_complex, tx);
#################
		
		#Output dumps for debug
        self.connect(rx, f_rxout);
        self.connect(to_complex, f_txout);