Ejemplo n.º 1
0
    def __init__(self, options, rx_callback):
        gr.flow_graph.__init__(self)

        # ----------------------------------------------------------------

        self.data_rate = 38400
        self.samples_per_symbol = 8
        self.usrp_decim = int(64e6 / self.samples_per_symbol / self.data_rate)
        self.fs = self.data_rate * self.samples_per_symbol
        payload_size = 128  # bytes

        print "data_rate = ", eng_notation.num_to_str(self.data_rate)
        print "samples_per_symbol = ", self.samples_per_symbol
        print "usrp_decim = ", self.usrp_decim
        print "fs = ", eng_notation.num_to_str(self.fs)

        max_deviation = self.data_rate / 4

        u = usrp.source_c(0, self.usrp_decim)
        if options.rx_subdev_spec is None:
            options.rx_subdev_spec = pick_subdevice(u)
        u.set_mux(usrp.determine_rx_mux_value(u, options.rx_subdev_spec))

        subdev = usrp.selected_subdev(u, options.rx_subdev_spec)
        print "Using RX d'board %s" % (subdev.side_and_name(), )

        #u.set_rx_freq (0, -options.cordic_freq)
        u.tune(0, subdev, options.cordic_freq_rx)
        u.set_pga(0, options.gain)
        u.set_pga(1, options.gain)

        filter_taps = gr.firdes.low_pass(
            1,  # gain
            self.fs,  # sampling rate
            self.data_rate / 2 * 1.1,  # cutoff
            self.data_rate,  # trans width
            gr.firdes.WIN_HANN)

        print "len = ", len(filter_taps)

        #filter = gr.fir_filter_ccf (1, filter_taps)

        # receiver
        gain_mu = 0.002 * self.samples_per_symbol
        self.packet_receiver = cc1k_sos_pkt.cc1k_demod_pkts(
            self,
            callback=rx_callback,
            sps=self.samples_per_symbol,
            symbol_rate=self.data_rate,
            p_size=payload_size,
            threshold=-1)

        #filesource = gr.file_source(gr.sizeof_gr_complex, 'tx_test.dat')
        self.connect(u, self.packet_receiver)

        #self.filesink = gr.file_sink(gr.sizeof_gr_complex, 'rx_test.dat')
        #self.connect(u, self.filesink)

        if 0 and not (options.no_gui):
            fft_input = fftsink.fft_sink_c(self,
                                           panel,
                                           title="Input",
                                           fft_size=512,
                                           sample_rate=self.fs)
            self.connect(u, fft_input)
            vbox.Add(fft_input.win, 1, wx.EXPAND)
    def __init__(self):
        gr.flow_graph.__init__(self)

        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=first one with a daughterboard)"
        )
        parser.add_option("-c",
                          "--cordic-freq1",
                          type="eng_float",
                          default=434845200,
                          help="set rx cordic frequency for channel 1 to FREQ",
                          metavar="FREQ")
        parser.add_option("-d",
                          "--cordic-freq2",
                          type="eng_float",
                          default=434318512,
                          help="set rx cordic frequency for channel 2 to FREQ",
                          metavar="FREQ")
        parser.add_option("-g",
                          "--gain",
                          type="eng_float",
                          default=0,
                          help="set Rx PGA gain in dB [0,20]")
        (options, args) = parser.parse_args()
        print "cordic_freq1 = %s" % (eng_notation.num_to_str(
            options.cordic_freq1))
        print "cordic_freq2 = %s" % (eng_notation.num_to_str(
            options.cordic_freq2))

        # ----------------------------------------------------------------

        self.data_rate = 38400
        self.samples_per_symbol = 8
        #we sample a band of 4 MHz.
        self.usrp_decim = int(64e6 / 4e6)
        self.decimation = self.usrp_decim / self.samples_per_symbol / self.data_rate

        self.fs = self.data_rate * self.samples_per_symbol
        payload_size = 128  # bytes

        print "data_rate = ", eng_notation.num_to_str(self.data_rate)
        print "samples_per_symbol = ", self.samples_per_symbol
        print "usrp_decim = ", self.usrp_decim
        print "decimation = ", self.decimation
        print "fs = ", eng_notation.num_to_str(self.fs)

        if options.cordic_freq1 < options.cordic_freq2:
            self.usrp_freq = options.cordic_freq1
            self.freq_diff = options.cordic_freq1 - options.cordic_freq2
        else:
            self.usrp_freq = options.cordic_freq2
            self.freq_diff = options.cordic_freq2 - options.cordic_freq1

        print "tune USRP to = ", self.usrp_freq
        u = usrp.source_c(0, self.usrp_decim)
        if options.rx_subdev_spec is None:
            options.rx_subdev_spec = pick_subdevice(u)
        u.set_mux(usrp.determine_rx_mux_value(u, options.rx_subdev_spec))

        subdev = usrp.selected_subdev(u, options.rx_subdev_spec)
        print "Using RX d'board %s" % (subdev.side_and_name(), )

        #u.set_rx_freq (0, -options.cordic_freq)
        u.tune(0, subdev, self.usrp_freq)
        u.set_pga(0, options.gain)
        u.set_pga(1, options.gain)

        # Create filter to get actual channels we want
        chan_coeffs = gr.firdes.low_pass(
            1.0,  # gain
            4e6,  # sampling rate
            150e3,  # low pass cutoff freq
            50e3,  # 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.ddc1 = gr.freq_xlating_fir_filter_ccf(
            13,  # decimation rate
            chan_coeffs,  # taps
            0,  # frequency translation amount
            4e6)  # input sample rate

        self.ddc2 = gr.freq_xlating_fir_filter_ccf(
            13,  # decimation rate
            chan_coeffs,  # taps
            self.freq_diff,  # frequency translation amount
            4e6)  # input sample rate

        # receiver
        gain_mu = 0.002 * self.samples_per_symbol
        self.packet_receiver1 = cc1k_sos_pkt.cc1k_demod_pkts(
            self,
            callback=self.rx_callback1,
            sps=self.samples_per_symbol,
            symbol_rate=self.data_rate,
            p_size=payload_size,
            threshold=-1)
        self.packet_receiver2 = cc1k_sos_pkt.cc1k_demod_pkts(
            self,
            callback=self.rx_callback2,
            sps=self.samples_per_symbol,
            symbol_rate=self.data_rate,
            p_size=payload_size,
            threshold=-1)

        u = gr.file_source(gr.sizeof_gr_complex, 'tx_test.dat')
        self.connect(u, self.ddc1, self.packet_receiver1)
        self.connect(u, self.ddc2, self.packet_receiver2)

        self.filesink = gr.file_sink(gr.sizeof_gr_complex, 'rx_test.dat')
        #self.connect(u, self.filesink)

        if 0 and not (options.no_gui):
            fft_input = fftsink.fft_sink_c(self,
                                           panel,
                                           title="Input",
                                           fft_size=512,
                                           sample_rate=self.fs)
            self.connect(u, fft_input)
            vbox.Add(fft_input.win, 1, wx.EXPAND)
