Hi everyone,
I am currently using gnuradio-3.5.2.1. I am trying to adjust
fm_tx_2_daughterboards.py, then it just send out one signal on side A.
The code is like this.
class example_signal_0(gr.hier_block2):
def init(self, sample_rate):
gr.hier_block2.init(self, “example_signal_0”,
gr.io_signature(0, 0, 0),
gr.io_signature(1, 1,
gr.sizeof_gr_complex))
src = gr.sig_source_c (sample_rate, # sample rate
gr.GR_SIN_WAVE, # waveform type
600, # frequency
1.0, # amplitude
0) # DC Offset
self.connect(src, self)
class my_top_block(gr.top_block):
def init(self):
gr.top_block.init(self)
usage="%prog: [options] tx-freq0 tx-freq1"
parser = OptionParser (option_class=eng_option, usage=usage)
parser.add_option("-a", “–args”, type=“string”, default="",
[default=%default]")
parser.add_option("", “–spec”, type=“string”, default=None,
help=“Subdevice of UHD device where appropriate”)
parser.add_option("-A", “–antenna”, type=“string”,
default=None,
help=“select Rx Antenna where appropriate”)
parser.add_option("-s", “–samp-rate”, type=“eng_float”,
default=320e3,
help=“set sample rate [default=%default]”)
parser.add_option("-g", “–gain”, type=“eng_float”,
default=None,
help=“set gain in dB (default is midpoint)”)
(options, args) = parser.parse_args ()
if len(args) != 1:
parser.print_help()
raise SystemExit
else:
freq0 = str_to_num(args[0])
# Set up USRP to transmit on both daughterboards
d = uhd.find_devices(uhd.device_addr(options.args))
uhd_type = d[0].get('type')
stream_args = uhd.stream_args('fc32', channels=range(1))
self.u = uhd.usrp_sink(device_addr=options.args,
stream_args=stream_args)
# Set up USRP system based on type
if(uhd_type == "usrp1"):
self.u.set_subdev_spec("A:AB")
# I try all of the usrp's subdev_spec, but it still doesn't
# work.
tr0 = uhd.tune_request(freq0)
# Use the tune requests to tune each channel
self.set_freq(tr0, 0)
self.usrp_rate = options.samp_rate
self.u.set_samp_rate(self.usrp_rate)
dev_rate = self.u.get_samp_rate()
# build two signal sources, interleave them, amplify and
# connect them to usrp
sig0 = example_signal_0(self.usrp_rate)
intl = gr.interleave(gr.sizeof_gr_complex)
self.connect(sig0, (intl, 0))
# Correct for any difference in requested and actual rates
rrate = self.usrp_rate / dev_rate
resamp = blks2.pfb_arb_resampler_ccf(rrate)
# and wire them up
self.connect(intl, resamp, self.u)
if options.gain is None:
# if no gain was specified, use the mid-point in dB
g = self.u.get_gain_range()
options.gain = float(g.start()+g.stop())/2.0
self.set_gain(options.gain, 0)
# Set the subdevice spec
if(options.spec):
self.u.set_subdev_spec(options.spec, 0)
# Set the antenna
if(options.antenna):
self.u.set_antenna(options.antenna, 0)
def set_freq(self, target_freq, chan):
r = self.u.set_center_freq(target_freq, chan)
print "Tuning channel %s to %sHz" % \
(chan, self.u.get_center_freq(0))
if r:
return True
else:
print " Set Frequency Failed!"
return False
def set_gain(self, gain, chan):
self.u.set_gain(gain, chan)
if name == ‘main’:
try:
my_top_block().run()
except KeyboardInterrupt:
pass
//////////////////////////////////////
I ran with following command:
python fm_tx_2_daughterboards.py -a type=usrp1 -s 3200000 222064000
What I got:
linux; GNU C++ version 4.6.1; Boost_104601; UHD_003.004.000-unknown
– Opening a USRP1 device…
– Using FPGA clock rate of 64.000000MHz…
Tuning channel 0 to 222064000.0Hz
gr_fir_ccf: using SSE
UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
I connected my usrp1 to Spectrum Analyzer, but I didn’t get any signal
from usrp.
I appreciate any help. Thank you very very much.