Questions about USRP2 sink block and upconversion

Hello:

I am still somewhat new to GNU Radio. I am running GNU Radio 3.3.0 under
openSUSE 11.2, and I have two USRP2 boards, each with a WBX
daughterboard. I need some help understanding some fundamental things
about GNU Radio and the USRP2 and upconversion.

I am trying generate a tone at 900.001 MHz (900,001,000 Hz). I am using
GRC to construct a simple flow graph where I have a signal source block
generating a 1 khz cosine at a sample rate of 195.312 khz (=100e6/512),
connected to a USRP2 sink block with the “decimation” parameter set to
512, and with the “frequency” parameter set to 900M. I then look at the
output on a spectrum analyzer. My understanding was that I should see a
clear spike at 900.001 MHz, but I don’t. Instead I see a peak at
899.99701 MHz. What am I doing wrong? I’m using the internal USRP2
clock. Is this happening because the internal clock is good to only
7ppm?

In general, how do I need to setup the frequency of a USRP2 source if I
want to place tones in the spectrum? I thought it was simple
upconversion. If I want to modulate a multitone signal (say with sine
components 1 KHz, 3 khz, and 7 khz) to obtain an upconverted signal with
tones at 901 MHz, 903 MHz, and 907 MHz, then I simply set the
“frequency” parameter of the USRP2 sink to 900 MHz, right? How exactly
does the USRP2 do the upconversion? What exactly does the “frequency”
parameter do?

I would really appreciate any help I could get,
and I appreciate your time.

Steve McMahon

On 11/03/2010 04:00 PM, Steve M. wrote:

Hello:

I am still somewhat new to GNU Radio. I am running GNU Radio 3.3.0 under
openSUSE 11.2, and I have two USRP2 boards, each with a WBX daughterboard. I need
some help understanding some fundamental things about GNU Radio and the USRP2 and
upconversion.

I am trying generate a tone at 900.001 MHz (900,001,000 Hz). I am using GRC to
construct a simple flow graph where I have a signal source block generating a 1
khz cosine at a sample rate of 195.312 khz (=100e6/512), connected to a USRP2 sink
block with the “decimation” parameter set to 512, and with the “frequency”
parameter set to 900M. I then look at the output on a spectrum analyzer. My
understanding was that I should see a clear spike at 900.001 MHz, but I don’t.
Instead I see a peak at 899.99701 MHz. What am I doing wrong? I’m using the
internal USRP2 clock. Is this happening because the internal clock is good to only
7ppm?

There are two sources of error–one, as you’ve observed is the precision
of the reference clock on
the USRP2. And the other is whatever residual measurement error your
Spectrum Analyser has.
Synthesized LOs are only as good as the reference clock, at least from
a frequency-precision
perspective. If you want to do better than that, then you can use an
external 10MHz reference
clock, such as a GPS frequency standard.

This is entirely normal for synthesized RF gear. Measure just about any
commercial radio out there
with a precision measurement device, and there’ll be some residual
frequency error, unless you get
lucky.

It’s usual in telecom systems for there to be some kind of AFC on the
receive side to compensate for
transmit-side frequency error.

In general, how do I need to setup the frequency of a USRP2 source if I want to
place tones in the spectrum? I thought it was simple upconversion. If I want to
modulate a multitone signal (say with sine components 1 KHz, 3 khz, and 7 khz) to
obtain an upconverted signal with tones at 901 MHz, 903 MHz, and 907 MHz, then I
simply set the “frequency” parameter of the USRP2 sink to 900 MHz, right? How
exactly does the USRP2 do the upconversion? What exactly does the “frequency”
parameter do?

The USRP2 takes your quadrature-sampled baseband signal, and
interpolates it up to the required
Tx-side sampling rate. It programs the Tx LO on the daughtercard to
the desired frequency,
and sends it on to the Tx mixer. Sometimes, due to LO frequency step
size limitations on specific
daughtercards, the USRP2 FPGA will use a DUC (Digital Up-converter)
stage to get to
exactly the desired frequency.

I’m not sure whether you meant 901,903 and 907Mhz, or 900.001MHz,
900.003Mhz, and
900.007Mhz.

For purposes of experiment, you can have 3 different signal generators,
add their outputs,
and send the resulting multi-tone baseband stream on to the USRP2.


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