Ejemplo n.º 3
0
    def __init__(self):
        gr.flow_graph.__init__ (self)

        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=first one with a daughterboard)")
        parser.add_option ("-c", "--cordic-freq", type="eng_float", default=434845200,
                           help="set Tx cordic frequency to FREQ", metavar="FREQ")
        parser.add_option ("-r", "--data-rate", type="eng_float", default=38400)
        parser.add_option ("-f", "--filename", type="string",
                           default="rx.dat", help="write data to FILENAME")
        parser.add_option ("-g", "--gain", type="eng_float", default=0,
                           help="set Rx PGA gain in dB [0,20]")
        parser.add_option ("-N", "--no-gui", action="store_true", default=False)

        (options, args) = parser.parse_args ()
        print "cordic_freq = %s" % (eng_notation.num_to_str (options.cordic_freq))

        # ----------------------------------------------------------------

        self.data_rate = options.data_rate
        self.samples_per_symbol = 8
        self.usrp_decim = int (64e6 / self.samples_per_symbol / self.data_rate)
        self.fs = self.data_rate * self.samples_per_symbol
        payload_size = 128             # bytes

        print "data_rate = ", eng_notation.num_to_str(self.data_rate)
        print "samples_per_symbol = ", self.samples_per_symbol
        print "usrp_decim = ", self.usrp_decim
        print "fs = ", eng_notation.num_to_str(self.fs)

        max_deviation = self.data_rate / 4
    
        u = usrp.source_c (0, self.usrp_decim)
        if options.rx_subdev_spec is None:
            options.rx_subdev_spec = pick_subdevice(u)
        u.set_mux(usrp.determine_rx_mux_value(u, options.rx_subdev_spec))

        subdev = usrp.selected_subdev(u, options.rx_subdev_spec)
        print "Using RX d'board %s" % (subdev.side_and_name(),)

        #u.set_rx_freq (0, -options.cordic_freq)
        u.tune(0, subdev, options.cordic_freq)
        u.set_pga(0, options.gain)
        u.set_pga(1, options.gain)


        filter_taps =  gr.firdes.low_pass (1,                   # gain
                                           self.fs,             # sampling rate
                                           self.data_rate / 2 * 1.1, # cutoff
                                           self.data_rate,           # trans width
                                           gr.firdes.WIN_HANN)

        print "len = ", len (filter_taps)

        #filter = gr.fir_filter_ccf (1, filter_taps)

        # receiver
        gain_mu = 0.002*self.samples_per_symbol
        self.packet_receiver = cc1k_sos_pkt.cc1k_demod_pkts(self,
                                                        callback=self.rx_callback,
                                                        sps=self.samples_per_symbol,
                                                        symbol_rate=self.data_rate,
                                                        p_size=payload_size,
                                                        threshold=-1)

        self.connect(u, self.packet_receiver)
            
        self.filesink = gr.file_sink(gr.sizeof_gr_complex, 'rx_test.dat')
        #self.connect(u, self.filesink)
        
        if 0 and not(options.no_gui):
            fft_input = fftsink.fft_sink_c (self, panel, title="Input", fft_size=512, sample_rate=self.fs)
            self.connect (u, fft_input)
            vbox.Add (fft_input.win, 1, wx.EXPAND)
