Spectrum_sense of a smaller banwidth

Hello!

Here is what I would like to do: I want to use spectrum_sense.py in
order to
detect the amplitude of the maximum power bin from a bandwidth of about
7
khz centered to 10.7Mhz and then display the result. I do not need to
change
the RF center frequency. What should I take out of the code acording to
my
needs?

Thank you!


View this message in context:
http://www.nabble.com/Spectrum_sense-of-a-smaller-banwidth-tp22413464p22413464.html
Sent from the GnuRadio mailing list archive at Nabble.com.

On Mon, Mar 09, 2009 at 08:34:50AM -0700, Adi85 wrote:

Hello!

Here is what I would like to do: I want to use spectrum_sense.py in order to
detect the amplitude of the maximum power bin from a bandwidth of about 7
khz centered to 10.7Mhz and then display the result. I do not need to change
the RF center frequency. What should I take out of the code acording to my
needs?

No need to use spectrum_sense.py. It solves a much more complicated
problem than you have. Just compute the FFT and search for the peak.

Eric

Ok…here is my code and my error message:

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

    fftsize = 4096
    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
throttle = gr.throttle(gr.sizeof_gr_complex, 100000) #
throttle=100k
v = gr.stream_to_vector(gr.sizeof_gr_complex, fftsize) #
complex
in, 4096 length

    v_sink = gr.vector_sink_c()

    self.connect(signal, throttle, v, fft, v_sink)

    # Do stuff with v_sink.data()

if name == “main”:
print “Initilizing…”
tb = topBlock()
print “Flowgraph start…”
tb.start()
print “Exiting…”

Error message:
Initilizing…
Traceback (most recent call last):
File “u0.py”, line 30, in
tb = topBlock()
File “u0.py”, line 24, in init
self.connect(signal, throttle, v, fft, v_sink)
File
“/usr/local/lib/python2.5/site-packages/gnuradio/gr/top_block.py”,
line 70, in connect
self._connect(points[i-1], points[i])
File
“/usr/local/lib/python2.5/site-packages/gnuradio/gr/top_block.py”,
line 76, in _connect
dst_block.basic_block(), dst_port)
File
“/usr/local/lib/python2.5/site-packages/gnuradio/gr/gnuradio_swig_py_runtime.py”,
line 1469, in connect
return _gnuradio_swig_py_runtime.gr_top_block_sptr_connect(*args)
ValueError: itemsize mismatch: fft_vcc_fftw(1):0 using 32768,
vector_sink_c(5):0 using 8

To be more specific I have a complex fft connected to a complex vectors
sink
so I do not know why it apears Item size mismatch!

Thank you

View this message in context:
http://www.nabble.com/Spectrum_sense-of-a-smaller-banwidth-tp22413464p22413681.html
Sent from the GnuRadio mailing list archive at Nabble.com.

On Mon, Mar 9, 2009 at 17:22, Adi85 [email protected] wrote:

    v_sink = gr.vector_sink_c()
  print “Exiting…”
line 70, in connect


Discuss-gnuradio mailing list
[email protected]
Discuss-gnuradio Info Page

throw out the gr.throttle and the gr.stream_to_vector

Dimitris S.
“If you think you’re too small to make a difference, try sleeping with
a mosquito!” - Amnesty International

On Tue, Mar 10, 2009 at 03:33:32AM -0700, Adi85 wrote:

   print v_sink.data()

ValueError: itemsize mismatch: usrp1_source_c(2):0 using 8,
fft_vcc_fftw(1):0 using 2048

the value 2048 depends of the fft size 2048=8*256

thank you very much!

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

Still getting an error!
thank you in advance

class topBlock(gr.top_block):

decimation=256
v_sink = gr.vector_sink_c()

   self.connect(signal, fft, v_sink)

   # Do stuff with v_sink.data()
   print v_sink.data()

if name == “main”:

print “Initilizing…”
tb = topBlock()
print “Flowgraph start…”
tb.start()
print “Exiting…”

but i get the same error:

ValueError: itemsize mismatch: usrp1_source_c(2):0 using 8,
fft_vcc_fftw(1):0 using 2048

the value 2048 depends of the fft size 2048=8*256

thank you very much!


View this message in context:
http://www.nabble.com/Spectrum_sense-of-a-smaller-banwidth-tp22413464p22431572.html
Sent from the GnuRadio mailing list archive at Nabble.com.

On Tue, Mar 10, 2009 at 6:33 AM, Adi85 [email protected] wrote:

   print v_sink.data()

ValueError: itemsize mismatch: usrp1_source_c(2):0 using 8,
fft_vcc_fftw(1):0 using 2048

the value 2048 depends of the fft size 2048=8*256

thank you very much!

It’s a slight misunderstanding of the word “vector.” The FFT outputs a
vector of size (sizeof(datatype)*fftsize). The vector sink is really
just a sink that stuffs a stream of items into a vector object. What
it really wants to see is a stream in, not a vector in.

Simply put, add a gr.vector_to_stream between the fft block and vector
sink block.

Tom