Monday, February 27, 2012

Re: [Discuss-gnuradio] uhd running parallel tx/rx flowgraphs

#!/usr/bin/env python
##################################################
# Gnuradio Python Flow Graph
# Title: Burst Tagger Uhd
# Generated: Mon Feb 27 20:52:20 2012
##################################################

from gnuradio import eng_notation
from gnuradio import gr
from gnuradio import uhd
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 wx

class burst_tagger_uhd(grc_wxgui.top_block_gui):

def __init__(self):
grc_wxgui.top_block_gui.__init__(self, title="Burst Tagger Uhd")
_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

##################################################
# Variables
##################################################
self.samp_rate = samp_rate = 250e3

##################################################
# Blocks
##################################################
self.uhd_usrp_sink_0 = uhd.usrp_sink(
device_addr="",
stream_args=uhd.stream_args(
cpu_format="fc32",
channels=range(1),
),
)
self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
self.uhd_usrp_sink_0.set_center_freq(0, 0)
self.uhd_usrp_sink_0.set_gain(0, 0)
self.gr_sig_source_x_0_0 = gr.sig_source_s(samp_rate, gr.GR_SQR_WAVE, 10, 1, 0)
self.gr_sig_source_x_0 = gr.sig_source_c(samp_rate, gr.GR_COS_WAVE, 25e3, 1, 0)
self.gr_burst_tagger_0 = gr.burst_tagger(gr.sizeof_gr_complex)
self.gr_burst_tagger_0.set_true_tag("tx_eob",True)
self.gr_burst_tagger_0.set_false_tag("tx_sob",True)

##################################################
# Connections
##################################################
self.connect((self.gr_burst_tagger_0, 0), (self.uhd_usrp_sink_0, 0))
self.connect((self.gr_sig_source_x_0, 0), (self.gr_burst_tagger_0, 0))
self.connect((self.gr_sig_source_x_0_0, 0), (self.gr_burst_tagger_0, 1))

def get_samp_rate(self):
return self.samp_rate

def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.uhd_usrp_sink_0.set_samp_rate(self.samp_rate)
self.gr_sig_source_x_0.set_sampling_freq(self.samp_rate)
self.gr_sig_source_x_0_0.set_sampling_freq(self.samp_rate)

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

On 27/02/12 08:30 PM, George Nychis wrote:

It's be good if you can chime in here, Josh :)

It seems like this is something that should be fixed about tunnel.py in future GNU Radio releases for use with UHD.
I've attached a skeletal piece of GRC that uses the "Burst Tagger" block with a 10Hz trigger input to insert
  tx_eob/tx_sob tags into the stream.  I'm not sure whether this will have the desired effect or not, but at
  least in theory it should.


 

I'm trying to do my fair share of research here and tackle it. If what you say is true, Marcus, the control I need is over the TX chain. 

I did a bunch of reading through the UHD docs here:

I see various controls using tx_streamer and tx_metadata_t to use tags to control samples to be part of a burst. Like, marking the start and end of my TX burst of samples which can construct a packet. 

No prob, I can do that. But it seems like there needs to be some sort of UHD stream command which turns the TX chain in to an "on-demand" chain and not continuously streaming. On the other hand, I would like RX to be continuous. 

I see the RX control to specify stream controls here:
http://files.ettus.com/uhd_docs/doxygen/html/structuhd_1_1stream__cmd__t.html

That is clearly documented as control of samples to the host to be continuous or not. 

However, I don't see that same control for the TX stream. Tx_metadata_t and t_streamer control the bursts, but don't seem to control the overall stream? Maybe I am missing something. 

On Sunday, February 26, 2012, Marcus D. Leech wrote:
On 02/26/2012 08:54 PM, George Nychis wrote:


On Sun, Feb 26, 2012 at 5:01 PM, Marcus D. Leech <mleech@ripnet.com> wrote:
On 02/26/2012 02:29 PM, Apurv Bhartia wrote:
Its an XCVR2450, but I do *not* start any 'packet' transmissions. All I do, is to start both the flowgraphs, and just listen for packets.

In which case, the TX side is running--even if you aren't sending any *data* bits, it's still transmitting, and blocking the receiver.

You'll have to get more sophisticated about half-duplex flow management, using tagging to tell UHD to turn on/off the TX side.

Josh probably has better words of wisdom on this than I.

Hi Marcus,

I'm working with Apurv, so I'm going to chime in here :)   

I tried doing some searching on the mailing list, but I wasn't really able to find much on this.  I also thought that auto tr would handle this.  I found a post from Josh on the mailing list that said Auto TR is always enabled in UHD.  



Yes, it is enabled in UHD.  But since Gnu Radio is a *streaming* model, you need to take special measures to control TX from within a
  Gnu Radio flow-graph.  YOu need to insert a tag in the stream to control the transmitter, otherwise, you'll be continuously streaming.

What you do is insert a burst-tagger into your stream, and set it to send the appropriate tags for UHD into the stream using the trigger
  input.  I just can't off the top of my head, remember what those stream tags are at the moment.  But the basic issue is that Gnu Radio
  uses a streaming model, and while UHD itself (at the C++ level) has fine-grianed control over transmitter functions, etc, gr-uhd doesn't
  directly expose any of that, because there's just not mechanism within Gnu Radio to expose that stuff.  The stream tagging, however,
  does allow you to control the transmitter state.  In the particular case of the XCVR2450, the hardware is physically incapable of
  TX and RX at the same time.


--  Marcus Leech Principal Investigator Shirleys Bay Radio Astronomy Consortium http://www.sbrac.org     


--  Principal Investigator Shirleys Bay Radio Astronomy Consortium http://www.sbrac.org

No comments:

Post a Comment