Ejemplo n.º 4
0
    def __init__(self, rx_callback_cc2420, rx_callback_cc1k):
        gr.flow_graph.__init__(self)
        cc2420_cordic_freq = 2475000000
        cc2420_data_rate = 2000000
        cc1k_cordic_freq = 434845200
        cc1k_data_rate = 38400
        cc1k_sps = 8
        payload_size = 128
        print "cc2420_cordic_freq = %s" % (eng_notation.num_to_str (cc2420_cordic_freq))
        print "cc1k_cordic_freq = %s" % (eng_notation.num_to_str (cc1k_cordic_freq))


        # ----------------------------------------------------------------

        self.data_rate = cc2420_data_rate
        self.samples_per_symbol = 2
        self.usrp_decim = int (64e6 / self.samples_per_symbol / self.data_rate)
        self.fs = self.data_rate * self.samples_per_symbol
        payload_size = 128             # bytes

        print "usrp_decim = ", self.usrp_decim
        print "fs = ", eng_notation.num_to_str(self.fs)

        u = usrp.source_c (0, nchan=2)
        u.set_decim_rate(self.usrp_decim)
        self.subdev = (u.db[0][0], u.db[1][0])
        print "Using RX d'board %s" % (self.subdev[0].side_and_name(),)
        print "Using RX d'board %s" % (self.subdev[1].side_and_name(),)
        u.set_mux(0x2301)
        
        width = 8
        shift = 8
        format = u.make_format(width, shift)
        r = u.set_format(format)

        #this is the cc2420 code
        u.tune(self.subdev[0]._which, self.subdev[0], cc2420_cordic_freq)
        u.tune(self.subdev[1]._which, self.subdev[1], cc1k_cordic_freq)
        
        u.set_pga(0, 0)
        u.set_pga(1, 0)

        self.u = u

        # deinterleave two channels from FPGA
        di = gr.deinterleave(gr.sizeof_gr_complex)
        
        # wire up the head of the chain
        self.connect(self.u, di)
        #self.u = gr.file_source(gr.sizeof_gr_complex, 'rx_test.dat')

        # CC2420 receiver
        self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts(self,
                                                                        callback=rx_callback_cc2420,
                                                                        sps=self.samples_per_symbol,
                                                                        symbol_rate=self.data_rate,
                                                                        threshold=-1)

        self.squelch = gr.pwr_squelch_cc(50, 1, 0, True)
        self.connect((di,0), self.squelch, self.packet_receiver)

        # CC1K receiver
        gain_mu = 0.002*self.samples_per_symbol
        self.packet_receiver_cc1k = cc1k_sos_pkt.cc1k_demod_pkts(self,
                                                        callback=rx_callback_cc1k,
                                                        sps=cc1k_sps,
                                                        symbol_rate=cc1k_data_rate,
                                                        p_size=payload_size,
                                                        threshold=-1)
        
        #self.squelch2 = gr.pwr_squelch_cc(50, 1, 0, True)
        keep = gr.keep_one_in_n(gr.sizeof_gr_complex, 13)
        #self.connect((di, 1), keep, self.squelch2, self.packet_receiver_cc1k)
        self.connect((di, 1), keep, self.packet_receiver_cc1k)
