Forum: GNU Radio 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.
Adi85 (Guest)
on 2009-03-09 17:36
(Received via mailing list)
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-...
Sent from the GnuRadio mailing list archive at Nabble.com.
Eric B. (Guest)
on 2009-03-09 17:59
(Received via mailing list)
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
Adi85 (Guest)
on 2009-03-09 18:25
(Received via mailing list)
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 <module>
    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-...
Sent from the GnuRadio mailing list archive at Nabble.com.
Dimitris S. (Guest)
on 2009-03-09 20:32
(Received via mailing list)
On Mon, Mar 9, 2009 at 17:22, Adi85 <removed_email_address@domain.invalid> 
wrote:
>
>        v_sink = gr.vector_sink_c()
>    print "Exiting.."
> line 70, in connect
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> removed_email_address@domain.invalid
> http://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>

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
Adi85 (Guest)
on 2009-03-10 12:36
(Received via mailing list)
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-...
Sent from the GnuRadio mailing list archive at Nabble.com.
Eric B. (Guest)
on 2009-03-10 19:06
(Received via mailing list)
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
Tom R. (Guest)
on 2009-03-11 16:48
(Received via mailing list)
On Tue, Mar 10, 2009 at 6:33 AM, Adi85 <removed_email_address@domain.invalid> 
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
This topic is locked and can not be replied to.