Hi All,
I am running gnu radio-3.2.2 now. I haven’t used gnuradio in a while
(since 2007). I had a old gnuradio code (from a project) that generated
a
signal repeatedly until I ask it to stop, and the source came from a
vector
source defined in the program (please see below). I know “flow_graph”
has
been changed to “top_block”. I made that change, rest of the old code
didn’t
complain while compiling. However, it does not produce the signal I
would
like it to produce (checked it on the spectrum analyzer). Could you
please
tell me what else, I need to change. It used to run perfectly in the old
version of gnuradio (around May 2007). Thank you for your time.
===========================The code with flow_graph changed into
top_block==============================
from datetime import datetime
from gnuradio import gr,usrp
from gnuradio import eng_notation
from optparse import OptionParser
from gnuradio.eng_option import eng_option
class my_top_block(gr.top_block):
def init(self, my_carrier, period, pulse, seq, interp=64):
global dest, src, sample_rate
global carrier
global BARK, QAM
global vector
self.BARK = 2
self.QAM = 1
carrier = my_carrier
self.vector = []
gr.top_block.__init__(self)
nchan = 1
duc0 = 5e6
self.dest = usrp.sink_c (0, interp, nchan)
self.sample_rate = self.dest.dac_freq() / interp
self.src = None
self.dest.set_tx_freq(0, duc0)
self.dest.set_pga(0,0)
max = 2**15 - 1
min = -max
if seq == self.QAM:
n = 4
else:
n = 11
nWidth = int(pulse*(self.sample_rate/1e6))
nPulse = int(nWidth/n)
nPeriod = int(period*(self.sample_rate/1e6))
nIdle = nPeriod - nPulse
if seq == self.QAM:
for i in range(nPulse):
self.vector.append(complex(max,max))
self.vector.append(complex(max,min))
self.vector.append(complex(min,max))
self.vector.append(complex(min,min))
else:
for i in range(nPulse):
self.vector.append(complex(max,0))
self.vector.append(complex(min,0))
self.vector.append(complex(max,0))
self.vector.append(complex(max,0))
self.vector.append(complex(min,0))
self.vector.append(complex(max,0))
self.vector.append(complex(max,0))
self.vector.append(complex(max,0))
self.vector.append(complex(min,0))
self.vector.append(complex(min,0))
self.vector.append(complex(min,0))
for i in range(nIdle):
self.vector.append(complex(0,0))
self.buildGraph()
def buildGraph(self):
self.disconnect_all()
self.src = gr.vector_source_c(self.vector, True)
self.connect(self.src, self.dest)
# Get an instance of daughterboard
dboard = usrp.selected_subdev(self.dest, (0,0))
dboard.set_gain(90)
# Display the name of the daughterboard
print "Signal will be generate by :", dboard.side_and_name()
# The parameters are which motherboard, daughterboard, the
carrier
frequence
rf = self.dest.tune(dboard.which(), dboard, carrier)
if rf:
print "Carrier :",carrier
else:
print "The range of the daugtherboard's frequency is :", \
eng_notation.num_to_str(dboard.freq_range()[0]), "-", \
eng_notation.num_to_str(dboard.freq_range()[1])
raise SystemExit
self.start()
if name == “main”:
parser = OptionParser (option_class=eng_option)
parser.add_option ("-p", “–pulse-width”, type=“int”, default=35,
help=“pulse width of jamming signal in
microseconds”)
parser.add_option ("-j", “–period”, type=“int”, default=400,
help=“idle width of jamming signal in
microseconds”)
parser.add_option ("-c", “–carrier”, type=“float”, default=2.462e9,
help=“the carrier frequency”)
parser.add_option ("–qam", dest=“seq”, action=“store_const”,
const=1,
help=“generate QAM signals”, default = 1)
parser.add_option ("–barker", dest=“seq”, action=“store_const”,
const=2,
help=“generate a BARKER sequence”)
(options, args) = parser.parse_args ()
if len(args) != 0:
parser.print_help()
raise SystemExit
g = my_top_block(options.carrier, options.period,
options.pulse_width,
options.seq)
print options
raw_input("Hit enter to stop: ")
g.stop()