# Simultaneous TX/RX Sample Code for RFX (FLEX) 400

**URL:** <https://www.ruby-forum.com/t/simultaneous-tx-rx-sample-code-for-rfx-flex-400/61066>\
**Category:** GNU Radio\
**Created:** [May 19, 2006, 8:27pm UTC](https://www.ruby-forum.com/t/simultaneous-tx-rx-sample-code-for-rfx-flex-400/61066 "2006-05-19T20:27:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rdmiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6f9a4e/32.png) [@rdmiller](https://www.ruby-forum.com/u/rdmiller)\
**Post date:** [May 19, 2006, 8:27pm UTC](https://www.ruby-forum.com/t/simultaneous-tx-rx-sample-code-for-rfx-flex-400/61066/1 "2006-05-19T20:27:54Z")

</div>

Greetings,

I am having an issue receiving signals properly using a single RFX  
(FLEX)  
400. I am using usrp\_siggen.py (with a sinusoid) to transmit via  
“TX/RX” in  
the 450 MHz range, and have verified its functionality via a spectrum  
analyzer. The transmitter (“TX/RX”) is hardwired to the receiver  
(“RX2”)  
via an SMA to SMA cable. I have tried the following:

1. Using usrp\_rx\_cfile.py directly  
==\> This results in incorrect data.
2. Adding the following line to usrp\_rx\_cfile:  
u.select\_rx\_antenna(1)  
==\> This results in an error, as the method (“select\_rx\_antenna”) is  
not  
found.
3. Adding the following line to usrp\_rx\_cfile:  
u.subdev.select\_rx\_antenna(1)  
==\> This also results in an invalid method error.

My question is whether or not any of the above tests should work. If  
not,  
can someone proved some simple sample code to properly receive data  
using  
“RX2” of the RFX 400 while the “TX/RX” port is being used as a  
transmitter?

## Thanks! Rob

View this message in context:  
[http://www.nabble.com/Simultaneous+TX-RX+Sample+Code+for+RFX+(FLEX)+400-t1651751.html#a4474699](http://www.nabble.com/Simultaneous+TX-RX+Sample+Code+for+RFX+%28FLEX%29+400-t1651751.html#a4474699)  
Sent from the GnuRadio forum at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![rdmiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6f9a4e/32.png) [@rdmiller](https://www.ruby-forum.com/u/rdmiller)\
**Post date:** [May 20, 2006, 3:30am UTC](https://www.ruby-forum.com/t/simultaneous-tx-rx-sample-code-for-rfx-flex-400/61066/2 "2006-05-20T03:30:35Z")

</div>

On Fri, May 19, 2006 at 11:26:54AM -0700, rdmiller wrote:

> ==\> This results in incorrect data.  
> 2. Adding the following line to usrp\_rx\_cfile:  
> u.select\_rx\_antenna(1)  
> ==\> This results in an error, as the method (“select\_rx\_antenna”) is not  
> found.  
> 3. Adding the following line to usrp\_rx\_cfile:  
> u.subdev.select\_rx\_antenna(1)  
> ==\> This also results in an invalid method error.

# not tested, but expected to work…

self.subdev.select\_rx\_antenna(‘RX2’)

> My question is whether or not any of the above tests should work. If not,  
> can someone proved some simple sample code to properly receive data using  
> “RX2” of the RFX 400 while the “TX/RX” port is being used as a transmitter?

You’re going to need a serious amount of attenuation (pad).  
Connecting the 100mW transmitter output directly into the Rx input  
port isn’t going to work.

Eric

---

<div class="post-metadata">

**Author:** ![rdmiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6f9a4e/32.png) [@rdmiller](https://www.ruby-forum.com/u/rdmiller)\
**Post date:** [May 21, 2006, 6:02am UTC](https://www.ruby-forum.com/t/simultaneous-tx-rx-sample-code-for-rfx-flex-400/61066/3 "2006-05-21T06:02:37Z")

</div>

Eric,

Thank you very much for the reply. I noticed that I was actually  
modifying  
a very old version of usrp\_rx\_cfile.py (found at  
[http://www.koders.com/python/fidB649E66943F7649C67371CB015D6E5ACAE276523.aspx](http://www.koders.com/python/fidB649E66943F7649C67371CB015D6E5ACAE276523.aspx)).  
I’ve taken a look at the latest version from cvs and have a question  
regarding the proper way to add the call to select\_rx\_antenna( ). It  
appears that the mux value is set based upon user input or another  
method,  
and that this may result in improper operation using RX2. I’ve tried  
setting the rx\_subdev\_spec to ‘RX2’ from the command line argument with  
error. The message is to use ‘A’, ‘A:0’, or ‘A:1’ when using the A side  
of  
the usrp. When trying ‘A:1’, an error also results. So, when I run the  
code I am using ‘A:0’ as the input. I am therefore fearful of having  
bad  
mux values even though the modified code (listed below) runs without  
error  
in terms of creating the data file. My question is whether or not there  
is  
a simple alteration to the code below that will result in using RX2 for  
receiving data while transmitting simultaneously from RX/TX?

Although I am aware that the signal will need to be attenuated severely,  
I  
am unsure what the RF front end of the RFX-400 is spec’d for. With a 20  
dBm  
signal at the TX, I am planning to use anywhere from 40 to 60 dB of  
attenuation. I believe this will give me a -20 to -40 dBm signal at  
RX2.  
This should be acceptable, right? Thanks again for your help, it is  
much  
appreciated.

Best Regards,  
Rob

As a note, the version of code I am now using follows:

========================================  
#!/usr/bin/env python

“”"  
Read samples from the USRP and write to file formatted as binary  
single-precision complex values.

“”"

from gnuradio import gr, eng\_notation  
from gnuradio import audio  
from gnuradio import usrp  
from gnuradio.eng\_option import eng\_option  
from optparse import OptionParser

class my\_graph(gr.flow\_graph):

```
def __init__ (self):
    gr.flow_graph. __init__ (self)

    usage="%prog: [options] output_filename"
    parser = OptionParser(option_class=eng_option, usage=usage)
    parser.add_option("-R", "--rx-subdev-spec", type="subdev",

```

default=(0, 0),  
help=“select USRP Rx side A or B (default=A)”)  
parser.add\_option(“-d”, “–decim”, type=“int”, default=16,  
help=“set fgpa decimation rate to DECIM  
[default=%default]”)  
parser.add\_option(“-f”, “–freq”, type=“eng\_float”,  
default=None,  
help=“set frequency to FREQ”, metavar=“FREQ”)  
parser.add\_option(“-g”, “–gain”, type=“eng\_float”,  
default=None,  
help=“set gain in dB (default is midpoint)”)  
parser.add\_option(“-N”, “–nsamples”, type=“eng\_float”,  
default=None,  
help=“number of samples to collect  
[default=+inf]”)  
(options, args) = parser.parse\_args ()  
if len(args) != 1:  
parser.print\_help()  
raise SystemExit, 1  
filename = args[0]

```
    if options.freq is None:
        parser.print_help()
        sys.stderr.write('You must specify the frequency with -f

```

FREQ\n’);  
raise SystemExit, 1

```
    # build the graph
    self.u = usrp.source_c(decim_rate=options.decim)
    self.dst = gr.file_sink(gr.sizeof_gr_complex, filename)
    if options.nsamples is None:
        self.connect(self.u, self.dst)
    else:
        self.head = gr.head(gr.sizeof_gr_complex, 

```

int(options.nsamples))  
self.connect(self.u, self.head, self.dst)

```
    if options.rx_subdev_spec is None:
        options.rx_subdev_spec = usrp.pick_rx_subdevice(self.u)
    self.u.set_mux(usrp.determine_rx_mux_value(self.u,

```

options.rx\_subdev\_spec))

```
   ##--- addition here ---##
   self.subdev.select_rx_antenna('RX2')

    # determine the daughterboard subdevice we're using
    self.subdev = usrp.selected_subdev(self.u, 

```

options.rx\_subdev\_spec)  
print “Using RX d’board %s” % (self.subdev.side\_and\_name(),)  
input\_rate = self.u.adc\_freq() / self.u.decim\_rate()  
print “USB sample rate %s” %  
(eng\_notation.num\_to\_str(input\_rate))

```
    if options.gain is None:
        # if no gain was specified, use the mid-point in dB
        g = self.subdev.gain_range()
        options.gain = float(g[0]+g[1])/2
    self.subdev.set_gain(options.gain)

    r = self.u.tune(0, self.subdev, options.freq)
    if not r:
        sys.stderr.write('Failed to set frequency\n')
        raise SystemExit, 1

```

# if **name** == ‘ **main** ’: try: my\_graph().run() except KeyboardInterrupt: pass

–  
View this message in context:  
[http://www.nabble.com/Simultaneous+TX-RX+Sample+Code+for+RFX+(FLEX)+400-t1651751.html#a4489360](http://www.nabble.com/Simultaneous+TX-RX+Sample+Code+for+RFX+%28FLEX%29+400-t1651751.html#a4489360)  
Sent from the GnuRadio forum at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![rdmiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6f9a4e/32.png) [@rdmiller](https://www.ruby-forum.com/u/rdmiller)\
**Post date:** [May 21, 2006, 6:14am UTC](https://www.ruby-forum.com/t/simultaneous-tx-rx-sample-code-for-rfx-flex-400/61066/4 "2006-05-21T06:14:51Z")

</div>

On Sat, May 20, 2006 at 08:59:00PM -0700, rdmiller wrote:

> setting the rx\_subdev\_spec to ‘RX2’ from the command line argument with  
> error. The message is to use ‘A’, ‘A:0’, or ‘A:1’ when using the A side of  
> the usrp. When trying ‘A:1’, an error also results. So, when I run the  
> code I am using ‘A:0’ as the input. I am therefore fearful of having bad  
> mux values even though the modified code (listed below) runs without error  
> in terms of creating the data file. My question is whether or not there is  
> a simple alteration to the code below that will result in using RX2 for  
> receiving data while transmitting simultaneously from RX/TX?

The subdevice spec has to do with selecting either the daughterboard  
on the A or B side. It has nothing to do with the selection of the  
TX/RX vs RX2 antenna port. The mux is set up depending on the A vs B  
selection.

Your code looks right. Sorry, not near a USRP to test it right now.

> Although I am aware that the signal will need to be attenuated severely, I  
> am unsure what the RF front end of the RFX-400 is spec’d for. With a 20 dBm  
> signal at the TX, I am planning to use anywhere from 40 to 60 dB of  
> attenuation. I believe this will give me a -20 to -40 dBm signal at RX2.  
> This should be acceptable, right? Thanks again for your help, it is much  
> appreciated.

I’m not sure. Matt’s the guy to answer this (unless it’s already on  
the daughterboard data sheet). He’s at the Dayton Hamvention now 😉

Eric

---

<div class="post-metadata">

**Author:** ![rdmiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6f9a4e/32.png) [@rdmiller](https://www.ruby-forum.com/u/rdmiller)\
**Post date:** [May 23, 2006, 12:41pm UTC](https://www.ruby-forum.com/t/simultaneous-tx-rx-sample-code-for-rfx-flex-400/61066/5 "2006-05-23T12:41:37Z")

</div>

Matt E. wrote:

> TX/RX switch has about 35 dB of isolation. You may get some extra  
> isolation by setting the RX input to RX2 and putting another dummy load  
> there.
> 
> You can also lower the TX power.  
> I thought the TX power allways had to be at maximum for the RFX boards.

greetings,  
Martin

---

<div class="post-metadata">

**Author:** ![rdmiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6f9a4e/32.png) [@rdmiller](https://www.ruby-forum.com/u/rdmiller)\
**Post date:** [May 22, 2006, 7:28pm UTC](https://www.ruby-forum.com/t/simultaneous-tx-rx-sample-code-for-rfx-flex-400/61066/6 "2006-05-22T19:28:32Z")

</div>

> > Although I am aware that the signal will need to be attenuated severely, I  
> > am unsure what the RF front end of the RFX-400 is spec’d for. With a 20 dBm  
> > signal at the TX, I am planning to use anywhere from 40 to 60 dB of  
> > attenuation. I believe this will give me a -20 to -40 dBm signal at RX2.  
> > This should be acceptable, right? Thanks again for your help, it is much  
> > appreciated.

There is enough leakage between the TX and RX side that you won’t need  
to connect them at all. Just put a dummy load on the TX side. The  
TX/RX switch has about 35 dB of isolation. You may get some extra  
isolation by setting the RX input to RX2 and putting another dummy load  
there.

You can also lower the TX power.

Matt

---

<div class="post-metadata">

**Author:** ![rdmiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6f9a4e/32.png) [@rdmiller](https://www.ruby-forum.com/u/rdmiller)\
**Post date:** [May 23, 2006, 5:18pm UTC](https://www.ruby-forum.com/t/simultaneous-tx-rx-sample-code-for-rfx-flex-400/61066/7 "2006-05-23T17:18:42Z")

</div>

On Tue, 2006-05-23 at 12:39 +0200, Martin D. wrote:

> > to connect them at all. Just put a dummy load on the TX side. The  
> > TX/RX switch has about 35 dB of isolation. You may get some extra  
> > isolation by setting the RX input to RX2 and putting another dummy load  
> > there.
> > 
> > You can also lower the TX power.  
> > I thought the TX power allways had to be at maximum for the RFX boards.

I meant that you can change TX power by lowering your signal level  
numerically. TX PGA gain must always be at the max.

Matt
