General question concerning usrp & audio

hHey!

I am just playing around with gnuradio and the usrp stuff and want to
achieve the following:

file1.py

[…]
self.u = usrp.sink_c(0, 64)
self.src gr.sig_source_c(48000, gr.GR_SIN_WAVE, 400, 1)

self.connect(self.src, self.u)
[…]

file2.py
[…]

self.u = usrp.source_c(0, self.decim_rate)

self.sndsink = audio.sink(48000, ‘plughw:0,0’)
self.blk = gr.complex_to_mag()
self.connect(self.u, self.blk, (self.sndsink, 0))
[…]

in words: file1.py should serve as the sender of sine signal with a
frequency of 400Hz and file2.py should receive this signal and emit it
on the soundcard. Both excerpts are implemented as a derived class from
gr.top_block().

Running usrp_oscope.py, I can see that a sine is transmitted, however i
can not here anything than noise(?). Actually I would have expected
something like the output of dial_tone.py. Can somebody tell me why I am
wrong and don’t receive what i expect.

Any hints are appreciated!

Tom


WEB.DE DSL SOMMER-SPECIAL: Surf & Phone Flat 16.000 für
nur 19,99 €/mtl.!* WEB.DE Produkte Übersicht: Apps, Browser, MailCheck & Co.

Thanks a lot for your help!

file2.py now looks like this:

class soundcheck(gr.top_block):

  def init(self):
    gr.top_block.init(self)

    self.decim_rate = 256
    self.u = usrp.source_c(0, self.decim_rate)

    self.rx_subdev_spec = usrp.pick_rx_subdevice(self.u)
    self.subdev = usrp.selected_subdev(self.u, self.rx_subdev_spec)
    self.input_rate = self.u.adc_freq() / self.decim_rate

   res = self.u.tune(0, self.subdev, 13.56e6)
   if res:
      print ‘frequency successfully changed to 13.56Mhz’
   else:
     print ‘tuning failed’
    sys.exit(1)

   interp = gru.lcm(self.input_rate, 48000) / self.input_rate
   decim = gru.lcm(self.input_rate, 48000) / 48000
   interp = int(interp)
  decim = int(decim)

  print ‘interp = %d, decim = %d’ % (interp, decim)
  rr = blks2.rational_resampler_ccc(interp, decim)

  self.sndsink = audio.sink(48000, ‘plughw:0,0’)
  self.magblk = gr.complex_to_mag()
  self.connect(self.u, rr, self.magblk, (self.sndsink, 0))

As one can see I added the reational_resampler_ccc(), hoping that it
does the magic work needed that I can hear a nice sine wave, but still
there is only noise. On the transmitting side a gr.sig_source_c(48000,
gr.GR_SIN_WAVE, 4000, 1000) is used with the interpolation of the USRP
set to a factor of 32. Maybe I still lack of a proper understanding of
the whole issue so that I would really appreciate your help.

Tom

-----Ursprüngliche Nachricht-----
Von: “Alexandru C.” [email protected]
Gesendet: Sep 21, 2010 12:32:17 PM
An: [email protected]
Betreff: Re: [Discuss-gnuradio] General question concerning usrp & audio

self.connect(self.u, self.blk, (self.sndsink, 0))
look at the receiver examples you’ll see that all of them use a
Discuss-gnuradio mailing list
[email protected]
Discuss-gnuradio Info Page


GRATIS: Spider-Man 1-3 sowie 300 weitere Videos!
Jetzt kostenlose Movie-FLAT freischalten! http://movieflat.web.de

Hi Tom,

The magnitude of a complex sine wave is constant so you can not hear
it. If you want to hear a tone you have to listen to either the real
or the imaginary part, i.e. use complex_to_real or complex_to_float.
You can easily test it by connecting a complex signal source to the
audio sink via complex_to_mag (you wont hear anything) and
complex_to_real/complex_to_imag (you will hear the tone).

In terms of radio complex_to_mag corresponds to a simple AM
demodulator but you don’t have any AM modulator on the transmitter
side. If you want to hear a tone with the AM receiver, you have to
send a real sine wave through an AM modulator in the transmitter.
Sending a complex tone to the USRP is pretty much the same as an
unmodulated carrier.

For the transmitter, you will have to use interpolation much higher
than 32. The DAC rate is 128 Msps and the max interpolation you can
use is 512 corresponding to 250 ksps (the same exercise as for the
receiver but the other way around).

Alex

On Tue, Sep 21, 2010 at 5:09 AM, Thomas S. [email protected]
wrote:

self.connect(self.src, self.u)
[…]

in words: file1.py should serve as the sender of sine signal with a frequency of 400Hz and file2.py should receive this signal and emit it on the soundcard. Both excerpts are implemented as a derived class from gr.top_block().

Running usrp_oscope.py, I can see that a sine is transmitted, however i can not here anything than noise(?). Actually I would have expected something like the output of dial_tone.py. Can somebody tell me why I am wrong and don’t receive what i expect.

One of the problems is that you connect the USRP to the audio sink
without any downsampling. Even with max decimation, 256, the USRP will
generate 250 ksps while your audio sink expects only 48 ksps. If you
look at the receiver examples you’ll see that all of them use a
channel filter (usually low pass) which also does some downsampling.
By the way, using a channel filter in a receiver is generally a good
idea :wink:

Other problems could be receiver settings (gain, frequency, antenna
selection, etc.).

Alex

On Tue, Sep 21, 2010 at 5:36 PM, Thomas S. [email protected]
wrote:

 self.u = usrp.source_c(0, self.decim_rate)
 sys.exit(1)

self.sndsink = audio.sink(48000, ‘plughw:0,0’)
self.magblk = gr.complex_to_mag()
self.connect(self.u, rr, self.magblk, (self.sndsink, 0))

As one can see I added the reational_resampler_ccc(), hoping that it does the magic work needed that I can hear a nice sine wave, but still there is only noise. On the transmitting side a gr.sig_source_c(48000, gr.GR_SIN_WAVE, 4000, 1000) is used with the interpolation of the USRP set to a factor of 32. Maybe I still lack of a proper understanding of the whole issue so that I would really appreciate your help.

Tom

I always find it useful to test a new transmitter by looking at the
received signal coming from the USRP. You can use usrp_fft.py to see
what’s happening in the spectrum. You should be seeing a clean tone at
the frequency you’re transmitting at. If the one isn’t clean or isn’t
there, you’re still doing something wrong (probably be with the sample
rates).

When you’re comfortable with the transmitter, then you can work on the
receiver (and Alexandru C.'s follow-up has good suggestions).

Tom