discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss-gnuradio] Re: 2 TVRx Boards on 1 USRP


From: Aadil Volkwin
Subject: [Discuss-gnuradio] Re: 2 TVRx Boards on 1 USRP
Date: Mon, 17 Mar 2008 22:37:15 +0200

For anyone with a similar predicament, the sillyness lies in tuning the second tuner to the incorrect channel.

Fix this and you'll be on your way.

Aadil


Hi,

I am trying to use 1 USRP with two TVRx daughter boards to capture Separate
FM signals and write them to file.

I get a noisy signal. I hope someone can tell me what i've done wrong. I
can't see the error.

I have included the code that i'm using. it's built from the
usrp_rx_cfile.py
---------------------------------------------------------------------------------------------------

class my_graph(gr.flow_graph):

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

        usage="%prog: [options] output_filename0 output_filename1 "
        parser = OptionParser(option_class=eng_option, usage=usage)
        parser.add_option("-R", "--rx-subdev-spec0", type="subdev",
default=None,
                        help="first channel select USRP Rx side A or B
(default=A)")
        parser.add_option("-r", "--rx-subdev-spec1", type="subdev",
default=None,
                        help="second channel select USRP Rx side A or B
(default=A)")
        parser.add_option("-d", "--decim", type="int", default=128,
                        help="set fgpa decimation rate to DECIM
[default=%default]")
        parser.add_option("-f", "--freq", type="eng_float", default=89e6,
                        help="set frequency to FREQ", metavar="FREQ")
        parser.add_option("-g", "--gain", type="eng_float", default=None,
                        help="set gain in dB (default is midpoint)")
        parser.add_option("-N", "--nsamples", type="eng_float",
default=9600000,
                        help="number of samples to collect
[default=9600000]")
        parser.add_option("-t", "--time", type="eng_float", default=0,
                        help="length of recording in seconds [default=0]")

        (options, args) = parser.parse_args ()
        if len(args) != 2:
            parser.print_help()
            raise SystemExit, 1

        filename0 = args[0]
        filename1 = args[1]

        decim_rate = options.decim

        if options.time:
            options.nsamples = int(float(options.time) * 64e6 /
float(decim_rate))
        else:
            options.time = float(options.nsamples / (64e6 /
float(decim_rate)) )

        if options.freq is None:
            parser.print_help()
            sys.stderr.write('You must specify the frequency with -f
FREQ\n');
            raise SystemExit, 1

        # build the graph

        self.u = usrp.source_c(decim_rate = options.decim, nchan = 2)

        self.head0 = gr.head(gr.sizeof_gr_complex, int(options.nsamples ))
        self.head1 = gr.head(gr.sizeof_gr_complex, int(options.nsamples ))

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

        self.dst0 = gr.file_sink(gr.sizeof_gr_complex, filename0)
        self.dst1 = gr.file_sink(gr.sizeof_gr_complex, filename1)

        # wire up the head of the chain
        self.connect(self.u, self.di)

        self.connect((self.di,0), self.head0, self.dst0)
        self.connect((self.di,1), self.head1, self.dst1)

        if options.rx_subdev_spec0 is None:
            options.rx_subdev_spec0 = (0,0)
        if options.rx_subdev_spec1 is None:
            options.rx_subdev_spec1 = (1,0)

        mux_val0 = usrp.determine_rx_mux_value(self.u,
options.rx_subdev_spec0)
        mux_val1 = usrp.determine_rx_mux_value(self.u,
options.rx_subdev_spec1)

        mux_val0 |= (mux_val1 <<  8) & 0xff00

        self.u.set_mux(mux_val0)

        # determine the daughterboard subdevice we're using
        self.subdev0 = usrp.selected_subdev(self.u, options.rx_subdev_spec0)
        print "Using RX d'board %s" % (self.subdev0.side_and_name(),)
        self.subdev1 = usrp.selected_subdev(self.u, options.rx_subdev_spec1)
        print "Using RX d'board %s" % (self.subdev1.side_and_name(),)

        input_rate = self.u.adc_freq() / self.u.decim_rate()
        print "USB sample rate: %s" % (eng_notation.num_to_str(input_rate))

        print "Freq is set to: %s" % (eng_notation.num_to_str(options.freq))

        print "Recording time is: %ss" % (options.time)

        print "Mux value is: %x" % (mux_val0 & 65535)

        if options.gain is None:
            # if no gain was specified, use the mid-point in dB
            g0 = self.subdev0.gain_range()
            g1 = self.subdev1.gain_range()
            options.gain = float(g0[0]+g0[1])/2


        self.subdev0.set_gain(options.gain)
        self.subdev1.set_gain(options.gain)

        r0 = self.u.tune(0, self.subdev0, options.freq)
        r1 = self.u.tune(0, self.subdev1, options.freq)

        if not r0:
            sys.stderr.write('Failed to set frequency\n')
            raise SystemExit, 1

        if not r1:
            sys.stderr.write('Failed to set frequency\n')
            raise SystemExit, 1


if __name__ == '__main__':
    try:
        my_graph().run()
    except KeyboardInterrupt:
        pass
------------------------------------------------------------------------------------------------------


thanks,

Aadil



reply via email to

[Prev in Thread] Current Thread [Next in Thread]