I want to use a sub usrp board to realize transmitting and receiving
simultaneously. But I met some problems. Forexample, at first i
generated a sin signal generated by gr.sig_source_c. And then I
connected it to usrp sink. At last, the signal i recieved from usrp
source is very different from the signal i generated. at least the
frequency changed a lot.
so i am confused wheather i can user one piece of sub board to realize
transmitting and receiving simultaneously.
my code is as follows
#!/usr/bin/env python
from gnuradio import gr, gru, blks2
from gnuradio import usrp
from gnuradio.wxgui import stdgui2, fftsink2, scopesink2
from gnuradio.eng_option import eng_option
from optparse import OptionParser
import wx
import sys
_dac_rate = 128e6
if_rate=128e4
class test_graph (stdgui2.std_top_block):
def init(self, frame, panel, vbox, argv):
stdgui2.std_top_block.init(self, frame, panel, vbox, argv)
parser = OptionParser (option_class=eng_option)
(options, args) = parser.parse_args ()
decim=8
interp = int(_dac_rate/if_rate)
utx =usrp.sink_c(which=0, interp_rate=64)
subdev1=usrp.pick_tx_subdevice(utx)
utx.set_mux(usrp.determine_tx_mux_value(utx, subdev1))
subdev_tx = usrp.selected_subdev(utx, subdev1)
freq=900000000
# usrp.tune(self._usrp, self._subdev.which(), self._subdev, freq)
tr=utx.tune(0, subdev_tx,freq)
if not (tr):
print "tx freq fail"
else:
print "tx freq is ok"
gain = float(subdev_tx.gain_range()[1]) # Max TX gain
subdev_tx.set_gain(gain)
subdev_tx.set_enable(True)
urx = usrp.source_c(which=0, decim_rate=decim)
subdev2=usrp.pick_rx_subdevice(urx)
urx.set_mux(usrp.determine_rx_mux_value(urx, subdev2))
subdev_rx = usrp.selected_subdev(urx, subdev2)
tr=urx.tune(0, subdev_rx,freq)
if not (tr):
print "rx freq fail"
else:
print "rx freq is ok"
s_rate = urx.adc_freq() / urx.decim_rate()
src = gr.sig_source_c (if_rate, gr.GR_SIN_WAVE, 800, 1)
fft = fftsink2.fft_sink_c(frame,
fft_size=1024,sample_rate=s_rate)
fft.win.set_baseband_freq(freq)
# scop = scopesink2.scope_sink_c(frame, sample_rate=s_rate)
vbox.Add(fft.win,1,wx.EXPAND)
thr = gr.throttle(gr.sizeof_gr_complex, if_rate)
#self.connect(src,thr,scop)
self.connect(src,thr,utx)
self.connect(urx,fft)
def main ():
app = stdgui2.stdapp (test_graph, “Test DFT filterbank”)
app.MainLoop ()
if name == ‘main’:
main ()