discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] questions about USRP2 sink block and upconversion


From: alexander levedahl
Subject: Re: [Discuss-gnuradio] questions about USRP2 sink block and upconversion
Date: Wed, 3 Nov 2010 17:53:14 -0400

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/16*scRate
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="" 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="" 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="" const=gr.GR_GAUSSIAN,
                      help="Generate Gaussian random output")
    parser.add_option("--uniform", dest="type", action="" const=gr.GR_UNIFORM,
                      help="Generate Uniform random output")
    parser.add_option("--2tone", dest="type", action="" const="2tone",
                      help="Generate Two Tone signal for IMD testing")
    parser.add_option("--sweep", dest="type", action="" 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="" 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()

reply via email to

[Prev in Thread] Current Thread [Next in Thread]