From 510e052b899bfed94117012b03583634bee4fc27 Mon Sep 17 00:00:00 2001 From: mer0m Date: Thu, 11 May 2017 09:06:01 +0200 Subject: [PATCH] double_dds client --- redpitaya/client/double_dds.grc | 1026 +++++++++++++++++++++++++++++++++++++++ redpitaya/client/double_dds.py | 257 ++++++++++ 2 files changed, 1283 insertions(+) create mode 100644 redpitaya/client/double_dds.grc create mode 100755 redpitaya/client/double_dds.py diff --git a/redpitaya/client/double_dds.grc b/redpitaya/client/double_dds.grc new file mode 100644 index 0000000..5c6b68f --- /dev/null +++ b/redpitaya/client/double_dds.grc @@ -0,0 +1,1026 @@ + + + + Thu Feb 2 22:54:58 2017 + + options + + author + + + + window_size + 1000, 2000 + + + category + [GRC Hier Blocks] + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + qt_gui + + + hier_block_src_path + .: + + + id + double_dds + + + max_nouts + 0 + + + qt_qss_theme + + + + realtime_scheduling + + + + run_command + {python} -u {filename} + + + run_options + prompt + + + run + True + + + thread_safe_setters + + + + title + + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 104) + + + _rotation + 0 + + + id + addr + + + value + "192.168.0.204" + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (256, 396) + + + gui_hint + 1, 0 + + + _rotation + 0 + + + id + dds1_ampl + + + label + dds1_ampl + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 1 + + + stop + 2**13-1 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (256, 20) + + + gui_hint + 0, 0 + + + _rotation + 0 + + + id + dds1_nco + + + label + dds1_nco + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 1000 + + + stop + 60000000 + + + rangeType + float + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (256, 684) + + + gui_hint + 2, 0 + + + _rotation + 0 + + + id + dds1_offset + + + label + dds1_offset + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + -2**13 + + + step + 1 + + + stop + 2**13-1 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (256, 996) + + + gui_hint + 3, 0 + + + _rotation + 0 + + + id + dds1_phase + + + label + dds1_phase + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + -2**13 + + + step + 1 + + + stop + 2**13-1 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (600, 396) + + + gui_hint + 1, 1 + + + _rotation + 0 + + + id + dds2_ampl + + + label + dds2_ampl + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 1 + + + stop + 2**13-1 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (600, 20) + + + gui_hint + 0, 1 + + + _rotation + 0 + + + id + dds2_nco + + + label + dds2_nco + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 1000 + + + stop + 60000000 + + + rangeType + float + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (600, 684) + + + gui_hint + 2, 1 + + + _rotation + 0 + + + id + dds2_offset + + + label + dds2_offset + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + -2**13 + + + step + 1 + + + stop + 2**13-1 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (600, 996) + + + gui_hint + 3, 1 + + + _rotation + 0 + + + id + dds2_phase + + + label + dds2_phase + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + -2**13 + + + step + 1 + + + stop + 2**13-1 + + + rangeType + int + + + widget + counter_slider + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 176) + + + _rotation + 0 + + + id + port + + + value + 1001 + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + dds1_offset + + + device + /dev/dds1_offset + + + _enabled + True + + + _coordinate + (256, 852) + + + _rotation + 0 + + + id + add_const_set_offset_0 + + + port + port + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + dds1_ampl + + + device + /dev/dds1_ampl + + + _enabled + True + + + _coordinate + (256, 548) + + + _rotation + 0 + + + id + add_const_set_offset_0_0 + + + port + port + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + dds2_ampl + + + device + /dev/dds2_ampl + + + _enabled + True + + + _coordinate + (600, 548) + + + _rotation + 0 + + + id + add_const_set_offset_0_0_0 + + + port + port + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + dds2_offset + + + device + /dev/dds2_offset + + + _enabled + True + + + _coordinate + (600, 852) + + + _rotation + 0 + + + id + add_const_set_offset_0_1 + + + port + port + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + dds2_phase + + + device + /dev/dds2_phase + + + _enabled + True + + + _coordinate + (600, 1164) + + + _rotation + 0 + + + id + add_const_set_offset_0_1_0 + + + port + port + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + dds1_phase + + + device + /dev/dds1_phase + + + _enabled + True + + + _coordinate + (256, 1164) + + + _rotation + 0 + + + id + add_const_set_offset_0_2 + + + port + port + + + + nco_counter_send_conf + + acc_size + 32 + + + addr + addr + + + alias + + + + comment + + + + device + /dev/dds1_nco + + + _enabled + True + + + freq_dds + dds1_nco + + + freq_ref + 125000000 + + + _coordinate + (256, 168) + + + _rotation + 0 + + + id + nco_counter_send_conf_0 + + + offset + 0 + + + pinc_sw + 1 + + + poff_sw + 0 + + + port + port + + + + nco_counter_send_conf + + acc_size + 32 + + + addr + addr + + + alias + + + + comment + + + + device + /dev/dds2_nco + + + _enabled + True + + + freq_dds + dds2_nco + + + freq_ref + 125000000 + + + _coordinate + (600, 168) + + + _rotation + 0 + + + id + nco_counter_send_conf_0_0 + + + offset + 0 + + + pinc_sw + 1 + + + poff_sw + 0 + + + port + port + + + diff --git a/redpitaya/client/double_dds.py b/redpitaya/client/double_dds.py new file mode 100755 index 0000000..c29468e --- /dev/null +++ b/redpitaya/client/double_dds.py @@ -0,0 +1,257 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +################################################## +# GNU Radio Python Flow Graph +# Title: Double Dds +# Generated: Thu May 11 08:24:36 2017 +################################################## + +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 eng_notation +from gnuradio import gr +from gnuradio.eng_option import eng_option +from gnuradio.filter import firdes +from gnuradio.qtgui import Range, RangeWidget +from optparse import OptionParser +import redpitaya_gnuradio +import sys + + +class double_dds(gr.top_block, Qt.QWidget): + + def __init__(self): + gr.top_block.__init__(self, "Double Dds") + Qt.QWidget.__init__(self) + self.setWindowTitle("Double Dds") + 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", "double_dds") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + ################################################## + # Variables + ################################################## + self.port = port = 1001 + self.dds2_phase = dds2_phase = 0 + self.dds2_offset = dds2_offset = 0 + self.dds2_nco = dds2_nco = 0 + self.dds2_ampl = dds2_ampl = 0 + self.dds1_phase = dds1_phase = 0 + self.dds1_offset = dds1_offset = 0 + self.dds1_nco = dds1_nco = 0 + self.dds1_ampl = dds1_ampl = 0 + self.addr = addr = "192.168.0.204" + + ################################################## + # Blocks + ################################################## + self._dds2_phase_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._dds2_phase_win = RangeWidget(self._dds2_phase_range, self.set_dds2_phase, 'dds2_phase', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds2_phase_win, 3, 1) + self._dds2_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._dds2_offset_win = RangeWidget(self._dds2_offset_range, self.set_dds2_offset, 'dds2_offset', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds2_offset_win, 2, 1) + self._dds2_nco_range = Range(0, 60000000, 1000, 0, 200) + self._dds2_nco_win = RangeWidget(self._dds2_nco_range, self.set_dds2_nco, 'dds2_nco', "counter_slider", float) + self.top_grid_layout.addWidget(self._dds2_nco_win, 0, 1) + self._dds2_ampl_range = Range(0, 2**13-1, 1, 0, 200) + self._dds2_ampl_win = RangeWidget(self._dds2_ampl_range, self.set_dds2_ampl, 'dds2_ampl', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds2_ampl_win, 1, 1) + self._dds1_phase_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._dds1_phase_win = RangeWidget(self._dds1_phase_range, self.set_dds1_phase, 'dds1_phase', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds1_phase_win, 3, 0) + self._dds1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._dds1_offset_win = RangeWidget(self._dds1_offset_range, self.set_dds1_offset, 'dds1_offset', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds1_offset_win, 2, 0) + self._dds1_nco_range = Range(0, 60000000, 1000, 0, 200) + self._dds1_nco_win = RangeWidget(self._dds1_nco_range, self.set_dds1_nco, 'dds1_nco', "counter_slider", float) + self.top_grid_layout.addWidget(self._dds1_nco_win, 0, 0) + self._dds1_ampl_range = Range(0, 2**13-1, 1, 0, 200) + self._dds1_ampl_win = RangeWidget(self._dds1_ampl_range, self.set_dds1_ampl, 'dds1_ampl', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds1_ampl_win, 1, 0) + self.nco_counter_send_conf_0_0 = redpitaya_gnuradio.nco_counter_send_conf( + addr=addr, + port=port, + device='/dev/dds2_nco', + freq_ref=125000000, + freq_dds=dds2_nco, + acc_size=32, + offset=0, + pinc_sw=1, + poff_sw=0, + ) + + self.nco_counter_send_conf_0 = redpitaya_gnuradio.nco_counter_send_conf( + addr=addr, + port=port, + device='/dev/dds1_nco', + freq_ref=125000000, + freq_dds=dds1_nco, + acc_size=32, + offset=0, + pinc_sw=1, + poff_sw=0, + ) + + self.add_const_set_offset_0_2 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds1_phase', + const=dds1_phase, + ) + + self.add_const_set_offset_0_1_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds2_phase', + const=dds2_phase, + ) + + self.add_const_set_offset_0_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds2_offset', + const=dds2_offset, + ) + + self.add_const_set_offset_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds2_ampl', + const=dds2_ampl, + ) + + self.add_const_set_offset_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds1_ampl', + const=dds1_ampl, + ) + + self.add_const_set_offset_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds1_offset', + const=dds1_offset, + ) + + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "double_dds") + self.settings.setValue("geometry", self.saveGeometry()) + event.accept() + + def get_port(self): + return self.port + + def set_port(self, port): + self.port = port + + def get_dds2_phase(self): + return self.dds2_phase + + def set_dds2_phase(self, dds2_phase): + self.dds2_phase = dds2_phase + self.add_const_set_offset_0_1_0.set_const(device='/dev/dds2_phase', const=self.dds2_phase) + + def get_dds2_offset(self): + return self.dds2_offset + + def set_dds2_offset(self, dds2_offset): + self.dds2_offset = dds2_offset + self.add_const_set_offset_0_1.set_const(device='/dev/dds2_offset', const=self.dds2_offset) + + def get_dds2_nco(self): + return self.dds2_nco + + def set_dds2_nco(self, dds2_nco): + self.dds2_nco = dds2_nco + self.nco_counter_send_conf_0_0.set_nco(device='/dev/dds2_nco', freq_ref=125000000, freq_dds=self.dds2_nco, acc_size=32, offset=0, pinc_sw=1, poff_sw=0) + + def get_dds2_ampl(self): + return self.dds2_ampl + + def set_dds2_ampl(self, dds2_ampl): + self.dds2_ampl = dds2_ampl + self.add_const_set_offset_0_0_0.set_const(device='/dev/dds2_ampl', const=self.dds2_ampl) + + def get_dds1_phase(self): + return self.dds1_phase + + def set_dds1_phase(self, dds1_phase): + self.dds1_phase = dds1_phase + self.add_const_set_offset_0_2.set_const(device='/dev/dds1_phase', const=self.dds1_phase) + + def get_dds1_offset(self): + return self.dds1_offset + + def set_dds1_offset(self, dds1_offset): + self.dds1_offset = dds1_offset + self.add_const_set_offset_0.set_const(device='/dev/dds1_offset', const=self.dds1_offset) + + def get_dds1_nco(self): + return self.dds1_nco + + def set_dds1_nco(self, dds1_nco): + self.dds1_nco = dds1_nco + self.nco_counter_send_conf_0.set_nco(device='/dev/dds1_nco', freq_ref=125000000, freq_dds=self.dds1_nco, acc_size=32, offset=0, pinc_sw=1, poff_sw=0) + + def get_dds1_ampl(self): + return self.dds1_ampl + + def set_dds1_ampl(self, dds1_ampl): + self.dds1_ampl = dds1_ampl + self.add_const_set_offset_0_0.set_const(device='/dev/dds1_ampl', const=self.dds1_ampl) + + def get_addr(self): + return self.addr + + def set_addr(self, addr): + self.addr = addr + + +def main(top_block_cls=double_dds, options=None): + + 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() + tb.start() + tb.show() + + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() + + +if __name__ == '__main__': + main() -- 2.16.4