Ejemplo n.º 5
0
    def __init__(self, rx_callback_cc2420, rx_callback_cc1k):
        gr.flow_graph.__init__(self)
        cc2420_cordic_freq = 2475000000
        cc2420_data_rate = 2000000
        cc1k_cordic_freq = 434845200
        cc1k_data_rate = 38400
        cc1k_sps = 8
        payload_size = 128
        print "cc2420_cordic_freq = %s" % (
            eng_notation.num_to_str(cc2420_cordic_freq))
        print "cc1k_cordic_freq = %s" % (
            eng_notation.num_to_str(cc1k_cordic_freq))

        # ----------------------------------------------------------------

        self.data_rate = cc2420_data_rate
        self.samples_per_symbol = 2
        self.usrp_decim = int(64e6 / self.samples_per_symbol / self.data_rate)
        self.fs = self.data_rate * self.samples_per_symbol
        payload_size = 128  # bytes

        print "usrp_decim = ", self.usrp_decim
        print "fs = ", eng_notation.num_to_str(self.fs)

        u = usrp.source_c(0, nchan=2)
        u.set_decim_rate(self.usrp_decim)
        self.subdev = (u.db[0][0], u.db[1][0])
        print "Using RX d'board %s" % (self.subdev[0].side_and_name(), )
        print "Using RX d'board %s" % (self.subdev[1].side_and_name(), )
        u.set_mux(0x2301)

        width = 8
        shift = 8
        format = u.make_format(width, shift)
        r = u.set_format(format)

        #this is the cc2420 code
        u.tune(self.subdev[0]._which, self.subdev[0], cc2420_cordic_freq)
        u.tune(self.subdev[1]._which, self.subdev[1], cc1k_cordic_freq)

        u.set_pga(0, 0)
        u.set_pga(1, 0)

        self.u = u

        # deinterleave two channels from FPGA
        di = gr.deinterleave(gr.sizeof_gr_complex)

        # wire up the head of the chain
        self.connect(self.u, di)
        #self.u = gr.file_source(gr.sizeof_gr_complex, 'rx_test.dat')

        # CC2420 receiver
        self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts(
            self,
            callback=rx_callback_cc2420,
            sps=self.samples_per_symbol,
            symbol_rate=self.data_rate,
            threshold=-1)

        self.squelch = gr.pwr_squelch_cc(50, 1, 0, True)
        self.connect((di, 0), self.squelch, self.packet_receiver)

        # CC1K receiver
        gain_mu = 0.002 * self.samples_per_symbol
        self.packet_receiver_cc1k = cc1k_sos_pkt.cc1k_demod_pkts(
            self,
            callback=rx_callback_cc1k,
            sps=cc1k_sps,
            symbol_rate=cc1k_data_rate,
            p_size=payload_size,
            threshold=-1)

        #self.squelch2 = gr.pwr_squelch_cc(50, 1, 0, True)
        keep = gr.keep_one_in_n(gr.sizeof_gr_complex, 13)
        #self.connect((di, 1), keep, self.squelch2, self.packet_receiver_cc1k)
        self.connect((di, 1), keep, self.packet_receiver_cc1k)
    def __init__(self):
        gr.flow_graph.__init__ (self)

        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=first one with a daughterboard)")
        parser.add_option ("-c", "--cordic-freq1", type="eng_float", default=434845200,
                           help="set rx cordic frequency for channel 1 to FREQ", metavar="FREQ")
        parser.add_option ("-d", "--cordic-freq2", type="eng_float", default=434318512,
                           help="set rx cordic frequency for channel 2 to FREQ", metavar="FREQ")
        parser.add_option ("-g", "--gain", type="eng_float", default=0,
                           help="set Rx PGA gain in dB [0,20]")
        (options, args) = parser.parse_args ()
        print "cordic_freq1 = %s" % (eng_notation.num_to_str (options.cordic_freq1))
        print "cordic_freq2 = %s" % (eng_notation.num_to_str (options.cordic_freq2))

        # ----------------------------------------------------------------

        self.data_rate = 38400
        self.samples_per_symbol = 8
        #we sample a band of 4 MHz.
        self.usrp_decim = int (64e6 / 4e6)
        self.decimation = self.usrp_decim / self.samples_per_symbol / self.data_rate
        
        self.fs = self.data_rate * self.samples_per_symbol
        payload_size = 128             # bytes

        print "data_rate = ", eng_notation.num_to_str(self.data_rate)
        print "samples_per_symbol = ", self.samples_per_symbol
        print "usrp_decim = ", self.usrp_decim
        print "decimation = ", self.decimation
        print "fs = ", eng_notation.num_to_str(self.fs)


        if options.cordic_freq1 < options.cordic_freq2:
            self.usrp_freq = options.cordic_freq1
            self.freq_diff = options.cordic_freq1 - options.cordic_freq2
        else:
            self.usrp_freq = options.cordic_freq2
            self.freq_diff = options.cordic_freq2 - options.cordic_freq1

        print "tune USRP to = ", self.usrp_freq
        u = usrp.source_c (0, self.usrp_decim)
        if options.rx_subdev_spec is None:
            options.rx_subdev_spec = pick_subdevice(u)
        u.set_mux(usrp.determine_rx_mux_value(u, options.rx_subdev_spec))

        subdev = usrp.selected_subdev(u, options.rx_subdev_spec)
        print "Using RX d'board %s" % (subdev.side_and_name(),)

        #u.set_rx_freq (0, -options.cordic_freq)
        u.tune(0, subdev, self.usrp_freq)
        u.set_pga(0, options.gain)
        u.set_pga(1, options.gain)

        # Create filter to get actual channels we want
        chan_coeffs = gr.firdes.low_pass (1.0,                # gain
                                          4e6,                # sampling rate
                                          150e3,              # low pass cutoff freq
                                          50e3,                # 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.ddc1 = gr.freq_xlating_fir_filter_ccf(13,       # decimation rate
                                                   chan_coeffs,    # taps
                                                   0,              # frequency translation amount
                                                   4e6)   # input sample rate

        self.ddc2 = gr.freq_xlating_fir_filter_ccf(13,       # decimation rate
                                                   chan_coeffs,    # taps
                                                   self.freq_diff,              # frequency translation amount
                                                   4e6)   # input sample rate


        # receiver
        gain_mu = 0.002*self.samples_per_symbol
        self.packet_receiver1 = cc1k_sos_pkt.cc1k_demod_pkts(self,
                                                        callback=self.rx_callback1,
                                                        sps=self.samples_per_symbol,
                                                        symbol_rate=self.data_rate,
                                                        p_size=payload_size,
                                                        threshold=-1)
        self.packet_receiver2 = cc1k_sos_pkt.cc1k_demod_pkts(self,
                                                        callback=self.rx_callback2,
                                                        sps=self.samples_per_symbol,
                                                        symbol_rate=self.data_rate,
                                                        p_size=payload_size,
                                                        threshold=-1)


        u = gr.file_source(gr.sizeof_gr_complex, 'tx_test.dat')
        self.connect(u, self.ddc1, self.packet_receiver1)
        self.connect(u, self.ddc2, self.packet_receiver2)
        
            
        self.filesink = gr.file_sink(gr.sizeof_gr_complex, 'rx_test.dat')
        #self.connect(u, self.filesink)
        
        if 0 and not(options.no_gui):
            fft_input = fftsink.fft_sink_c (self, panel, title="Input", fft_size=512, sample_rate=self.fs)
            self.connect (u, fft_input)
            vbox.Add (fft_input.win, 1, wx.EXPAND)