I’ve written a small program to capture and plot fft data from the USRP.
Because it can also sweep and I have a limited knowledge (for now!) of
writing GNURadio blocks, I decided to use a separate main loop to run
the flowgraph and then handle the data. The flowgraph uses the head
block to exit automatically when it has captured the necessary amount of
samples. This setup really simplified handling retuning and plotting the
data for me.
When sweeping, I expect there to be some junk samples acquired in the
buffer while the LO retunes and I can handle that with the skip block,
but when I set my program to only tune the USRP once and then plot the
FFT constantly (basically emulating uhd_fft), I’m still getting junk
data. I’ve double checked that the LO remains locked after the initial
tune, so I think this extra junk data is a result of running the
flowgraph, letting it exit, processing the data, and then running it
again. uhd_fft, which is implemented as a block, does not have the same
I’ve included 3 screenshots. 1 is uhd_fft running on my USRP N210, the
other two are data from from my program plotted in matplotlib. In 1, you
can see noise plotted as you’d expect, except that the LO is MUCH more
visible than in uhd_fft. I confirmed that uhd_fft is not offsetting the
LO so I’m not sure if this is another side effect of how I’m handing the
flowgraph. Another screenshot shows the junk data that occasionally pops
in and ruins my day.
My basic flowgraph setup is:
self.connect(self.usrp, self.skip) # USRP attached to skip
block (modified to be resetable like head)
self.connect(self.skip, s2v, self.head) # skip ->
stream_to_vector -> head
self.connect(self.head, fft) # head -> fft_vcc
self.connect(c2mag_sq, stats, W2dBm, self.final_vsink)
In the last line, stats is just a block that can handle averaging, W2dBm
translates to dBm, and then all samples are dumped into a float vector
My program was set to skip 0 samples for these tests.
The main loop in pseudocode:
data = topblock.final_vsink.data()
process and plot data
- Is there anything tricky I should know about running a flowgraph from
a separate loop like I’m doing?
- What could cause the LO to be so much more pronounced in my plots as
compared to uhd_fft? For the screenshots I went to great lengths to
ensure I was using the same tuning and plotting parameters. Also,
although I can control the “junk” data by skipping samples with the
“skip” block, it does not reduce the LO throughput.
- Any leads on what could be causing the junk data even when the USRP is
not being retuned?
I’m at wits end, thanks in advance for any hints whatsoever.