问题
I've written a small GNU Radio program to capture and plot FFT data from the USRP N210.
To avoid locking up my GUI (matplotlib and wxpython), I am only running the flowgraph after the GUI reports that it's idle.
In order to do that kind of timing, I'm using a non-flowgraph centered approach, introduced in the GNU Radio Tutorial.
Essentially, I have a main loop that looks like this (pseudocode):
topblock.set_usrp_freq()
while True:
topblock.run()
data = topblock.vector_sink.data()
thread-safe call to plot data
wait for gui.EVT_IDLE
topblock.skiphead.reset()
topblock.head.reset()
Where the flowgraph looks basically like:
self.connect(usrp, skiphead, stream_to_vector, head, fft, c2mag_sq, stats, volts_to_dBm, vector_sink)
# skiphead is modified to be resettable like head
When I use similar parameters, I expect to see the same thing that I see when I run uhd_fft -f 700M -s 10e6
:
The output from my matplotlib plot is, at first, very similar, with the exception of a very pronounced LO. I have tried to follow the code through uhd_fft
and I don't see them doing any LO offsetting, so my first questions is Q: Does uhd_fft avoid plotting the LO in some way, or is the way I'm running my flowgraph from a main loop causing the LO to be pronounced?
Edit: I've confirmed that the extreme LO is a byproduct of a voltage spike that occurs each time the flowgraph is "run()". The number of samples you need to drop to lower to LO can be seen in the time data in my follow-up post: voltage pulse from USRP when using simple GNU Radio flowgraph from Python
After the second run, I periodically get strange data plotted that definitely doesnt' happen in uhd_fft. I can make this go away by dumping several thousand samples per flowgraph run with the skiphead
block, but my second question is: Q: Why does running the flowgraph from a separate main loop cause junk data to be plotted, even though the USRP is not being retuned? uhd_fft
uses a flowgraph-centric process and does not have this issue:
My intuition is that there are some caveats with running a non-flowgraph centered app that aren't mentioned in the tutorial.
来源:https://stackoverflow.com/questions/27932064/fft-in-non-flowgraph-centered-application-different-from-flowgraph-centered-apps