def configure_cc1k(self):
        #self.disconnect_all()
        cordic_freq = 434845200
        data_rate = 38400
        gain = 0

        print "cordic_freq = %s" % (eng_notation.num_to_str(cordic_freq))

        self.data_rate = data_rate
        self.samples_per_symbol = 8
        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 "fs = ", eng_notation.num_to_str(self.fs)

        self.normal_gain = 8000

        dac_rate = self.u.dac_rate()

        self.interp = int(128e6 / self.samples_per_symbol / self.data_rate)
        print "usrp interp = ", self.interp
        self.fs = 128e6 / self.interp

        self.u.set_interp_rate(self.interp)

        # determine the daughterboard subdevice we're using
        self.u.set_mux(usrp.determine_tx_mux_value(self.u, (1, 0)))
        self.subdev = usrp.selected_subdev(self.u, (1, 0))
        print "Using TX d'board %s" % (self.subdev.side_and_name(), )

        self.u.tune(self.subdev._which, self.subdev, cordic_freq)
        self.u.set_pga(0, gain)
        self.u.set_pga(1, gain)

        # transmitter
        self.packet_transmitter = cc1k_sos_pkt.cc1k_mod_pkts(
            self, spb=self.samples_per_symbol, msgq_limit=2)
        self.amp = gr.multiply_const_cc(self.normal_gain)

        self.connect(self.packet_transmitter, self.amp, self.u)

        self.set_gain(self.subdev.gain_range()[1])  # set max Tx gain
        self.set_auto_tr(True)  # enable Auto Transmit/Receive switching
    def configure_cc1k(self):
        #self.disconnect_all()
        cordic_freq = 434845200
        data_rate = 38400
        gain=0

        print "cordic_freq = %s" % (eng_notation.num_to_str (cordic_freq))

        self.data_rate = data_rate
        self.samples_per_symbol = 8
        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 "fs = ", eng_notation.num_to_str(self.fs)

        self.normal_gain = 8000

        dac_rate = self.u.dac_rate();

        self.interp = int(128e6 / self.samples_per_symbol / self.data_rate)
        print "usrp interp = ", self.interp
        self.fs = 128e6 / self.interp

        self.u.set_interp_rate(self.interp)

        # determine the daughterboard subdevice we're using
        self.u.set_mux(usrp.determine_tx_mux_value(self.u, (1, 0)))
        self.subdev = usrp.selected_subdev(self.u, (1, 0))
        print "Using TX d'board %s" % (self.subdev.side_and_name(),)

        self.u.tune(self.subdev._which, self.subdev, cordic_freq)
        self.u.set_pga(0, gain)
        self.u.set_pga(1, gain)

        # transmitter
        self.packet_transmitter = cc1k_sos_pkt.cc1k_mod_pkts(self, spb=self.samples_per_symbol, msgq_limit=2)
        self.amp = gr.multiply_const_cc (self.normal_gain)

        self.connect(self.packet_transmitter, self.amp, self.u)

        self.set_gain(self.subdev.gain_range()[1])  # set max Tx gain
        self.set_auto_tr(True)                      # enable Auto Transmit/Receive switching
