Monday, January 24, 2011

GNU Radio the story so far...

After experimenting with a standalone C program, I decided to implement everything in GNU Radio. The hope is that eventually we can get something running in real-time, and this is the first step towards that goal.

So, at this point the 'energy detector' is implemented in two parts: ed.py and a modified version of gr_bin_statistics_f.

ed.py


This Python script follows much of the GNU Radio examples and uses the USRP as a signal source. Currently the script allows you to collect N samples, then perform an FFT followed by squaring the magnitude output. Originally the time-averaging of the PSDs was done in gr_bin_statistics_f, but the same if-not-better results were obtained using the pre-built single_pole_iir_filter. Finally the output is scaled with a log function before an output file is generated with the test statistics.

Here is the GNU Radio flow-graph:

USRP -> s2v -> FFT -> c2mag -> avg -> log -> stats

gr_bin_statistics_f


Originally, gr_bin_statistics_f was a key component in the usrp_spectrum_sense.py script. It's original function was to gather the maximum values of the FFT output and generate messages for the Python code. It implements a simple state-machine which also allows you to callback to the Python code and re-tune the USRP.

In it's current heavily-modified state, it simple calculates an average of the FFT output over a given window to generate our test stats. At this point I intend on creating a whole new block which removes much of the old functionality.

So, given a window center frequency and bandwidth, the modified code sums M bins and generates a test stat T in the form of a Python message. These messages are then tallied up by ed.py and put into an output file which is plotted directly with GNUplot.



In the end we have essentially the same functionality as my stand-alone C program, only now everything is implemented under GNU Radio and we are much closer to something that can be tuned to run in real-time.

No comments:

Post a Comment