# Can I use uhd\_fft or gnu-radio to display the spectrum with adjustable frequency resolution

**URL:** <https://www.ruby-forum.com/t/can-i-use-uhd-fft-or-gnu-radio-to-display-the-spectrum-with-adjustable-frequency-resolution/230183>\
**Category:** GNU Radio\
**Created:** [June 4, 2014, 12:49am UTC](https://www.ruby-forum.com/t/can-i-use-uhd-fft-or-gnu-radio-to-display-the-spectrum-with-adjustable-frequency-resolution/230183 "2014-06-04T00:49:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason\_sam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7993a0/32.png) [@jason\_sam](https://www.ruby-forum.com/u/jason_sam)\
**Post date:** [June 4, 2014, 12:49am UTC](https://www.ruby-forum.com/t/can-i-use-uhd-fft-or-gnu-radio-to-display-the-spectrum-with-adjustable-frequency-resolution/230183/1 "2014-06-04T00:49:28Z")

</div>

I am trying to use the uhd\_fft or gnu-radio scope in a way that it can  
show  
a real-time spectrum but with adjustable resolution. The uhd\_fft  
spectrum  
resolution appears to be fixed and not changeable. The gnu-radio scope  
block  
only puts out time series but not real-time spectrum. What is my way out  
of  
this situation?

Thanks,

LD

---

<div class="post-metadata">

**Author:** ![LD\_Zhang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/90ced4/32.png) [@LD\_Zhang](https://www.ruby-forum.com/u/LD_Zhang)\
**Post date:** [June 4, 2014, 1:07am UTC](https://www.ruby-forum.com/t/can-i-use-uhd-fft-or-gnu-radio-to-display-the-spectrum-with-adjustable-frequency-resolution/230183/2 "2014-06-04T01:07:44Z")

</div>

Hi LD,

you’re right the QT GUI sink does not seem to care about changing FFT  
sizes.  
I remember the set\_fft\_size function being implemented, I think it’s  
mainly a matter of having a callback defined for changes of the fft size  
parameter.  
As I’m not too familiar with that, my mileage when playing with the QT  
sinks may vary.  
Could you try adding  
set\_frequency\_range($fc, $bw)  
to gr-qtqui/grc/qtgui\_freq\_sink\_x.xml where the other callbacks are  
defined and try if it works for you?

Greetings,  
Marcus

---

<div class="post-metadata">

**Author:** ![LD\_Zhang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/90ced4/32.png) [@LD\_Zhang](https://www.ruby-forum.com/u/LD_Zhang)\
**Post date:** [June 4, 2014, 1:16am UTC](https://www.ruby-forum.com/t/can-i-use-uhd-fft-or-gnu-radio-to-display-the-spectrum-with-adjustable-frequency-resolution/230183/3 "2014-06-04T01:16:34Z")

</div>

Hi!  
On 04.06.2014 01:05, Marcus M. wrote:

> set\_frequency\_range($fc, $bw)  
> to gr-qtqui/grc/qtgui\_freq\_sink\_x.xml where the other callbacks are  
> defined and try if it works for you?  
> Sorry, copied the wrong line.  
> What I wanted to paste was:  
> set\_fft\_size($fftsize)

Greetings,  
Marcus

---

<div class="post-metadata">

**Author:** ![LD\_Zhang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/90ced4/32.png) [@LD\_Zhang](https://www.ruby-forum.com/u/LD_Zhang)\
**Post date:** [June 4, 2014, 1:36am UTC](https://www.ruby-forum.com/t/can-i-use-uhd-fft-or-gnu-radio-to-display-the-spectrum-with-adjustable-frequency-resolution/230183/4 "2014-06-04T01:36:36Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

So I couldn’t resist, and the line that would actually call the  
set\_fft\_size callback function correctly would’ve been  
set\_fft\_size(min(int($fftsize),4))

However, QT Gui spectacularly SEGFAULTs on me when doing that.  
That actually happens in  
line 123 of gr-qtgui/lib/freqdisplayform.cc :

d\_sizemenu-\>getActionFromSize(newsize)-\>setChecked(true);

which _might_ be some relict from older times, but I can’t really tell.  
I hope someone more familiar with the qtgui infrastructure might chime  
in.

Greetings,  
Marcus

On 04.06.2014 01:14, Marcus M. wrote:

> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Discuss-gnuradio  
> mailing list [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio)

-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1  
Comment: Using GnuPG with Thunderbird - [http://www.enigmail.net/](http://www.enigmail.net/)

iQEcBAEBAgAGBQJTjlvFAAoJEBQ6EdjyzlHtIN4IAMHXlNAi86/E+Y3oSc8WkjEQ  
Hyh370ab55EaFrbvHYb9yLEXjC7hS1ccBLIpbMSKIRrHL/Z4rfIfMzlhEF4LA2cW  
TSJ0ydXb+KktRJ7bQ+V62RIufcyUXZc4OWZjfYvjT42GIzgUZAp3kI18n6Ohfeta  
FfoNWUnFJMxywYlgIE7QUgUYWIwMq4FTMGqNjGbBL8Jn6/RE7X8kJbnErjqNUprH  
Rx96MSj1MBiZrDPuPKYCgj8LR1c00jALorgA8lXtpYK1gufjSmYO0Bjol179kegb  
nQFPhMy6cfZChy8cTP0oBxQmC9aPrPtpCmHBcBCoDCIZxcUBU/x4TEEejgFM64g=  
=s2I+  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![LD\_Zhang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/90ced4/32.png) [@LD\_Zhang](https://www.ruby-forum.com/u/LD_Zhang)\
**Post date:** [June 4, 2014, 1:44am UTC](https://www.ruby-forum.com/t/can-i-use-uhd-fft-or-gnu-radio-to-display-the-spectrum-with-adjustable-frequency-resolution/230183/5 "2014-06-04T01:44:51Z")

</div>

On Tue, Jun 3, 2014 at 4:35 PM, Marcus Müller [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I hope someone more familiar with the qtgui infrastructure might chime in.

Hey Marcus,

Did you try debugging the SEGFAULT using gdb? This is a good reference  
to  
try:

> **[RMS's gdb Tutorial: Segmentation Fault Example](http://www.unknownroad.com/rtfm/gdbtut/gdbsegfault.html)**
>
> A Question-And-Answer tutorial on how to use GDB (the GNU Debugger)

---

<div class="post-metadata">

**Author:** ![LD\_Zhang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/90ced4/32.png) [@LD\_Zhang](https://www.ruby-forum.com/u/LD_Zhang)\
**Post date:** [June 4, 2014, 9:23am UTC](https://www.ruby-forum.com/t/can-i-use-uhd-fft-or-gnu-radio-to-display-the-spectrum-with-adjustable-frequency-resolution/230183/6 "2014-06-04T09:23:58Z")

</div>

Hi!

Alfredo: Jep, did that. GDB was how I figured out things went wrong in  
FreqDisplayForm::setFFTSize() in the first place :).  
J?rg: Interesting; but the error is quite reproducibly at the same  
place; I’ll try to set a breakpoint at the kernel call and see if that  
happens again. But that will require some gdb magic (so that GDB only  
interrupts program flow when the fft size changes), and that’s  
definitively something that would be worthwhile to learn, however I’m  
postponing this for now for reasons of time available.

Greetings,  
Marcus

---

<div class="post-metadata">

**Author:** ![LD\_Zhang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/90ced4/32.png) [@LD\_Zhang](https://www.ruby-forum.com/u/LD_Zhang)\
**Post date:** [June 4, 2014, 10:14am UTC](https://www.ruby-forum.com/t/can-i-use-uhd-fft-or-gnu-radio-to-display-the-spectrum-with-adjustable-frequency-resolution/230183/7 "2014-06-04T10:14:03Z")

</div>

I think it’s going wrong in getActionFromSize, which easy as it  
looks[1], I don’t get the hang of.  
Why do we need a specific QAction based on the FFT length we’re setting?  
And why does an FFT size of 4 lead to negative indices in a QList?

Anyway, the actual bug was on my side, as I was constantly setting an  
FFT size of 4. Which seemingly doesn’t work.  
@LD: try  
set\_fft\_size(max(int($fftsize),32))  
instead. I was then able to change the displayed FFT on the fly using QT  
Gui sliders [2].

Greetings,  
Marcus

[1] gr-qtgui/include/gnuradio/qtgui/form\_menus.h  
[2] [Adjustable QT FFT · GitHub](https://gist.github.com/marcusmueller/edfef568a92821261f9f) , the  
adjustable\_qtgui\_fft.grc file should load nicely in a 3.7.4 GNU Radio, I  
think it should work with 3.7.x

---

<div class="post-metadata">

**Author:** ![LD\_Zhang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/90ced4/32.png) [@LD\_Zhang](https://www.ruby-forum.com/u/LD_Zhang)\
**Post date:** [June 4, 2014, 8:49am UTC](https://www.ruby-forum.com/t/can-i-use-uhd-fft-or-gnu-radio-to-display-the-spectrum-with-adjustable-frequency-resolution/230183/8 "2014-06-04T08:49:12Z")

</div>

Hey,

I know another GSoC Student has problems with the a GT GUI sink as well.  
It would randomly SEGFAULT in a volk multiply kernel. I think it is the  
volk\_32\_fc\_32f\_multiply\_32fc kernel used in  
waterfall\_sink\_X\_impl::fft(). This kernel takes the FFT size as an input  
argument, so it could be related to your problem. I just had a quick  
glance at it so I am not sure though. I’ll ask him to post his exact  
problem when he arrives at the lab. Maybe he can shed a bit more light  
on this problem

-Jan
