I have attached them now. sorry about that. the sample rate is 40MHz because I am trying to send a chirp over 20MHz, so I figured with nyquist's theorem (sampling rate 2x highest frequency), that would be the correct one. However any sample rate above ~10MHz causes my grc window to freeze.
Thanks for your response!! Laura ________________________________________ From: Maximilian Stiefel [stiefel.maximil...@online.de] Sent: Friday, April 27, 2018 6:46 PM To: Laura Huddleston Cc: discuss-gnuradio@gnu.org Subject: Re: [Discuss-gnuradio] Frequency hopping code printing UUUUU Hello Laura, It is definitely not afternoon here in Sweden. There is no flowgraph attached. Happens to me as well, every time ;) This output usually indicates you are doing are something, that causes samples to be dropped, i.e. not transmitted, because something is not fast enough. What sample rate are we talking about? Cheers, Max Lördag den 28 april 2018 skrev Laura Huddleston: > > Good afternoon, > > I am creating a flowgraph that will chirp and then hop center frequency and > repeat. > > This is on the ettus n200 with a cable connection the transmit to the receive > port. > > The code worked perfectly until I increased the range of the chirp and > subsequently the sample rate. Now every time I run the code, it outputs > UUUUUUUUUUU and freezes the GRC window even after closing the pop up window > printing out the center frequency. > > Until recently it was graphing the received data on a waterfall plot, but I > assumed that was the reason the computer couldn't process the higher sample > rate, so I replaced it with several file meta sinks to prove the data was > what it was supposed to be. > > Thanks for any help you can provide, > attached is the flowgraph > > Laura >
chirp_hopper.grc
Description: chirp_hopper.grc
#!/usr/bin/env python2 # -*- coding: utf-8 -*- ################################################## # GNU Radio Python Flow Graph # Title: Chirp Hopper # Generated: Fri Apr 27 12:37:29 2018 ################################################## if __name__ == '__main__': import ctypes import sys if sys.platform.startswith('linux'): try: x11 = ctypes.cdll.LoadLibrary('libX11.so') x11.XInitThreads() except: print "Warning: failed to XInitThreads()" from PyQt4 import Qt from gnuradio import analog from gnuradio import blocks from gnuradio import eng_notation from gnuradio import gr from gnuradio import gr, blocks from gnuradio import uhd from gnuradio.eng_option import eng_option from gnuradio.filter import firdes from optparse import OptionParser import numpy as np import sys import threading import time from gnuradio import qtgui class chirp_hopper(gr.top_block, Qt.QWidget): def __init__(self, center_freq_max=2.7e9, center_freq_min=2.2e9, chirpLen_s=100e-3, freq_step=40e6, period_s=.2, phase_rad=0, pre_gain=0.25, sps=64, start_Hz=1, stop_Hz=20e6, tx_gain=0): gr.top_block.__init__(self, "Chirp Hopper") Qt.QWidget.__init__(self) self.setWindowTitle("Chirp Hopper") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "chirp_hopper") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.center_freq_max = center_freq_max self.center_freq_min = center_freq_min self.chirpLen_s = chirpLen_s self.freq_step = freq_step self.period_s = period_s self.phase_rad = phase_rad self.pre_gain = pre_gain self.sps = sps self.start_Hz = start_Hz self.stop_Hz = stop_Hz self.tx_gain = tx_gain ################################################## # Variables ################################################## self.samp_rate = samp_rate = 40e6 self.numSamples = numSamples = samp_rate*chirpLen_s self.times_s = times_s = np.linspace(0,chirpLen_s,numSamples) self.k = k = (stop_Hz-start_Hz)/chirpLen_s self.sweepFreqs_Hz = sweepFreqs_Hz = (start_Hz+k/2.*times_s)*times_s self.func_center_freq = func_center_freq = [center_freq_min] self.lo_offset = lo_offset = -((samp_rate) * 1.25) self.chirp = chirp = np.sin(phase_rad +2*np.pi*sweepFreqs_Hz) self.Current_Center_Frequency = Current_Center_Frequency = int(func_center_freq[0]) ################################################## # Blocks ################################################## self.probe_center_freq = blocks.probe_signal_vf(1) def _func_center_freq_probe(): while True: val = self.probe_center_freq.level() try: self.set_func_center_freq(val) except AttributeError: pass time.sleep(1.0 / (5)) _func_center_freq_thread = threading.Thread(target=_func_center_freq_probe) _func_center_freq_thread.daemon = True _func_center_freq_thread.start() self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(func_center_freq[0], 0) self.uhd_usrp_source_0.set_gain(tx_gain, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(func_center_freq[0], 0) self.uhd_usrp_sink_0.set_gain(tx_gain, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.blocks_vector_source_x_0 = blocks.vector_source_c(np.hstack((chirp, np.zeros(int((period_s-chirpLen_s)*samp_rate)))), True, 1, []) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((0, )) self.blocks_file_meta_sink_2 = blocks.file_meta_sink(gr.sizeof_gr_complex*1, '/home/laura.huddleston/Documents/GNURadioCompanion/data/freq_hop_data.dat', samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", False) self.blocks_file_meta_sink_2.set_unbuffered(False) self.blocks_file_meta_sink_1 = blocks.file_meta_sink(gr.sizeof_gr_complex*1, '/home/laura.huddleston/Documents/GNURadioCompanion/data/output_data.dat', samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", False) self.blocks_file_meta_sink_1.set_unbuffered(False) self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_gr_complex*1, '/home/laura.huddleston/Documents/GNURadioCompanion/data/input_data.dat', samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", False) self.blocks_file_meta_sink_0.set_unbuffered(False) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_const_source_x_0_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, center_freq_min if ((func_center_freq[0] > center_freq_max) or (func_center_freq[0] < center_freq_min)) else (func_center_freq[0] + freq_step)) self.analog_const_source_x_0 = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, func_center_freq[0]) self._Current_Center_Frequency_tool_bar = Qt.QToolBar(self) if None: self._Current_Center_Frequency_formatter = None else: self._Current_Center_Frequency_formatter = lambda x: str(x) self._Current_Center_Frequency_tool_bar.addWidget(Qt.QLabel("Current_Center_Frequency"+": ")) self._Current_Center_Frequency_label = Qt.QLabel(str(self._Current_Center_Frequency_formatter(self.Current_Center_Frequency))) self._Current_Center_Frequency_tool_bar.addWidget(self._Current_Center_Frequency_label) self.top_layout.addWidget(self._Current_Center_Frequency_tool_bar) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_file_meta_sink_2, 0)) self.connect((self.analog_const_source_x_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.probe_center_freq, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_file_meta_sink_1, 0)) def closeEvent(self, event): self.settings = Qt.QSettings("GNU Radio", "chirp_hopper") self.settings.setValue("geometry", self.saveGeometry()) event.accept() def get_center_freq_max(self): return self.center_freq_max def set_center_freq_max(self, center_freq_max): self.center_freq_max = center_freq_max self.analog_const_source_x_0_0.set_offset(self.center_freq_min if ((self.func_center_freq[0] > self.center_freq_max) or (self.func_center_freq[0] < self.center_freq_min)) else (self.func_center_freq[0] + self.freq_step)) def get_center_freq_min(self): return self.center_freq_min def set_center_freq_min(self, center_freq_min): self.center_freq_min = center_freq_min self.set_func_center_freq([self.center_freq_min]) self.analog_const_source_x_0_0.set_offset(self.center_freq_min if ((self.func_center_freq[0] > self.center_freq_max) or (self.func_center_freq[0] < self.center_freq_min)) else (self.func_center_freq[0] + self.freq_step)) def get_chirpLen_s(self): return self.chirpLen_s def set_chirpLen_s(self, chirpLen_s): self.chirpLen_s = chirpLen_s self.set_times_s(np.linspace(0,self.chirpLen_s,self.numSamples)) self.set_numSamples(self.samp_rate*self.chirpLen_s) self.set_k((self.stop_Hz-self.start_Hz)/self.chirpLen_s) self.blocks_vector_source_x_0.set_data(np.hstack((self.chirp, np.zeros(int((self.period_s-self.chirpLen_s)*self.samp_rate)))), []) def get_freq_step(self): return self.freq_step def set_freq_step(self, freq_step): self.freq_step = freq_step self.analog_const_source_x_0_0.set_offset(self.center_freq_min if ((self.func_center_freq[0] > self.center_freq_max) or (self.func_center_freq[0] < self.center_freq_min)) else (self.func_center_freq[0] + self.freq_step)) def get_period_s(self): return self.period_s def set_period_s(self, period_s): self.period_s = period_s self.blocks_vector_source_x_0.set_data(np.hstack((self.chirp, np.zeros(int((self.period_s-self.chirpLen_s)*self.samp_rate)))), []) def get_phase_rad(self): return self.phase_rad def set_phase_rad(self, phase_rad): self.phase_rad = phase_rad self.set_chirp(np.sin(self.phase_rad +2*np.pi*self.sweepFreqs_Hz)) def get_pre_gain(self): return self.pre_gain def set_pre_gain(self, pre_gain): self.pre_gain = pre_gain def get_sps(self): return self.sps def set_sps(self, sps): self.sps = sps def get_start_Hz(self): return self.start_Hz def set_start_Hz(self, start_Hz): self.start_Hz = start_Hz self.set_sweepFreqs_Hz((self.start_Hz+self.k/2.*self.times_s)*self.times_s) self.set_k((self.stop_Hz-self.start_Hz)/self.chirpLen_s) def get_stop_Hz(self): return self.stop_Hz def set_stop_Hz(self, stop_Hz): self.stop_Hz = stop_Hz self.set_k((self.stop_Hz-self.start_Hz)/self.chirpLen_s) def get_tx_gain(self): return self.tx_gain def set_tx_gain(self, tx_gain): self.tx_gain = tx_gain self.uhd_usrp_source_0.set_gain(self.tx_gain, 0) self.uhd_usrp_sink_0.set_gain(self.tx_gain, 0) def get_samp_rate(self): return self.samp_rate def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.uhd_usrp_source_0.set_samp_rate(self.samp_rate) self.uhd_usrp_sink_0.set_samp_rate(self.samp_rate) self.set_numSamples(self.samp_rate*self.chirpLen_s) self.set_lo_offset(-((self.samp_rate) * 1.25)) self.blocks_vector_source_x_0.set_data(np.hstack((self.chirp, np.zeros(int((self.period_s-self.chirpLen_s)*self.samp_rate)))), []) def get_numSamples(self): return self.numSamples def set_numSamples(self, numSamples): self.numSamples = numSamples self.set_times_s(np.linspace(0,self.chirpLen_s,self.numSamples)) def get_times_s(self): return self.times_s def set_times_s(self, times_s): self.times_s = times_s self.set_sweepFreqs_Hz((self.start_Hz+self.k/2.*self.times_s)*self.times_s) def get_k(self): return self.k def set_k(self, k): self.k = k self.set_sweepFreqs_Hz((self.start_Hz+self.k/2.*self.times_s)*self.times_s) def get_sweepFreqs_Hz(self): return self.sweepFreqs_Hz def set_sweepFreqs_Hz(self, sweepFreqs_Hz): self.sweepFreqs_Hz = sweepFreqs_Hz self.set_chirp(np.sin(self.phase_rad +2*np.pi*self.sweepFreqs_Hz)) def get_func_center_freq(self): return self.func_center_freq def set_func_center_freq(self, func_center_freq): self.func_center_freq = func_center_freq self.uhd_usrp_source_0.set_center_freq(self.func_center_freq[0], 0) self.uhd_usrp_sink_0.set_center_freq(self.func_center_freq[0], 0) self.analog_const_source_x_0_0.set_offset(self.center_freq_min if ((self.func_center_freq[0] > self.center_freq_max) or (self.func_center_freq[0] < self.center_freq_min)) else (self.func_center_freq[0] + self.freq_step)) self.analog_const_source_x_0.set_offset(self.func_center_freq[0]) self.set_Current_Center_Frequency(self._Current_Center_Frequency_formatter(int(self.func_center_freq[0]))) def get_lo_offset(self): return self.lo_offset def set_lo_offset(self, lo_offset): self.lo_offset = lo_offset def get_chirp(self): return self.chirp def set_chirp(self, chirp): self.chirp = chirp self.blocks_vector_source_x_0.set_data(np.hstack((self.chirp, np.zeros(int((self.period_s-self.chirpLen_s)*self.samp_rate)))), []) def get_Current_Center_Frequency(self): return self.Current_Center_Frequency def set_Current_Center_Frequency(self, Current_Center_Frequency): self.Current_Center_Frequency = Current_Center_Frequency Qt.QMetaObject.invokeMethod(self._Current_Center_Frequency_label, "setText", Qt.Q_ARG("QString", self.Current_Center_Frequency)) def argument_parser(): parser = OptionParser(usage="%prog: [options]", option_class=eng_option) parser.add_option( "-m", "--center-freq-max", dest="center_freq_max", type="eng_float", default=eng_notation.num_to_str(2.7e9), help="Set center_freq_max [default=%default]") parser.add_option( "-f", "--center-freq-min", dest="center_freq_min", type="eng_float", default=eng_notation.num_to_str(2.2e9), help="Set center_freq_min [default=%default]") parser.add_option( "", "--chirpLen-s", dest="chirpLen_s", type="eng_float", default=eng_notation.num_to_str(100e-3), help="Set chirpLen_s [default=%default]") parser.add_option( "-e", "--freq-step", dest="freq_step", type="eng_float", default=eng_notation.num_to_str(40e6), help="Set freq_step [default=%default]") parser.add_option( "", "--period-s", dest="period_s", type="eng_float", default=eng_notation.num_to_str(.2), help="Set period_s [default=%default]") parser.add_option( "", "--phase-rad", dest="phase_rad", type="intx", default=0, help="Set phase_rad [default=%default]") parser.add_option( "-p", "--pre-gain", dest="pre_gain", type="eng_float", default=eng_notation.num_to_str(0.25), help="Set pre_gain [default=%default]") parser.add_option( "-y", "--sps", dest="sps", type="intx", default=64, help="Set samples per symbol [default=%default]") parser.add_option( "", "--start-Hz", dest="start_Hz", type="eng_float", default=eng_notation.num_to_str(1), help="Set start_Hz [default=%default]") parser.add_option( "", "--stop-Hz", dest="stop_Hz", type="eng_float", default=eng_notation.num_to_str(20e6), help="Set stop_Hz [default=%default]") parser.add_option( "-t", "--tx-gain", dest="tx_gain", type="eng_float", default=eng_notation.num_to_str(0), help="Set tx_gain [default=%default]") return parser def main(top_block_cls=chirp_hopper, options=None): if options is None: options, _ = argument_parser().parse_args() from distutils.version import StrictVersion if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"): style = gr.prefs().get_string('qtgui', 'style', 'raster') Qt.QApplication.setGraphicsSystem(style) qapp = Qt.QApplication(sys.argv) tb = top_block_cls(center_freq_max=options.center_freq_max, center_freq_min=options.center_freq_min, chirpLen_s=options.chirpLen_s, freq_step=options.freq_step, period_s=options.period_s, phase_rad=options.phase_rad, pre_gain=options.pre_gain, sps=options.sps, start_Hz=options.start_Hz, stop_Hz=options.stop_Hz, tx_gain=options.tx_gain) tb.start() tb.show() def quitting(): tb.stop() tb.wait() qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) qapp.exec_() if __name__ == '__main__': main()
_______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio