from gnuradio import gr, uhd, blocks
import numpy as np
import matplotlib.pyplot as plt
class topblock(gr.top_block):
def __init__(self, freq=700e6, rate=1e6, nsamps=100):
gr.top_block.__init__(self)
self.u = uhd.usrp_source(device_addr="", stream_args=uhd.stream_args('fc32'))
self.u.set_center_freq(freq)
self.u.set_samp_rate(rate)
self.head = blocks.head(gr.sizeof_gr_complex, nsamps)
self.vsink = blocks.vector_sink_c()
self.connect(self.u, self.head, self.vsink)
tb = topblock()
fig, (freqplot, timeplot) = plt.subplots(2, sharex=True)
freqplot.set_title("Frequency domain")
timeplot.set_title("Time domain")
def plot():
tb.run()
data = "">
shifted_fft = np.fft.fftshift(np.fft.fft(data))
dBm = 20*np.log10(np.abs(shifted_fft)) - 30
freqplot.plot(dBm)
timeplot.plot(np.abs(data))
tb.head.reset()
tb.vsink.reset()
def run_tb(times=25):
for _ in range(times):
plot()
plt.show(block=False)
Douglas Anderson
| Intern
DOC/NTIA/ITS-T | 325 Broadway St., Boulder, CO 80305 | P:
303 497 3582
From: Marcus D. Leech address@hidden
Sent: Thursday, January 15, 2015 11:40 AM
To: Anderson, Douglas J.
Cc: GNURadio Discussion List
Subject: Re: [Discuss-gnuradio] voltage pulse from UHD driver
On 01/15/2015 01:11 PM, Anderson, Douglas J. wrote:
Marcus, thank you.. the "optimized for steady state streaming" comment confirms some suspensions, although I'd love to understand more deeply why exactly this happens consistently to acquisitions long after a retune.
I think the code snippet I posted to StackExchange might illustrate the difference I'm seeing a little better. In that example, I did not use uhd.finite_acquisition, I used a standard flowgraph and topblock.run().
What if I took that code and tried to just continually plot acquisitions, almost like a simplified uhd_fft. I would get these "pulses" whereas you don't see them in uhd_fft. The frontend tune only happens once, and the only difference I can see about how
things are being handled is that one (uhd_fft) creates one flowgraph and uses a block to plot the data, whereas in my example I create one flowgraph and plot the data returned after a toblock.run()
I'm trying to figure out if there's some garbage data/samples created each time the flowgraph is started that doesn't happen in a constantly running flowgraph, and your comments somewhat confirm that that is the case.
Thanks for the info!
-Doug
Could you post that StackExchange code here, please, so that we can comment on it?
When a flow-graph is run, then stopped, then run again, gr-uhd will have to go through starting/stopping streaming. Which means you're starting and
stopping the DSP chain in the USRP. That will, necessarily, involve non-steady-state data. I don't think there's a mode in USRP which basically
says "run DSP steady-state, but don't send me data until I want to stream samples". Starting streaming/stopping stream also starts/stops the
DSP engine.
I don't think it's tuning effects, if I'm understanding that correctly. You mean that after you retune the USRP, the LO will take some time to settle?
In the script I posted, that shouldn't be a factor, as the UHD instance is created and tuned when I import the file in the python interpreter, and the acquisitions are then run later and without retuning the USRP.
I might be misunderstanding the issue, like if there is something that needs to settle each and every time an acquisition is requested independent of actual frequency tuning.
... but that's the reason for my question: so that I can better understand the underlying process. Thank you for the details!
-Doug
From: Nick Foster [address@hidden]
Sent: Thursday, January 15, 2015 10:49 AM
To: Anderson, Douglas J.
Cc: GNURadio Discussion List
Subject: Re: [Discuss-gnuradio] voltage pulse from UHD driver
Nothing. The timing might be a little different -- if it's tuning effects you're seeing, there's effectively a race condition between tuning and sample collection. Gnuradio will never discard samples off the front unless you use a Skip Head block,
which you should probably be doing as evidently you aren't expecting your samples to be tightly synchronized to any particular point in time.
--n
--
Marcus Leech
Principal Investigator
Shirleys Bay Radio Astronomy Consortium
http://www.sbrac.org