Marcus wrote:

It’s usual in telecom systems for there to be some kind of AFC on the
receive side to compensate for transmit-side frequency error.
Can’t this problem also be solved with a transmit-side correction?

If the “error” in this particular USPR2 LO is about 900MHz -
899.99701MHz = 0.00299 MHz, then won’t telling the USPR2 to modulate to
900.00299 MHz pretty much get the tones to the right place?

I imagine the correction will change with device temperature and age,
and also by intended “center frequency”.

But as a first cut, won’t that work?

– Dan H.

I am having difficulty transmitting anything at all. When I run the
below
script on one USRP2, and then run usrp2_fft.py on another computer with
another USRP2 hooked up to it, that shows nothing. I have the
appropriate
daughterboards to transmit in that frequency range. When I run a
transmit
script on the other computer that came with GNUradio, it works. The
part
that plays the audio works as expected.

Alex

#!/usr/bin/env python

from gnuradio import gr
from gnuradio import usrp2
from gnuradio import audio
from gnuradio import eng_notation
from gnuradio.eng_option import eng_option
from optparse import OptionParser
import math

def build_graph(options, args):
#These are set to 440 and 350
freq0 = options.waveform_freq
freq1 = options.waveform2_freq
#This is the USRP2
sink1 = usrp2.sink_32fc(options.interface,options.mac_addr)
DACRate = sink1.dac_rate()
interp = options.interp
amp = .5
scRate = 50e3
cFreq = 1/16scRate
tWidt = 1/16
scRate
tFreq = 2.6e9
#Sets the tranmsmit center frequency
tx = sink1.set_center_freq(tFreq)
print tx
g = sink1.set_gain(1)
print g

fg = gr.top_block()
ethRate = DACRate/interp
#Frequency generators
src0 = gr.sig_source_f(scRate,gr.GR_SIN_WAVE,int(freq0),amp)
src1 = gr.sig_source_f(scRate,gr.GR_SIN_WAVE,int(freq1),amp)
add0 = gr.add_ff()
#Converts the input samples to complex to transmit to USRP2
f2c = gr.float_to_complex()

#Creates filter for interpolator
chanCoeffs = gr.firdes.low_pass(1.0, scRate, 1000, 3000,
gr.firdes.WIN_HAMMING)
print ethRate/scRate
print DACRate
#Upsamples the input stream to transmit to the USRP2
interp = gr.interp_fir_filter_ccf(int(ethRate/scRate),chanCoeffs)

#Plays the two tones over speakers
sink0 = audio.sink(int(scRate))
fg.connect((src0, 0), (add0, 0))
fg.connect((src1, 0), (add0, 1))
fg.connect(add0, sink0)
fg.connect(add0, f2c)
fg.connect(f2c, interp)
fg.connect(interp, sink1)
return fg
def get_options():
usage="%prog: [options]"

parser = OptionParser(option_class=eng_option, usage=usage)

