Hi

I am having some problems with the USRP2 not sending back to the PC both the
real and complex parts of the receive signal. I get the real component of
the signal but the complex part is just zeros. The signal that is being
receive is transmitted from the same USRP2 board. I am using the Basic RX &
TX boards, they are connected by two cables. I have test the Basic TX board
by pugging it into a scope and I get both wave forms out. I have attached a
copy of my code, it generates 1024 sample long chirp which is repeated every
second. It then writes only the first 256 000 samples to a file.

I suspected that there is a flag I have missed during the start up of the
USRP2 but I can not find it the documentation I have. Any help would be
great.

Regards

Alan Jones
#!/usr/bin/env python
##################################################
# Gnuradio Python Flow Graph
# Title: Chirp Test
# Author: Alan Jones
# Generated: Mon Dec  6 10:27:37 2010
##################################################

from gnuradio import eng_notation
from gnuradio import gr
from gnuradio import usrp2
from gnuradio.eng_option import eng_option
from gnuradio.gr import firdes
from grc_gnuradio import wxgui as grc_wxgui
from optparse import OptionParser
import math
import wx
import sys
import Numeric

class Chirp_Test(grc_wxgui.top_block_gui):

	def __init__(self):
		grc_wxgui.top_block_gui.__init__(self, title="Chirp Test")
		_icon_path = "/home/alan/.local/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Variables
		##################################################
		self.samp_rate = samp_rate = 32000
		self.fs = fs = (100e6/samp_rate)/8
		self.nsamples = nsamples = int(256e3)
		self.k = k = 2*math.pi*samp_rate/fs
		self.Min_Freq = Min_Freq = 39e3
		self.Max_Freq = Max_Freq = 41e3
		self.File_name = File_name = "./Chirp_Data_128000_2.bin"
		self.Chirp_Length = Chirp_Length = int(1024)

		vec1 = Numeric.zeros(samp_rate)
		for x in range (Chirp_Length):
			vec1 [x] = 0.000032*(Min_Freq + x * ((Max_Freq - Min_Freq)/Chirp_Length))

		##################################################
		# Blocks
		##################################################
		self.gr_file_sink_0 = gr.file_sink(gr.sizeof_gr_complex*1, File_name)
		self.gr_frequency_modulator_fc_0 = gr.frequency_modulator_fc(k)
		self.gr_head_0 = gr.head(gr.sizeof_gr_complex*1, int(nsamples))
		self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((14, ))
		self.gr_vector_source_x_0 = gr.vector_source_f(vec1, True, 1)
		self.usrp2_sink_xxxx_0 = usrp2.sink_32fc("eth1")
		self.usrp2_sink_xxxx_0.set_interp(int(100e6)/samp_rate)
		self.usrp2_sink_xxxx_0.set_center_freq(0)
		self.usrp2_sink_xxxx_0.set_gain(10)
		self.usrp2_source_xxxx_0 = usrp2.source_32fc("eth1")
		self.usrp2_source_xxxx_0.set_decim(int(100e6)/samp_rate)
		self.usrp2_source_xxxx_0.set_center_freq(0)
		self.usrp2_source_xxxx_0.set_gain(100)

		rx_subdev_spec = self.usrp2_source_xxxx_0.daughterboard_id ();
		tx_subdev_spec = self.usrp2_sink_xxxx_0.daughterboard_id ();
		
		print "TX"
		print tx_subdev_spec
		print "RX"
		print rx_subdev_spec

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_vector_source_x_0, 0), (self.gr_frequency_modulator_fc_0, 0))
		self.connect((self.gr_frequency_modulator_fc_0, 0), (self.usrp2_sink_xxxx_0, 0))
		self.connect((self.usrp2_source_xxxx_0, 0), (self.gr_multiply_const_vxx_0, 0))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_head_0, 0))
		self.connect((self.gr_head_0, 0), (self.gr_file_sink_0, 0))

	def set_samp_rate(self, samp_rate):
		self.samp_rate = samp_rate
		self.set_fs((100e6/self.samp_rate)/8)
		self.set_k(2*math.pi*self.samp_rate/self.fs)
		self.usrp2_sink_xxxx_0.set_interp(100000000/self.samp_rate)
		self.usrp2_source_xxxx_0.set_decim(int(100e6)/self.samp_rate)

	def set_fs(self, fs):
		self.fs = fs
		self.set_k(2*math.pi*self.samp_rate/self.fs)

	def set_nsamples(self, nsamples):
		self.nsamples = nsamples

	def set_k(self, k):
		self.k = k

	def set_Min_Freq(self, Min_Freq):
		self.Min_Freq = Min_Freq

	def set_Max_Freq(self, Max_Freq):
		self.Max_Freq = Max_Freq

	def set_File_name(self, File_name):
		self.File_name = File_name

if __name__ == '__main__':
	parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
	(options, args) = parser.parse_args()
	tb = Chirp_Test()
	tb.Run(True)

_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to