示例#3
0
    def __init__(self):

        parser = OptionParser (option_class=eng_option)
        parser.add_option("-T", "--tx-subdev-spec", type="subdev", default=None,
                          help="select USRP Tx 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.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 "fs = ", eng_notation.num_to_str(self.fs)

        gr.flow_graph.__init__(self)
        self.normal_gain = 8000

        self.u = usrp.sink_c()
        dac_rate = self.u.dac_rate();

        self.interp = int(128e6 / self.samples_per_symbol / self.data_rate)
        print "usrp interp = ", self.interp
        self.fs = 128e6 / self.interp

        self.u.set_interp_rate(self.interp)

        # determine the daughterboard subdevice we're using
        if options.tx_subdev_spec is None:
            options.tx_subdev_spec = usrp.pick_tx_subdevice(self.u)
        self.u.set_mux(usrp.determine_tx_mux_value(self.u, options.tx_subdev_spec))
        self.subdev = usrp.selected_subdev(self.u, options.tx_subdev_spec)
        print "Using TX d'board %s" % (self.subdev.side_and_name(),)

        self.u.tune(self.subdev._which, self.subdev, options.cordic_freq)
        self.u.set_pga(0, options.gain)
        self.u.set_pga(1, options.gain)

        # transmitter
        self.packet_transmitter = cc1k_sos_pkt.cc1k_mod_pkts(self, spb=self.samples_per_symbol, msgq_limit=2)
        self.amp = gr.multiply_const_cc (self.normal_gain)
        self.filesink = gr.file_sink(gr.sizeof_gr_complex, 'tx_test.dat')
        
        self.connect(self.amp, self.filesink)
        self.connect(self.packet_transmitter, self.amp, self.u)

        self.set_gain(self.subdev.gain_range()[1])  # set max Tx gain
        self.set_auto_tr(True)                      # enable Auto Transmit/Receive switching
    def __init__(self):

        parser = OptionParser (option_class=eng_option)
        parser.add_option("-T", "--tx-subdev-spec", type="subdev", default=None,
                          help="select USRP Tx side A or B (default=first one with a daughterboard)")
        parser.add_option ("-c", "--cordic-freq1", type="eng_float", default=434845200,
                           help="set Tx cordic frequency 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
        self.channel_fs = self.data_rate * self.samples_per_symbol
        self.fs = 4e6
        payload_size = 128             # bytes

        print "data_rate = ", eng_notation.num_to_str(self.data_rate)
        print "samples_per_symbol = ", self.samples_per_symbol
        print "fs = ", eng_notation.num_to_str(self.fs)
        
        gr.flow_graph.__init__(self)
        self.normal_gain = 8000

        self.u = usrp.sink_c()
        dac_rate = self.u.dac_rate();

        self.interp = int(dac_rate / self.fs )
        print "usrp interp = ", self.interp

        self.u.set_interp_rate(self.interp)

        # determine the daughterboard subdevice we're using
        if options.tx_subdev_spec is None:
            options.tx_subdev_spec = usrp.pick_tx_subdevice(self.u)
        self.u.set_mux(usrp.determine_tx_mux_value(self.u, options.tx_subdev_spec))
        self.subdev = usrp.selected_subdev(self.u, options.tx_subdev_spec)
        print "Using TX d'board %s" % (self.subdev.side_and_name(),)

        if options.cordic_freq1 < options.cordic_freq2:
            self.usrp_freq = options.cordic_freq1
            self.freq_diff = options.cordic_freq2 - options.cordic_freq1
        else:
            self.usrp_freq = options.cordic_freq2
            self.freq_diff = options.cordic_freq1 - options.cordic_freq2
        print "freq_diff = ", eng_notation.num_to_str(self.freq_diff)

        self.u.tune(self.subdev._which, self.subdev, self.usrp_freq)
        print "tune USRP to = ", eng_notation.num_to_str(self.usrp_freq)
        self.u.set_pga(0, options.gain)
        self.u.set_pga(1, options.gain)

        interp_factor = int(self.fs / self.channel_fs)
        quad_rate = self.fs
        print "interp_factor = ", interp_factor
        
        # Create filter for the interpolation
        interp_taps = gr.firdes.low_pass (interp_factor,   # gain
                                          self.channel_fs*interp_factor,       # Fs
                                          self.channel_fs/2, # low pass cutoff freq
                                          self.channel_fs*0.1,# width of trans. band
                                          gr.firdes.WIN_HANN) #filter type

        print "len(interp_taps) =", len(interp_taps)

        self.interpolator1 = gr.interp_fir_filter_ccc(interp_factor, interp_taps)
        self.interpolator2 = gr.interp_fir_filter_ccc(interp_factor, interp_taps)

        self.multiplicator = gr.multiply_cc()

        self.adder = gr.add_cc()
        
        self.sin = gr.sig_source_c(self.channel_fs * interp_factor, gr.GR_SIN_WAVE, self.freq_diff, 1, complex(0, 0))

        # transmitter
        self.packet_transmitter1 = cc1k_sos_pkt.cc1k_mod_pkts(self, spb=self.samples_per_symbol, msgq_limit=2)
        #self.packet_transmitter2 = cc1k_sos_pkt.cc1k_mod_pkts(self, spb=self.samples_per_symbol, msgq_limit=2)

        self.amp = gr.multiply_const_cc (self.normal_gain)
        self.filesink = gr.file_sink(gr.sizeof_gr_complex, 'tx_test.dat')
        self.filesink2 = gr.file_sink(gr.sizeof_gr_complex, 'tx_test2.dat')
        self.filesink3 = gr.file_sink(gr.sizeof_gr_complex, 'tx_test3.dat')

        # interpolate the two transmitters
        self.connect(self.packet_transmitter1, self.interpolator1)
        #self.connect(self.packet_transmitter2, self.interpolator2)
        # upconvert the first transmitter)
        self.connect(self.interpolator1, (self.multiplicator, 1))
        self.connect(self.sin, (self.multiplicator, 0))
        # add the two signals
        #self.connect(self.multiplicator, (self.adder, 0))
        #self.connect(self.interpolator2, (self.adder, 1))
        # send the signal to the USRP
        self.connect(self.interpolator1, self.amp, self.filesink)
        self.connect(self.multiplicator, self.filesink2)
        self.connect(self.sin, self.filesink3)
        
        self.set_gain(self.subdev.gain_range()[1])  # set max Tx gain
        self.set_auto_tr(True)                      # enable Auto Transmit/Receive switching
示例#5
0
    def __init__(self):

        parser = OptionParser(option_class=eng_option)
        parser.add_option(
            "-T",
            "--tx-subdev-spec",
            type="subdev",
            default=None,
            help=
            "select USRP Tx side A or B (default=first one with a daughterboard)"
        )
        parser.add_option("-c",
                          "--cordic-freq1",
                          type="eng_float",
                          default=434845200,
                          help="set Tx cordic frequency 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
        self.channel_fs = self.data_rate * self.samples_per_symbol
        self.fs = 4e6
        payload_size = 128  # bytes

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

        gr.flow_graph.__init__(self)
        self.normal_gain = 8000

        self.u = usrp.sink_c()
        dac_rate = self.u.dac_rate()

        self.interp = int(dac_rate / self.fs)
        print "usrp interp = ", self.interp

        self.u.set_interp_rate(self.interp)

        # determine the daughterboard subdevice we're using
        if options.tx_subdev_spec is None:
            options.tx_subdev_spec = usrp.pick_tx_subdevice(self.u)
        self.u.set_mux(
            usrp.determine_tx_mux_value(self.u, options.tx_subdev_spec))
        self.subdev = usrp.selected_subdev(self.u, options.tx_subdev_spec)
        print "Using TX d'board %s" % (self.subdev.side_and_name(), )

        if options.cordic_freq1 < options.cordic_freq2:
            self.usrp_freq = options.cordic_freq1
            self.freq_diff = options.cordic_freq2 - options.cordic_freq1
        else:
            self.usrp_freq = options.cordic_freq2
            self.freq_diff = options.cordic_freq1 - options.cordic_freq2
        print "freq_diff = ", eng_notation.num_to_str(self.freq_diff)

        self.u.tune(self.subdev._which, self.subdev, self.usrp_freq)
        print "tune USRP to = ", eng_notation.num_to_str(self.usrp_freq)
        self.u.set_pga(0, options.gain)
        self.u.set_pga(1, options.gain)

        interp_factor = int(self.fs / self.channel_fs)
        quad_rate = self.fs
        print "interp_factor = ", interp_factor

        # Create filter for the interpolation
        interp_taps = gr.firdes.low_pass(
            interp_factor,  # gain
            self.channel_fs * interp_factor,  # Fs
            self.channel_fs / 2,  # low pass cutoff freq
            self.channel_fs * 0.1,  # width of trans. band
            gr.firdes.WIN_HANN)  #filter type

        print "len(interp_taps) =", len(interp_taps)

        self.interpolator1 = gr.interp_fir_filter_ccc(interp_factor,
                                                      interp_taps)
        self.interpolator2 = gr.interp_fir_filter_ccc(interp_factor,
                                                      interp_taps)

        self.multiplicator = gr.multiply_cc()

        self.adder = gr.add_cc()

        self.sin = gr.sig_source_c(self.channel_fs * interp_factor,
                                   gr.GR_SIN_WAVE, self.freq_diff, 1,
                                   complex(0, 0))

        # transmitter
        self.packet_transmitter1 = cc1k_sos_pkt.cc1k_mod_pkts(
            self, spb=self.samples_per_symbol, msgq_limit=2)
        #self.packet_transmitter2 = cc1k_sos_pkt.cc1k_mod_pkts(self, spb=self.samples_per_symbol, msgq_limit=2)

        self.amp = gr.multiply_const_cc(self.normal_gain)
        self.filesink = gr.file_sink(gr.sizeof_gr_complex, 'tx_test.dat')
        self.filesink2 = gr.file_sink(gr.sizeof_gr_complex, 'tx_test2.dat')
        self.filesink3 = gr.file_sink(gr.sizeof_gr_complex, 'tx_test3.dat')

        # interpolate the two transmitters
        self.connect(self.packet_transmitter1, self.interpolator1)
        #self.connect(self.packet_transmitter2, self.interpolator2)
        # upconvert the first transmitter)
        self.connect(self.interpolator1, (self.multiplicator, 1))
        self.connect(self.sin, (self.multiplicator, 0))
        # add the two signals
        #self.connect(self.multiplicator, (self.adder, 0))
        #self.connect(self.interpolator2, (self.adder, 1))
        # send the signal to the USRP
        self.connect(self.interpolator1, self.amp, self.filesink)
        self.connect(self.multiplicator, self.filesink2)
        self.connect(self.sin, self.filesink3)

        self.set_gain(self.subdev.gain_range()[1])  # set max Tx gain
        self.set_auto_tr(True)  # enable Auto Transmit/Receive switching