parser.add_option("-e", "--interface", type="string", 

default=“eth0”,
help=“Use specified Ethernet interface
[default=%default]”)
parser.add_option("-m", “–mac-addr”, type=“string”, default="",
help=“Use USRP2 at specified MAC address
[default=None]”)
parser.add_option("-i", “–interp”, type=“int”, default=16,
metavar=“INTERP”,
help=“Set FPGA interpolation rate of INTERP
[default=%default]”)
parser.add_option("-f", “–tx-freq”, type=“eng_float”, default=None,
help=“Set carrier frequency to FREQ
[default=mid-point]”, metavar=“FREQ”)
parser.add_option("–lo-offset", type=“eng_float”, default=None,
help=“set daughterboard LO offset to OFFSET
[default=hw default]”)
parser.add_option("-g", “–gain”, type=“eng_float”, default=None,
help=“Set TX gain to GAIN [default=mid-point]”)
parser.add_option("-w", “–waveform-freq”, type=“eng_float”,
default=440,
help=“Set baseband waveform frequency to FREQ
[default=%default]”)
parser.add_option("-x", “–waveform2-freq”, type=“eng_float”,
default=350,
help=“Set 2nd waveform frequency to FREQ
[default=%default]”)
parser.add_option("–sine", dest=“type”, action=“store_const”,
const=gr.GR_SIN_WAVE,
help=“Generate a carrier modulated by a complex
sine
wave”, default=gr.GR_SIN_WAVE)
parser.add_option("–const", dest=“type”, action=“store_const”,
const=gr.GR_CONST_WAVE,
help=“Generate a constant carrier”)
parser.add_option("–offset", type=“eng_float”, default=0,
help=“Set waveform phase offset to OFFSET
[default=%default]”)
parser.add_option("–gaussian", dest=“type”, action=“store_const”,
const=gr.GR_GAUSSIAN,
help=“Generate Gaussian random output”)
parser.add_option("–uniform", dest=“type”, action=“store_const”,
const=gr.GR_UNIFORM,
help=“Generate Uniform random output”)
parser.add_option("–2tone", dest=“type”, action=“store_const”,
const=“2tone”,
help=“Generate Two Tone signal for IMD testing”)
parser.add_option("–sweep", dest=“type”, action=“store_const”,
const=“sweep”,
help=“Generate a swept sine wave”)
parser.add_option("-a", “–amplitude”, type=“eng_float”,
default=0.1,
help=“Set output amplitude to AMPL (0.0-1.0)
[default=%default]”, metavar=“AMPL”)
parser.add_option("-v", “–verbose”, action=“store_true”,
default=False,
help=“Use verbose console output
[default=%default]”)

(options, args) = parser.parse_args()

return (options, args)

if name==“main”:
(options, args) = get_options()
fg = build_graph(options, args)
fg.start()
raw_input('Press enter to quit: ')
fg.stop()

On 11/03/2010 05:27 PM, Dan H. wrote:

and also by intended “center frequency”.

But as a first cut, won’t that work?
Well, sure, you could “correct” the tx-side, but since the Tx has no way
of knowing how bad
the Rx side is “out”, it’s better for the Rx side to use something
like AFC, and just let the
Tx “do whatever it’s going to do”.

Particularly when there’s more than one Tx/Rx pair.


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

On 11/03/2010 06:57 PM, Markus Heller M.A. (relix GmbH) wrote:

  • sample rate
  • interpolation on the usrp2

The maximum interpolation rate on the USRP2 is 512, which means that the
narrowest baseband
signal you can squirt over the Ethernet to it is 100Msps/512, or
195312.5Hz.

So, the sample rate for your (complex) signal should be at a minimum,
195312.5Hz, and then
request an interpolation rate of 512 when setting up the USRP2 sink.

Although, it may be “tidier” to use an interpolation of 500, and thus a
sample rate of 200KHz.

Create a 1Khz sinusoidal signal, sampled at 200KHz, send that to your
USRP2, tuned to
10.0000MHz. You should see that on your HF receiver in CW mode,
somewhere around
10.001MHz or so (+/- handwaving).

The interpolation tells the FPGA in the USRP2 how to “expand” the
bandwidth of your signal to
match the fixed sample rate of the DAC that feeds the analog Tx chain.

The sample rate of your signal source had better match what you told the
USRP2 for interpolation,
or your signal won’t be interpreted correctly.

Different types of signals have different inherent bandwidths, and you
chose sample rates and
interpolation rates to “fit” the signal at hand. A typical amateur
radio SSB signal, for example,
is only a couple of Khz wide, but remember that the minimum
bandwidth you can squirt over
the Ethernet, and get interpolated up to the DAC rate is 100Msps/512.
Which means that
narrow-band signals tend to get oversampled by quite a bit inside the
flow-graph before
they end up being presented to the USRP2.


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

I kindof have a similar problem. Guess I havent understood this yet.

I want to generate a very basic signal at 10.000000 MHz. A little up or
down is not relevant, but I want to hear a signal at all. I have a very
sensitive HF receiver right next to my dummy load, so that should work
with a very faint rest.

In GRC I have a signal generator and a USRP2 sink.

Can you please tell me reference values for

  • sample rate
  • interpolation on the usrp2

Is the product of these two required to be 100M? Or 50M?

Thanks in advance for the clarification.

BR
Markus

Am Mittwoch, den 03.11.2010, 17:27 -0400 schrieb Dan H.:

