Hi All,
I tried to access the output of FFT by using self.dst1 =
gr.vector_sink_s()
and use gr.argmax_fs(self.fft_size) to find the index of the maximum
value.
However, I can not get the output, dst1.data(). I attached the code
below.
Actually, I also want to find the maximum value using dst2 =
gr.vector_sink_f() and valmax = gr.max_ff(self.fft_size), but it doesn’t
work. Can anyone help me with this?
Thanks,
Brook
start
self.s2p = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size)
self.one_in_n = gr.keep_one_in_n(gr.sizeof_gr_complex *
self.fft_size,max(1,
int(input_rate/self.fft_size/self.fft_size)))
mywindow = window.blackmanharris(self.fft_size)
self.fft = gr.fft_vcc(self.fft_size, True, mywindow)
power = 0
for tap in mywindow:
power += tap*tap
self.c2mag = gr.complex_to_mag(self.fft_size)
self.avg = gr.single_pole_iir_filter_ff(1.0, self.fft_size)
FIXME We need to add 3dB to all bins but the DC bin
self.log = gr.nlog10_ff(20,
self.fft_size,-20math.log10(self.fft_size)-10math.log10(power/self.fft_size))
self.dst1 = gr.vector_sink_s()# (gr.sizeof_short, “out1.txt”)
argmax = gr.argmax_fs(self.fft_size)
#dst2 = gr.vector_sink_f()
#valmax = gr.max_ff(self.fft_size)
self.connect(self.u, self.s2p, self.one_in_n, self.fft, self.c2mag,
self.avg, self.log)
self.connect(self.log, (argmax, 0))
self.connect((argmax, 0), self.dst1)
#self.connect(self.log, (valmax, 0))
#self.connect((valmax, 0), dst2)
self.index = dst1.data()
print ‘index AAA’, self.index however, the output is printed out like
index AAA (), why I can not get the exact number
#####end################################################
View this message in context:
http://www.nabble.com/output-of-gr.argmax---gr.max--tp15997864p15997864.html
Sent from the GnuRadio mailing list archive at Nabble.com.
And I also want to show this maximum value on the status bar in wxgui,
which
shows the fft plot in the gnuradio-example. Any suggestion?
In short, when I run usrp_fft.py, how can I show the peak value on the
wxgui
window? Can I do it like what I did now?(I mean the code I attached
previously). If not, do you have some good idea to do it?
Thanks,
–
View this message in context:
http://www.nabble.com/output-of-gr.argmax---gr.max--tp15997864p15998547.html
Sent from the GnuRadio mailing list archive at Nabble.com.
I do this by sending the value of argmax to the gui using number_sink
for
the gui.
BTW I sent a message to this list the other day questioning the “-20*
math.log10(self.fft_size)…”
in the line below (taken from your code above). I argue it should be
“-10*
math.log10(self.fft_size)…”
[from Brook L.]
self.fft_size,-20math.log10(self.fft_size)-10math.log10
(power/self.fft_size))
Any comments?
Here is some quick code to display the max index of the FFT output in a
gui
ss2v = gr.streams_to_vector(gr.sizeof_gr_complex, 128)
pick_one = gr.keep_one_in_n(gr.sizeof_gr_complex * 128,1024)
my_fft = gr.fft_vcc(128,1,[])
my_mag = gr.complex_to_mag(128)
my_argmax = gr.argmax_fs(128)
my_s2f = gr.short_to_float()
self.my0_s2f = gr.short_to_float()
self.connect(self.chan_filt
,ss2v,pick_one,my_fft,my_mag,(my_argmax,0))
self.connect((my_argmax,0),self.my0_s2f,self.my0_probe)
self.connect((my_argmax,1),my_s2f,self.my_probe)
#Now in the gui area
self.my_number = numbersink2.number_sink_f(self.panel,label=
“maxIndex”,decimal_places=2)
self.connect (self.my0_s2f, self.my_number)
vbox.Add (self.my_number.win, 4, wx.EXPAND)
Tim
Tim M. wrote am 2008-03-12 11:28:
BTW I sent a message to this list the other day questioning the
“-20math.log10(self.fft_size)…"
in the line below (taken from your code above). I argue it should be
"-10math.log10(self.fft_size)…”
[from Brook L.]
self.fft_size,-20math.log10(self.fft_size)-10math.log10(power/self.fft_size))
It is:
for tap in mywindow:
power += taptap
self.log = gr.nlog10_ff(20,
self.fft_size,
-20math.log10(self.fft_size)
-10*math.log10(power/self.fft_size)
)
The variable power is a square of amplitudes, which is a power value, so
-10*math.log10(power/self.fft_size) is correct.
Patrick
Engineers motto: cheap, good, fast: choose any two
Patrick S.
Student of Telematik, Techn. University Graz, Austria
self.connect(self.chan_filt,ss2v,pick_one,my_fft,my_mag,(my_argmax,0))
self.connect((my_argmax,0),self.my0_s2f,self.my0_probe)
self.connect((my_argmax,1),my_s2f,self.my_probe)
Thanks Tim. The code is clear. But I have questions on my0_probe and
my_probe. Are they fft.win, or numbersink or other kind of sink?
Thanks~~
Tim M. wrote:
(power/self.fft_size))
my_s2f = gr.short_to_float()
“maxIndex”,decimal_places=2)
Discuss-gnuradio Info Page
Discuss-gnuradio mailing list
[email protected]
Discuss-gnuradio Info Page
–
View this message in context:
http://www.nabble.com/output-of-gr.argmax---gr.max--tp15997864p16012522.html
Sent from the GnuRadio mailing list archive at Nabble.com.
On Wed, Mar 12, 2008 at 11:31 AM, Brook L. [email protected] wrote:
self.connect(self.chan_filt,ss2v,pick_one,my_fft,my_mag,(my_argmax,0))
self.connect((my_argmax,0),self.my0_s2f,self.my0_probe)
self.connect((my_argmax,1),my_s2f,self.my_probe)
Thanks Tim. The code is clear. But I have questions on my0_probe and
my_probe. Are they fft.win, or numbersink or other kind of sink?
The probes are gr.probe_signal_f()
You don’t have to use them. number_sink_f() is the object that will
display
the number in your gui.
this is the number sink that will display
self.my_number = numbersink2.number_sink_f(self.panel,label=
“maxIndex”,decimal_places=2)
self.connect (self.my0_s2f, self.my_number)
vbox.Add (self.my_number.win, 4, wx.EXPAND)
Hy!
I would need something like this as well but I do not know what is
self.chan_filt doing abd what are its parameters…without using it I get
an
error like:
streams_to_vector(2): insufficient connected input ports (128 needed, 1
connected)
thank you!
–
View this message in context:
http://www.nabble.com/output-of-gr.argmax---gr.max--tp15997864p22431789.html
Sent from the GnuRadio mailing list archive at Nabble.com.