Forum: GNU Radio Re: Spectrum_sense of a smaller banwidth

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
992f87e02b2be858b3f4997a67c223b7?d=identicon&s=25 David Adrian (Guest)
on 2009-03-10 18:49
(Received via mailing list)
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
745d8202ef5a58c1058d0e5395a78f9c?d=identicon&s=25 Eric Blossom (Guest)
on 2009-03-10 19:06
(Received via mailing list)
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 topic is locked and can not be replied to.