I wanted to let you know that I’ve checked in some code that should be
useful for building “spectrum sensing” applications, or for that
matter, anything that needs to scan across a wide chunk of RF (bigger
than you can get across the USB in a single chunk).
There are two primary pieces:
(1) gnuradio-core/src/lib/general/gr_bin_statistics_f, which combines
statistics gathering with a state machine for controlling the tuning
(2) gnuradio-examples/python/usrp/usrp_spectrum_sense.py which is
an application (closer to a skeleton) that ties it all together.
[[email protected] usrp]$ ./usrp_spectrum_sense.py --help
usage: usrp_spectrum_sense.py [options] min_freq max_freq
-h, --help show this help message and exit
-R RX_SUBDEV_SPEC, --rx-subdev-spec=RX_SUBDEV_SPEC
select USRP Rx side A or B (default=A)
-g GAIN, --gain=GAIN set gain in dB (default is midpoint)
–tune-delay=SECS time to delay (in seconds) after changing
–dwell-delay=SECS time to dwell (in seconds) at a given frequncy
-F FFT_SIZE, --fft-size=FFT_SIZE
specify number of FFT bins [default=256]
-d DECIM, --decim=DECIM
set decimation to DECIM [default=16]
–real-time Attempt to enable real-time scheduling
-B FUSB_BLOCK_SIZE, --fusb-block-size=FUSB_BLOCK_SIZE
specify fast usb block size [default=0]
-N FUSB_NBLOCKS, --fusb-nblocks=FUSB_NBLOCKS
specify number of fast usb blocks [default=0]
[[email protected] usrp]$ ./usrp_spectrum_sense.py -R b -F 256 902M 928M
You may want to subclass gr_bin_statistics_f, it currently just
keeps track of the maximum power in each FFT bin.
You’ll also want to play with the --tune-delay and --dwell-delay
command line options to determine appropriate values. --tune-delay
should include time for the front end PLL to settle, plus time for the
new samples to propagate through the pipeline. The default is 1ms,
which is probably in the ballpark on the RFX-* boards. The TV RX
board is much slower. The tuner data sheets says it could take 100ms to
settle. YMMV. Please test and let us know what you find.
–dwell-delay says how long you want to “stare” at any particular
Let me know if you’ve got any questions. As always, patches are welcome
When we’ve got the inband-signaling in place, we’ll be able to
pipeline the tuning and our effective scanning rate will increase.