On 11/03/2010 11:11 PM, Markus Heller M.A. (relix GmbH) wrote:

  * Signal source at 1 KHz, amplitude at a minimum of 0.001 - to
    make sure that a bad SWR does no harm. BTW, this is a good
    counter check that you can really influence the output power!
  * USRP2 sink: interpolation 500, frequency 14 MHz

Result: I hear a clear signal at 14.000 MHz, +/- 1 kHz

Thanks very much!

In the spirit of a “conspiracy of Mar[ck]uses”:

http://www.sbrac.org/files/ssb_xmitter.grc

It’s not actually connected to USRP2, but to an FFT sink, but it samples
at 200KHz, so one
could easily replace that FFT block with an USRP2 block.

It uses an audio source sampled at 20KHz, and then uses a bandpass
filter after interpolating
up to 200KHz to pick off either the upper or lower side-bands, which
are limited to a roughly
2.7KHz bandwidth: LSB: -3KHz to -300Hz and USB: 300Hz to 3KHz.

Audio and baseband signal levels will need to be adjusted, etc, but it’s
a good starting point.

It uses a “0Hz carrier”, which happens to work perfectly when you’re
dealing with a
complex baseband signal.


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

Marcus:

Thank you for your reply. Let me ask you another question to make sure
I’m understanding this correctly. Remember, I have a USRP2 board with a
WBX daughterboard. If I construct a flow graph where a signal source
block generates a 7 khz cosine at a sample rate of 200 khz (100e6/500),
and if this cosine is fed into a USRP2 sink block with its “frequency”
parameter set to “900M”, then will I see a spike in the WBX output
spectrum at 907 MHz, or at 893 MHz, or both? (assuming perfect precision
of the internal reference clock on the USRP2) What if it were a sine
instead of a cosine? Thanks again for your help. I really appreciate
your time.

Steve McMahon

Hi Marcus,

great, now I know what was wrong. I didn’t expect my dummy load to be so
safe. It was a real signal lock :slight_smile:

For all the others, here’s a short experiment report:

Here are the parameters:

  * Sample rate 200k
  * Signal source at 1 KHz, amplitude at a minimum of 0.001 - to
    make sure that a bad SWR does no harm. BTW, this is a good
    counter check that you can really influence the output power!
  * USRP2 sink: interpolation 500, frequency 14 MHz

Result: I hear a clear signal at 14.000 MHz, +/- 1 kHz

Thanks very much!

BR & 73s
Markus
DL8RDS

Am Mittwoch, den 03.11.2010, 22:46 -0400 schrieb Marcus D. Leech:

Hi Marcus,

thanks a lot for sending the flowgraph. I completely understand it and I
am very confident that I can get this going. Only thing, I currently
don’t have an external 3,5mm plugged microphone :slight_smile:

BR
Markus
DL8RDS

Am Mittwoch, den 03.11.2010, 23:54 -0400 schrieb Marcus D. Leech:

On 11/04/2010 01:02 AM, Steve M. wrote:

Marcus:

Thank you for your reply. Let me ask you another question to make sure I’m
understanding this correctly. Remember, I have a USRP2 board with a WBX
daughterboard. If I construct a flow graph where a signal source block generates a
7 khz cosine at a sample rate of 200 khz (100e6/500), and if this cosine is fed
into a USRP2 sink block with its “frequency” parameter set to “900M”, then will I
see a spike in the WBX output spectrum at 907 MHz, or at 893 MHz, or both?
(assuming perfect precision of the internal reference clock on the USRP2) What if
it were a sine instead of a cosine? Thanks again for your help. I really
appreciate your time.

Steve McMahon

You’ll see a spectral spike at 900.007Mhz. Regardless of the phase.
You keep making the
“907MHz” mistake in your posts. Remember that upconversion doesn’t
“expand” the frequency
components. So a spectral component at 7Khz will still be at 7Khz
relative to the upconverted
“DC” frequency.

Your complex baseband signal has spectral components that stretch from
-bandwidth/2 to
+bandwidth/2. If you have a component at +7KHz, it’ll still be at
+7Khz
when it’s finished being upconverted.

Interpolation also doesn’t change the relative spacing of spectral
components, only the time-domain
resolution of the samples of those spectral components. So your +7Khz
signal sampled at
200KHz will still be at +7Khz when sampled at 100MHz.

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs