Re: Spectrum_sense of a smaller banwidth

Thanks for the reply Eric, here is what I have now:

#!/usr/bin/env python

from gnuradio import gr, gru, window
from gnuradio import usrp

from gnuradio.wxgui import stdgui, fftsink, scopesink
import wx

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

      fftsize = 256
      udecim = 256

      mywin = window.blackmanharris(fftsize)
      fft = gr.fft_vcc(fftsize, True, mywin)

      signal = usrp.source_c(0,udecim)   # signal from Basic RX,
decimation=256

      ss2v = gr.stream_to_vector(gr.sizeof_gr_complex, fftsize)
      v2ss = gr.vector_to_stream(gr.sizeof_gr_complex, fftsize)

      f_sink = gr.file_sink(gr.sizeof_gr_complex,“output.dat”)

      self.connect(signal, ss2v, fft, v2ss, f_sink)

      # Do stuff with fsink.data()
     Â

def main():
   print “Initilizing…”
   tb = topBlock()
   print “Flowgraph start…”
   tb.start()

   print “Exiting…”

if name == “main”:
   main()

But the output.dat file is empty. What I want to do here is to calculate
the fft of a bunch of samples and from there to extract the bin with the
maximum value in order to be able later to “follow” that signal in a
aprox 200 Hz bandwidth

Adrian

You need to insert a gr.stream_to_vector block between the usrp and
the fft. Also, using vector_sink_c is not recommended for anything
but QA code that runs with a small number of samples. If used like
you are trying to use it, it will consume all of the memory on your
system. Use a gr.file_sink instead.

Eric

On Tue, Mar 10, 2009 at 10:48:10AM -0700, David Adrian wrote:

class topBlock(gr.top_block):

def main():
But the output.dat file is empty. What I want to do here is to
calculate the fft of a bunch of samples and from there to extract
the bin with the maximum value in order to be able later to “follow”
that signal in a aprox 200 Hz bandwidth

Adrian

Use tb.run() instead of tb.start().
As written this exits immediately.

Eric

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