From 1a31d75add510d645bc4cb15b2c9ff974e1a2285 Mon Sep 17 00:00:00 2001 From: bma Date: Tue, 6 Feb 2018 20:42:50 +0100 Subject: [PATCH] replace 4 spaces by tabs --- redpitaya/client/dds_gnuradio.py | 260 +++---- redpitaya/client/double_dds.py | 450 ++++++------ redpitaya/client/double_pid_vco.py | 1104 ++++++++++++++-------------- redpitaya/client/iq_demod_only.py | 342 ++++----- redpitaya/client/iq_pid_vco.py | 712 +++++++++--------- redpitaya/client/pid_only.py | 444 +++++------ redpitaya/client/pid_vco.py | 670 ++++++++--------- redpitaya/client/pid_vco_pid_only.py | 874 +++++++++++----------- redpitaya/client/redpitaya_gnuradio.py | 78 +- redpitaya/client/vco_only.py | 468 ++++++------ redpitaya/server/server.py | 40 +- redpitaya/server/tests/set_offset.py | 42 +- redpitaya/server/tests/test.py | 6 +- redpitaya/server/tests/test_dac_offsets.py | 42 +- sdr/fm_radio/fm_radio.py | 312 ++++---- sdr/fm_radio/fm_radio_comp_decim_lpf.py | 420 +++++------ 16 files changed, 3132 insertions(+), 3132 deletions(-) diff --git a/redpitaya/client/dds_gnuradio.py b/redpitaya/client/dds_gnuradio.py index 5d71152..b6de25f 100755 --- a/redpitaya/client/dds_gnuradio.py +++ b/redpitaya/client/dds_gnuradio.py @@ -7,14 +7,14 @@ ################################################## 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()" + 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 @@ -29,134 +29,134 @@ import sys class dds_gnuradio(gr.top_block, Qt.QWidget): - def __init__(self): - gr.top_block.__init__(self, "Dds Gnuradio") - Qt.QWidget.__init__(self) - self.setWindowTitle("Dds Gnuradio") - 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", "dds_gnuradio") - self.restoreGeometry(self.settings.value("geometry").toByteArray()) - - ################################################## - # Variables - ################################################## - self.port = port = 1001 - self.offset_out1 = offset_out1 = 0 - self.f_dds = f_dds = 0 - self.addr = addr = "192.168.0.201" - self.a_dds = a_dds = 0 - - ################################################## - # Blocks - ################################################## - self._offset_out1_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._offset_out1_win = RangeWidget(self._offset_out1_range, self.set_offset_out1, 'Offset DDS', "counter_slider", int) - self.top_grid_layout.addWidget(self._offset_out1_win, 2, 0) - self._f_dds_range = Range(0, 60000000, 1000, 0, 200) - self._f_dds_win = RangeWidget(self._f_dds_range, self.set_f_dds, 'DDS frequency', "counter_slider", float) - self.top_grid_layout.addWidget(self._f_dds_win, 0, 0) - self._a_dds_range = Range(0, 2**13-1, 1, 0, 200) - self._a_dds_win = RangeWidget(self._a_dds_range, self.set_a_dds, 'DDS amplitude', "counter_slider", int) - self.top_grid_layout.addWidget(self._a_dds_win, 1, 0) - self.nco_counter_send_conf_0 = redpitaya_gnuradio.nco_counter_send_conf( - addr=addr, - port=port, - device='/dev/dds_freq', - freq_ref=125000000, - freq_dds=f_dds, - acc_size=32, - offset=0, - pinc_sw=1, - poff_sw=1, - ) - - self.add_const_set_offset_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds_ampl', - const=a_dds, - ) - - self.add_const_set_offset_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds_offset', - const=offset_out1, - ) - - - def closeEvent(self, event): - self.settings = Qt.QSettings("GNU Radio", "dds_gnuradio") - 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_offset_out1(self): - return self.offset_out1 - - def set_offset_out1(self, offset_out1): - self.offset_out1 = offset_out1 - self.add_const_set_offset_0.set_const(device='/dev/dds_offset', const=self.offset_out1) - - def get_f_dds(self): - return self.f_dds - - def set_f_dds(self, f_dds): - self.f_dds = f_dds - self.nco_counter_send_conf_0.set_nco(device='/dev/dds_freq', freq_ref=125000000, freq_dds=self.f_dds, acc_size=32, offset=0, pinc_sw=1, poff_sw=1) - - def get_addr(self): - return self.addr - - def set_addr(self, addr): - self.addr = addr - - def get_a_dds(self): - return self.a_dds - - def set_a_dds(self, a_dds): - self.a_dds = a_dds - self.add_const_set_offset_0_0.set_const(device='/dev/dds_ampl', const=self.a_dds) + def __init__(self): + gr.top_block.__init__(self, "Dds Gnuradio") + Qt.QWidget.__init__(self) + self.setWindowTitle("Dds Gnuradio") + 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", "dds_gnuradio") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + ################################################## + # Variables + ################################################## + self.port = port = 1001 + self.offset_out1 = offset_out1 = 0 + self.f_dds = f_dds = 0 + self.addr = addr = "192.168.0.201" + self.a_dds = a_dds = 0 + + ################################################## + # Blocks + ################################################## + self._offset_out1_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._offset_out1_win = RangeWidget(self._offset_out1_range, self.set_offset_out1, 'Offset DDS', "counter_slider", int) + self.top_grid_layout.addWidget(self._offset_out1_win, 2, 0) + self._f_dds_range = Range(0, 60000000, 1000, 0, 200) + self._f_dds_win = RangeWidget(self._f_dds_range, self.set_f_dds, 'DDS frequency', "counter_slider", float) + self.top_grid_layout.addWidget(self._f_dds_win, 0, 0) + self._a_dds_range = Range(0, 2**13-1, 1, 0, 200) + self._a_dds_win = RangeWidget(self._a_dds_range, self.set_a_dds, 'DDS amplitude', "counter_slider", int) + self.top_grid_layout.addWidget(self._a_dds_win, 1, 0) + self.nco_counter_send_conf_0 = redpitaya_gnuradio.nco_counter_send_conf( + addr=addr, + port=port, + device='/dev/dds_freq', + freq_ref=125000000, + freq_dds=f_dds, + acc_size=32, + offset=0, + pinc_sw=1, + poff_sw=1, + ) + + self.add_const_set_offset_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds_ampl', + const=a_dds, + ) + + self.add_const_set_offset_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds_offset', + const=offset_out1, + ) + + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "dds_gnuradio") + 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_offset_out1(self): + return self.offset_out1 + + def set_offset_out1(self, offset_out1): + self.offset_out1 = offset_out1 + self.add_const_set_offset_0.set_const(device='/dev/dds_offset', const=self.offset_out1) + + def get_f_dds(self): + return self.f_dds + + def set_f_dds(self, f_dds): + self.f_dds = f_dds + self.nco_counter_send_conf_0.set_nco(device='/dev/dds_freq', freq_ref=125000000, freq_dds=self.f_dds, acc_size=32, offset=0, pinc_sw=1, poff_sw=1) + + def get_addr(self): + return self.addr + + def set_addr(self, addr): + self.addr = addr + + def get_a_dds(self): + return self.a_dds + + def set_a_dds(self, a_dds): + self.a_dds = a_dds + self.add_const_set_offset_0_0.set_const(device='/dev/dds_ampl', const=self.a_dds) def main(top_block_cls=dds_gnuradio, 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) + 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() + tb = top_block_cls() + tb.start() + tb.show() - def quitting(): - tb.stop() - tb.wait() - qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) - qapp.exec_() + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() if __name__ == '__main__': - main() + main() diff --git a/redpitaya/client/double_dds.py b/redpitaya/client/double_dds.py index d7f9eb7..28d665a 100755 --- a/redpitaya/client/double_dds.py +++ b/redpitaya/client/double_dds.py @@ -7,14 +7,14 @@ ################################################## 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()" + 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 @@ -29,229 +29,229 @@ 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 __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) + 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() + tb = top_block_cls() + tb.start() + tb.show() - def quitting(): - tb.stop() - tb.wait() - qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) - qapp.exec_() + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() if __name__ == '__main__': - main() + main() diff --git a/redpitaya/client/double_pid_vco.py b/redpitaya/client/double_pid_vco.py index c82b247..abc1ee1 100755 --- a/redpitaya/client/double_pid_vco.py +++ b/redpitaya/client/double_pid_vco.py @@ -7,14 +7,14 @@ ################################################## 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()" + 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 @@ -29,595 +29,595 @@ import sys class double_pid_vco(gr.top_block, Qt.QWidget): - def __init__(self): - gr.top_block.__init__(self, "Double Pid Vco") - Qt.QWidget.__init__(self) - self.setWindowTitle("Double Pid Vco") - 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_pid_vco") - self.restoreGeometry(self.settings.value("geometry").toByteArray()) - - ################################################## - # Variables - ################################################## - self.port = port = 1001 - self.pid2_sign = pid2_sign = 0 - self.pid2_setpoint = pid2_setpoint = 0 - self.pid2_rst_int = pid2_rst_int = 0 - self.pid2_kp = pid2_kp = 0 - self.pid2_ki = pid2_ki = 0 - self.pid2_kd = pid2_kd = 0 - self.pid1_sign = pid1_sign = 0 - self.pid1_setpoint = pid1_setpoint = 0 - self.pid1_rst_int = pid1_rst_int = 0 - self.pid1_kp = pid1_kp = 0 - self.pid1_ki = pid1_ki = 0 - self.pid1_kd = pid1_kd = 0 - self.dds2_range = dds2_range = 0 - self.dds2_poff_sw = dds2_poff_sw = 1 - self.dds2_pinc_sw = dds2_pinc_sw = 1 - self.dds2_offset = dds2_offset = 0 - self.dds2_nco = dds2_nco = 40750000 - self.dds2_f0 = dds2_f0 = 40750000 - self.dds2_ampl = dds2_ampl = 0 - self.dds1_range = dds1_range = 0 - self.dds1_poff_sw = dds1_poff_sw = 1 - self.dds1_pinc_sw = dds1_pinc_sw = 1 - self.dds1_offset = dds1_offset = 0 - self.dds1_nco = dds1_nco = 39500000 - self.dds1_f0 = dds1_f0 = 39500000 - self.dds1_ampl = dds1_ampl = 0 - self.addr = addr = "192.168.0.203" - self.adc2_offset = adc2_offset = 0 - self.adc1_offset = adc1_offset = 0 - - ################################################## - # Blocks - ################################################## - _pid2_sign_check_box = Qt.QCheckBox('pid2_sign') - self._pid2_sign_choices = {True: 1, False: 0} - self._pid2_sign_choices_inv = dict((v,k) for k,v in self._pid2_sign_choices.iteritems()) - self._pid2_sign_callback = lambda i: Qt.QMetaObject.invokeMethod(_pid2_sign_check_box, "setChecked", Qt.Q_ARG("bool", self._pid2_sign_choices_inv[i])) - self._pid2_sign_callback(self.pid2_sign) - _pid2_sign_check_box.stateChanged.connect(lambda i: self.set_pid2_sign(self._pid2_sign_choices[bool(i)])) - self.top_grid_layout.addWidget(_pid2_sign_check_box, 10,1) - self._pid2_setpoint_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._pid2_setpoint_win = RangeWidget(self._pid2_setpoint_range, self.set_pid2_setpoint, 'pid2_setpoint', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid2_setpoint_win, 9,1) - _pid2_rst_int_push_button = Qt.QPushButton('pid2_rst_int') - self._pid2_rst_int_choices = {'Pressed': 1, 'Released': 0} - _pid2_rst_int_push_button.pressed.connect(lambda: self.set_pid2_rst_int(self._pid2_rst_int_choices['Pressed'])) - _pid2_rst_int_push_button.released.connect(lambda: self.set_pid2_rst_int(self._pid2_rst_int_choices['Released'])) - self.top_grid_layout.addWidget(_pid2_rst_int_push_button, 11,1) - self._pid2_kp_range = Range(0, 2**13-1, 1, 0, 200) - self._pid2_kp_win = RangeWidget(self._pid2_kp_range, self.set_pid2_kp, 'pid2_kp', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid2_kp_win, 6,1) - self._pid2_ki_range = Range(0, 2**13-1, 1, 0, 200) - self._pid2_ki_win = RangeWidget(self._pid2_ki_range, self.set_pid2_ki, 'pid2_ki', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid2_ki_win, 7,1) - self._pid2_kd_range = Range(0, 2**13-1, 1, 0, 200) - self._pid2_kd_win = RangeWidget(self._pid2_kd_range, self.set_pid2_kd, 'pid2_kd', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid2_kd_win, 8,1) - _pid1_sign_check_box = Qt.QCheckBox('pid1_sign') - self._pid1_sign_choices = {True: 1, False: 0} - self._pid1_sign_choices_inv = dict((v,k) for k,v in self._pid1_sign_choices.iteritems()) - self._pid1_sign_callback = lambda i: Qt.QMetaObject.invokeMethod(_pid1_sign_check_box, "setChecked", Qt.Q_ARG("bool", self._pid1_sign_choices_inv[i])) - self._pid1_sign_callback(self.pid1_sign) - _pid1_sign_check_box.stateChanged.connect(lambda i: self.set_pid1_sign(self._pid1_sign_choices[bool(i)])) - self.top_grid_layout.addWidget(_pid1_sign_check_box, 10,0) - self._pid1_setpoint_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._pid1_setpoint_win = RangeWidget(self._pid1_setpoint_range, self.set_pid1_setpoint, 'pid1_setpoint', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid1_setpoint_win, 9,0) - _pid1_rst_int_push_button = Qt.QPushButton('pid1_rst_int') - self._pid1_rst_int_choices = {'Pressed': 1, 'Released': 0} - _pid1_rst_int_push_button.pressed.connect(lambda: self.set_pid1_rst_int(self._pid1_rst_int_choices['Pressed'])) - _pid1_rst_int_push_button.released.connect(lambda: self.set_pid1_rst_int(self._pid1_rst_int_choices['Released'])) - self.top_grid_layout.addWidget(_pid1_rst_int_push_button, 11,0) - self._pid1_kp_range = Range(0, 2**13-1, 1, 0, 200) - self._pid1_kp_win = RangeWidget(self._pid1_kp_range, self.set_pid1_kp, 'pid1_kp', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid1_kp_win, 6,0) - self._pid1_ki_range = Range(0, 2**13-1, 1, 0, 200) - self._pid1_ki_win = RangeWidget(self._pid1_ki_range, self.set_pid1_ki, 'pid1_ki', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid1_ki_win, 7,0) - self._pid1_kd_range = Range(0, 2**13-1, 1, 0, 200) - self._pid1_kd_win = RangeWidget(self._pid1_kd_range, self.set_pid1_kd, 'pid1_kd', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid1_kd_win, 8,0) - self._dds2_range_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._dds2_range_win = RangeWidget(self._dds2_range_range, self.set_dds2_range, 'dds2_range', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds2_range_win, 13,1) - _dds2_poff_sw_check_box = Qt.QCheckBox('dds2_poff_sw') - self._dds2_poff_sw_choices = {True: 1, False: 0} - self._dds2_poff_sw_choices_inv = dict((v,k) for k,v in self._dds2_poff_sw_choices.iteritems()) - self._dds2_poff_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds2_poff_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds2_poff_sw_choices_inv[i])) - self._dds2_poff_sw_callback(self.dds2_poff_sw) - _dds2_poff_sw_check_box.stateChanged.connect(lambda i: self.set_dds2_poff_sw(self._dds2_poff_sw_choices[bool(i)])) - self.top_grid_layout.addWidget(_dds2_poff_sw_check_box, 2, 1) - _dds2_pinc_sw_check_box = Qt.QCheckBox('dds2_pinc_sw') - self._dds2_pinc_sw_choices = {True: 1, False: 0} - self._dds2_pinc_sw_choices_inv = dict((v,k) for k,v in self._dds2_pinc_sw_choices.iteritems()) - self._dds2_pinc_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds2_pinc_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds2_pinc_sw_choices_inv[i])) - self._dds2_pinc_sw_callback(self.dds2_pinc_sw) - _dds2_pinc_sw_check_box.stateChanged.connect(lambda i: self.set_dds2_pinc_sw(self._dds2_pinc_sw_choices[bool(i)])) - self.top_grid_layout.addWidget(_dds2_pinc_sw_check_box, 1,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, 4,1) - self._dds2_nco_range = Range(0, 60000000, 1, 40750000, 200) - self._dds2_nco_win = RangeWidget(self._dds2_nco_range, self.set_dds2_nco, 'dds2_nco', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds2_nco_win, 0,1) - self._dds2_f0_range = Range(0, 60000000, 1, 40750000, 200) - self._dds2_f0_win = RangeWidget(self._dds2_f0_range, self.set_dds2_f0, 'dds2_f0', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds2_f0_win, 12,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, 3,1) - self._dds1_range_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._dds1_range_win = RangeWidget(self._dds1_range_range, self.set_dds1_range, 'dds1_range', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds1_range_win, 13,0) - _dds1_poff_sw_check_box = Qt.QCheckBox('dds1_poff_sw') - self._dds1_poff_sw_choices = {True: 1, False: 0} - self._dds1_poff_sw_choices_inv = dict((v,k) for k,v in self._dds1_poff_sw_choices.iteritems()) - self._dds1_poff_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds1_poff_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds1_poff_sw_choices_inv[i])) - self._dds1_poff_sw_callback(self.dds1_poff_sw) - _dds1_poff_sw_check_box.stateChanged.connect(lambda i: self.set_dds1_poff_sw(self._dds1_poff_sw_choices[bool(i)])) - self.top_grid_layout.addWidget(_dds1_poff_sw_check_box, 2, 0) - _dds1_pinc_sw_check_box = Qt.QCheckBox('dds1_pinc_sw') - self._dds1_pinc_sw_choices = {True: 1, False: 0} - self._dds1_pinc_sw_choices_inv = dict((v,k) for k,v in self._dds1_pinc_sw_choices.iteritems()) - self._dds1_pinc_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds1_pinc_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds1_pinc_sw_choices_inv[i])) - self._dds1_pinc_sw_callback(self.dds1_pinc_sw) - _dds1_pinc_sw_check_box.stateChanged.connect(lambda i: self.set_dds1_pinc_sw(self._dds1_pinc_sw_choices[bool(i)])) - self.top_grid_layout.addWidget(_dds1_pinc_sw_check_box, 1,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, 4,0) - self._dds1_nco_range = Range(0, 60000000, 1, 39500000, 200) - self._dds1_nco_win = RangeWidget(self._dds1_nco_range, self.set_dds1_nco, 'dds1_nco', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds1_nco_win, 0,0) - self._dds1_f0_range = Range(0, 60000000, 1, 39500000, 200) - self._dds1_f0_win = RangeWidget(self._dds1_f0_range, self.set_dds1_f0, 'dds1_f0', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds1_f0_win, 12,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, 3,0) - self._adc2_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._adc2_offset_win = RangeWidget(self._adc2_offset_range, self.set_adc2_offset, 'adc2_offset', "counter_slider", int) - self.top_grid_layout.addWidget(self._adc2_offset_win, 5,1) - self._adc1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._adc1_offset_win = RangeWidget(self._adc1_offset_range, self.set_adc1_offset, 'adc1_offset', "counter_slider", int) - self.top_grid_layout.addWidget(self._adc1_offset_win, 5,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=dds2_pinc_sw, - poff_sw=dds2_poff_sw, - ) - - 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=dds1_pinc_sw, - poff_sw=dds1_poff_sw, - ) - - self.add_const_set_offset_0_0_0_1_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid2_setpoint', - const=pid2_setpoint, - ) - - self.add_const_set_offset_0_0_0_1_0_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid2_kp', - const=pid2_kp, - ) - - self.add_const_set_offset_0_0_0_1_0_0_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid2_ki', - const=pid2_ki, - ) - - self.add_const_set_offset_0_0_0_1_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid2_kd', - const=pid2_kd, - ) - - self.add_const_set_offset_0_0_0_1_0_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid2_sign', - const=pid2_sign, - ) - - self.add_const_set_offset_0_0_0_1_0_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid2_rst_int', - const=pid2_rst_int, - ) - - self.add_const_set_offset_0_0_0_1_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid1_rst_int', - const=pid1_rst_int, - ) - - self.add_const_set_offset_0_0_0_1_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid1_sign', - const=pid1_sign, - ) - - self.add_const_set_offset_0_0_0_1_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid1_kd', - const=pid1_kd, - ) - - self.add_const_set_offset_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid1_ki', - const=pid1_ki, - ) - - self.add_const_set_offset_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid1_kp', - const=pid1_kp, - ) - - self.add_const_set_offset_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid1_setpoint', - const=pid1_setpoint, - ) - - self.add_const_set_offset_0_0_0_0_1_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_0_1_0_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds2_f0', - const=int(dds2_f0/(125e6/2**32)), - ) - - self.add_const_set_offset_0_0_0_0_1_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds2_range', - const=dds2_range, - ) - - self.add_const_set_offset_0_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds1_range', - const=dds1_range, - ) - - self.add_const_set_offset_0_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds1_f0', - const=int(dds1_f0/(125e6/2**32)), - ) - - self.add_const_set_offset_0_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds1_offset', - const=dds1_offset, - ) - - self.add_const_set_offset_0_0_0_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_0_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_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/adc2_offset', - const=adc2_offset, - ) - - self.add_const_set_offset_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/adc1_offset', - const=adc1_offset, - ) - - - def closeEvent(self, event): - self.settings = Qt.QSettings("GNU Radio", "double_pid_vco") - 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_pid2_sign(self): - return self.pid2_sign - - def set_pid2_sign(self, pid2_sign): - self.pid2_sign = pid2_sign - self._pid2_sign_callback(self.pid2_sign) - self.add_const_set_offset_0_0_0_1_0_0_0_0_1.set_const(device='/dev/pid2_sign', const=self.pid2_sign) - - def get_pid2_setpoint(self): - return self.pid2_setpoint - - def set_pid2_setpoint(self, pid2_setpoint): - self.pid2_setpoint = pid2_setpoint - self.add_const_set_offset_0_0_0_1_1.set_const(device='/dev/pid2_setpoint', const=self.pid2_setpoint) - - def get_pid2_rst_int(self): - return self.pid2_rst_int - - def set_pid2_rst_int(self, pid2_rst_int): - self.pid2_rst_int = pid2_rst_int - self.add_const_set_offset_0_0_0_1_0_0_0_0_0_0.set_const(device='/dev/pid2_rst_int', const=self.pid2_rst_int) - - def get_pid2_kp(self): - return self.pid2_kp - - def set_pid2_kp(self, pid2_kp): - self.pid2_kp = pid2_kp - self.add_const_set_offset_0_0_0_1_0_1.set_const(device='/dev/pid2_kp', const=self.pid2_kp) - - def get_pid2_ki(self): - return self.pid2_ki - - def set_pid2_ki(self, pid2_ki): - self.pid2_ki = pid2_ki - self.add_const_set_offset_0_0_0_1_0_0_1.set_const(device='/dev/pid2_ki', const=self.pid2_ki) - - def get_pid2_kd(self): - return self.pid2_kd - - def set_pid2_kd(self, pid2_kd): - self.pid2_kd = pid2_kd - self.add_const_set_offset_0_0_0_1_0_0_0_1.set_const(device='/dev/pid2_kd', const=self.pid2_kd) - - def get_pid1_sign(self): - return self.pid1_sign - - def set_pid1_sign(self, pid1_sign): - self.pid1_sign = pid1_sign - self._pid1_sign_callback(self.pid1_sign) - self.add_const_set_offset_0_0_0_1_0_0_0_0.set_const(device='/dev/pid1_sign', const=self.pid1_sign) - - def get_pid1_setpoint(self): - return self.pid1_setpoint - - def set_pid1_setpoint(self, pid1_setpoint): - self.pid1_setpoint = pid1_setpoint - self.add_const_set_offset_0_0_0_1.set_const(device='/dev/pid1_setpoint', const=self.pid1_setpoint) - - def get_pid1_rst_int(self): - return self.pid1_rst_int - - def set_pid1_rst_int(self, pid1_rst_int): - self.pid1_rst_int = pid1_rst_int - self.add_const_set_offset_0_0_0_1_0_0_0_0_0.set_const(device='/dev/pid1_rst_int', const=self.pid1_rst_int) - - def get_pid1_kp(self): - return self.pid1_kp + def __init__(self): + gr.top_block.__init__(self, "Double Pid Vco") + Qt.QWidget.__init__(self) + self.setWindowTitle("Double Pid Vco") + 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_pid_vco") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + ################################################## + # Variables + ################################################## + self.port = port = 1001 + self.pid2_sign = pid2_sign = 0 + self.pid2_setpoint = pid2_setpoint = 0 + self.pid2_rst_int = pid2_rst_int = 0 + self.pid2_kp = pid2_kp = 0 + self.pid2_ki = pid2_ki = 0 + self.pid2_kd = pid2_kd = 0 + self.pid1_sign = pid1_sign = 0 + self.pid1_setpoint = pid1_setpoint = 0 + self.pid1_rst_int = pid1_rst_int = 0 + self.pid1_kp = pid1_kp = 0 + self.pid1_ki = pid1_ki = 0 + self.pid1_kd = pid1_kd = 0 + self.dds2_range = dds2_range = 0 + self.dds2_poff_sw = dds2_poff_sw = 1 + self.dds2_pinc_sw = dds2_pinc_sw = 1 + self.dds2_offset = dds2_offset = 0 + self.dds2_nco = dds2_nco = 40750000 + self.dds2_f0 = dds2_f0 = 40750000 + self.dds2_ampl = dds2_ampl = 0 + self.dds1_range = dds1_range = 0 + self.dds1_poff_sw = dds1_poff_sw = 1 + self.dds1_pinc_sw = dds1_pinc_sw = 1 + self.dds1_offset = dds1_offset = 0 + self.dds1_nco = dds1_nco = 39500000 + self.dds1_f0 = dds1_f0 = 39500000 + self.dds1_ampl = dds1_ampl = 0 + self.addr = addr = "192.168.0.203" + self.adc2_offset = adc2_offset = 0 + self.adc1_offset = adc1_offset = 0 + + ################################################## + # Blocks + ################################################## + _pid2_sign_check_box = Qt.QCheckBox('pid2_sign') + self._pid2_sign_choices = {True: 1, False: 0} + self._pid2_sign_choices_inv = dict((v,k) for k,v in self._pid2_sign_choices.iteritems()) + self._pid2_sign_callback = lambda i: Qt.QMetaObject.invokeMethod(_pid2_sign_check_box, "setChecked", Qt.Q_ARG("bool", self._pid2_sign_choices_inv[i])) + self._pid2_sign_callback(self.pid2_sign) + _pid2_sign_check_box.stateChanged.connect(lambda i: self.set_pid2_sign(self._pid2_sign_choices[bool(i)])) + self.top_grid_layout.addWidget(_pid2_sign_check_box, 10,1) + self._pid2_setpoint_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._pid2_setpoint_win = RangeWidget(self._pid2_setpoint_range, self.set_pid2_setpoint, 'pid2_setpoint', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid2_setpoint_win, 9,1) + _pid2_rst_int_push_button = Qt.QPushButton('pid2_rst_int') + self._pid2_rst_int_choices = {'Pressed': 1, 'Released': 0} + _pid2_rst_int_push_button.pressed.connect(lambda: self.set_pid2_rst_int(self._pid2_rst_int_choices['Pressed'])) + _pid2_rst_int_push_button.released.connect(lambda: self.set_pid2_rst_int(self._pid2_rst_int_choices['Released'])) + self.top_grid_layout.addWidget(_pid2_rst_int_push_button, 11,1) + self._pid2_kp_range = Range(0, 2**13-1, 1, 0, 200) + self._pid2_kp_win = RangeWidget(self._pid2_kp_range, self.set_pid2_kp, 'pid2_kp', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid2_kp_win, 6,1) + self._pid2_ki_range = Range(0, 2**13-1, 1, 0, 200) + self._pid2_ki_win = RangeWidget(self._pid2_ki_range, self.set_pid2_ki, 'pid2_ki', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid2_ki_win, 7,1) + self._pid2_kd_range = Range(0, 2**13-1, 1, 0, 200) + self._pid2_kd_win = RangeWidget(self._pid2_kd_range, self.set_pid2_kd, 'pid2_kd', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid2_kd_win, 8,1) + _pid1_sign_check_box = Qt.QCheckBox('pid1_sign') + self._pid1_sign_choices = {True: 1, False: 0} + self._pid1_sign_choices_inv = dict((v,k) for k,v in self._pid1_sign_choices.iteritems()) + self._pid1_sign_callback = lambda i: Qt.QMetaObject.invokeMethod(_pid1_sign_check_box, "setChecked", Qt.Q_ARG("bool", self._pid1_sign_choices_inv[i])) + self._pid1_sign_callback(self.pid1_sign) + _pid1_sign_check_box.stateChanged.connect(lambda i: self.set_pid1_sign(self._pid1_sign_choices[bool(i)])) + self.top_grid_layout.addWidget(_pid1_sign_check_box, 10,0) + self._pid1_setpoint_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._pid1_setpoint_win = RangeWidget(self._pid1_setpoint_range, self.set_pid1_setpoint, 'pid1_setpoint', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid1_setpoint_win, 9,0) + _pid1_rst_int_push_button = Qt.QPushButton('pid1_rst_int') + self._pid1_rst_int_choices = {'Pressed': 1, 'Released': 0} + _pid1_rst_int_push_button.pressed.connect(lambda: self.set_pid1_rst_int(self._pid1_rst_int_choices['Pressed'])) + _pid1_rst_int_push_button.released.connect(lambda: self.set_pid1_rst_int(self._pid1_rst_int_choices['Released'])) + self.top_grid_layout.addWidget(_pid1_rst_int_push_button, 11,0) + self._pid1_kp_range = Range(0, 2**13-1, 1, 0, 200) + self._pid1_kp_win = RangeWidget(self._pid1_kp_range, self.set_pid1_kp, 'pid1_kp', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid1_kp_win, 6,0) + self._pid1_ki_range = Range(0, 2**13-1, 1, 0, 200) + self._pid1_ki_win = RangeWidget(self._pid1_ki_range, self.set_pid1_ki, 'pid1_ki', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid1_ki_win, 7,0) + self._pid1_kd_range = Range(0, 2**13-1, 1, 0, 200) + self._pid1_kd_win = RangeWidget(self._pid1_kd_range, self.set_pid1_kd, 'pid1_kd', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid1_kd_win, 8,0) + self._dds2_range_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._dds2_range_win = RangeWidget(self._dds2_range_range, self.set_dds2_range, 'dds2_range', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds2_range_win, 13,1) + _dds2_poff_sw_check_box = Qt.QCheckBox('dds2_poff_sw') + self._dds2_poff_sw_choices = {True: 1, False: 0} + self._dds2_poff_sw_choices_inv = dict((v,k) for k,v in self._dds2_poff_sw_choices.iteritems()) + self._dds2_poff_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds2_poff_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds2_poff_sw_choices_inv[i])) + self._dds2_poff_sw_callback(self.dds2_poff_sw) + _dds2_poff_sw_check_box.stateChanged.connect(lambda i: self.set_dds2_poff_sw(self._dds2_poff_sw_choices[bool(i)])) + self.top_grid_layout.addWidget(_dds2_poff_sw_check_box, 2, 1) + _dds2_pinc_sw_check_box = Qt.QCheckBox('dds2_pinc_sw') + self._dds2_pinc_sw_choices = {True: 1, False: 0} + self._dds2_pinc_sw_choices_inv = dict((v,k) for k,v in self._dds2_pinc_sw_choices.iteritems()) + self._dds2_pinc_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds2_pinc_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds2_pinc_sw_choices_inv[i])) + self._dds2_pinc_sw_callback(self.dds2_pinc_sw) + _dds2_pinc_sw_check_box.stateChanged.connect(lambda i: self.set_dds2_pinc_sw(self._dds2_pinc_sw_choices[bool(i)])) + self.top_grid_layout.addWidget(_dds2_pinc_sw_check_box, 1,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, 4,1) + self._dds2_nco_range = Range(0, 60000000, 1, 40750000, 200) + self._dds2_nco_win = RangeWidget(self._dds2_nco_range, self.set_dds2_nco, 'dds2_nco', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds2_nco_win, 0,1) + self._dds2_f0_range = Range(0, 60000000, 1, 40750000, 200) + self._dds2_f0_win = RangeWidget(self._dds2_f0_range, self.set_dds2_f0, 'dds2_f0', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds2_f0_win, 12,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, 3,1) + self._dds1_range_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._dds1_range_win = RangeWidget(self._dds1_range_range, self.set_dds1_range, 'dds1_range', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds1_range_win, 13,0) + _dds1_poff_sw_check_box = Qt.QCheckBox('dds1_poff_sw') + self._dds1_poff_sw_choices = {True: 1, False: 0} + self._dds1_poff_sw_choices_inv = dict((v,k) for k,v in self._dds1_poff_sw_choices.iteritems()) + self._dds1_poff_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds1_poff_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds1_poff_sw_choices_inv[i])) + self._dds1_poff_sw_callback(self.dds1_poff_sw) + _dds1_poff_sw_check_box.stateChanged.connect(lambda i: self.set_dds1_poff_sw(self._dds1_poff_sw_choices[bool(i)])) + self.top_grid_layout.addWidget(_dds1_poff_sw_check_box, 2, 0) + _dds1_pinc_sw_check_box = Qt.QCheckBox('dds1_pinc_sw') + self._dds1_pinc_sw_choices = {True: 1, False: 0} + self._dds1_pinc_sw_choices_inv = dict((v,k) for k,v in self._dds1_pinc_sw_choices.iteritems()) + self._dds1_pinc_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds1_pinc_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds1_pinc_sw_choices_inv[i])) + self._dds1_pinc_sw_callback(self.dds1_pinc_sw) + _dds1_pinc_sw_check_box.stateChanged.connect(lambda i: self.set_dds1_pinc_sw(self._dds1_pinc_sw_choices[bool(i)])) + self.top_grid_layout.addWidget(_dds1_pinc_sw_check_box, 1,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, 4,0) + self._dds1_nco_range = Range(0, 60000000, 1, 39500000, 200) + self._dds1_nco_win = RangeWidget(self._dds1_nco_range, self.set_dds1_nco, 'dds1_nco', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds1_nco_win, 0,0) + self._dds1_f0_range = Range(0, 60000000, 1, 39500000, 200) + self._dds1_f0_win = RangeWidget(self._dds1_f0_range, self.set_dds1_f0, 'dds1_f0', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds1_f0_win, 12,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, 3,0) + self._adc2_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._adc2_offset_win = RangeWidget(self._adc2_offset_range, self.set_adc2_offset, 'adc2_offset', "counter_slider", int) + self.top_grid_layout.addWidget(self._adc2_offset_win, 5,1) + self._adc1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._adc1_offset_win = RangeWidget(self._adc1_offset_range, self.set_adc1_offset, 'adc1_offset', "counter_slider", int) + self.top_grid_layout.addWidget(self._adc1_offset_win, 5,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=dds2_pinc_sw, + poff_sw=dds2_poff_sw, + ) + + 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=dds1_pinc_sw, + poff_sw=dds1_poff_sw, + ) + + self.add_const_set_offset_0_0_0_1_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid2_setpoint', + const=pid2_setpoint, + ) + + self.add_const_set_offset_0_0_0_1_0_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid2_kp', + const=pid2_kp, + ) + + self.add_const_set_offset_0_0_0_1_0_0_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid2_ki', + const=pid2_ki, + ) + + self.add_const_set_offset_0_0_0_1_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid2_kd', + const=pid2_kd, + ) + + self.add_const_set_offset_0_0_0_1_0_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid2_sign', + const=pid2_sign, + ) + + self.add_const_set_offset_0_0_0_1_0_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid2_rst_int', + const=pid2_rst_int, + ) + + self.add_const_set_offset_0_0_0_1_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid1_rst_int', + const=pid1_rst_int, + ) + + self.add_const_set_offset_0_0_0_1_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid1_sign', + const=pid1_sign, + ) + + self.add_const_set_offset_0_0_0_1_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid1_kd', + const=pid1_kd, + ) + + self.add_const_set_offset_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid1_ki', + const=pid1_ki, + ) + + self.add_const_set_offset_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid1_kp', + const=pid1_kp, + ) + + self.add_const_set_offset_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid1_setpoint', + const=pid1_setpoint, + ) + + self.add_const_set_offset_0_0_0_0_1_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_0_1_0_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds2_f0', + const=int(dds2_f0/(125e6/2**32)), + ) + + self.add_const_set_offset_0_0_0_0_1_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds2_range', + const=dds2_range, + ) + + self.add_const_set_offset_0_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds1_range', + const=dds1_range, + ) + + self.add_const_set_offset_0_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds1_f0', + const=int(dds1_f0/(125e6/2**32)), + ) + + self.add_const_set_offset_0_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds1_offset', + const=dds1_offset, + ) + + self.add_const_set_offset_0_0_0_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_0_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_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/adc2_offset', + const=adc2_offset, + ) + + self.add_const_set_offset_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/adc1_offset', + const=adc1_offset, + ) + + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "double_pid_vco") + 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_pid2_sign(self): + return self.pid2_sign + + def set_pid2_sign(self, pid2_sign): + self.pid2_sign = pid2_sign + self._pid2_sign_callback(self.pid2_sign) + self.add_const_set_offset_0_0_0_1_0_0_0_0_1.set_const(device='/dev/pid2_sign', const=self.pid2_sign) + + def get_pid2_setpoint(self): + return self.pid2_setpoint + + def set_pid2_setpoint(self, pid2_setpoint): + self.pid2_setpoint = pid2_setpoint + self.add_const_set_offset_0_0_0_1_1.set_const(device='/dev/pid2_setpoint', const=self.pid2_setpoint) + + def get_pid2_rst_int(self): + return self.pid2_rst_int + + def set_pid2_rst_int(self, pid2_rst_int): + self.pid2_rst_int = pid2_rst_int + self.add_const_set_offset_0_0_0_1_0_0_0_0_0_0.set_const(device='/dev/pid2_rst_int', const=self.pid2_rst_int) + + def get_pid2_kp(self): + return self.pid2_kp + + def set_pid2_kp(self, pid2_kp): + self.pid2_kp = pid2_kp + self.add_const_set_offset_0_0_0_1_0_1.set_const(device='/dev/pid2_kp', const=self.pid2_kp) + + def get_pid2_ki(self): + return self.pid2_ki + + def set_pid2_ki(self, pid2_ki): + self.pid2_ki = pid2_ki + self.add_const_set_offset_0_0_0_1_0_0_1.set_const(device='/dev/pid2_ki', const=self.pid2_ki) + + def get_pid2_kd(self): + return self.pid2_kd + + def set_pid2_kd(self, pid2_kd): + self.pid2_kd = pid2_kd + self.add_const_set_offset_0_0_0_1_0_0_0_1.set_const(device='/dev/pid2_kd', const=self.pid2_kd) + + def get_pid1_sign(self): + return self.pid1_sign + + def set_pid1_sign(self, pid1_sign): + self.pid1_sign = pid1_sign + self._pid1_sign_callback(self.pid1_sign) + self.add_const_set_offset_0_0_0_1_0_0_0_0.set_const(device='/dev/pid1_sign', const=self.pid1_sign) + + def get_pid1_setpoint(self): + return self.pid1_setpoint + + def set_pid1_setpoint(self, pid1_setpoint): + self.pid1_setpoint = pid1_setpoint + self.add_const_set_offset_0_0_0_1.set_const(device='/dev/pid1_setpoint', const=self.pid1_setpoint) + + def get_pid1_rst_int(self): + return self.pid1_rst_int + + def set_pid1_rst_int(self, pid1_rst_int): + self.pid1_rst_int = pid1_rst_int + self.add_const_set_offset_0_0_0_1_0_0_0_0_0.set_const(device='/dev/pid1_rst_int', const=self.pid1_rst_int) + + def get_pid1_kp(self): + return self.pid1_kp - def set_pid1_kp(self, pid1_kp): - self.pid1_kp = pid1_kp - self.add_const_set_offset_0_0_0_1_0.set_const(device='/dev/pid1_kp', const=self.pid1_kp) + def set_pid1_kp(self, pid1_kp): + self.pid1_kp = pid1_kp + self.add_const_set_offset_0_0_0_1_0.set_const(device='/dev/pid1_kp', const=self.pid1_kp) - def get_pid1_ki(self): - return self.pid1_ki + def get_pid1_ki(self): + return self.pid1_ki - def set_pid1_ki(self, pid1_ki): - self.pid1_ki = pid1_ki - self.add_const_set_offset_0_0_0_1_0_0.set_const(device='/dev/pid1_ki', const=self.pid1_ki) + def set_pid1_ki(self, pid1_ki): + self.pid1_ki = pid1_ki + self.add_const_set_offset_0_0_0_1_0_0.set_const(device='/dev/pid1_ki', const=self.pid1_ki) - def get_pid1_kd(self): - return self.pid1_kd + def get_pid1_kd(self): + return self.pid1_kd - def set_pid1_kd(self, pid1_kd): - self.pid1_kd = pid1_kd - self.add_const_set_offset_0_0_0_1_0_0_0.set_const(device='/dev/pid1_kd', const=self.pid1_kd) + def set_pid1_kd(self, pid1_kd): + self.pid1_kd = pid1_kd + self.add_const_set_offset_0_0_0_1_0_0_0.set_const(device='/dev/pid1_kd', const=self.pid1_kd) - def get_dds2_range(self): - return self.dds2_range + def get_dds2_range(self): + return self.dds2_range - def set_dds2_range(self, dds2_range): - self.dds2_range = dds2_range - self.add_const_set_offset_0_0_0_0_1_0_0_0.set_const(device='/dev/dds2_range', const=self.dds2_range) + def set_dds2_range(self, dds2_range): + self.dds2_range = dds2_range + self.add_const_set_offset_0_0_0_0_1_0_0_0.set_const(device='/dev/dds2_range', const=self.dds2_range) - def get_dds2_poff_sw(self): - return self.dds2_poff_sw + def get_dds2_poff_sw(self): + return self.dds2_poff_sw - def set_dds2_poff_sw(self, dds2_poff_sw): - self.dds2_poff_sw = dds2_poff_sw - self._dds2_poff_sw_callback(self.dds2_poff_sw) - 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=self.dds2_pinc_sw, poff_sw=self.dds2_poff_sw) + def set_dds2_poff_sw(self, dds2_poff_sw): + self.dds2_poff_sw = dds2_poff_sw + self._dds2_poff_sw_callback(self.dds2_poff_sw) + 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=self.dds2_pinc_sw, poff_sw=self.dds2_poff_sw) - def get_dds2_pinc_sw(self): - return self.dds2_pinc_sw + def get_dds2_pinc_sw(self): + return self.dds2_pinc_sw - def set_dds2_pinc_sw(self, dds2_pinc_sw): - self.dds2_pinc_sw = dds2_pinc_sw - self._dds2_pinc_sw_callback(self.dds2_pinc_sw) - 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=self.dds2_pinc_sw, poff_sw=self.dds2_poff_sw) + def set_dds2_pinc_sw(self, dds2_pinc_sw): + self.dds2_pinc_sw = dds2_pinc_sw + self._dds2_pinc_sw_callback(self.dds2_pinc_sw) + 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=self.dds2_pinc_sw, poff_sw=self.dds2_poff_sw) - def get_dds2_offset(self): - return self.dds2_offset + 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_0_0_0_1_1.set_const(device='/dev/dds2_offset', const=self.dds2_offset) + def set_dds2_offset(self, dds2_offset): + self.dds2_offset = dds2_offset + self.add_const_set_offset_0_0_0_0_1_1.set_const(device='/dev/dds2_offset', const=self.dds2_offset) - def get_dds2_nco(self): - return self.dds2_nco + 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=self.dds2_pinc_sw, poff_sw=self.dds2_poff_sw) + 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=self.dds2_pinc_sw, poff_sw=self.dds2_poff_sw) - def get_dds2_f0(self): - return self.dds2_f0 + def get_dds2_f0(self): + return self.dds2_f0 - def set_dds2_f0(self, dds2_f0): - self.dds2_f0 = dds2_f0 - self.add_const_set_offset_0_0_0_0_1_0_1.set_const(device='/dev/dds2_f0', const=int(self.dds2_f0/(125e6/2**32))) + def set_dds2_f0(self, dds2_f0): + self.dds2_f0 = dds2_f0 + self.add_const_set_offset_0_0_0_0_1_0_1.set_const(device='/dev/dds2_f0', const=int(self.dds2_f0/(125e6/2**32))) - def get_dds2_ampl(self): - return self.dds2_ampl + 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_0_0_0.set_const(device='/dev/dds2_ampl', const=self.dds2_ampl) + def set_dds2_ampl(self, dds2_ampl): + self.dds2_ampl = dds2_ampl + self.add_const_set_offset_0_0_0_0_0_0.set_const(device='/dev/dds2_ampl', const=self.dds2_ampl) - def get_dds1_range(self): - return self.dds1_range + def get_dds1_range(self): + return self.dds1_range - def set_dds1_range(self, dds1_range): - self.dds1_range = dds1_range - self.add_const_set_offset_0_0_0_0_1_0_0.set_const(device='/dev/dds1_range', const=self.dds1_range) + def set_dds1_range(self, dds1_range): + self.dds1_range = dds1_range + self.add_const_set_offset_0_0_0_0_1_0_0.set_const(device='/dev/dds1_range', const=self.dds1_range) - def get_dds1_poff_sw(self): - return self.dds1_poff_sw + def get_dds1_poff_sw(self): + return self.dds1_poff_sw - def set_dds1_poff_sw(self, dds1_poff_sw): - self.dds1_poff_sw = dds1_poff_sw - self._dds1_poff_sw_callback(self.dds1_poff_sw) - 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=self.dds1_pinc_sw, poff_sw=self.dds1_poff_sw) + def set_dds1_poff_sw(self, dds1_poff_sw): + self.dds1_poff_sw = dds1_poff_sw + self._dds1_poff_sw_callback(self.dds1_poff_sw) + 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=self.dds1_pinc_sw, poff_sw=self.dds1_poff_sw) - def get_dds1_pinc_sw(self): - return self.dds1_pinc_sw + def get_dds1_pinc_sw(self): + return self.dds1_pinc_sw - def set_dds1_pinc_sw(self, dds1_pinc_sw): - self.dds1_pinc_sw = dds1_pinc_sw - self._dds1_pinc_sw_callback(self.dds1_pinc_sw) - 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=self.dds1_pinc_sw, poff_sw=self.dds1_poff_sw) + def set_dds1_pinc_sw(self, dds1_pinc_sw): + self.dds1_pinc_sw = dds1_pinc_sw + self._dds1_pinc_sw_callback(self.dds1_pinc_sw) + 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=self.dds1_pinc_sw, poff_sw=self.dds1_poff_sw) - def get_dds1_offset(self): - return self.dds1_offset + 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_0_0_0_1.set_const(device='/dev/dds1_offset', const=self.dds1_offset) + def set_dds1_offset(self, dds1_offset): + self.dds1_offset = dds1_offset + self.add_const_set_offset_0_0_0_0_1.set_const(device='/dev/dds1_offset', const=self.dds1_offset) - def get_dds1_nco(self): - return self.dds1_nco + 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=self.dds1_pinc_sw, poff_sw=self.dds1_poff_sw) + 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=self.dds1_pinc_sw, poff_sw=self.dds1_poff_sw) - def get_dds1_f0(self): - return self.dds1_f0 + def get_dds1_f0(self): + return self.dds1_f0 - def set_dds1_f0(self, dds1_f0): - self.dds1_f0 = dds1_f0 - self.add_const_set_offset_0_0_0_0_1_0.set_const(device='/dev/dds1_f0', const=int(self.dds1_f0/(125e6/2**32))) + def set_dds1_f0(self, dds1_f0): + self.dds1_f0 = dds1_f0 + self.add_const_set_offset_0_0_0_0_1_0.set_const(device='/dev/dds1_f0', const=int(self.dds1_f0/(125e6/2**32))) - def get_dds1_ampl(self): - return self.dds1_ampl + 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_0_0_0.set_const(device='/dev/dds1_ampl', const=self.dds1_ampl) + def set_dds1_ampl(self, dds1_ampl): + self.dds1_ampl = dds1_ampl + self.add_const_set_offset_0_0_0_0_0.set_const(device='/dev/dds1_ampl', const=self.dds1_ampl) - def get_addr(self): - return self.addr + def get_addr(self): + return self.addr - def set_addr(self, addr): - self.addr = addr + def set_addr(self, addr): + self.addr = addr - def get_adc2_offset(self): - return self.adc2_offset + def get_adc2_offset(self): + return self.adc2_offset - def set_adc2_offset(self, adc2_offset): - self.adc2_offset = adc2_offset - self.add_const_set_offset_0_0_0_0.set_const(device='/dev/adc2_offset', const=self.adc2_offset) + def set_adc2_offset(self, adc2_offset): + self.adc2_offset = adc2_offset + self.add_const_set_offset_0_0_0_0.set_const(device='/dev/adc2_offset', const=self.adc2_offset) - def get_adc1_offset(self): - return self.adc1_offset + def get_adc1_offset(self): + return self.adc1_offset - def set_adc1_offset(self, adc1_offset): - self.adc1_offset = adc1_offset - self.add_const_set_offset_0_0_0.set_const(device='/dev/adc1_offset', const=self.adc1_offset) + def set_adc1_offset(self, adc1_offset): + self.adc1_offset = adc1_offset + self.add_const_set_offset_0_0_0.set_const(device='/dev/adc1_offset', const=self.adc1_offset) def main(top_block_cls=double_pid_vco, 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) + 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() + tb = top_block_cls() + tb.start() + tb.show() - def quitting(): - tb.stop() - tb.wait() - qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) - qapp.exec_() + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() if __name__ == '__main__': - main() + main() diff --git a/redpitaya/client/iq_demod_only.py b/redpitaya/client/iq_demod_only.py index 62391b6..a9aebcb 100755 --- a/redpitaya/client/iq_demod_only.py +++ b/redpitaya/client/iq_demod_only.py @@ -7,14 +7,14 @@ ################################################## 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()" + 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 @@ -29,175 +29,175 @@ import sys class iq_demod_only(gr.top_block, Qt.QWidget): - def __init__(self): - gr.top_block.__init__(self, "Iq Demod Only") - Qt.QWidget.__init__(self) - self.setWindowTitle("Iq Demod Only") - 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", "iq_demod_only") - self.restoreGeometry(self.settings.value("geometry").toByteArray()) - - ################################################## - # Variables - ################################################## - self.port = port = 1001 - self.f_dds = f_dds = 0 - self.demod_f = demod_f = 0 - self.dds_offset = dds_offset = 0 - self.dds_ampl = dds_ampl = 0 - self.addr = addr = "192.168.0.201" - self.adc1_offset = adc1_offset = 0 - - ################################################## - # Blocks - ################################################## - self._f_dds_range = Range(0, 60000000, 1000, 0, 200) - self._f_dds_win = RangeWidget(self._f_dds_range, self.set_f_dds, 'f_dds', "counter_slider", float) - self.top_grid_layout.addWidget(self._f_dds_win, 0, 0) - self._demod_f_range = Range(0, 60000000, 1000, 0, 200) - self._demod_f_win = RangeWidget(self._demod_f_range, self.set_demod_f, 'demod_f', "counter_slider", float) - self.top_grid_layout.addWidget(self._demod_f_win, 1, 1) - self._dds_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._dds_offset_win = RangeWidget(self._dds_offset_range, self.set_dds_offset, 'dds_offset', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds_offset_win, 2, 0) - self._dds_ampl_range = Range(0, 2**13-1, 1, 0, 200) - self._dds_ampl_win = RangeWidget(self._dds_ampl_range, self.set_dds_ampl, 'dds_ampl', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds_ampl_win, 1, 0) - self._adc1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._adc1_offset_win = RangeWidget(self._adc1_offset_range, self.set_adc1_offset, 'adc1_offset', "counter_slider", int) - self.top_grid_layout.addWidget(self._adc1_offset_win, 0, 1) - self.nco_counter_send_conf_0_0 = redpitaya_gnuradio.nco_counter_send_conf( - addr=addr, - port=port, - device='/dev/demod_nco', - freq_ref=125000000, - freq_dds=demod_f, - acc_size=32, - offset=0, - pinc_sw=1, - poff_sw=1, - ) - - self.nco_counter_send_conf_0 = redpitaya_gnuradio.nco_counter_send_conf( - addr=addr, - port=port, - device='/dev/dds_nco', - freq_ref=125000000, - freq_dds=f_dds, - acc_size=32, - offset=0, - pinc_sw=1, - poff_sw=1, - ) - - self.add_const_set_offset_0_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/adc1_offset', - const=adc1_offset, - ) - - self.add_const_set_offset_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds_ampl', - const=dds_ampl, - ) - - self.add_const_set_offset_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds_offset', - const=dds_offset, - ) - - - def closeEvent(self, event): - self.settings = Qt.QSettings("GNU Radio", "iq_demod_only") - 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_f_dds(self): - return self.f_dds - - def set_f_dds(self, f_dds): - self.f_dds = f_dds - self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.f_dds, acc_size=32, offset=0, pinc_sw=1, poff_sw=1) - - def get_demod_f(self): - return self.demod_f - - def set_demod_f(self, demod_f): - self.demod_f = demod_f - self.nco_counter_send_conf_0_0.set_nco(device='/dev/demod_nco', freq_ref=125000000, freq_dds=self.demod_f, acc_size=32, offset=0, pinc_sw=1, poff_sw=1) - - def get_dds_offset(self): - return self.dds_offset - - def set_dds_offset(self, dds_offset): - self.dds_offset = dds_offset - self.add_const_set_offset_0.set_const(device='/dev/dds_offset', const=self.dds_offset) - - def get_dds_ampl(self): - return self.dds_ampl - - def set_dds_ampl(self, dds_ampl): - self.dds_ampl = dds_ampl - self.add_const_set_offset_0_0.set_const(device='/dev/dds_ampl', const=self.dds_ampl) - - def get_addr(self): - return self.addr - - def set_addr(self, addr): - self.addr = addr - - def get_adc1_offset(self): - return self.adc1_offset - - def set_adc1_offset(self, adc1_offset): - self.adc1_offset = adc1_offset - self.add_const_set_offset_0_1.set_const(device='/dev/adc1_offset', const=self.adc1_offset) + def __init__(self): + gr.top_block.__init__(self, "Iq Demod Only") + Qt.QWidget.__init__(self) + self.setWindowTitle("Iq Demod Only") + 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", "iq_demod_only") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + ################################################## + # Variables + ################################################## + self.port = port = 1001 + self.f_dds = f_dds = 0 + self.demod_f = demod_f = 0 + self.dds_offset = dds_offset = 0 + self.dds_ampl = dds_ampl = 0 + self.addr = addr = "192.168.0.201" + self.adc1_offset = adc1_offset = 0 + + ################################################## + # Blocks + ################################################## + self._f_dds_range = Range(0, 60000000, 1000, 0, 200) + self._f_dds_win = RangeWidget(self._f_dds_range, self.set_f_dds, 'f_dds', "counter_slider", float) + self.top_grid_layout.addWidget(self._f_dds_win, 0, 0) + self._demod_f_range = Range(0, 60000000, 1000, 0, 200) + self._demod_f_win = RangeWidget(self._demod_f_range, self.set_demod_f, 'demod_f', "counter_slider", float) + self.top_grid_layout.addWidget(self._demod_f_win, 1, 1) + self._dds_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._dds_offset_win = RangeWidget(self._dds_offset_range, self.set_dds_offset, 'dds_offset', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds_offset_win, 2, 0) + self._dds_ampl_range = Range(0, 2**13-1, 1, 0, 200) + self._dds_ampl_win = RangeWidget(self._dds_ampl_range, self.set_dds_ampl, 'dds_ampl', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds_ampl_win, 1, 0) + self._adc1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._adc1_offset_win = RangeWidget(self._adc1_offset_range, self.set_adc1_offset, 'adc1_offset', "counter_slider", int) + self.top_grid_layout.addWidget(self._adc1_offset_win, 0, 1) + self.nco_counter_send_conf_0_0 = redpitaya_gnuradio.nco_counter_send_conf( + addr=addr, + port=port, + device='/dev/demod_nco', + freq_ref=125000000, + freq_dds=demod_f, + acc_size=32, + offset=0, + pinc_sw=1, + poff_sw=1, + ) + + self.nco_counter_send_conf_0 = redpitaya_gnuradio.nco_counter_send_conf( + addr=addr, + port=port, + device='/dev/dds_nco', + freq_ref=125000000, + freq_dds=f_dds, + acc_size=32, + offset=0, + pinc_sw=1, + poff_sw=1, + ) + + self.add_const_set_offset_0_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/adc1_offset', + const=adc1_offset, + ) + + self.add_const_set_offset_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds_ampl', + const=dds_ampl, + ) + + self.add_const_set_offset_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds_offset', + const=dds_offset, + ) + + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "iq_demod_only") + 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_f_dds(self): + return self.f_dds + + def set_f_dds(self, f_dds): + self.f_dds = f_dds + self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.f_dds, acc_size=32, offset=0, pinc_sw=1, poff_sw=1) + + def get_demod_f(self): + return self.demod_f + + def set_demod_f(self, demod_f): + self.demod_f = demod_f + self.nco_counter_send_conf_0_0.set_nco(device='/dev/demod_nco', freq_ref=125000000, freq_dds=self.demod_f, acc_size=32, offset=0, pinc_sw=1, poff_sw=1) + + def get_dds_offset(self): + return self.dds_offset + + def set_dds_offset(self, dds_offset): + self.dds_offset = dds_offset + self.add_const_set_offset_0.set_const(device='/dev/dds_offset', const=self.dds_offset) + + def get_dds_ampl(self): + return self.dds_ampl + + def set_dds_ampl(self, dds_ampl): + self.dds_ampl = dds_ampl + self.add_const_set_offset_0_0.set_const(device='/dev/dds_ampl', const=self.dds_ampl) + + def get_addr(self): + return self.addr + + def set_addr(self, addr): + self.addr = addr + + def get_adc1_offset(self): + return self.adc1_offset + + def set_adc1_offset(self, adc1_offset): + self.adc1_offset = adc1_offset + self.add_const_set_offset_0_1.set_const(device='/dev/adc1_offset', const=self.adc1_offset) def main(top_block_cls=iq_demod_only, 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) + 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() + tb = top_block_cls() + tb.start() + tb.show() - def quitting(): - tb.stop() - tb.wait() - qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) - qapp.exec_() + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() if __name__ == '__main__': - main() + main() diff --git a/redpitaya/client/iq_pid_vco.py b/redpitaya/client/iq_pid_vco.py index bee8205..e1562ac 100755 --- a/redpitaya/client/iq_pid_vco.py +++ b/redpitaya/client/iq_pid_vco.py @@ -7,14 +7,14 @@ ################################################## 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()" + 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 @@ -29,376 +29,376 @@ import sys class iq_pid_vco(gr.top_block, Qt.QWidget): - def __init__(self): - gr.top_block.__init__(self, "Iq Pid Vco") - Qt.QWidget.__init__(self) - self.setWindowTitle("Iq Pid Vco") - 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", "iq_pid_vco") - self.restoreGeometry(self.settings.value("geometry").toByteArray()) - - ################################################## - # Variables - ################################################## - self.port = port = 1001 - self.pid_sign = pid_sign = 0 - self.pid_setpoint = pid_setpoint = 0 - self.pid_rst_int = pid_rst_int = 0 - self.pid_kp = pid_kp = 0 - self.pid_ki = pid_ki = 0 - self.pid_kd = pid_kd = 0 - self.demod_nco = demod_nco = 42000000 - self.dds_range = dds_range = 0 - self.dds_poff_sw = dds_poff_sw = 1 - self.dds_pinc_sw = dds_pinc_sw = 1 - self.dds_offset = dds_offset = 0 - self.dds_nco = dds_nco = 21000000 - self.dds_f0 = dds_f0 = 21000000 - self.dds_ampl = dds_ampl = 0 - self.dac2_offset = dac2_offset = 0 - self.addr = addr = "192.168.0.202" - self.adc1_offset = adc1_offset = 0 - - ################################################## - # Blocks - ################################################## - _pid_sign_check_box = Qt.QCheckBox('pid_sign') - self._pid_sign_choices = {True: 1, False: 0} - self._pid_sign_choices_inv = dict((v,k) for k,v in self._pid_sign_choices.iteritems()) - self._pid_sign_callback = lambda i: Qt.QMetaObject.invokeMethod(_pid_sign_check_box, "setChecked", Qt.Q_ARG("bool", self._pid_sign_choices_inv[i])) - self._pid_sign_callback(self.pid_sign) - _pid_sign_check_box.stateChanged.connect(lambda i: self.set_pid_sign(self._pid_sign_choices[bool(i)])) - self.top_grid_layout.addWidget(_pid_sign_check_box, 3, 2) - self._pid_setpoint_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._pid_setpoint_win = RangeWidget(self._pid_setpoint_range, self.set_pid_setpoint, 'pid_setpoint', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid_setpoint_win, 2, 2) - _pid_rst_int_push_button = Qt.QPushButton('pid_rst_int') - self._pid_rst_int_choices = {'Pressed': 1, 'Released': 0} - _pid_rst_int_push_button.pressed.connect(lambda: self.set_pid_rst_int(self._pid_rst_int_choices['Pressed'])) - _pid_rst_int_push_button.released.connect(lambda: self.set_pid_rst_int(self._pid_rst_int_choices['Released'])) - self.top_grid_layout.addWidget(_pid_rst_int_push_button, 4, 2) - self._pid_kp_range = Range(0, 2**13-1, 1, 0, 200) - self._pid_kp_win = RangeWidget(self._pid_kp_range, self.set_pid_kp, 'pid_kp', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid_kp_win, 2, 1) - self._pid_ki_range = Range(0, 2**13-1, 1, 0, 200) - self._pid_ki_win = RangeWidget(self._pid_ki_range, self.set_pid_ki, 'pid_ki', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid_ki_win, 3, 1) - self._pid_kd_range = Range(0, 2**13-1, 1, 0, 200) - self._pid_kd_win = RangeWidget(self._pid_kd_range, self.set_pid_kd, 'pid_kd', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid_kd_win, 4, 1) - self._demod_nco_range = Range(0, 60000000, 1, 42000000, 200) - self._demod_nco_win = RangeWidget(self._demod_nco_range, self.set_demod_nco, 'demod_nco', "counter_slider", int) - self.top_grid_layout.addWidget(self._demod_nco_win, 3, 4) - self._dds_range_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._dds_range_win = RangeWidget(self._dds_range_range, self.set_dds_range, 'dds_range', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds_range_win, 5, 3) - _dds_poff_sw_check_box = Qt.QCheckBox('dds_poff_sw') - self._dds_poff_sw_choices = {True: 1, False: 0} - self._dds_poff_sw_choices_inv = dict((v,k) for k,v in self._dds_poff_sw_choices.iteritems()) - self._dds_poff_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds_poff_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds_poff_sw_choices_inv[i])) - self._dds_poff_sw_callback(self.dds_poff_sw) - _dds_poff_sw_check_box.stateChanged.connect(lambda i: self.set_dds_poff_sw(self._dds_poff_sw_choices[bool(i)])) - self.top_grid_layout.addWidget(_dds_poff_sw_check_box, 2, 4) - _dds_pinc_sw_check_box = Qt.QCheckBox('dds_pinc_sw') - self._dds_pinc_sw_choices = {True: 1, False: 0} - self._dds_pinc_sw_choices_inv = dict((v,k) for k,v in self._dds_pinc_sw_choices.iteritems()) - self._dds_pinc_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds_pinc_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds_pinc_sw_choices_inv[i])) - self._dds_pinc_sw_callback(self.dds_pinc_sw) - _dds_pinc_sw_check_box.stateChanged.connect(lambda i: self.set_dds_pinc_sw(self._dds_pinc_sw_choices[bool(i)])) - self.top_grid_layout.addWidget(_dds_pinc_sw_check_box, 1, 4) - self._dds_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._dds_offset_win = RangeWidget(self._dds_offset_range, self.set_dds_offset, 'dds_offset', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds_offset_win, 3, 3) - self._dds_nco_range = Range(0, 60000000, 1, 21000000, 200) - self._dds_nco_win = RangeWidget(self._dds_nco_range, self.set_dds_nco, 'dds_nco', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds_nco_win, 2, 3) - self._dds_f0_range = Range(0, 60000000, 1, 21000000, 200) - self._dds_f0_win = RangeWidget(self._dds_f0_range, self.set_dds_f0, 'dds_f0', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds_f0_win, 4, 3) - self._dds_ampl_range = Range(0, 2**13-1, 1, 0, 200) - self._dds_ampl_win = RangeWidget(self._dds_ampl_range, self.set_dds_ampl, 'dds_ampl', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds_ampl_win, 1, 3) - self._dac2_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._dac2_offset_win = RangeWidget(self._dac2_offset_range, self.set_dac2_offset, 'dac2_offset', "counter_slider", int) - self.top_grid_layout.addWidget(self._dac2_offset_win, 1, 2) - self._adc1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._adc1_offset_win = RangeWidget(self._adc1_offset_range, self.set_adc1_offset, 'adc1_offset', "counter_slider", int) - self.top_grid_layout.addWidget(self._adc1_offset_win, 1, 1) - self.nco_counter_send_conf_0_0 = redpitaya_gnuradio.nco_counter_send_conf( - addr=addr, - port=port, - device='/dev/demod_nco', - freq_ref=125000000, - freq_dds=demod_nco, - acc_size=32, - offset=0, - pinc_sw=1, - poff_sw=1, - ) - - self.nco_counter_send_conf_0 = redpitaya_gnuradio.nco_counter_send_conf( - addr=addr, - port=port, - device='/dev/dds_nco', - freq_ref=125000000, - freq_dds=dds_nco, - acc_size=32, - offset=0, - pinc_sw=dds_pinc_sw, - poff_sw=dds_poff_sw, - ) - - self.add_const_set_offset_0_0_0_1_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid_rst_int', - const=pid_rst_int, - ) - - self.add_const_set_offset_0_0_0_1_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid_sign', - const=pid_sign, - ) - - self.add_const_set_offset_0_0_0_1_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid_kd', - const=pid_kd, - ) - - self.add_const_set_offset_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid_ki', - const=pid_ki, - ) - - self.add_const_set_offset_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid_kp', - const=pid_kp, - ) - - self.add_const_set_offset_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid_setpoint', - const=pid_setpoint, - ) - - self.add_const_set_offset_0_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds_range', - const=dds_range, - ) - - self.add_const_set_offset_0_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds_f0', - const=int(dds_f0/(125e6/2**32)), - ) - - self.add_const_set_offset_0_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds_offset', - const=dds_offset, - ) - - self.add_const_set_offset_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds_ampl', - const=dds_ampl, - ) - - self.add_const_set_offset_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dac2_offset', - const=dac2_offset, - ) - - self.add_const_set_offset_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/adc1_offset', - const=adc1_offset, - ) - - - def closeEvent(self, event): - self.settings = Qt.QSettings("GNU Radio", "iq_pid_vco") - 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_pid_sign(self): - return self.pid_sign - - def set_pid_sign(self, pid_sign): - self.pid_sign = pid_sign - self._pid_sign_callback(self.pid_sign) - self.add_const_set_offset_0_0_0_1_0_0_0_0.set_const(device='/dev/pid_sign', const=self.pid_sign) - - def get_pid_setpoint(self): - return self.pid_setpoint - - def set_pid_setpoint(self, pid_setpoint): - self.pid_setpoint = pid_setpoint - self.add_const_set_offset_0_0_0_1.set_const(device='/dev/pid_setpoint', const=self.pid_setpoint) - - def get_pid_rst_int(self): - return self.pid_rst_int - - def set_pid_rst_int(self, pid_rst_int): - self.pid_rst_int = pid_rst_int - self.add_const_set_offset_0_0_0_1_0_0_0_0_0.set_const(device='/dev/pid_rst_int', const=self.pid_rst_int) - - def get_pid_kp(self): - return self.pid_kp - - def set_pid_kp(self, pid_kp): - self.pid_kp = pid_kp - self.add_const_set_offset_0_0_0_1_0.set_const(device='/dev/pid_kp', const=self.pid_kp) - - def get_pid_ki(self): - return self.pid_ki - - def set_pid_ki(self, pid_ki): - self.pid_ki = pid_ki - self.add_const_set_offset_0_0_0_1_0_0.set_const(device='/dev/pid_ki', const=self.pid_ki) - - def get_pid_kd(self): - return self.pid_kd - - def set_pid_kd(self, pid_kd): - self.pid_kd = pid_kd - self.add_const_set_offset_0_0_0_1_0_0_0.set_const(device='/dev/pid_kd', const=self.pid_kd) - - def get_demod_nco(self): - return self.demod_nco - - def set_demod_nco(self, demod_nco): - self.demod_nco = demod_nco - self.nco_counter_send_conf_0_0.set_nco(device='/dev/demod_nco', freq_ref=125000000, freq_dds=self.demod_nco, acc_size=32, offset=0, pinc_sw=1, poff_sw=1) - - def get_dds_range(self): - return self.dds_range - - def set_dds_range(self, dds_range): - self.dds_range = dds_range - self.add_const_set_offset_0_0_0_0_1_0_0.set_const(device='/dev/dds_range', const=self.dds_range) - - def get_dds_poff_sw(self): - return self.dds_poff_sw - - def set_dds_poff_sw(self, dds_poff_sw): - self.dds_poff_sw = dds_poff_sw - self._dds_poff_sw_callback(self.dds_poff_sw) - self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.dds_nco, acc_size=32, offset=0, pinc_sw=self.dds_pinc_sw, poff_sw=self.dds_poff_sw) + def __init__(self): + gr.top_block.__init__(self, "Iq Pid Vco") + Qt.QWidget.__init__(self) + self.setWindowTitle("Iq Pid Vco") + 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", "iq_pid_vco") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + ################################################## + # Variables + ################################################## + self.port = port = 1001 + self.pid_sign = pid_sign = 0 + self.pid_setpoint = pid_setpoint = 0 + self.pid_rst_int = pid_rst_int = 0 + self.pid_kp = pid_kp = 0 + self.pid_ki = pid_ki = 0 + self.pid_kd = pid_kd = 0 + self.demod_nco = demod_nco = 42000000 + self.dds_range = dds_range = 0 + self.dds_poff_sw = dds_poff_sw = 1 + self.dds_pinc_sw = dds_pinc_sw = 1 + self.dds_offset = dds_offset = 0 + self.dds_nco = dds_nco = 21000000 + self.dds_f0 = dds_f0 = 21000000 + self.dds_ampl = dds_ampl = 0 + self.dac2_offset = dac2_offset = 0 + self.addr = addr = "192.168.0.202" + self.adc1_offset = adc1_offset = 0 + + ################################################## + # Blocks + ################################################## + _pid_sign_check_box = Qt.QCheckBox('pid_sign') + self._pid_sign_choices = {True: 1, False: 0} + self._pid_sign_choices_inv = dict((v,k) for k,v in self._pid_sign_choices.iteritems()) + self._pid_sign_callback = lambda i: Qt.QMetaObject.invokeMethod(_pid_sign_check_box, "setChecked", Qt.Q_ARG("bool", self._pid_sign_choices_inv[i])) + self._pid_sign_callback(self.pid_sign) + _pid_sign_check_box.stateChanged.connect(lambda i: self.set_pid_sign(self._pid_sign_choices[bool(i)])) + self.top_grid_layout.addWidget(_pid_sign_check_box, 3, 2) + self._pid_setpoint_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._pid_setpoint_win = RangeWidget(self._pid_setpoint_range, self.set_pid_setpoint, 'pid_setpoint', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid_setpoint_win, 2, 2) + _pid_rst_int_push_button = Qt.QPushButton('pid_rst_int') + self._pid_rst_int_choices = {'Pressed': 1, 'Released': 0} + _pid_rst_int_push_button.pressed.connect(lambda: self.set_pid_rst_int(self._pid_rst_int_choices['Pressed'])) + _pid_rst_int_push_button.released.connect(lambda: self.set_pid_rst_int(self._pid_rst_int_choices['Released'])) + self.top_grid_layout.addWidget(_pid_rst_int_push_button, 4, 2) + self._pid_kp_range = Range(0, 2**13-1, 1, 0, 200) + self._pid_kp_win = RangeWidget(self._pid_kp_range, self.set_pid_kp, 'pid_kp', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid_kp_win, 2, 1) + self._pid_ki_range = Range(0, 2**13-1, 1, 0, 200) + self._pid_ki_win = RangeWidget(self._pid_ki_range, self.set_pid_ki, 'pid_ki', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid_ki_win, 3, 1) + self._pid_kd_range = Range(0, 2**13-1, 1, 0, 200) + self._pid_kd_win = RangeWidget(self._pid_kd_range, self.set_pid_kd, 'pid_kd', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid_kd_win, 4, 1) + self._demod_nco_range = Range(0, 60000000, 1, 42000000, 200) + self._demod_nco_win = RangeWidget(self._demod_nco_range, self.set_demod_nco, 'demod_nco', "counter_slider", int) + self.top_grid_layout.addWidget(self._demod_nco_win, 3, 4) + self._dds_range_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._dds_range_win = RangeWidget(self._dds_range_range, self.set_dds_range, 'dds_range', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds_range_win, 5, 3) + _dds_poff_sw_check_box = Qt.QCheckBox('dds_poff_sw') + self._dds_poff_sw_choices = {True: 1, False: 0} + self._dds_poff_sw_choices_inv = dict((v,k) for k,v in self._dds_poff_sw_choices.iteritems()) + self._dds_poff_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds_poff_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds_poff_sw_choices_inv[i])) + self._dds_poff_sw_callback(self.dds_poff_sw) + _dds_poff_sw_check_box.stateChanged.connect(lambda i: self.set_dds_poff_sw(self._dds_poff_sw_choices[bool(i)])) + self.top_grid_layout.addWidget(_dds_poff_sw_check_box, 2, 4) + _dds_pinc_sw_check_box = Qt.QCheckBox('dds_pinc_sw') + self._dds_pinc_sw_choices = {True: 1, False: 0} + self._dds_pinc_sw_choices_inv = dict((v,k) for k,v in self._dds_pinc_sw_choices.iteritems()) + self._dds_pinc_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds_pinc_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds_pinc_sw_choices_inv[i])) + self._dds_pinc_sw_callback(self.dds_pinc_sw) + _dds_pinc_sw_check_box.stateChanged.connect(lambda i: self.set_dds_pinc_sw(self._dds_pinc_sw_choices[bool(i)])) + self.top_grid_layout.addWidget(_dds_pinc_sw_check_box, 1, 4) + self._dds_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._dds_offset_win = RangeWidget(self._dds_offset_range, self.set_dds_offset, 'dds_offset', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds_offset_win, 3, 3) + self._dds_nco_range = Range(0, 60000000, 1, 21000000, 200) + self._dds_nco_win = RangeWidget(self._dds_nco_range, self.set_dds_nco, 'dds_nco', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds_nco_win, 2, 3) + self._dds_f0_range = Range(0, 60000000, 1, 21000000, 200) + self._dds_f0_win = RangeWidget(self._dds_f0_range, self.set_dds_f0, 'dds_f0', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds_f0_win, 4, 3) + self._dds_ampl_range = Range(0, 2**13-1, 1, 0, 200) + self._dds_ampl_win = RangeWidget(self._dds_ampl_range, self.set_dds_ampl, 'dds_ampl', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds_ampl_win, 1, 3) + self._dac2_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._dac2_offset_win = RangeWidget(self._dac2_offset_range, self.set_dac2_offset, 'dac2_offset', "counter_slider", int) + self.top_grid_layout.addWidget(self._dac2_offset_win, 1, 2) + self._adc1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._adc1_offset_win = RangeWidget(self._adc1_offset_range, self.set_adc1_offset, 'adc1_offset', "counter_slider", int) + self.top_grid_layout.addWidget(self._adc1_offset_win, 1, 1) + self.nco_counter_send_conf_0_0 = redpitaya_gnuradio.nco_counter_send_conf( + addr=addr, + port=port, + device='/dev/demod_nco', + freq_ref=125000000, + freq_dds=demod_nco, + acc_size=32, + offset=0, + pinc_sw=1, + poff_sw=1, + ) + + self.nco_counter_send_conf_0 = redpitaya_gnuradio.nco_counter_send_conf( + addr=addr, + port=port, + device='/dev/dds_nco', + freq_ref=125000000, + freq_dds=dds_nco, + acc_size=32, + offset=0, + pinc_sw=dds_pinc_sw, + poff_sw=dds_poff_sw, + ) + + self.add_const_set_offset_0_0_0_1_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid_rst_int', + const=pid_rst_int, + ) + + self.add_const_set_offset_0_0_0_1_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid_sign', + const=pid_sign, + ) + + self.add_const_set_offset_0_0_0_1_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid_kd', + const=pid_kd, + ) + + self.add_const_set_offset_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid_ki', + const=pid_ki, + ) + + self.add_const_set_offset_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid_kp', + const=pid_kp, + ) + + self.add_const_set_offset_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid_setpoint', + const=pid_setpoint, + ) + + self.add_const_set_offset_0_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds_range', + const=dds_range, + ) + + self.add_const_set_offset_0_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds_f0', + const=int(dds_f0/(125e6/2**32)), + ) + + self.add_const_set_offset_0_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds_offset', + const=dds_offset, + ) + + self.add_const_set_offset_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds_ampl', + const=dds_ampl, + ) + + self.add_const_set_offset_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dac2_offset', + const=dac2_offset, + ) + + self.add_const_set_offset_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/adc1_offset', + const=adc1_offset, + ) + + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "iq_pid_vco") + 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_pid_sign(self): + return self.pid_sign + + def set_pid_sign(self, pid_sign): + self.pid_sign = pid_sign + self._pid_sign_callback(self.pid_sign) + self.add_const_set_offset_0_0_0_1_0_0_0_0.set_const(device='/dev/pid_sign', const=self.pid_sign) + + def get_pid_setpoint(self): + return self.pid_setpoint + + def set_pid_setpoint(self, pid_setpoint): + self.pid_setpoint = pid_setpoint + self.add_const_set_offset_0_0_0_1.set_const(device='/dev/pid_setpoint', const=self.pid_setpoint) + + def get_pid_rst_int(self): + return self.pid_rst_int + + def set_pid_rst_int(self, pid_rst_int): + self.pid_rst_int = pid_rst_int + self.add_const_set_offset_0_0_0_1_0_0_0_0_0.set_const(device='/dev/pid_rst_int', const=self.pid_rst_int) + + def get_pid_kp(self): + return self.pid_kp + + def set_pid_kp(self, pid_kp): + self.pid_kp = pid_kp + self.add_const_set_offset_0_0_0_1_0.set_const(device='/dev/pid_kp', const=self.pid_kp) + + def get_pid_ki(self): + return self.pid_ki + + def set_pid_ki(self, pid_ki): + self.pid_ki = pid_ki + self.add_const_set_offset_0_0_0_1_0_0.set_const(device='/dev/pid_ki', const=self.pid_ki) + + def get_pid_kd(self): + return self.pid_kd + + def set_pid_kd(self, pid_kd): + self.pid_kd = pid_kd + self.add_const_set_offset_0_0_0_1_0_0_0.set_const(device='/dev/pid_kd', const=self.pid_kd) + + def get_demod_nco(self): + return self.demod_nco + + def set_demod_nco(self, demod_nco): + self.demod_nco = demod_nco + self.nco_counter_send_conf_0_0.set_nco(device='/dev/demod_nco', freq_ref=125000000, freq_dds=self.demod_nco, acc_size=32, offset=0, pinc_sw=1, poff_sw=1) + + def get_dds_range(self): + return self.dds_range + + def set_dds_range(self, dds_range): + self.dds_range = dds_range + self.add_const_set_offset_0_0_0_0_1_0_0.set_const(device='/dev/dds_range', const=self.dds_range) + + def get_dds_poff_sw(self): + return self.dds_poff_sw + + def set_dds_poff_sw(self, dds_poff_sw): + self.dds_poff_sw = dds_poff_sw + self._dds_poff_sw_callback(self.dds_poff_sw) + self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.dds_nco, acc_size=32, offset=0, pinc_sw=self.dds_pinc_sw, poff_sw=self.dds_poff_sw) - def get_dds_pinc_sw(self): - return self.dds_pinc_sw + def get_dds_pinc_sw(self): + return self.dds_pinc_sw - def set_dds_pinc_sw(self, dds_pinc_sw): - self.dds_pinc_sw = dds_pinc_sw - self._dds_pinc_sw_callback(self.dds_pinc_sw) - self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.dds_nco, acc_size=32, offset=0, pinc_sw=self.dds_pinc_sw, poff_sw=self.dds_poff_sw) + def set_dds_pinc_sw(self, dds_pinc_sw): + self.dds_pinc_sw = dds_pinc_sw + self._dds_pinc_sw_callback(self.dds_pinc_sw) + self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.dds_nco, acc_size=32, offset=0, pinc_sw=self.dds_pinc_sw, poff_sw=self.dds_poff_sw) - def get_dds_offset(self): - return self.dds_offset + def get_dds_offset(self): + return self.dds_offset - def set_dds_offset(self, dds_offset): - self.dds_offset = dds_offset - self.add_const_set_offset_0_0_0_0_1.set_const(device='/dev/dds_offset', const=self.dds_offset) + def set_dds_offset(self, dds_offset): + self.dds_offset = dds_offset + self.add_const_set_offset_0_0_0_0_1.set_const(device='/dev/dds_offset', const=self.dds_offset) - def get_dds_nco(self): - return self.dds_nco + def get_dds_nco(self): + return self.dds_nco - def set_dds_nco(self, dds_nco): - self.dds_nco = dds_nco - self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.dds_nco, acc_size=32, offset=0, pinc_sw=self.dds_pinc_sw, poff_sw=self.dds_poff_sw) + def set_dds_nco(self, dds_nco): + self.dds_nco = dds_nco + self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.dds_nco, acc_size=32, offset=0, pinc_sw=self.dds_pinc_sw, poff_sw=self.dds_poff_sw) - def get_dds_f0(self): - return self.dds_f0 + def get_dds_f0(self): + return self.dds_f0 - def set_dds_f0(self, dds_f0): - self.dds_f0 = dds_f0 - self.add_const_set_offset_0_0_0_0_1_0.set_const(device='/dev/dds_f0', const=int(self.dds_f0/(125e6/2**32))) + def set_dds_f0(self, dds_f0): + self.dds_f0 = dds_f0 + self.add_const_set_offset_0_0_0_0_1_0.set_const(device='/dev/dds_f0', const=int(self.dds_f0/(125e6/2**32))) - def get_dds_ampl(self): - return self.dds_ampl + def get_dds_ampl(self): + return self.dds_ampl - def set_dds_ampl(self, dds_ampl): - self.dds_ampl = dds_ampl - self.add_const_set_offset_0_0_0_0_0.set_const(device='/dev/dds_ampl', const=self.dds_ampl) + def set_dds_ampl(self, dds_ampl): + self.dds_ampl = dds_ampl + self.add_const_set_offset_0_0_0_0_0.set_const(device='/dev/dds_ampl', const=self.dds_ampl) - def get_dac2_offset(self): - return self.dac2_offset + def get_dac2_offset(self): + return self.dac2_offset - def set_dac2_offset(self, dac2_offset): - self.dac2_offset = dac2_offset - self.add_const_set_offset_0_0_0_0.set_const(device='/dev/dac2_offset', const=self.dac2_offset) + def set_dac2_offset(self, dac2_offset): + self.dac2_offset = dac2_offset + self.add_const_set_offset_0_0_0_0.set_const(device='/dev/dac2_offset', const=self.dac2_offset) - def get_addr(self): - return self.addr + def get_addr(self): + return self.addr - def set_addr(self, addr): - self.addr = addr + def set_addr(self, addr): + self.addr = addr - def get_adc1_offset(self): - return self.adc1_offset + def get_adc1_offset(self): + return self.adc1_offset - def set_adc1_offset(self, adc1_offset): - self.adc1_offset = adc1_offset - self.add_const_set_offset_0_0_0.set_const(device='/dev/adc1_offset', const=self.adc1_offset) + def set_adc1_offset(self, adc1_offset): + self.adc1_offset = adc1_offset + self.add_const_set_offset_0_0_0.set_const(device='/dev/adc1_offset', const=self.adc1_offset) def main(top_block_cls=iq_pid_vco, 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) + 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() + tb = top_block_cls() + tb.start() + tb.show() - def quitting(): - tb.stop() - tb.wait() - qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) - qapp.exec_() + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() if __name__ == '__main__': - main() + main() diff --git a/redpitaya/client/pid_only.py b/redpitaya/client/pid_only.py index d85f473..7abf5f9 100755 --- a/redpitaya/client/pid_only.py +++ b/redpitaya/client/pid_only.py @@ -7,14 +7,14 @@ ################################################## 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()" + 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 @@ -29,226 +29,226 @@ import sys class pid_only(gr.top_block, Qt.QWidget): - def __init__(self): - gr.top_block.__init__(self, "Pid Only") - Qt.QWidget.__init__(self) - self.setWindowTitle("Pid Only") - 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", "pid_only") - self.restoreGeometry(self.settings.value("geometry").toByteArray()) - - ################################################## - # Variables - ################################################## - self.port = port = 1001 - self.pid_sp = pid_sp = 0 - self.pid_sign = pid_sign = 0 - self.pid_kp = pid_kp = 0 - self.pid_ki = pid_ki = 0 - self.pid_kd = pid_kd = 0 - self.pid_int_rst = pid_int_rst = 0 - self.dac1_offset = dac1_offset = 0 - self.addr = addr = "192.168.0.201" - self.adc1_offset = adc1_offset = 0 - - ################################################## - # Blocks - ################################################## - self._pid_sp_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._pid_sp_win = RangeWidget(self._pid_sp_range, self.set_pid_sp, 'pid_sp', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid_sp_win, 2, 2) - _pid_sign_check_box = Qt.QCheckBox('pid_sign') - self._pid_sign_choices = {True: 1, False: 0} - self._pid_sign_choices_inv = dict((v,k) for k,v in self._pid_sign_choices.iteritems()) - self._pid_sign_callback = lambda i: Qt.QMetaObject.invokeMethod(_pid_sign_check_box, "setChecked", Qt.Q_ARG("bool", self._pid_sign_choices_inv[i])) - self._pid_sign_callback(self.pid_sign) - _pid_sign_check_box.stateChanged.connect(lambda i: self.set_pid_sign(self._pid_sign_choices[bool(i)])) - self.top_grid_layout.addWidget(_pid_sign_check_box, 3, 2) - self._pid_kp_range = Range(0, 2**13-1, 1, 0, 200) - self._pid_kp_win = RangeWidget(self._pid_kp_range, self.set_pid_kp, 'pid_kp', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid_kp_win, 2, 1) - self._pid_ki_range = Range(0, 2**13-1, 1, 0, 200) - self._pid_ki_win = RangeWidget(self._pid_ki_range, self.set_pid_ki, 'pid_ki', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid_ki_win, 3, 1) - self._pid_kd_range = Range(0, 2**13-1, 1, 0, 200) - self._pid_kd_win = RangeWidget(self._pid_kd_range, self.set_pid_kd, 'pid_kd', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid_kd_win, 4, 1) - _pid_int_rst_push_button = Qt.QPushButton('pid_int_rst') - self._pid_int_rst_choices = {'Pressed': 1, 'Released': 0} - _pid_int_rst_push_button.pressed.connect(lambda: self.set_pid_int_rst(self._pid_int_rst_choices['Pressed'])) - _pid_int_rst_push_button.released.connect(lambda: self.set_pid_int_rst(self._pid_int_rst_choices['Released'])) - self.top_grid_layout.addWidget(_pid_int_rst_push_button, 4, 2) - self._dac1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._dac1_offset_win = RangeWidget(self._dac1_offset_range, self.set_dac1_offset, 'dac1_offset', "counter_slider", int) - self.top_grid_layout.addWidget(self._dac1_offset_win, 1, 2) - self._adc1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._adc1_offset_win = RangeWidget(self._adc1_offset_range, self.set_adc1_offset, 'adc1_offset', "counter_slider", int) - self.top_grid_layout.addWidget(self._adc1_offset_win, 1, 1) - self.add_const_set_offset_0_0_0_1_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid_int_rst', - const=pid_int_rst, - ) - - self.add_const_set_offset_0_0_0_1_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid_sign', - const=pid_sign, - ) - - self.add_const_set_offset_0_0_0_1_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid_kd', - const=pid_kd, - ) - - self.add_const_set_offset_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid_ki', - const=pid_ki, - ) - - self.add_const_set_offset_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid_kp', - const=pid_kp, - ) - - self.add_const_set_offset_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid_sp', - const=pid_sp, - ) - - self.add_const_set_offset_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dac1_offset', - const=dac1_offset, - ) - - self.add_const_set_offset_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/adc1_offset', - const=adc1_offset, - ) - - - def closeEvent(self, event): - self.settings = Qt.QSettings("GNU Radio", "pid_only") - 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_pid_sp(self): - return self.pid_sp - - def set_pid_sp(self, pid_sp): - self.pid_sp = pid_sp - self.add_const_set_offset_0_0_0_1.set_const(device='/dev/pid_sp', const=self.pid_sp) - - def get_pid_sign(self): - return self.pid_sign - - def set_pid_sign(self, pid_sign): - self.pid_sign = pid_sign - self._pid_sign_callback(self.pid_sign) - self.add_const_set_offset_0_0_0_1_0_0_0_0.set_const(device='/dev/pid_sign', const=self.pid_sign) - - def get_pid_kp(self): - return self.pid_kp - - def set_pid_kp(self, pid_kp): - self.pid_kp = pid_kp - self.add_const_set_offset_0_0_0_1_0.set_const(device='/dev/pid_kp', const=self.pid_kp) - - def get_pid_ki(self): - return self.pid_ki - - def set_pid_ki(self, pid_ki): - self.pid_ki = pid_ki - self.add_const_set_offset_0_0_0_1_0_0.set_const(device='/dev/pid_ki', const=self.pid_ki) - - def get_pid_kd(self): - return self.pid_kd - - def set_pid_kd(self, pid_kd): - self.pid_kd = pid_kd - self.add_const_set_offset_0_0_0_1_0_0_0.set_const(device='/dev/pid_kd', const=self.pid_kd) - - def get_pid_int_rst(self): - return self.pid_int_rst - - def set_pid_int_rst(self, pid_int_rst): - self.pid_int_rst = pid_int_rst - self.add_const_set_offset_0_0_0_1_0_0_0_0_0.set_const(device='/dev/pid_int_rst', const=self.pid_int_rst) - - def get_dac1_offset(self): - return self.dac1_offset - - def set_dac1_offset(self, dac1_offset): - self.dac1_offset = dac1_offset - self.add_const_set_offset_0_0_0_0.set_const(device='/dev/dac1_offset', const=self.dac1_offset) - - def get_addr(self): - return self.addr - - def set_addr(self, addr): - self.addr = addr - - def get_adc1_offset(self): - return self.adc1_offset - - def set_adc1_offset(self, adc1_offset): - self.adc1_offset = adc1_offset - self.add_const_set_offset_0_0_0.set_const(device='/dev/adc1_offset', const=self.adc1_offset) + def __init__(self): + gr.top_block.__init__(self, "Pid Only") + Qt.QWidget.__init__(self) + self.setWindowTitle("Pid Only") + 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", "pid_only") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + ################################################## + # Variables + ################################################## + self.port = port = 1001 + self.pid_sp = pid_sp = 0 + self.pid_sign = pid_sign = 0 + self.pid_kp = pid_kp = 0 + self.pid_ki = pid_ki = 0 + self.pid_kd = pid_kd = 0 + self.pid_int_rst = pid_int_rst = 0 + self.dac1_offset = dac1_offset = 0 + self.addr = addr = "192.168.0.201" + self.adc1_offset = adc1_offset = 0 + + ################################################## + # Blocks + ################################################## + self._pid_sp_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._pid_sp_win = RangeWidget(self._pid_sp_range, self.set_pid_sp, 'pid_sp', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid_sp_win, 2, 2) + _pid_sign_check_box = Qt.QCheckBox('pid_sign') + self._pid_sign_choices = {True: 1, False: 0} + self._pid_sign_choices_inv = dict((v,k) for k,v in self._pid_sign_choices.iteritems()) + self._pid_sign_callback = lambda i: Qt.QMetaObject.invokeMethod(_pid_sign_check_box, "setChecked", Qt.Q_ARG("bool", self._pid_sign_choices_inv[i])) + self._pid_sign_callback(self.pid_sign) + _pid_sign_check_box.stateChanged.connect(lambda i: self.set_pid_sign(self._pid_sign_choices[bool(i)])) + self.top_grid_layout.addWidget(_pid_sign_check_box, 3, 2) + self._pid_kp_range = Range(0, 2**13-1, 1, 0, 200) + self._pid_kp_win = RangeWidget(self._pid_kp_range, self.set_pid_kp, 'pid_kp', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid_kp_win, 2, 1) + self._pid_ki_range = Range(0, 2**13-1, 1, 0, 200) + self._pid_ki_win = RangeWidget(self._pid_ki_range, self.set_pid_ki, 'pid_ki', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid_ki_win, 3, 1) + self._pid_kd_range = Range(0, 2**13-1, 1, 0, 200) + self._pid_kd_win = RangeWidget(self._pid_kd_range, self.set_pid_kd, 'pid_kd', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid_kd_win, 4, 1) + _pid_int_rst_push_button = Qt.QPushButton('pid_int_rst') + self._pid_int_rst_choices = {'Pressed': 1, 'Released': 0} + _pid_int_rst_push_button.pressed.connect(lambda: self.set_pid_int_rst(self._pid_int_rst_choices['Pressed'])) + _pid_int_rst_push_button.released.connect(lambda: self.set_pid_int_rst(self._pid_int_rst_choices['Released'])) + self.top_grid_layout.addWidget(_pid_int_rst_push_button, 4, 2) + self._dac1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._dac1_offset_win = RangeWidget(self._dac1_offset_range, self.set_dac1_offset, 'dac1_offset', "counter_slider", int) + self.top_grid_layout.addWidget(self._dac1_offset_win, 1, 2) + self._adc1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._adc1_offset_win = RangeWidget(self._adc1_offset_range, self.set_adc1_offset, 'adc1_offset', "counter_slider", int) + self.top_grid_layout.addWidget(self._adc1_offset_win, 1, 1) + self.add_const_set_offset_0_0_0_1_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid_int_rst', + const=pid_int_rst, + ) + + self.add_const_set_offset_0_0_0_1_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid_sign', + const=pid_sign, + ) + + self.add_const_set_offset_0_0_0_1_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid_kd', + const=pid_kd, + ) + + self.add_const_set_offset_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid_ki', + const=pid_ki, + ) + + self.add_const_set_offset_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid_kp', + const=pid_kp, + ) + + self.add_const_set_offset_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid_sp', + const=pid_sp, + ) + + self.add_const_set_offset_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dac1_offset', + const=dac1_offset, + ) + + self.add_const_set_offset_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/adc1_offset', + const=adc1_offset, + ) + + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "pid_only") + 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_pid_sp(self): + return self.pid_sp + + def set_pid_sp(self, pid_sp): + self.pid_sp = pid_sp + self.add_const_set_offset_0_0_0_1.set_const(device='/dev/pid_sp', const=self.pid_sp) + + def get_pid_sign(self): + return self.pid_sign + + def set_pid_sign(self, pid_sign): + self.pid_sign = pid_sign + self._pid_sign_callback(self.pid_sign) + self.add_const_set_offset_0_0_0_1_0_0_0_0.set_const(device='/dev/pid_sign', const=self.pid_sign) + + def get_pid_kp(self): + return self.pid_kp + + def set_pid_kp(self, pid_kp): + self.pid_kp = pid_kp + self.add_const_set_offset_0_0_0_1_0.set_const(device='/dev/pid_kp', const=self.pid_kp) + + def get_pid_ki(self): + return self.pid_ki + + def set_pid_ki(self, pid_ki): + self.pid_ki = pid_ki + self.add_const_set_offset_0_0_0_1_0_0.set_const(device='/dev/pid_ki', const=self.pid_ki) + + def get_pid_kd(self): + return self.pid_kd + + def set_pid_kd(self, pid_kd): + self.pid_kd = pid_kd + self.add_const_set_offset_0_0_0_1_0_0_0.set_const(device='/dev/pid_kd', const=self.pid_kd) + + def get_pid_int_rst(self): + return self.pid_int_rst + + def set_pid_int_rst(self, pid_int_rst): + self.pid_int_rst = pid_int_rst + self.add_const_set_offset_0_0_0_1_0_0_0_0_0.set_const(device='/dev/pid_int_rst', const=self.pid_int_rst) + + def get_dac1_offset(self): + return self.dac1_offset + + def set_dac1_offset(self, dac1_offset): + self.dac1_offset = dac1_offset + self.add_const_set_offset_0_0_0_0.set_const(device='/dev/dac1_offset', const=self.dac1_offset) + + def get_addr(self): + return self.addr + + def set_addr(self, addr): + self.addr = addr + + def get_adc1_offset(self): + return self.adc1_offset + + def set_adc1_offset(self, adc1_offset): + self.adc1_offset = adc1_offset + self.add_const_set_offset_0_0_0.set_const(device='/dev/adc1_offset', const=self.adc1_offset) def main(top_block_cls=pid_only, 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) + 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() + tb = top_block_cls() + tb.start() + tb.show() - def quitting(): - tb.stop() - tb.wait() - qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) - qapp.exec_() + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() if __name__ == '__main__': - main() + main() diff --git a/redpitaya/client/pid_vco.py b/redpitaya/client/pid_vco.py index b030888..cc6a3d8 100755 --- a/redpitaya/client/pid_vco.py +++ b/redpitaya/client/pid_vco.py @@ -7,14 +7,14 @@ ################################################## 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()" + 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 @@ -29,353 +29,353 @@ import sys class pid_vco(gr.top_block, Qt.QWidget): - def __init__(self): - gr.top_block.__init__(self, "Pid Vco") - Qt.QWidget.__init__(self) - self.setWindowTitle("Pid Vco") - 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", "pid_vco") - self.restoreGeometry(self.settings.value("geometry").toByteArray()) - - ################################################## - # Variables - ################################################## - self.port = port = 1001 - self.pid_sign = pid_sign = 0 - self.pid_setpoint = pid_setpoint = 0 - self.pid_rst_int = pid_rst_int = 0 - self.pid_kp = pid_kp = 0 - self.pid_ki = pid_ki = 0 - self.pid_kd = pid_kd = 0 - self.dds_range = dds_range = 0 - self.dds_poff_sw = dds_poff_sw = 1 - self.dds_pinc_sw = dds_pinc_sw = 1 - self.dds_offset = dds_offset = 0 - self.dds_nco = dds_nco = 0 - self.dds_f0 = dds_f0 = 0 - self.dds_ampl = dds_ampl = 0 - self.dac1_offset = dac1_offset = 0 - self.addr = addr = "192.168.0.201" - self.adc1_offset = adc1_offset = 0 - - ################################################## - # Blocks - ################################################## - _pid_sign_check_box = Qt.QCheckBox('pid_sign') - self._pid_sign_choices = {True: 1, False: 0} - self._pid_sign_choices_inv = dict((v,k) for k,v in self._pid_sign_choices.iteritems()) - self._pid_sign_callback = lambda i: Qt.QMetaObject.invokeMethod(_pid_sign_check_box, "setChecked", Qt.Q_ARG("bool", self._pid_sign_choices_inv[i])) - self._pid_sign_callback(self.pid_sign) - _pid_sign_check_box.stateChanged.connect(lambda i: self.set_pid_sign(self._pid_sign_choices[bool(i)])) - self.top_grid_layout.addWidget(_pid_sign_check_box, 3, 2) - self._pid_setpoint_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._pid_setpoint_win = RangeWidget(self._pid_setpoint_range, self.set_pid_setpoint, 'pid_setpoint', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid_setpoint_win, 2, 2) - _pid_rst_int_push_button = Qt.QPushButton('pid_rst_int') - self._pid_rst_int_choices = {'Pressed': 1, 'Released': 0} - _pid_rst_int_push_button.pressed.connect(lambda: self.set_pid_rst_int(self._pid_rst_int_choices['Pressed'])) - _pid_rst_int_push_button.released.connect(lambda: self.set_pid_rst_int(self._pid_rst_int_choices['Released'])) - self.top_grid_layout.addWidget(_pid_rst_int_push_button, 4, 2) - self._pid_kp_range = Range(0, 2**13-1, 1, 0, 200) - self._pid_kp_win = RangeWidget(self._pid_kp_range, self.set_pid_kp, 'pid_kp', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid_kp_win, 2, 1) - self._pid_ki_range = Range(0, 2**13-1, 1, 0, 200) - self._pid_ki_win = RangeWidget(self._pid_ki_range, self.set_pid_ki, 'pid_ki', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid_ki_win, 3, 1) - self._pid_kd_range = Range(0, 2**13-1, 1, 0, 200) - self._pid_kd_win = RangeWidget(self._pid_kd_range, self.set_pid_kd, 'pid_kd', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid_kd_win, 4, 1) - self._dds_range_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._dds_range_win = RangeWidget(self._dds_range_range, self.set_dds_range, 'dds_range', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds_range_win, 5, 3) - _dds_poff_sw_check_box = Qt.QCheckBox('dds_poff_sw') - self._dds_poff_sw_choices = {True: 1, False: 0} - self._dds_poff_sw_choices_inv = dict((v,k) for k,v in self._dds_poff_sw_choices.iteritems()) - self._dds_poff_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds_poff_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds_poff_sw_choices_inv[i])) - self._dds_poff_sw_callback(self.dds_poff_sw) - _dds_poff_sw_check_box.stateChanged.connect(lambda i: self.set_dds_poff_sw(self._dds_poff_sw_choices[bool(i)])) - self.top_grid_layout.addWidget(_dds_poff_sw_check_box, 2, 4) - _dds_pinc_sw_check_box = Qt.QCheckBox('dds_pinc_sw') - self._dds_pinc_sw_choices = {True: 1, False: 0} - self._dds_pinc_sw_choices_inv = dict((v,k) for k,v in self._dds_pinc_sw_choices.iteritems()) - self._dds_pinc_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds_pinc_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds_pinc_sw_choices_inv[i])) - self._dds_pinc_sw_callback(self.dds_pinc_sw) - _dds_pinc_sw_check_box.stateChanged.connect(lambda i: self.set_dds_pinc_sw(self._dds_pinc_sw_choices[bool(i)])) - self.top_grid_layout.addWidget(_dds_pinc_sw_check_box, 1, 4) - self._dds_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._dds_offset_win = RangeWidget(self._dds_offset_range, self.set_dds_offset, 'dds_offset', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds_offset_win, 3, 3) - self._dds_nco_range = Range(0, 60000000, 1, 0, 200) - self._dds_nco_win = RangeWidget(self._dds_nco_range, self.set_dds_nco, 'dds_nco', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds_nco_win, 2, 3) - self._dds_f0_range = Range(0, 60000000, 1, 0, 200) - self._dds_f0_win = RangeWidget(self._dds_f0_range, self.set_dds_f0, 'dds_f0', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds_f0_win, 4, 3) - self._dds_ampl_range = Range(0, 2**13-1, 1, 0, 200) - self._dds_ampl_win = RangeWidget(self._dds_ampl_range, self.set_dds_ampl, 'dds_ampl', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds_ampl_win, 1, 3) - self._dac1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._dac1_offset_win = RangeWidget(self._dac1_offset_range, self.set_dac1_offset, 'dac1_offset', "counter_slider", int) - self.top_grid_layout.addWidget(self._dac1_offset_win, 1, 2) - self._adc1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._adc1_offset_win = RangeWidget(self._adc1_offset_range, self.set_adc1_offset, 'adc1_offset', "counter_slider", int) - self.top_grid_layout.addWidget(self._adc1_offset_win, 1, 1) - self.nco_counter_send_conf_0 = redpitaya_gnuradio.nco_counter_send_conf( - addr=addr, - port=port, - device='/dev/dds_nco', - freq_ref=125000000, - freq_dds=dds_nco, - acc_size=32, - offset=0, - pinc_sw=dds_pinc_sw, - poff_sw=dds_poff_sw, - ) - - self.add_const_set_offset_0_0_0_1_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid_rst_int', - const=pid_rst_int, - ) - - self.add_const_set_offset_0_0_0_1_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid_sign', - const=pid_sign, - ) - - self.add_const_set_offset_0_0_0_1_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid_kd', - const=pid_kd, - ) - - self.add_const_set_offset_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid_ki', - const=pid_ki, - ) - - self.add_const_set_offset_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid_kp', - const=pid_kp, - ) - - self.add_const_set_offset_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid_setpoint', - const=pid_setpoint, - ) - - self.add_const_set_offset_0_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds_range', - const=dds_range, - ) - - self.add_const_set_offset_0_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds_f0', - const=int(dds_f0/(125e6/2**32)), - ) - - self.add_const_set_offset_0_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds_offset', - const=dds_offset, - ) - - self.add_const_set_offset_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds_ampl', - const=dds_ampl, - ) - - self.add_const_set_offset_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dac1_offset', - const=dac1_offset, - ) - - self.add_const_set_offset_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/adc1_offset', - const=adc1_offset, - ) - - - def closeEvent(self, event): - self.settings = Qt.QSettings("GNU Radio", "pid_vco") - 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_pid_sign(self): - return self.pid_sign - - def set_pid_sign(self, pid_sign): - self.pid_sign = pid_sign - self._pid_sign_callback(self.pid_sign) - self.add_const_set_offset_0_0_0_1_0_0_0_0.set_const(device='/dev/pid_sign', const=self.pid_sign) - - def get_pid_setpoint(self): - return self.pid_setpoint - - def set_pid_setpoint(self, pid_setpoint): - self.pid_setpoint = pid_setpoint - self.add_const_set_offset_0_0_0_1.set_const(device='/dev/pid_setpoint', const=self.pid_setpoint) - - def get_pid_rst_int(self): - return self.pid_rst_int - - def set_pid_rst_int(self, pid_rst_int): - self.pid_rst_int = pid_rst_int - self.add_const_set_offset_0_0_0_1_0_0_0_0_0.set_const(device='/dev/pid_rst_int', const=self.pid_rst_int) - - def get_pid_kp(self): - return self.pid_kp - - def set_pid_kp(self, pid_kp): - self.pid_kp = pid_kp - self.add_const_set_offset_0_0_0_1_0.set_const(device='/dev/pid_kp', const=self.pid_kp) - - def get_pid_ki(self): - return self.pid_ki - - def set_pid_ki(self, pid_ki): - self.pid_ki = pid_ki - self.add_const_set_offset_0_0_0_1_0_0.set_const(device='/dev/pid_ki', const=self.pid_ki) - - def get_pid_kd(self): - return self.pid_kd - - def set_pid_kd(self, pid_kd): - self.pid_kd = pid_kd - self.add_const_set_offset_0_0_0_1_0_0_0.set_const(device='/dev/pid_kd', const=self.pid_kd) - - def get_dds_range(self): - return self.dds_range - - def set_dds_range(self, dds_range): - self.dds_range = dds_range - self.add_const_set_offset_0_0_0_0_1_0_0.set_const(device='/dev/dds_range', const=self.dds_range) - - def get_dds_poff_sw(self): - return self.dds_poff_sw - - def set_dds_poff_sw(self, dds_poff_sw): - self.dds_poff_sw = dds_poff_sw - self._dds_poff_sw_callback(self.dds_poff_sw) - self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.dds_nco, acc_size=32, offset=0, pinc_sw=self.dds_pinc_sw, poff_sw=self.dds_poff_sw) - - def get_dds_pinc_sw(self): - return self.dds_pinc_sw - - def set_dds_pinc_sw(self, dds_pinc_sw): - self.dds_pinc_sw = dds_pinc_sw - self._dds_pinc_sw_callback(self.dds_pinc_sw) - self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.dds_nco, acc_size=32, offset=0, pinc_sw=self.dds_pinc_sw, poff_sw=self.dds_poff_sw) + def __init__(self): + gr.top_block.__init__(self, "Pid Vco") + Qt.QWidget.__init__(self) + self.setWindowTitle("Pid Vco") + 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", "pid_vco") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + ################################################## + # Variables + ################################################## + self.port = port = 1001 + self.pid_sign = pid_sign = 0 + self.pid_setpoint = pid_setpoint = 0 + self.pid_rst_int = pid_rst_int = 0 + self.pid_kp = pid_kp = 0 + self.pid_ki = pid_ki = 0 + self.pid_kd = pid_kd = 0 + self.dds_range = dds_range = 0 + self.dds_poff_sw = dds_poff_sw = 1 + self.dds_pinc_sw = dds_pinc_sw = 1 + self.dds_offset = dds_offset = 0 + self.dds_nco = dds_nco = 0 + self.dds_f0 = dds_f0 = 0 + self.dds_ampl = dds_ampl = 0 + self.dac1_offset = dac1_offset = 0 + self.addr = addr = "192.168.0.201" + self.adc1_offset = adc1_offset = 0 + + ################################################## + # Blocks + ################################################## + _pid_sign_check_box = Qt.QCheckBox('pid_sign') + self._pid_sign_choices = {True: 1, False: 0} + self._pid_sign_choices_inv = dict((v,k) for k,v in self._pid_sign_choices.iteritems()) + self._pid_sign_callback = lambda i: Qt.QMetaObject.invokeMethod(_pid_sign_check_box, "setChecked", Qt.Q_ARG("bool", self._pid_sign_choices_inv[i])) + self._pid_sign_callback(self.pid_sign) + _pid_sign_check_box.stateChanged.connect(lambda i: self.set_pid_sign(self._pid_sign_choices[bool(i)])) + self.top_grid_layout.addWidget(_pid_sign_check_box, 3, 2) + self._pid_setpoint_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._pid_setpoint_win = RangeWidget(self._pid_setpoint_range, self.set_pid_setpoint, 'pid_setpoint', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid_setpoint_win, 2, 2) + _pid_rst_int_push_button = Qt.QPushButton('pid_rst_int') + self._pid_rst_int_choices = {'Pressed': 1, 'Released': 0} + _pid_rst_int_push_button.pressed.connect(lambda: self.set_pid_rst_int(self._pid_rst_int_choices['Pressed'])) + _pid_rst_int_push_button.released.connect(lambda: self.set_pid_rst_int(self._pid_rst_int_choices['Released'])) + self.top_grid_layout.addWidget(_pid_rst_int_push_button, 4, 2) + self._pid_kp_range = Range(0, 2**13-1, 1, 0, 200) + self._pid_kp_win = RangeWidget(self._pid_kp_range, self.set_pid_kp, 'pid_kp', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid_kp_win, 2, 1) + self._pid_ki_range = Range(0, 2**13-1, 1, 0, 200) + self._pid_ki_win = RangeWidget(self._pid_ki_range, self.set_pid_ki, 'pid_ki', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid_ki_win, 3, 1) + self._pid_kd_range = Range(0, 2**13-1, 1, 0, 200) + self._pid_kd_win = RangeWidget(self._pid_kd_range, self.set_pid_kd, 'pid_kd', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid_kd_win, 4, 1) + self._dds_range_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._dds_range_win = RangeWidget(self._dds_range_range, self.set_dds_range, 'dds_range', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds_range_win, 5, 3) + _dds_poff_sw_check_box = Qt.QCheckBox('dds_poff_sw') + self._dds_poff_sw_choices = {True: 1, False: 0} + self._dds_poff_sw_choices_inv = dict((v,k) for k,v in self._dds_poff_sw_choices.iteritems()) + self._dds_poff_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds_poff_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds_poff_sw_choices_inv[i])) + self._dds_poff_sw_callback(self.dds_poff_sw) + _dds_poff_sw_check_box.stateChanged.connect(lambda i: self.set_dds_poff_sw(self._dds_poff_sw_choices[bool(i)])) + self.top_grid_layout.addWidget(_dds_poff_sw_check_box, 2, 4) + _dds_pinc_sw_check_box = Qt.QCheckBox('dds_pinc_sw') + self._dds_pinc_sw_choices = {True: 1, False: 0} + self._dds_pinc_sw_choices_inv = dict((v,k) for k,v in self._dds_pinc_sw_choices.iteritems()) + self._dds_pinc_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds_pinc_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds_pinc_sw_choices_inv[i])) + self._dds_pinc_sw_callback(self.dds_pinc_sw) + _dds_pinc_sw_check_box.stateChanged.connect(lambda i: self.set_dds_pinc_sw(self._dds_pinc_sw_choices[bool(i)])) + self.top_grid_layout.addWidget(_dds_pinc_sw_check_box, 1, 4) + self._dds_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._dds_offset_win = RangeWidget(self._dds_offset_range, self.set_dds_offset, 'dds_offset', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds_offset_win, 3, 3) + self._dds_nco_range = Range(0, 60000000, 1, 0, 200) + self._dds_nco_win = RangeWidget(self._dds_nco_range, self.set_dds_nco, 'dds_nco', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds_nco_win, 2, 3) + self._dds_f0_range = Range(0, 60000000, 1, 0, 200) + self._dds_f0_win = RangeWidget(self._dds_f0_range, self.set_dds_f0, 'dds_f0', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds_f0_win, 4, 3) + self._dds_ampl_range = Range(0, 2**13-1, 1, 0, 200) + self._dds_ampl_win = RangeWidget(self._dds_ampl_range, self.set_dds_ampl, 'dds_ampl', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds_ampl_win, 1, 3) + self._dac1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._dac1_offset_win = RangeWidget(self._dac1_offset_range, self.set_dac1_offset, 'dac1_offset', "counter_slider", int) + self.top_grid_layout.addWidget(self._dac1_offset_win, 1, 2) + self._adc1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._adc1_offset_win = RangeWidget(self._adc1_offset_range, self.set_adc1_offset, 'adc1_offset', "counter_slider", int) + self.top_grid_layout.addWidget(self._adc1_offset_win, 1, 1) + self.nco_counter_send_conf_0 = redpitaya_gnuradio.nco_counter_send_conf( + addr=addr, + port=port, + device='/dev/dds_nco', + freq_ref=125000000, + freq_dds=dds_nco, + acc_size=32, + offset=0, + pinc_sw=dds_pinc_sw, + poff_sw=dds_poff_sw, + ) + + self.add_const_set_offset_0_0_0_1_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid_rst_int', + const=pid_rst_int, + ) + + self.add_const_set_offset_0_0_0_1_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid_sign', + const=pid_sign, + ) + + self.add_const_set_offset_0_0_0_1_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid_kd', + const=pid_kd, + ) + + self.add_const_set_offset_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid_ki', + const=pid_ki, + ) + + self.add_const_set_offset_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid_kp', + const=pid_kp, + ) + + self.add_const_set_offset_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid_setpoint', + const=pid_setpoint, + ) + + self.add_const_set_offset_0_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds_range', + const=dds_range, + ) + + self.add_const_set_offset_0_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds_f0', + const=int(dds_f0/(125e6/2**32)), + ) + + self.add_const_set_offset_0_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds_offset', + const=dds_offset, + ) + + self.add_const_set_offset_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds_ampl', + const=dds_ampl, + ) + + self.add_const_set_offset_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dac1_offset', + const=dac1_offset, + ) + + self.add_const_set_offset_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/adc1_offset', + const=adc1_offset, + ) + + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "pid_vco") + 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_pid_sign(self): + return self.pid_sign + + def set_pid_sign(self, pid_sign): + self.pid_sign = pid_sign + self._pid_sign_callback(self.pid_sign) + self.add_const_set_offset_0_0_0_1_0_0_0_0.set_const(device='/dev/pid_sign', const=self.pid_sign) + + def get_pid_setpoint(self): + return self.pid_setpoint + + def set_pid_setpoint(self, pid_setpoint): + self.pid_setpoint = pid_setpoint + self.add_const_set_offset_0_0_0_1.set_const(device='/dev/pid_setpoint', const=self.pid_setpoint) + + def get_pid_rst_int(self): + return self.pid_rst_int + + def set_pid_rst_int(self, pid_rst_int): + self.pid_rst_int = pid_rst_int + self.add_const_set_offset_0_0_0_1_0_0_0_0_0.set_const(device='/dev/pid_rst_int', const=self.pid_rst_int) + + def get_pid_kp(self): + return self.pid_kp + + def set_pid_kp(self, pid_kp): + self.pid_kp = pid_kp + self.add_const_set_offset_0_0_0_1_0.set_const(device='/dev/pid_kp', const=self.pid_kp) + + def get_pid_ki(self): + return self.pid_ki + + def set_pid_ki(self, pid_ki): + self.pid_ki = pid_ki + self.add_const_set_offset_0_0_0_1_0_0.set_const(device='/dev/pid_ki', const=self.pid_ki) + + def get_pid_kd(self): + return self.pid_kd + + def set_pid_kd(self, pid_kd): + self.pid_kd = pid_kd + self.add_const_set_offset_0_0_0_1_0_0_0.set_const(device='/dev/pid_kd', const=self.pid_kd) + + def get_dds_range(self): + return self.dds_range + + def set_dds_range(self, dds_range): + self.dds_range = dds_range + self.add_const_set_offset_0_0_0_0_1_0_0.set_const(device='/dev/dds_range', const=self.dds_range) + + def get_dds_poff_sw(self): + return self.dds_poff_sw + + def set_dds_poff_sw(self, dds_poff_sw): + self.dds_poff_sw = dds_poff_sw + self._dds_poff_sw_callback(self.dds_poff_sw) + self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.dds_nco, acc_size=32, offset=0, pinc_sw=self.dds_pinc_sw, poff_sw=self.dds_poff_sw) + + def get_dds_pinc_sw(self): + return self.dds_pinc_sw + + def set_dds_pinc_sw(self, dds_pinc_sw): + self.dds_pinc_sw = dds_pinc_sw + self._dds_pinc_sw_callback(self.dds_pinc_sw) + self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.dds_nco, acc_size=32, offset=0, pinc_sw=self.dds_pinc_sw, poff_sw=self.dds_poff_sw) - def get_dds_offset(self): - return self.dds_offset + def get_dds_offset(self): + return self.dds_offset - def set_dds_offset(self, dds_offset): - self.dds_offset = dds_offset - self.add_const_set_offset_0_0_0_0_1.set_const(device='/dev/dds_offset', const=self.dds_offset) + def set_dds_offset(self, dds_offset): + self.dds_offset = dds_offset + self.add_const_set_offset_0_0_0_0_1.set_const(device='/dev/dds_offset', const=self.dds_offset) - def get_dds_nco(self): - return self.dds_nco + def get_dds_nco(self): + return self.dds_nco - def set_dds_nco(self, dds_nco): - self.dds_nco = dds_nco - self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.dds_nco, acc_size=32, offset=0, pinc_sw=self.dds_pinc_sw, poff_sw=self.dds_poff_sw) + def set_dds_nco(self, dds_nco): + self.dds_nco = dds_nco + self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.dds_nco, acc_size=32, offset=0, pinc_sw=self.dds_pinc_sw, poff_sw=self.dds_poff_sw) - def get_dds_f0(self): - return self.dds_f0 + def get_dds_f0(self): + return self.dds_f0 - def set_dds_f0(self, dds_f0): - self.dds_f0 = dds_f0 - self.add_const_set_offset_0_0_0_0_1_0.set_const(device='/dev/dds_f0', const=int(self.dds_f0/(125e6/2**32))) + def set_dds_f0(self, dds_f0): + self.dds_f0 = dds_f0 + self.add_const_set_offset_0_0_0_0_1_0.set_const(device='/dev/dds_f0', const=int(self.dds_f0/(125e6/2**32))) - def get_dds_ampl(self): - return self.dds_ampl + def get_dds_ampl(self): + return self.dds_ampl - def set_dds_ampl(self, dds_ampl): - self.dds_ampl = dds_ampl - self.add_const_set_offset_0_0_0_0_0.set_const(device='/dev/dds_ampl', const=self.dds_ampl) + def set_dds_ampl(self, dds_ampl): + self.dds_ampl = dds_ampl + self.add_const_set_offset_0_0_0_0_0.set_const(device='/dev/dds_ampl', const=self.dds_ampl) - def get_dac1_offset(self): - return self.dac1_offset + def get_dac1_offset(self): + return self.dac1_offset - def set_dac1_offset(self, dac1_offset): - self.dac1_offset = dac1_offset - self.add_const_set_offset_0_0_0_0.set_const(device='/dev/dac1_offset', const=self.dac1_offset) + def set_dac1_offset(self, dac1_offset): + self.dac1_offset = dac1_offset + self.add_const_set_offset_0_0_0_0.set_const(device='/dev/dac1_offset', const=self.dac1_offset) - def get_addr(self): - return self.addr + def get_addr(self): + return self.addr - def set_addr(self, addr): - self.addr = addr + def set_addr(self, addr): + self.addr = addr - def get_adc1_offset(self): - return self.adc1_offset + def get_adc1_offset(self): + return self.adc1_offset - def set_adc1_offset(self, adc1_offset): - self.adc1_offset = adc1_offset - self.add_const_set_offset_0_0_0.set_const(device='/dev/adc1_offset', const=self.adc1_offset) + def set_adc1_offset(self, adc1_offset): + self.adc1_offset = adc1_offset + self.add_const_set_offset_0_0_0.set_const(device='/dev/adc1_offset', const=self.adc1_offset) def main(top_block_cls=pid_vco, 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) + 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() + tb = top_block_cls() + tb.start() + tb.show() - def quitting(): - tb.stop() - tb.wait() - qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) - qapp.exec_() + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() if __name__ == '__main__': - main() + main() diff --git a/redpitaya/client/pid_vco_pid_only.py b/redpitaya/client/pid_vco_pid_only.py index 5d72925..600dd41 100755 --- a/redpitaya/client/pid_vco_pid_only.py +++ b/redpitaya/client/pid_vco_pid_only.py @@ -7,14 +7,14 @@ ################################################## 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()" + 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 @@ -29,468 +29,468 @@ import sys class pid_vco_pid_only(gr.top_block, Qt.QWidget): - def __init__(self): - gr.top_block.__init__(self, "Pid Vco Pid Only") - Qt.QWidget.__init__(self) - self.setWindowTitle("Pid Vco Pid Only") - 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", "pid_vco_pid_only") - self.restoreGeometry(self.settings.value("geometry").toByteArray()) - - ################################################## - # Variables - ################################################## - self.port = port = 1001 - self.pid2_sign = pid2_sign = 0 - self.pid2_setpoint = pid2_setpoint = 0 - self.pid2_rst_int = pid2_rst_int = 0 - self.pid2_offset = pid2_offset = 0 - self.pid2_kp = pid2_kp = 0 - self.pid2_ki = pid2_ki = 0 - self.pid2_kd = pid2_kd = 0 - self.pid1_sign = pid1_sign = 0 - self.pid1_setpoint = pid1_setpoint = 0 - self.pid1_rst_int = pid1_rst_int = 0 - self.pid1_kp = pid1_kp = 0 - self.pid1_ki = pid1_ki = 0 - self.pid1_kd = pid1_kd = 0 - self.dds1_range = dds1_range = 0 - self.dds1_poff_sw = dds1_poff_sw = 1 - self.dds1_pinc_sw = dds1_pinc_sw = 1 - self.dds1_offset = dds1_offset = 0 - self.dds1_nco = dds1_nco = 40000000 - self.dds1_f0 = dds1_f0 = 40000000 - self.dds1_ampl = dds1_ampl = 0 - self.addr = addr = "192.168.0.201" - self.adc1_offset = adc1_offset = 0 - - ################################################## - # Blocks - ################################################## - _pid2_sign_check_box = Qt.QCheckBox('pid2_sign') - self._pid2_sign_choices = {True: 1, False: 0} - self._pid2_sign_choices_inv = dict((v,k) for k,v in self._pid2_sign_choices.iteritems()) - self._pid2_sign_callback = lambda i: Qt.QMetaObject.invokeMethod(_pid2_sign_check_box, "setChecked", Qt.Q_ARG("bool", self._pid2_sign_choices_inv[i])) - self._pid2_sign_callback(self.pid2_sign) - _pid2_sign_check_box.stateChanged.connect(lambda i: self.set_pid2_sign(self._pid2_sign_choices[bool(i)])) - self.top_grid_layout.addWidget(_pid2_sign_check_box, 10,1) - self._pid2_setpoint_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._pid2_setpoint_win = RangeWidget(self._pid2_setpoint_range, self.set_pid2_setpoint, 'pid2_setpoint', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid2_setpoint_win, 9,1) - _pid2_rst_int_push_button = Qt.QPushButton('pid2_rst_int') - self._pid2_rst_int_choices = {'Pressed': 1, 'Released': 0} - _pid2_rst_int_push_button.pressed.connect(lambda: self.set_pid2_rst_int(self._pid2_rst_int_choices['Pressed'])) - _pid2_rst_int_push_button.released.connect(lambda: self.set_pid2_rst_int(self._pid2_rst_int_choices['Released'])) - self.top_grid_layout.addWidget(_pid2_rst_int_push_button, 11,1) - self._pid2_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._pid2_offset_win = RangeWidget(self._pid2_offset_range, self.set_pid2_offset, 'pid2_offset', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid2_offset_win, 4,1) - self._pid2_kp_range = Range(0, 2**13-1, 1, 0, 200) - self._pid2_kp_win = RangeWidget(self._pid2_kp_range, self.set_pid2_kp, 'pid2_kp', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid2_kp_win, 6,1) - self._pid2_ki_range = Range(0, 2**13-1, 1, 0, 200) - self._pid2_ki_win = RangeWidget(self._pid2_ki_range, self.set_pid2_ki, 'pid2_ki', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid2_ki_win, 7,1) - self._pid2_kd_range = Range(0, 2**13-1, 1, 0, 200) - self._pid2_kd_win = RangeWidget(self._pid2_kd_range, self.set_pid2_kd, 'pid2_kd', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid2_kd_win, 8,1) - _pid1_sign_check_box = Qt.QCheckBox('pid1_sign') - self._pid1_sign_choices = {True: 1, False: 0} - self._pid1_sign_choices_inv = dict((v,k) for k,v in self._pid1_sign_choices.iteritems()) - self._pid1_sign_callback = lambda i: Qt.QMetaObject.invokeMethod(_pid1_sign_check_box, "setChecked", Qt.Q_ARG("bool", self._pid1_sign_choices_inv[i])) - self._pid1_sign_callback(self.pid1_sign) - _pid1_sign_check_box.stateChanged.connect(lambda i: self.set_pid1_sign(self._pid1_sign_choices[bool(i)])) - self.top_grid_layout.addWidget(_pid1_sign_check_box, 10,0) - self._pid1_setpoint_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._pid1_setpoint_win = RangeWidget(self._pid1_setpoint_range, self.set_pid1_setpoint, 'pid1_setpoint', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid1_setpoint_win, 9,0) - _pid1_rst_int_push_button = Qt.QPushButton('pid1_rst_int') - self._pid1_rst_int_choices = {'Pressed': 1, 'Released': 0} - _pid1_rst_int_push_button.pressed.connect(lambda: self.set_pid1_rst_int(self._pid1_rst_int_choices['Pressed'])) - _pid1_rst_int_push_button.released.connect(lambda: self.set_pid1_rst_int(self._pid1_rst_int_choices['Released'])) - self.top_grid_layout.addWidget(_pid1_rst_int_push_button, 11,0) - self._pid1_kp_range = Range(0, 2**13-1, 1, 0, 200) - self._pid1_kp_win = RangeWidget(self._pid1_kp_range, self.set_pid1_kp, 'pid1_kp', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid1_kp_win, 6,0) - self._pid1_ki_range = Range(0, 2**13-1, 1, 0, 200) - self._pid1_ki_win = RangeWidget(self._pid1_ki_range, self.set_pid1_ki, 'pid1_ki', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid1_ki_win, 7,0) - self._pid1_kd_range = Range(0, 2**13-1, 1, 0, 200) - self._pid1_kd_win = RangeWidget(self._pid1_kd_range, self.set_pid1_kd, 'pid1_kd', "counter_slider", int) - self.top_grid_layout.addWidget(self._pid1_kd_win, 8,0) - self._dds1_range_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._dds1_range_win = RangeWidget(self._dds1_range_range, self.set_dds1_range, 'dds1_range', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds1_range_win, 13,0) - _dds1_poff_sw_check_box = Qt.QCheckBox('dds1_poff_sw') - self._dds1_poff_sw_choices = {True: 1, False: 0} - self._dds1_poff_sw_choices_inv = dict((v,k) for k,v in self._dds1_poff_sw_choices.iteritems()) - self._dds1_poff_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds1_poff_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds1_poff_sw_choices_inv[i])) - self._dds1_poff_sw_callback(self.dds1_poff_sw) - _dds1_poff_sw_check_box.stateChanged.connect(lambda i: self.set_dds1_poff_sw(self._dds1_poff_sw_choices[bool(i)])) - self.top_grid_layout.addWidget(_dds1_poff_sw_check_box, 2, 0) - _dds1_pinc_sw_check_box = Qt.QCheckBox('dds1_pinc_sw') - self._dds1_pinc_sw_choices = {True: 1, False: 0} - self._dds1_pinc_sw_choices_inv = dict((v,k) for k,v in self._dds1_pinc_sw_choices.iteritems()) - self._dds1_pinc_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds1_pinc_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds1_pinc_sw_choices_inv[i])) - self._dds1_pinc_sw_callback(self.dds1_pinc_sw) - _dds1_pinc_sw_check_box.stateChanged.connect(lambda i: self.set_dds1_pinc_sw(self._dds1_pinc_sw_choices[bool(i)])) - self.top_grid_layout.addWidget(_dds1_pinc_sw_check_box, 1,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, 4,0) - self._dds1_nco_range = Range(0, 60000000, 1, 40000000, 200) - self._dds1_nco_win = RangeWidget(self._dds1_nco_range, self.set_dds1_nco, 'dds1_nco', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds1_nco_win, 0,0) - self._dds1_f0_range = Range(0, 60000000, 1, 40000000, 200) - self._dds1_f0_win = RangeWidget(self._dds1_f0_range, self.set_dds1_f0, 'dds1_f0', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds1_f0_win, 12,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, 3,0) - self._adc1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._adc1_offset_win = RangeWidget(self._adc1_offset_range, self.set_adc1_offset, 'adc1_offset', "counter_slider", int) - self.top_grid_layout.addWidget(self._adc1_offset_win, 5,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=dds1_pinc_sw, - poff_sw=dds1_poff_sw, - ) - - self.add_const_set_offset_0_0_0_1_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid2_setpoint', - const=pid2_setpoint, - ) - - self.add_const_set_offset_0_0_0_1_0_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid2_kp', - const=pid2_kp, - ) - - self.add_const_set_offset_0_0_0_1_0_0_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid2_ki', - const=pid2_ki, - ) - - self.add_const_set_offset_0_0_0_1_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid2_kd', - const=pid2_kd, - ) - - self.add_const_set_offset_0_0_0_1_0_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid2_sign', - const=pid2_sign, - ) - - self.add_const_set_offset_0_0_0_1_0_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid2_rst_int', - const=pid2_rst_int, - ) - - self.add_const_set_offset_0_0_0_1_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid1_rst_int', - const=pid1_rst_int, - ) - - self.add_const_set_offset_0_0_0_1_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid1_sign', - const=pid1_sign, - ) - - self.add_const_set_offset_0_0_0_1_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid1_kd', - const=pid1_kd, - ) - - self.add_const_set_offset_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid1_ki', - const=pid1_ki, - ) - - self.add_const_set_offset_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid1_kp', - const=pid1_kp, - ) - - self.add_const_set_offset_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid1_setpoint', - const=pid1_setpoint, - ) - - self.add_const_set_offset_0_0_0_0_1_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/pid2_offset', - const=pid2_offset, - ) - - self.add_const_set_offset_0_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds1_range', - const=dds1_range, - ) - - self.add_const_set_offset_0_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds1_f0', - const=int(dds1_f0/(125e6/2**32)), - ) - - self.add_const_set_offset_0_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds1_offset', - const=dds1_offset, - ) - - self.add_const_set_offset_0_0_0_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_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/adc1_offset', - const=adc1_offset, - ) - - - def closeEvent(self, event): - self.settings = Qt.QSettings("GNU Radio", "pid_vco_pid_only") - 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_pid2_sign(self): - return self.pid2_sign - - def set_pid2_sign(self, pid2_sign): - self.pid2_sign = pid2_sign - self._pid2_sign_callback(self.pid2_sign) - self.add_const_set_offset_0_0_0_1_0_0_0_0_1.set_const(device='/dev/pid2_sign', const=self.pid2_sign) - - def get_pid2_setpoint(self): - return self.pid2_setpoint - - def set_pid2_setpoint(self, pid2_setpoint): - self.pid2_setpoint = pid2_setpoint - self.add_const_set_offset_0_0_0_1_1.set_const(device='/dev/pid2_setpoint', const=self.pid2_setpoint) - - def get_pid2_rst_int(self): - return self.pid2_rst_int - - def set_pid2_rst_int(self, pid2_rst_int): - self.pid2_rst_int = pid2_rst_int - self.add_const_set_offset_0_0_0_1_0_0_0_0_0_0.set_const(device='/dev/pid2_rst_int', const=self.pid2_rst_int) - - def get_pid2_offset(self): - return self.pid2_offset - - def set_pid2_offset(self, pid2_offset): - self.pid2_offset = pid2_offset - self.add_const_set_offset_0_0_0_0_1_1.set_const(device='/dev/pid2_offset', const=self.pid2_offset) - - def get_pid2_kp(self): - return self.pid2_kp - - def set_pid2_kp(self, pid2_kp): - self.pid2_kp = pid2_kp - self.add_const_set_offset_0_0_0_1_0_1.set_const(device='/dev/pid2_kp', const=self.pid2_kp) - - def get_pid2_ki(self): - return self.pid2_ki - - def set_pid2_ki(self, pid2_ki): - self.pid2_ki = pid2_ki - self.add_const_set_offset_0_0_0_1_0_0_1.set_const(device='/dev/pid2_ki', const=self.pid2_ki) - - def get_pid2_kd(self): - return self.pid2_kd - - def set_pid2_kd(self, pid2_kd): - self.pid2_kd = pid2_kd - self.add_const_set_offset_0_0_0_1_0_0_0_1.set_const(device='/dev/pid2_kd', const=self.pid2_kd) - - def get_pid1_sign(self): - return self.pid1_sign - - def set_pid1_sign(self, pid1_sign): - self.pid1_sign = pid1_sign - self._pid1_sign_callback(self.pid1_sign) - self.add_const_set_offset_0_0_0_1_0_0_0_0.set_const(device='/dev/pid1_sign', const=self.pid1_sign) - - def get_pid1_setpoint(self): - return self.pid1_setpoint + def __init__(self): + gr.top_block.__init__(self, "Pid Vco Pid Only") + Qt.QWidget.__init__(self) + self.setWindowTitle("Pid Vco Pid Only") + 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", "pid_vco_pid_only") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + ################################################## + # Variables + ################################################## + self.port = port = 1001 + self.pid2_sign = pid2_sign = 0 + self.pid2_setpoint = pid2_setpoint = 0 + self.pid2_rst_int = pid2_rst_int = 0 + self.pid2_offset = pid2_offset = 0 + self.pid2_kp = pid2_kp = 0 + self.pid2_ki = pid2_ki = 0 + self.pid2_kd = pid2_kd = 0 + self.pid1_sign = pid1_sign = 0 + self.pid1_setpoint = pid1_setpoint = 0 + self.pid1_rst_int = pid1_rst_int = 0 + self.pid1_kp = pid1_kp = 0 + self.pid1_ki = pid1_ki = 0 + self.pid1_kd = pid1_kd = 0 + self.dds1_range = dds1_range = 0 + self.dds1_poff_sw = dds1_poff_sw = 1 + self.dds1_pinc_sw = dds1_pinc_sw = 1 + self.dds1_offset = dds1_offset = 0 + self.dds1_nco = dds1_nco = 40000000 + self.dds1_f0 = dds1_f0 = 40000000 + self.dds1_ampl = dds1_ampl = 0 + self.addr = addr = "192.168.0.201" + self.adc1_offset = adc1_offset = 0 + + ################################################## + # Blocks + ################################################## + _pid2_sign_check_box = Qt.QCheckBox('pid2_sign') + self._pid2_sign_choices = {True: 1, False: 0} + self._pid2_sign_choices_inv = dict((v,k) for k,v in self._pid2_sign_choices.iteritems()) + self._pid2_sign_callback = lambda i: Qt.QMetaObject.invokeMethod(_pid2_sign_check_box, "setChecked", Qt.Q_ARG("bool", self._pid2_sign_choices_inv[i])) + self._pid2_sign_callback(self.pid2_sign) + _pid2_sign_check_box.stateChanged.connect(lambda i: self.set_pid2_sign(self._pid2_sign_choices[bool(i)])) + self.top_grid_layout.addWidget(_pid2_sign_check_box, 10,1) + self._pid2_setpoint_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._pid2_setpoint_win = RangeWidget(self._pid2_setpoint_range, self.set_pid2_setpoint, 'pid2_setpoint', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid2_setpoint_win, 9,1) + _pid2_rst_int_push_button = Qt.QPushButton('pid2_rst_int') + self._pid2_rst_int_choices = {'Pressed': 1, 'Released': 0} + _pid2_rst_int_push_button.pressed.connect(lambda: self.set_pid2_rst_int(self._pid2_rst_int_choices['Pressed'])) + _pid2_rst_int_push_button.released.connect(lambda: self.set_pid2_rst_int(self._pid2_rst_int_choices['Released'])) + self.top_grid_layout.addWidget(_pid2_rst_int_push_button, 11,1) + self._pid2_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._pid2_offset_win = RangeWidget(self._pid2_offset_range, self.set_pid2_offset, 'pid2_offset', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid2_offset_win, 4,1) + self._pid2_kp_range = Range(0, 2**13-1, 1, 0, 200) + self._pid2_kp_win = RangeWidget(self._pid2_kp_range, self.set_pid2_kp, 'pid2_kp', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid2_kp_win, 6,1) + self._pid2_ki_range = Range(0, 2**13-1, 1, 0, 200) + self._pid2_ki_win = RangeWidget(self._pid2_ki_range, self.set_pid2_ki, 'pid2_ki', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid2_ki_win, 7,1) + self._pid2_kd_range = Range(0, 2**13-1, 1, 0, 200) + self._pid2_kd_win = RangeWidget(self._pid2_kd_range, self.set_pid2_kd, 'pid2_kd', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid2_kd_win, 8,1) + _pid1_sign_check_box = Qt.QCheckBox('pid1_sign') + self._pid1_sign_choices = {True: 1, False: 0} + self._pid1_sign_choices_inv = dict((v,k) for k,v in self._pid1_sign_choices.iteritems()) + self._pid1_sign_callback = lambda i: Qt.QMetaObject.invokeMethod(_pid1_sign_check_box, "setChecked", Qt.Q_ARG("bool", self._pid1_sign_choices_inv[i])) + self._pid1_sign_callback(self.pid1_sign) + _pid1_sign_check_box.stateChanged.connect(lambda i: self.set_pid1_sign(self._pid1_sign_choices[bool(i)])) + self.top_grid_layout.addWidget(_pid1_sign_check_box, 10,0) + self._pid1_setpoint_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._pid1_setpoint_win = RangeWidget(self._pid1_setpoint_range, self.set_pid1_setpoint, 'pid1_setpoint', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid1_setpoint_win, 9,0) + _pid1_rst_int_push_button = Qt.QPushButton('pid1_rst_int') + self._pid1_rst_int_choices = {'Pressed': 1, 'Released': 0} + _pid1_rst_int_push_button.pressed.connect(lambda: self.set_pid1_rst_int(self._pid1_rst_int_choices['Pressed'])) + _pid1_rst_int_push_button.released.connect(lambda: self.set_pid1_rst_int(self._pid1_rst_int_choices['Released'])) + self.top_grid_layout.addWidget(_pid1_rst_int_push_button, 11,0) + self._pid1_kp_range = Range(0, 2**13-1, 1, 0, 200) + self._pid1_kp_win = RangeWidget(self._pid1_kp_range, self.set_pid1_kp, 'pid1_kp', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid1_kp_win, 6,0) + self._pid1_ki_range = Range(0, 2**13-1, 1, 0, 200) + self._pid1_ki_win = RangeWidget(self._pid1_ki_range, self.set_pid1_ki, 'pid1_ki', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid1_ki_win, 7,0) + self._pid1_kd_range = Range(0, 2**13-1, 1, 0, 200) + self._pid1_kd_win = RangeWidget(self._pid1_kd_range, self.set_pid1_kd, 'pid1_kd', "counter_slider", int) + self.top_grid_layout.addWidget(self._pid1_kd_win, 8,0) + self._dds1_range_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._dds1_range_win = RangeWidget(self._dds1_range_range, self.set_dds1_range, 'dds1_range', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds1_range_win, 13,0) + _dds1_poff_sw_check_box = Qt.QCheckBox('dds1_poff_sw') + self._dds1_poff_sw_choices = {True: 1, False: 0} + self._dds1_poff_sw_choices_inv = dict((v,k) for k,v in self._dds1_poff_sw_choices.iteritems()) + self._dds1_poff_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds1_poff_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds1_poff_sw_choices_inv[i])) + self._dds1_poff_sw_callback(self.dds1_poff_sw) + _dds1_poff_sw_check_box.stateChanged.connect(lambda i: self.set_dds1_poff_sw(self._dds1_poff_sw_choices[bool(i)])) + self.top_grid_layout.addWidget(_dds1_poff_sw_check_box, 2, 0) + _dds1_pinc_sw_check_box = Qt.QCheckBox('dds1_pinc_sw') + self._dds1_pinc_sw_choices = {True: 1, False: 0} + self._dds1_pinc_sw_choices_inv = dict((v,k) for k,v in self._dds1_pinc_sw_choices.iteritems()) + self._dds1_pinc_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds1_pinc_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds1_pinc_sw_choices_inv[i])) + self._dds1_pinc_sw_callback(self.dds1_pinc_sw) + _dds1_pinc_sw_check_box.stateChanged.connect(lambda i: self.set_dds1_pinc_sw(self._dds1_pinc_sw_choices[bool(i)])) + self.top_grid_layout.addWidget(_dds1_pinc_sw_check_box, 1,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, 4,0) + self._dds1_nco_range = Range(0, 60000000, 1, 40000000, 200) + self._dds1_nco_win = RangeWidget(self._dds1_nco_range, self.set_dds1_nco, 'dds1_nco', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds1_nco_win, 0,0) + self._dds1_f0_range = Range(0, 60000000, 1, 40000000, 200) + self._dds1_f0_win = RangeWidget(self._dds1_f0_range, self.set_dds1_f0, 'dds1_f0', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds1_f0_win, 12,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, 3,0) + self._adc1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._adc1_offset_win = RangeWidget(self._adc1_offset_range, self.set_adc1_offset, 'adc1_offset', "counter_slider", int) + self.top_grid_layout.addWidget(self._adc1_offset_win, 5,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=dds1_pinc_sw, + poff_sw=dds1_poff_sw, + ) + + self.add_const_set_offset_0_0_0_1_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid2_setpoint', + const=pid2_setpoint, + ) + + self.add_const_set_offset_0_0_0_1_0_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid2_kp', + const=pid2_kp, + ) + + self.add_const_set_offset_0_0_0_1_0_0_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid2_ki', + const=pid2_ki, + ) + + self.add_const_set_offset_0_0_0_1_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid2_kd', + const=pid2_kd, + ) + + self.add_const_set_offset_0_0_0_1_0_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid2_sign', + const=pid2_sign, + ) + + self.add_const_set_offset_0_0_0_1_0_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid2_rst_int', + const=pid2_rst_int, + ) + + self.add_const_set_offset_0_0_0_1_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid1_rst_int', + const=pid1_rst_int, + ) + + self.add_const_set_offset_0_0_0_1_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid1_sign', + const=pid1_sign, + ) + + self.add_const_set_offset_0_0_0_1_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid1_kd', + const=pid1_kd, + ) + + self.add_const_set_offset_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid1_ki', + const=pid1_ki, + ) + + self.add_const_set_offset_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid1_kp', + const=pid1_kp, + ) + + self.add_const_set_offset_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid1_setpoint', + const=pid1_setpoint, + ) + + self.add_const_set_offset_0_0_0_0_1_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/pid2_offset', + const=pid2_offset, + ) + + self.add_const_set_offset_0_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds1_range', + const=dds1_range, + ) + + self.add_const_set_offset_0_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds1_f0', + const=int(dds1_f0/(125e6/2**32)), + ) + + self.add_const_set_offset_0_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds1_offset', + const=dds1_offset, + ) + + self.add_const_set_offset_0_0_0_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_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/adc1_offset', + const=adc1_offset, + ) + + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "pid_vco_pid_only") + 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_pid2_sign(self): + return self.pid2_sign + + def set_pid2_sign(self, pid2_sign): + self.pid2_sign = pid2_sign + self._pid2_sign_callback(self.pid2_sign) + self.add_const_set_offset_0_0_0_1_0_0_0_0_1.set_const(device='/dev/pid2_sign', const=self.pid2_sign) + + def get_pid2_setpoint(self): + return self.pid2_setpoint + + def set_pid2_setpoint(self, pid2_setpoint): + self.pid2_setpoint = pid2_setpoint + self.add_const_set_offset_0_0_0_1_1.set_const(device='/dev/pid2_setpoint', const=self.pid2_setpoint) + + def get_pid2_rst_int(self): + return self.pid2_rst_int + + def set_pid2_rst_int(self, pid2_rst_int): + self.pid2_rst_int = pid2_rst_int + self.add_const_set_offset_0_0_0_1_0_0_0_0_0_0.set_const(device='/dev/pid2_rst_int', const=self.pid2_rst_int) + + def get_pid2_offset(self): + return self.pid2_offset + + def set_pid2_offset(self, pid2_offset): + self.pid2_offset = pid2_offset + self.add_const_set_offset_0_0_0_0_1_1.set_const(device='/dev/pid2_offset', const=self.pid2_offset) + + def get_pid2_kp(self): + return self.pid2_kp + + def set_pid2_kp(self, pid2_kp): + self.pid2_kp = pid2_kp + self.add_const_set_offset_0_0_0_1_0_1.set_const(device='/dev/pid2_kp', const=self.pid2_kp) + + def get_pid2_ki(self): + return self.pid2_ki + + def set_pid2_ki(self, pid2_ki): + self.pid2_ki = pid2_ki + self.add_const_set_offset_0_0_0_1_0_0_1.set_const(device='/dev/pid2_ki', const=self.pid2_ki) + + def get_pid2_kd(self): + return self.pid2_kd + + def set_pid2_kd(self, pid2_kd): + self.pid2_kd = pid2_kd + self.add_const_set_offset_0_0_0_1_0_0_0_1.set_const(device='/dev/pid2_kd', const=self.pid2_kd) + + def get_pid1_sign(self): + return self.pid1_sign + + def set_pid1_sign(self, pid1_sign): + self.pid1_sign = pid1_sign + self._pid1_sign_callback(self.pid1_sign) + self.add_const_set_offset_0_0_0_1_0_0_0_0.set_const(device='/dev/pid1_sign', const=self.pid1_sign) + + def get_pid1_setpoint(self): + return self.pid1_setpoint - def set_pid1_setpoint(self, pid1_setpoint): - self.pid1_setpoint = pid1_setpoint - self.add_const_set_offset_0_0_0_1.set_const(device='/dev/pid1_setpoint', const=self.pid1_setpoint) + def set_pid1_setpoint(self, pid1_setpoint): + self.pid1_setpoint = pid1_setpoint + self.add_const_set_offset_0_0_0_1.set_const(device='/dev/pid1_setpoint', const=self.pid1_setpoint) - def get_pid1_rst_int(self): - return self.pid1_rst_int + def get_pid1_rst_int(self): + return self.pid1_rst_int - def set_pid1_rst_int(self, pid1_rst_int): - self.pid1_rst_int = pid1_rst_int - self.add_const_set_offset_0_0_0_1_0_0_0_0_0.set_const(device='/dev/pid1_rst_int', const=self.pid1_rst_int) + def set_pid1_rst_int(self, pid1_rst_int): + self.pid1_rst_int = pid1_rst_int + self.add_const_set_offset_0_0_0_1_0_0_0_0_0.set_const(device='/dev/pid1_rst_int', const=self.pid1_rst_int) - def get_pid1_kp(self): - return self.pid1_kp + def get_pid1_kp(self): + return self.pid1_kp - def set_pid1_kp(self, pid1_kp): - self.pid1_kp = pid1_kp - self.add_const_set_offset_0_0_0_1_0.set_const(device='/dev/pid1_kp', const=self.pid1_kp) + def set_pid1_kp(self, pid1_kp): + self.pid1_kp = pid1_kp + self.add_const_set_offset_0_0_0_1_0.set_const(device='/dev/pid1_kp', const=self.pid1_kp) - def get_pid1_ki(self): - return self.pid1_ki + def get_pid1_ki(self): + return self.pid1_ki - def set_pid1_ki(self, pid1_ki): - self.pid1_ki = pid1_ki - self.add_const_set_offset_0_0_0_1_0_0.set_const(device='/dev/pid1_ki', const=self.pid1_ki) + def set_pid1_ki(self, pid1_ki): + self.pid1_ki = pid1_ki + self.add_const_set_offset_0_0_0_1_0_0.set_const(device='/dev/pid1_ki', const=self.pid1_ki) - def get_pid1_kd(self): - return self.pid1_kd + def get_pid1_kd(self): + return self.pid1_kd - def set_pid1_kd(self, pid1_kd): - self.pid1_kd = pid1_kd - self.add_const_set_offset_0_0_0_1_0_0_0.set_const(device='/dev/pid1_kd', const=self.pid1_kd) + def set_pid1_kd(self, pid1_kd): + self.pid1_kd = pid1_kd + self.add_const_set_offset_0_0_0_1_0_0_0.set_const(device='/dev/pid1_kd', const=self.pid1_kd) - def get_dds1_range(self): - return self.dds1_range + def get_dds1_range(self): + return self.dds1_range - def set_dds1_range(self, dds1_range): - self.dds1_range = dds1_range - self.add_const_set_offset_0_0_0_0_1_0_0.set_const(device='/dev/dds1_range', const=self.dds1_range) + def set_dds1_range(self, dds1_range): + self.dds1_range = dds1_range + self.add_const_set_offset_0_0_0_0_1_0_0.set_const(device='/dev/dds1_range', const=self.dds1_range) - def get_dds1_poff_sw(self): - return self.dds1_poff_sw + def get_dds1_poff_sw(self): + return self.dds1_poff_sw - def set_dds1_poff_sw(self, dds1_poff_sw): - self.dds1_poff_sw = dds1_poff_sw - self._dds1_poff_sw_callback(self.dds1_poff_sw) - 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=self.dds1_pinc_sw, poff_sw=self.dds1_poff_sw) + def set_dds1_poff_sw(self, dds1_poff_sw): + self.dds1_poff_sw = dds1_poff_sw + self._dds1_poff_sw_callback(self.dds1_poff_sw) + 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=self.dds1_pinc_sw, poff_sw=self.dds1_poff_sw) - def get_dds1_pinc_sw(self): - return self.dds1_pinc_sw + def get_dds1_pinc_sw(self): + return self.dds1_pinc_sw - def set_dds1_pinc_sw(self, dds1_pinc_sw): - self.dds1_pinc_sw = dds1_pinc_sw - self._dds1_pinc_sw_callback(self.dds1_pinc_sw) - 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=self.dds1_pinc_sw, poff_sw=self.dds1_poff_sw) + def set_dds1_pinc_sw(self, dds1_pinc_sw): + self.dds1_pinc_sw = dds1_pinc_sw + self._dds1_pinc_sw_callback(self.dds1_pinc_sw) + 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=self.dds1_pinc_sw, poff_sw=self.dds1_poff_sw) - def get_dds1_offset(self): - return self.dds1_offset + 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_0_0_0_1.set_const(device='/dev/dds1_offset', const=self.dds1_offset) + def set_dds1_offset(self, dds1_offset): + self.dds1_offset = dds1_offset + self.add_const_set_offset_0_0_0_0_1.set_const(device='/dev/dds1_offset', const=self.dds1_offset) - def get_dds1_nco(self): - return self.dds1_nco + 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=self.dds1_pinc_sw, poff_sw=self.dds1_poff_sw) + 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=self.dds1_pinc_sw, poff_sw=self.dds1_poff_sw) - def get_dds1_f0(self): - return self.dds1_f0 + def get_dds1_f0(self): + return self.dds1_f0 - def set_dds1_f0(self, dds1_f0): - self.dds1_f0 = dds1_f0 - self.add_const_set_offset_0_0_0_0_1_0.set_const(device='/dev/dds1_f0', const=int(self.dds1_f0/(125e6/2**32))) + def set_dds1_f0(self, dds1_f0): + self.dds1_f0 = dds1_f0 + self.add_const_set_offset_0_0_0_0_1_0.set_const(device='/dev/dds1_f0', const=int(self.dds1_f0/(125e6/2**32))) - def get_dds1_ampl(self): - return self.dds1_ampl + 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_0_0_0.set_const(device='/dev/dds1_ampl', const=self.dds1_ampl) + def set_dds1_ampl(self, dds1_ampl): + self.dds1_ampl = dds1_ampl + self.add_const_set_offset_0_0_0_0_0.set_const(device='/dev/dds1_ampl', const=self.dds1_ampl) - def get_addr(self): - return self.addr + def get_addr(self): + return self.addr - def set_addr(self, addr): - self.addr = addr + def set_addr(self, addr): + self.addr = addr - def get_adc1_offset(self): - return self.adc1_offset + def get_adc1_offset(self): + return self.adc1_offset - def set_adc1_offset(self, adc1_offset): - self.adc1_offset = adc1_offset - self.add_const_set_offset_0_0_0.set_const(device='/dev/adc1_offset', const=self.adc1_offset) + def set_adc1_offset(self, adc1_offset): + self.adc1_offset = adc1_offset + self.add_const_set_offset_0_0_0.set_const(device='/dev/adc1_offset', const=self.adc1_offset) def main(top_block_cls=pid_vco_pid_only, 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) + 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() + tb = top_block_cls() + tb.start() + tb.show() - def quitting(): - tb.stop() - tb.wait() - qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) - qapp.exec_() + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() if __name__ == '__main__': - main() + main() diff --git a/redpitaya/client/redpitaya_gnuradio.py b/redpitaya/client/redpitaya_gnuradio.py index 24a59ba..0392f9f 100644 --- a/redpitaya/client/redpitaya_gnuradio.py +++ b/redpitaya/client/redpitaya_gnuradio.py @@ -21,51 +21,51 @@ import socket, os from gnuradio import gr, blocks class add_const_set_offset(gr.hier_block2): - def __init__(self, addr, port, device, const): - self.name = "add_const_set_offset" - gr.hier_block2.__init__( - self, - name = self.name, - input_signature = gr.io_signature(0, 0, 0), - output_signature = gr.io_signature(0, 0, 0) - ) - self.ctrl_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.ctrl_sock.connect((addr, port)) - self.set_const(device, const) + def __init__(self, addr, port, device, const): + self.name = "add_const_set_offset" + gr.hier_block2.__init__( + self, + name = self.name, + input_signature = gr.io_signature(0, 0, 0), + output_signature = gr.io_signature(0, 0, 0) + ) + self.ctrl_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.ctrl_sock.connect((addr, port)) + self.set_const(device, const) - def set_const(self, device, const): - self.ctrl_sock.send('%s;%s;%i\n'%(self.name, device, const)) + def set_const(self, device, const): + self.ctrl_sock.send('%s;%s;%i\n'%(self.name, device, const)) class nco_counter_send_conf(gr.hier_block2): - def __init__(self, addr, port, device, freq_ref, freq_dds, acc_size, offset, pinc_sw, poff_sw): - self.name = "nco_counter_send_conf" - gr.hier_block2.__init__( - self, - name = self.name, - input_signature = gr.io_signature(0, 0, 0), - output_signature = gr.io_signature(0, 0, 0) - ) - self.ctrl_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.ctrl_sock.connect((addr, port)) - self.set_nco(device, freq_ref, freq_dds, acc_size, offset, pinc_sw, poff_sw) + def __init__(self, addr, port, device, freq_ref, freq_dds, acc_size, offset, pinc_sw, poff_sw): + self.name = "nco_counter_send_conf" + gr.hier_block2.__init__( + self, + name = self.name, + input_signature = gr.io_signature(0, 0, 0), + output_signature = gr.io_signature(0, 0, 0) + ) + self.ctrl_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.ctrl_sock.connect((addr, port)) + self.set_nco(device, freq_ref, freq_dds, acc_size, offset, pinc_sw, poff_sw) - def set_nco(self, device, freq_ref, freq_dds, acc_size, offset, pinc_sw, poff_sw): - self.ctrl_sock.send('%s;%s;%i;%i;%i;%i;%i;%i\n'%(self.name, device, freq_ref, freq_dds, acc_size, offset, pinc_sw, poff_sw)) + def set_nco(self, device, freq_ref, freq_dds, acc_size, offset, pinc_sw, poff_sw): + self.ctrl_sock.send('%s;%s;%i;%i;%i;%i;%i;%i\n'%(self.name, device, freq_ref, freq_dds, acc_size, offset, pinc_sw, poff_sw)) '''~ class source_test(gr.hier_block2): - def __init__(self): - self.name = "source_test" - gr.hier_block2.__init__( - self, - name = self.name, - input_signature = gr.io_signature(0, 0, 0), - output_signature = gr.io_signature(1, 1, gr.sizeof_gr_complex) - ) - self.data_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.data_sock.connect((addr, port)) - self.data_sock.send('%s'%self.name) - fd = os.dup(self.data_sock.fileno()) - self.connect(blocks.file_descriptor_source(gr.sizeof_gr_complex, fd), self) + def __init__(self): + self.name = "source_test" + gr.hier_block2.__init__( + self, + name = self.name, + input_signature = gr.io_signature(0, 0, 0), + output_signature = gr.io_signature(1, 1, gr.sizeof_gr_complex) + ) + self.data_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.data_sock.connect((addr, port)) + self.data_sock.send('%s'%self.name) + fd = os.dup(self.data_sock.fileno()) + self.connect(blocks.file_descriptor_source(gr.sizeof_gr_complex, fd), self) ''' diff --git a/redpitaya/client/vco_only.py b/redpitaya/client/vco_only.py index 5c4b8d4..7062e4c 100755 --- a/redpitaya/client/vco_only.py +++ b/redpitaya/client/vco_only.py @@ -7,14 +7,14 @@ ################################################## 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()" + 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 @@ -29,238 +29,238 @@ import sys class vco_only(gr.top_block, Qt.QWidget): - def __init__(self): - gr.top_block.__init__(self, "Vco Only") - Qt.QWidget.__init__(self) - self.setWindowTitle("Vco Only") - 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", "vco_only") - self.restoreGeometry(self.settings.value("geometry").toByteArray()) - - ################################################## - # Variables - ################################################## - self.port = port = 1001 - self.off_sw = off_sw = 0 - self.inc_sw = inc_sw = 0 - self.dds_range = dds_range = 0 - self.dds_offset = dds_offset = 0 - self.dds_nco = dds_nco = 0 - self.dds_f0 = dds_f0 = 0 - self.dds_ampl = dds_ampl = 0 - self.dac1_offset = dac1_offset = 0 - self.addr = addr = "192.168.0.203" - self.adc1_offset = adc1_offset = 0 - - ################################################## - # Blocks - ################################################## - _off_sw_check_box = Qt.QCheckBox('off_sw') - self._off_sw_choices = {True: 1, False: 0} - self._off_sw_choices_inv = dict((v,k) for k,v in self._off_sw_choices.iteritems()) - self._off_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_off_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._off_sw_choices_inv[i])) - self._off_sw_callback(self.off_sw) - _off_sw_check_box.stateChanged.connect(lambda i: self.set_off_sw(self._off_sw_choices[bool(i)])) - self.top_grid_layout.addWidget(_off_sw_check_box, 2, 2) - _inc_sw_check_box = Qt.QCheckBox('inc_sw') - self._inc_sw_choices = {True: 1, False: 0} - self._inc_sw_choices_inv = dict((v,k) for k,v in self._inc_sw_choices.iteritems()) - self._inc_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_inc_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._inc_sw_choices_inv[i])) - self._inc_sw_callback(self.inc_sw) - _inc_sw_check_box.stateChanged.connect(lambda i: self.set_inc_sw(self._inc_sw_choices[bool(i)])) - self.top_grid_layout.addWidget(_inc_sw_check_box, 2, 1) - self._dds_range_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._dds_range_win = RangeWidget(self._dds_range_range, self.set_dds_range, 'dds_range', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds_range_win, 5, 3) - self._dds_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._dds_offset_win = RangeWidget(self._dds_offset_range, self.set_dds_offset, 'dds_offset', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds_offset_win, 3, 3) - self._dds_nco_range = Range(0, 60000000, 1, 0, 200) - self._dds_nco_win = RangeWidget(self._dds_nco_range, self.set_dds_nco, 'dds_nco', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds_nco_win, 2, 3) - self._dds_f0_range = Range(0, 60000000, 1000, 0, 200) - self._dds_f0_win = RangeWidget(self._dds_f0_range, self.set_dds_f0, 'dds_f0', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds_f0_win, 4, 3) - self._dds_ampl_range = Range(0, 2**13-1, 1, 0, 200) - self._dds_ampl_win = RangeWidget(self._dds_ampl_range, self.set_dds_ampl, 'dds_ampl', "counter_slider", int) - self.top_grid_layout.addWidget(self._dds_ampl_win, 1, 3) - self._dac1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._dac1_offset_win = RangeWidget(self._dac1_offset_range, self.set_dac1_offset, 'dac1_offset', "counter_slider", int) - self.top_grid_layout.addWidget(self._dac1_offset_win, 1, 2) - self._adc1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) - self._adc1_offset_win = RangeWidget(self._adc1_offset_range, self.set_adc1_offset, 'adc1_offset', "counter_slider", int) - self.top_grid_layout.addWidget(self._adc1_offset_win, 1, 1) - self.nco_counter_send_conf_0 = redpitaya_gnuradio.nco_counter_send_conf( - addr=addr, - port=port, - device='/dev/dds_nco', - freq_ref=125000000, - freq_dds=dds_nco, - acc_size=32, - offset=0, - pinc_sw=inc_sw, - poff_sw=off_sw, - ) - - self.add_const_set_offset_0_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds_f0', - const=int(dds_f0/(125e6/2**32)), - ) - - self.add_const_set_offset_0_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds_offset', - const=dds_offset, - ) - - self.add_const_set_offset_0_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds_range', - const=dds_range, - ) - - self.add_const_set_offset_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dds_ampl', - const=dds_ampl, - ) - - self.add_const_set_offset_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/dac1_offset', - const=dac1_offset, - ) - - self.add_const_set_offset_0_0_0 = redpitaya_gnuradio.add_const_set_offset( - addr=addr, - port=port, - device='/dev/adc1_offset', - const=adc1_offset, - ) - - - def closeEvent(self, event): - self.settings = Qt.QSettings("GNU Radio", "vco_only") - 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_off_sw(self): - return self.off_sw - - def set_off_sw(self, off_sw): - self.off_sw = off_sw - self._off_sw_callback(self.off_sw) - self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.dds_nco, acc_size=32, offset=0, pinc_sw=self.inc_sw, poff_sw=self.off_sw) - - def get_inc_sw(self): - return self.inc_sw - - def set_inc_sw(self, inc_sw): - self.inc_sw = inc_sw - self._inc_sw_callback(self.inc_sw) - self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.dds_nco, acc_size=32, offset=0, pinc_sw=self.inc_sw, poff_sw=self.off_sw) - - def get_dds_range(self): - return self.dds_range - - def set_dds_range(self, dds_range): - self.dds_range = dds_range - self.add_const_set_offset_0_0_0_0_0_0.set_const(device='/dev/dds_range', const=self.dds_range) - - def get_dds_offset(self): - return self.dds_offset - - def set_dds_offset(self, dds_offset): - self.dds_offset = dds_offset - self.add_const_set_offset_0_0_0_0_1.set_const(device='/dev/dds_offset', const=self.dds_offset) - - def get_dds_nco(self): - return self.dds_nco - - def set_dds_nco(self, dds_nco): - self.dds_nco = dds_nco - self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.dds_nco, acc_size=32, offset=0, pinc_sw=self.inc_sw, poff_sw=self.off_sw) - - def get_dds_f0(self): - return self.dds_f0 - - def set_dds_f0(self, dds_f0): - self.dds_f0 = dds_f0 - self.add_const_set_offset_0_0_0_0_1_0.set_const(device='/dev/dds_f0', const=int(self.dds_f0/(125e6/2**32))) - - def get_dds_ampl(self): - return self.dds_ampl - - def set_dds_ampl(self, dds_ampl): - self.dds_ampl = dds_ampl - self.add_const_set_offset_0_0_0_0_0.set_const(device='/dev/dds_ampl', const=self.dds_ampl) - - def get_dac1_offset(self): - return self.dac1_offset - - def set_dac1_offset(self, dac1_offset): - self.dac1_offset = dac1_offset - self.add_const_set_offset_0_0_0_0.set_const(device='/dev/dac1_offset', const=self.dac1_offset) - - def get_addr(self): - return self.addr - - def set_addr(self, addr): - self.addr = addr - - def get_adc1_offset(self): - return self.adc1_offset - - def set_adc1_offset(self, adc1_offset): - self.adc1_offset = adc1_offset - self.add_const_set_offset_0_0_0.set_const(device='/dev/adc1_offset', const=self.adc1_offset) + def __init__(self): + gr.top_block.__init__(self, "Vco Only") + Qt.QWidget.__init__(self) + self.setWindowTitle("Vco Only") + 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", "vco_only") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + ################################################## + # Variables + ################################################## + self.port = port = 1001 + self.off_sw = off_sw = 0 + self.inc_sw = inc_sw = 0 + self.dds_range = dds_range = 0 + self.dds_offset = dds_offset = 0 + self.dds_nco = dds_nco = 0 + self.dds_f0 = dds_f0 = 0 + self.dds_ampl = dds_ampl = 0 + self.dac1_offset = dac1_offset = 0 + self.addr = addr = "192.168.0.203" + self.adc1_offset = adc1_offset = 0 + + ################################################## + # Blocks + ################################################## + _off_sw_check_box = Qt.QCheckBox('off_sw') + self._off_sw_choices = {True: 1, False: 0} + self._off_sw_choices_inv = dict((v,k) for k,v in self._off_sw_choices.iteritems()) + self._off_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_off_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._off_sw_choices_inv[i])) + self._off_sw_callback(self.off_sw) + _off_sw_check_box.stateChanged.connect(lambda i: self.set_off_sw(self._off_sw_choices[bool(i)])) + self.top_grid_layout.addWidget(_off_sw_check_box, 2, 2) + _inc_sw_check_box = Qt.QCheckBox('inc_sw') + self._inc_sw_choices = {True: 1, False: 0} + self._inc_sw_choices_inv = dict((v,k) for k,v in self._inc_sw_choices.iteritems()) + self._inc_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_inc_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._inc_sw_choices_inv[i])) + self._inc_sw_callback(self.inc_sw) + _inc_sw_check_box.stateChanged.connect(lambda i: self.set_inc_sw(self._inc_sw_choices[bool(i)])) + self.top_grid_layout.addWidget(_inc_sw_check_box, 2, 1) + self._dds_range_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._dds_range_win = RangeWidget(self._dds_range_range, self.set_dds_range, 'dds_range', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds_range_win, 5, 3) + self._dds_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._dds_offset_win = RangeWidget(self._dds_offset_range, self.set_dds_offset, 'dds_offset', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds_offset_win, 3, 3) + self._dds_nco_range = Range(0, 60000000, 1, 0, 200) + self._dds_nco_win = RangeWidget(self._dds_nco_range, self.set_dds_nco, 'dds_nco', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds_nco_win, 2, 3) + self._dds_f0_range = Range(0, 60000000, 1000, 0, 200) + self._dds_f0_win = RangeWidget(self._dds_f0_range, self.set_dds_f0, 'dds_f0', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds_f0_win, 4, 3) + self._dds_ampl_range = Range(0, 2**13-1, 1, 0, 200) + self._dds_ampl_win = RangeWidget(self._dds_ampl_range, self.set_dds_ampl, 'dds_ampl', "counter_slider", int) + self.top_grid_layout.addWidget(self._dds_ampl_win, 1, 3) + self._dac1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._dac1_offset_win = RangeWidget(self._dac1_offset_range, self.set_dac1_offset, 'dac1_offset', "counter_slider", int) + self.top_grid_layout.addWidget(self._dac1_offset_win, 1, 2) + self._adc1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) + self._adc1_offset_win = RangeWidget(self._adc1_offset_range, self.set_adc1_offset, 'adc1_offset', "counter_slider", int) + self.top_grid_layout.addWidget(self._adc1_offset_win, 1, 1) + self.nco_counter_send_conf_0 = redpitaya_gnuradio.nco_counter_send_conf( + addr=addr, + port=port, + device='/dev/dds_nco', + freq_ref=125000000, + freq_dds=dds_nco, + acc_size=32, + offset=0, + pinc_sw=inc_sw, + poff_sw=off_sw, + ) + + self.add_const_set_offset_0_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds_f0', + const=int(dds_f0/(125e6/2**32)), + ) + + self.add_const_set_offset_0_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds_offset', + const=dds_offset, + ) + + self.add_const_set_offset_0_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds_range', + const=dds_range, + ) + + self.add_const_set_offset_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds_ampl', + const=dds_ampl, + ) + + self.add_const_set_offset_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dac1_offset', + const=dac1_offset, + ) + + self.add_const_set_offset_0_0_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/adc1_offset', + const=adc1_offset, + ) + + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "vco_only") + 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_off_sw(self): + return self.off_sw + + def set_off_sw(self, off_sw): + self.off_sw = off_sw + self._off_sw_callback(self.off_sw) + self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.dds_nco, acc_size=32, offset=0, pinc_sw=self.inc_sw, poff_sw=self.off_sw) + + def get_inc_sw(self): + return self.inc_sw + + def set_inc_sw(self, inc_sw): + self.inc_sw = inc_sw + self._inc_sw_callback(self.inc_sw) + self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.dds_nco, acc_size=32, offset=0, pinc_sw=self.inc_sw, poff_sw=self.off_sw) + + def get_dds_range(self): + return self.dds_range + + def set_dds_range(self, dds_range): + self.dds_range = dds_range + self.add_const_set_offset_0_0_0_0_0_0.set_const(device='/dev/dds_range', const=self.dds_range) + + def get_dds_offset(self): + return self.dds_offset + + def set_dds_offset(self, dds_offset): + self.dds_offset = dds_offset + self.add_const_set_offset_0_0_0_0_1.set_const(device='/dev/dds_offset', const=self.dds_offset) + + def get_dds_nco(self): + return self.dds_nco + + def set_dds_nco(self, dds_nco): + self.dds_nco = dds_nco + self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.dds_nco, acc_size=32, offset=0, pinc_sw=self.inc_sw, poff_sw=self.off_sw) + + def get_dds_f0(self): + return self.dds_f0 + + def set_dds_f0(self, dds_f0): + self.dds_f0 = dds_f0 + self.add_const_set_offset_0_0_0_0_1_0.set_const(device='/dev/dds_f0', const=int(self.dds_f0/(125e6/2**32))) + + def get_dds_ampl(self): + return self.dds_ampl + + def set_dds_ampl(self, dds_ampl): + self.dds_ampl = dds_ampl + self.add_const_set_offset_0_0_0_0_0.set_const(device='/dev/dds_ampl', const=self.dds_ampl) + + def get_dac1_offset(self): + return self.dac1_offset + + def set_dac1_offset(self, dac1_offset): + self.dac1_offset = dac1_offset + self.add_const_set_offset_0_0_0_0.set_const(device='/dev/dac1_offset', const=self.dac1_offset) + + def get_addr(self): + return self.addr + + def set_addr(self, addr): + self.addr = addr + + def get_adc1_offset(self): + return self.adc1_offset + + def set_adc1_offset(self, adc1_offset): + self.adc1_offset = adc1_offset + self.add_const_set_offset_0_0_0.set_const(device='/dev/adc1_offset', const=self.adc1_offset) def main(top_block_cls=vco_only, 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) + 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() + tb = top_block_cls() + tb.start() + tb.show() - def quitting(): - tb.stop() - tb.wait() - qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) - qapp.exec_() + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() if __name__ == '__main__': - main() + main() diff --git a/redpitaya/server/server.py b/redpitaya/server/server.py index 5077251..c137b3b 100755 --- a/redpitaya/server/server.py +++ b/redpitaya/server/server.py @@ -7,22 +7,22 @@ import liboscimp_fpga ########################################################### def clientThread(conn, addr): - print('Open connection from ' + addr[0] + ':' + str(addr[1]) + '\n') - while True: - data = '' - while '\n' not in data: - data += conn.recv(8) - recv = data.split(';') - if recv[0] == "add_const_set_offset": - try: - liboscimp_fpga.add_const_set_offset(recv[1], int(recv[2])) - except: - pass - if recv[0] == "nco_counter_send_conf": - try: - liboscimp_fpga.nco_counter_send_conf(recv[1], int(recv[2]), int(recv[3]), int(recv[4]), int(recv[5]), int(recv[6]), int(recv[7])) - except: - pass + print('Open connection from ' + addr[0] + ':' + str(addr[1]) + '\n') + while True: + data = '' + while '\n' not in data: + data += conn.recv(8) + recv = data.split(';') + if recv[0] == "add_const_set_offset": + try: + liboscimp_fpga.add_const_set_offset(recv[1], int(recv[2])) + except: + pass + if recv[0] == "nco_counter_send_conf": + try: + liboscimp_fpga.nco_counter_send_conf(recv[1], int(recv[2]), int(recv[3]), int(recv[4]), int(recv[5]), int(recv[6]), int(recv[7])) + except: + pass ########################################################### @@ -31,8 +31,8 @@ ctrl_sock.bind(('', 1001)) ctrl_sock.listen(10) try: - while True: - conn, addr = ctrl_sock.accept() - start_new_thread(clientThread ,(conn, addr,)) + while True: + conn, addr = ctrl_sock.accept() + start_new_thread(clientThread ,(conn, addr,)) except KeyboardInterrupt: - ctrl_sock.close() + ctrl_sock.close() diff --git a/redpitaya/server/tests/set_offset.py b/redpitaya/server/tests/set_offset.py index 837fd52..b0c749c 100755 --- a/redpitaya/server/tests/set_offset.py +++ b/redpitaya/server/tests/set_offset.py @@ -3,28 +3,28 @@ import ctypes, argparse import liboscimp_fpga def parse(): - parser = argparse.ArgumentParser(description = 'Set offsets to DAC1 and DAC2') - parser.add_argument('-of1', - action='store', - dest='of1', - default=0, - help='DAC1 offset (bits)') - parser.add_argument('-of2', - action='store', - dest='of2', - default=0, - help='DAC2 offset (bits)') - args = parser.parse_args() - return args + parser = argparse.ArgumentParser(description = 'Set offsets to DAC1 and DAC2') + parser.add_argument('-of1', + action='store', + dest='of1', + default=0, + help='DAC1 offset (bits)') + parser.add_argument('-of2', + action='store', + dest='of2', + default=0, + help='DAC2 offset (bits)') + args = parser.parse_args() + return args def main(): - args = parse() - of1 = int(args.of1) - of2 = int(args.of2) - liboscimp_fpga.add_const_set_offset("/dev/add_const_0", of1) - liboscimp_fpga.add_const_set_offset("/dev/add_const_1", of2) - print('offset DAC1 : %i'%of1) - print('offset DAC2 : %i'%of2) + args = parse() + of1 = int(args.of1) + of2 = int(args.of2) + liboscimp_fpga.add_const_set_offset("/dev/add_const_0", of1) + liboscimp_fpga.add_const_set_offset("/dev/add_const_1", of2) + print('offset DAC1 : %i'%of1) + print('offset DAC2 : %i'%of2) if __name__ == "__main__": - main() + main() diff --git a/redpitaya/server/tests/test.py b/redpitaya/server/tests/test.py index 2ba73ef..15b672a 100644 --- a/redpitaya/server/tests/test.py +++ b/redpitaya/server/tests/test.py @@ -1,6 +1,6 @@ import time with open('/dev/data16_adc12', 'r') as f: - for line in f: - print(line.encode('bin')) - time.sleep(0.1) + for line in f: + print(line.encode('bin')) + time.sleep(0.1) diff --git a/redpitaya/server/tests/test_dac_offsets.py b/redpitaya/server/tests/test_dac_offsets.py index 837fd52..b0c749c 100755 --- a/redpitaya/server/tests/test_dac_offsets.py +++ b/redpitaya/server/tests/test_dac_offsets.py @@ -3,28 +3,28 @@ import ctypes, argparse import liboscimp_fpga def parse(): - parser = argparse.ArgumentParser(description = 'Set offsets to DAC1 and DAC2') - parser.add_argument('-of1', - action='store', - dest='of1', - default=0, - help='DAC1 offset (bits)') - parser.add_argument('-of2', - action='store', - dest='of2', - default=0, - help='DAC2 offset (bits)') - args = parser.parse_args() - return args + parser = argparse.ArgumentParser(description = 'Set offsets to DAC1 and DAC2') + parser.add_argument('-of1', + action='store', + dest='of1', + default=0, + help='DAC1 offset (bits)') + parser.add_argument('-of2', + action='store', + dest='of2', + default=0, + help='DAC2 offset (bits)') + args = parser.parse_args() + return args def main(): - args = parse() - of1 = int(args.of1) - of2 = int(args.of2) - liboscimp_fpga.add_const_set_offset("/dev/add_const_0", of1) - liboscimp_fpga.add_const_set_offset("/dev/add_const_1", of2) - print('offset DAC1 : %i'%of1) - print('offset DAC2 : %i'%of2) + args = parse() + of1 = int(args.of1) + of2 = int(args.of2) + liboscimp_fpga.add_const_set_offset("/dev/add_const_0", of1) + liboscimp_fpga.add_const_set_offset("/dev/add_const_1", of2) + print('offset DAC1 : %i'%of1) + print('offset DAC2 : %i'%of2) if __name__ == "__main__": - main() + main() diff --git a/sdr/fm_radio/fm_radio.py b/sdr/fm_radio/fm_radio.py index e7ea6d4..2695989 100755 --- a/sdr/fm_radio/fm_radio.py +++ b/sdr/fm_radio/fm_radio.py @@ -7,14 +7,14 @@ ################################################## 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()" + 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 @@ -35,160 +35,160 @@ import time class fm_radio(gr.top_block, Qt.QWidget): - def __init__(self): - gr.top_block.__init__(self, "Fm Radio") - Qt.QWidget.__init__(self) - self.setWindowTitle("Fm Radio") - 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", "fm_radio") - self.restoreGeometry(self.settings.value("geometry").toByteArray()) - - ################################################## - # Variables - ################################################## - self.samp_rate = samp_rate = 48e3 - self.freq = freq = 218013000 - - ################################################## - # Blocks - ################################################## - self._freq_range = Range(52e6, 2e9, 1e3, 218013000, 200) - self._freq_win = RangeWidget(self._freq_range, self.set_freq, "freq", "counter_slider", float) - self.top_grid_layout.addWidget(self._freq_win, 0,0) - self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' ) - self.rtlsdr_source_0.set_sample_rate(samp_rate*8*4) - self.rtlsdr_source_0.set_center_freq(freq, 0) - self.rtlsdr_source_0.set_freq_corr(0, 0) - self.rtlsdr_source_0.set_dc_offset_mode(0, 0) - self.rtlsdr_source_0.set_iq_balance_mode(0, 0) - self.rtlsdr_source_0.set_gain_mode(False, 0) - self.rtlsdr_source_0.set_gain(20, 0) - self.rtlsdr_source_0.set_if_gain(20, 0) - self.rtlsdr_source_0.set_bb_gain(20, 0) - self.rtlsdr_source_0.set_antenna('', 0) - self.rtlsdr_source_0.set_bandwidth(0, 0) - - self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( - interpolation=1, - decimation=8, - taps=None, - fractional_bw=None, - ) - self.rational_resampler_xxx_0 = filter.rational_resampler_fff( - interpolation=1, - decimation=4, - taps=None, - fractional_bw=None, - ) - self.qtgui_sink_x_1 = qtgui.sink_f( - 1024, #fftsize - firdes.WIN_BLACKMAN_hARRIS, #wintype - 0, #fc - samp_rate*8, #bw - "", #name - True, #plotfreq - True, #plotwaterfall - True, #plottime - True, #plotconst - ) - self.qtgui_sink_x_1.set_update_time(1.0/10) - self._qtgui_sink_x_1_win = sip.wrapinstance(self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget) - self.top_grid_layout.addWidget(self._qtgui_sink_x_1_win, 10,0) - - self.qtgui_sink_x_1.enable_rf_freq(False) - - - - self.qtgui_sink_x_0 = qtgui.sink_c( - 1024, #fftsize - firdes.WIN_BLACKMAN_hARRIS, #wintype - 0, #fc - samp_rate*8*4, #bw - "", #name - True, #plotfreq - True, #plotwaterfall - True, #plottime - True, #plotconst - ) - self.qtgui_sink_x_0.set_update_time(1.0/10) - self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) - self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win, 9,0) - - self.qtgui_sink_x_0.enable_rf_freq(False) - - - - self.audio_sink_0 = audio.sink(int(samp_rate), '', True) - self.analog_wfm_rcv_0 = analog.wfm_rcv( - quad_rate=samp_rate*8, - audio_decimation=1, - ) - - ################################################## - # Connections - ################################################## - self.connect((self.analog_wfm_rcv_0, 0), (self.qtgui_sink_x_1, 0)) - self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_0, 0)) - self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0)) - self.connect((self.rational_resampler_xxx_0_0, 0), (self.analog_wfm_rcv_0, 0)) - self.connect((self.rtlsdr_source_0, 0), (self.qtgui_sink_x_0, 0)) - self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_0_0, 0)) - - def closeEvent(self, event): - self.settings = Qt.QSettings("GNU Radio", "fm_radio") - self.settings.setValue("geometry", self.saveGeometry()) - event.accept() - - def get_samp_rate(self): - return self.samp_rate - - def set_samp_rate(self, samp_rate): - self.samp_rate = samp_rate - self.rtlsdr_source_0.set_sample_rate(self.samp_rate*8*4) - self.qtgui_sink_x_1.set_frequency_range(0, self.samp_rate*8) - self.qtgui_sink_x_0.set_frequency_range(0, self.samp_rate*8*4) - - def get_freq(self): - return self.freq - - def set_freq(self, freq): - self.freq = freq - self.rtlsdr_source_0.set_center_freq(self.freq, 0) + def __init__(self): + gr.top_block.__init__(self, "Fm Radio") + Qt.QWidget.__init__(self) + self.setWindowTitle("Fm Radio") + 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", "fm_radio") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + ################################################## + # Variables + ################################################## + self.samp_rate = samp_rate = 48e3 + self.freq = freq = 218013000 + + ################################################## + # Blocks + ################################################## + self._freq_range = Range(52e6, 2e9, 1e3, 218013000, 200) + self._freq_win = RangeWidget(self._freq_range, self.set_freq, "freq", "counter_slider", float) + self.top_grid_layout.addWidget(self._freq_win, 0,0) + self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' ) + self.rtlsdr_source_0.set_sample_rate(samp_rate*8*4) + self.rtlsdr_source_0.set_center_freq(freq, 0) + self.rtlsdr_source_0.set_freq_corr(0, 0) + self.rtlsdr_source_0.set_dc_offset_mode(0, 0) + self.rtlsdr_source_0.set_iq_balance_mode(0, 0) + self.rtlsdr_source_0.set_gain_mode(False, 0) + self.rtlsdr_source_0.set_gain(20, 0) + self.rtlsdr_source_0.set_if_gain(20, 0) + self.rtlsdr_source_0.set_bb_gain(20, 0) + self.rtlsdr_source_0.set_antenna('', 0) + self.rtlsdr_source_0.set_bandwidth(0, 0) + + self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( + interpolation=1, + decimation=8, + taps=None, + fractional_bw=None, + ) + self.rational_resampler_xxx_0 = filter.rational_resampler_fff( + interpolation=1, + decimation=4, + taps=None, + fractional_bw=None, + ) + self.qtgui_sink_x_1 = qtgui.sink_f( + 1024, #fftsize + firdes.WIN_BLACKMAN_hARRIS, #wintype + 0, #fc + samp_rate*8, #bw + "", #name + True, #plotfreq + True, #plotwaterfall + True, #plottime + True, #plotconst + ) + self.qtgui_sink_x_1.set_update_time(1.0/10) + self._qtgui_sink_x_1_win = sip.wrapinstance(self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget) + self.top_grid_layout.addWidget(self._qtgui_sink_x_1_win, 10,0) + + self.qtgui_sink_x_1.enable_rf_freq(False) + + + + self.qtgui_sink_x_0 = qtgui.sink_c( + 1024, #fftsize + firdes.WIN_BLACKMAN_hARRIS, #wintype + 0, #fc + samp_rate*8*4, #bw + "", #name + True, #plotfreq + True, #plotwaterfall + True, #plottime + True, #plotconst + ) + self.qtgui_sink_x_0.set_update_time(1.0/10) + self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) + self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win, 9,0) + + self.qtgui_sink_x_0.enable_rf_freq(False) + + + + self.audio_sink_0 = audio.sink(int(samp_rate), '', True) + self.analog_wfm_rcv_0 = analog.wfm_rcv( + quad_rate=samp_rate*8, + audio_decimation=1, + ) + + ################################################## + # Connections + ################################################## + self.connect((self.analog_wfm_rcv_0, 0), (self.qtgui_sink_x_1, 0)) + self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_0, 0)) + self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0)) + self.connect((self.rational_resampler_xxx_0_0, 0), (self.analog_wfm_rcv_0, 0)) + self.connect((self.rtlsdr_source_0, 0), (self.qtgui_sink_x_0, 0)) + self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_0_0, 0)) + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "fm_radio") + self.settings.setValue("geometry", self.saveGeometry()) + event.accept() + + def get_samp_rate(self): + return self.samp_rate + + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + self.rtlsdr_source_0.set_sample_rate(self.samp_rate*8*4) + self.qtgui_sink_x_1.set_frequency_range(0, self.samp_rate*8) + self.qtgui_sink_x_0.set_frequency_range(0, self.samp_rate*8*4) + + def get_freq(self): + return self.freq + + def set_freq(self, freq): + self.freq = freq + self.rtlsdr_source_0.set_center_freq(self.freq, 0) def main(top_block_cls=fm_radio, 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) + 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() + tb = top_block_cls() + tb.start() + tb.show() - def quitting(): - tb.stop() - tb.wait() - qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) - qapp.exec_() + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() if __name__ == '__main__': - main() + main() diff --git a/sdr/fm_radio/fm_radio_comp_decim_lpf.py b/sdr/fm_radio/fm_radio_comp_decim_lpf.py index e8ccdb5..c19c4dd 100755 --- a/sdr/fm_radio/fm_radio_comp_decim_lpf.py +++ b/sdr/fm_radio/fm_radio_comp_decim_lpf.py @@ -7,14 +7,14 @@ ################################################## 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()" + 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 @@ -35,223 +35,223 @@ import time class fm_radio_comp_decim_lpf(gr.top_block, Qt.QWidget): - def __init__(self): - gr.top_block.__init__(self, "Fm Radio Comp Decim Lpf") - Qt.QWidget.__init__(self) - self.setWindowTitle("Fm Radio Comp Decim Lpf") - 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) + def __init__(self): + gr.top_block.__init__(self, "Fm Radio Comp Decim Lpf") + Qt.QWidget.__init__(self) + self.setWindowTitle("Fm Radio Comp Decim Lpf") + 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", "fm_radio_comp_decim_lpf") - self.restoreGeometry(self.settings.value("geometry").toByteArray()) + self.settings = Qt.QSettings("GNU Radio", "fm_radio_comp_decim_lpf") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) - ################################################## - # Variables - ################################################## - self.samp_rate = samp_rate = 48e3 - self.freq = freq = 91e6 + ################################################## + # Variables + ################################################## + self.samp_rate = samp_rate = 48e3 + self.freq = freq = 91e6 - ################################################## - # Blocks - ################################################## - self._freq_range = Range(1e6, 2e9, 1e5, 91e6, 200) - self._freq_win = RangeWidget(self._freq_range, self.set_freq, "freq", "counter_slider", float) - self.top_grid_layout.addWidget(self._freq_win, 0,0) - self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' ) - self.rtlsdr_source_0.set_sample_rate(samp_rate*10*4) - self.rtlsdr_source_0.set_center_freq(freq, 0) - self.rtlsdr_source_0.set_freq_corr(0, 0) - self.rtlsdr_source_0.set_dc_offset_mode(0, 0) - self.rtlsdr_source_0.set_iq_balance_mode(0, 0) - self.rtlsdr_source_0.set_gain_mode(False, 0) - self.rtlsdr_source_0.set_gain(30, 0) - self.rtlsdr_source_0.set_if_gain(30, 0) - self.rtlsdr_source_0.set_bb_gain(30, 0) - self.rtlsdr_source_0.set_antenna('', 0) - self.rtlsdr_source_0.set_bandwidth(0, 0) - - self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( - interpolation=1, - decimation=4, - taps=(1, ), - fractional_bw=None, - ) - self.rational_resampler_xxx_0 = filter.rational_resampler_fff( - interpolation=1, - decimation=10, - taps=(1, ), - fractional_bw=None, - ) - self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_f( - 1024, #size - firdes.WIN_BLACKMAN_hARRIS, #wintype - 0, #fc - samp_rate*10, #bw - "", #name - 2 #number of inputs - ) - self.qtgui_freq_sink_x_0_0.set_update_time(0.10) - self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) - self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') - self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") - self.qtgui_freq_sink_x_0_0.enable_autoscale(False) - self.qtgui_freq_sink_x_0_0.enable_grid(True) - self.qtgui_freq_sink_x_0_0.set_fft_average(0.05) - self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) - self.qtgui_freq_sink_x_0_0.enable_control_panel(False) - - if not True: - self.qtgui_freq_sink_x_0_0.disable_legend() - - if "float" == "float" or "float" == "msg_float": - self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) - - labels = ['', '', '', '', '', - '', '', '', '', ''] - widths = [1, 1, 1, 1, 1, - 1, 1, 1, 1, 1] - colors = ["blue", "red", "green", "black", "cyan", - "magenta", "yellow", "dark red", "dark green", "dark blue"] - alphas = [1.0, 1.0, 1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 1.0, 1.0] - for i in xrange(2): - if len(labels[i]) == 0: - self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) - else: - self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) - self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) - self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) - self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) - - self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) - self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 12,0) - self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( - 1024, #size - firdes.WIN_BLACKMAN_hARRIS, #wintype - 0, #fc - samp_rate, #bw - "", #name - 2 #number of inputs - ) - self.qtgui_freq_sink_x_0.set_update_time(0.10) - self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) - self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') - self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") - self.qtgui_freq_sink_x_0.enable_autoscale(False) - self.qtgui_freq_sink_x_0.enable_grid(True) - self.qtgui_freq_sink_x_0.set_fft_average(1.0) - self.qtgui_freq_sink_x_0.enable_axis_labels(True) - self.qtgui_freq_sink_x_0.enable_control_panel(False) - - if not True: - self.qtgui_freq_sink_x_0.disable_legend() - - if "float" == "float" or "float" == "msg_float": - self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) - - labels = ['', '', '', '', '', - '', '', '', '', ''] - widths = [1, 1, 1, 1, 1, - 1, 1, 1, 1, 1] - colors = ["blue", "red", "green", "black", "cyan", - "magenta", "yellow", "dark red", "dark green", "dark blue"] - alphas = [1.0, 1.0, 1.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 1.0, 1.0] - for i in xrange(2): - if len(labels[i]) == 0: - self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) - else: - self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) - self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) - self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) - self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) - - self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) - self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 13,0) - self.low_pass_filter_0_0 = filter.fir_filter_fff(10, firdes.low_pass( - 1, samp_rate*10, samp_rate, 1e3, firdes.WIN_HAMMING, 6.76)) - self.low_pass_filter_0 = filter.fir_filter_ccf(4, firdes.low_pass( - 1, samp_rate*10*4, samp_rate*10/4, 1e3, firdes.WIN_HAMMING, 6.76)) - self.audio_sink_0 = audio.sink(int(samp_rate), '', True) - self.analog_wfm_rcv_0_0 = analog.wfm_rcv( - quad_rate=samp_rate*10, - audio_decimation=1, - ) - self.analog_wfm_rcv_0 = analog.wfm_rcv( - quad_rate=samp_rate*10, - audio_decimation=1, - ) + ################################################## + # Blocks + ################################################## + self._freq_range = Range(1e6, 2e9, 1e5, 91e6, 200) + self._freq_win = RangeWidget(self._freq_range, self.set_freq, "freq", "counter_slider", float) + self.top_grid_layout.addWidget(self._freq_win, 0,0) + self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' ) + self.rtlsdr_source_0.set_sample_rate(samp_rate*10*4) + self.rtlsdr_source_0.set_center_freq(freq, 0) + self.rtlsdr_source_0.set_freq_corr(0, 0) + self.rtlsdr_source_0.set_dc_offset_mode(0, 0) + self.rtlsdr_source_0.set_iq_balance_mode(0, 0) + self.rtlsdr_source_0.set_gain_mode(False, 0) + self.rtlsdr_source_0.set_gain(30, 0) + self.rtlsdr_source_0.set_if_gain(30, 0) + self.rtlsdr_source_0.set_bb_gain(30, 0) + self.rtlsdr_source_0.set_antenna('', 0) + self.rtlsdr_source_0.set_bandwidth(0, 0) + + self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( + interpolation=1, + decimation=4, + taps=(1, ), + fractional_bw=None, + ) + self.rational_resampler_xxx_0 = filter.rational_resampler_fff( + interpolation=1, + decimation=10, + taps=(1, ), + fractional_bw=None, + ) + self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_f( + 1024, #size + firdes.WIN_BLACKMAN_hARRIS, #wintype + 0, #fc + samp_rate*10, #bw + "", #name + 2 #number of inputs + ) + self.qtgui_freq_sink_x_0_0.set_update_time(0.10) + self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) + self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') + self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") + self.qtgui_freq_sink_x_0_0.enable_autoscale(False) + self.qtgui_freq_sink_x_0_0.enable_grid(True) + self.qtgui_freq_sink_x_0_0.set_fft_average(0.05) + self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) + self.qtgui_freq_sink_x_0_0.enable_control_panel(False) + + if not True: + self.qtgui_freq_sink_x_0_0.disable_legend() + + if "float" == "float" or "float" == "msg_float": + self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) + + labels = ['', '', '', '', '', + '', '', '', '', ''] + widths = [1, 1, 1, 1, 1, + 1, 1, 1, 1, 1] + colors = ["blue", "red", "green", "black", "cyan", + "magenta", "yellow", "dark red", "dark green", "dark blue"] + alphas = [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0] + for i in xrange(2): + if len(labels[i]) == 0: + self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) + else: + self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) + self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) + self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) + self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) + + self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) + self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 12,0) + self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( + 1024, #size + firdes.WIN_BLACKMAN_hARRIS, #wintype + 0, #fc + samp_rate, #bw + "", #name + 2 #number of inputs + ) + self.qtgui_freq_sink_x_0.set_update_time(0.10) + self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) + self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') + self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") + self.qtgui_freq_sink_x_0.enable_autoscale(False) + self.qtgui_freq_sink_x_0.enable_grid(True) + self.qtgui_freq_sink_x_0.set_fft_average(1.0) + self.qtgui_freq_sink_x_0.enable_axis_labels(True) + self.qtgui_freq_sink_x_0.enable_control_panel(False) + + if not True: + self.qtgui_freq_sink_x_0.disable_legend() + + if "float" == "float" or "float" == "msg_float": + self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) + + labels = ['', '', '', '', '', + '', '', '', '', ''] + widths = [1, 1, 1, 1, 1, + 1, 1, 1, 1, 1] + colors = ["blue", "red", "green", "black", "cyan", + "magenta", "yellow", "dark red", "dark green", "dark blue"] + alphas = [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0] + for i in xrange(2): + if len(labels[i]) == 0: + self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) + else: + self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) + self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) + self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) + self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) + + self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) + self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 13,0) + self.low_pass_filter_0_0 = filter.fir_filter_fff(10, firdes.low_pass( + 1, samp_rate*10, samp_rate, 1e3, firdes.WIN_HAMMING, 6.76)) + self.low_pass_filter_0 = filter.fir_filter_ccf(4, firdes.low_pass( + 1, samp_rate*10*4, samp_rate*10/4, 1e3, firdes.WIN_HAMMING, 6.76)) + self.audio_sink_0 = audio.sink(int(samp_rate), '', True) + self.analog_wfm_rcv_0_0 = analog.wfm_rcv( + quad_rate=samp_rate*10, + audio_decimation=1, + ) + self.analog_wfm_rcv_0 = analog.wfm_rcv( + quad_rate=samp_rate*10, + audio_decimation=1, + ) - ################################################## - # Connections - ################################################## - self.connect((self.analog_wfm_rcv_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) - self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_0, 0)) - self.connect((self.analog_wfm_rcv_0_0, 0), (self.low_pass_filter_0_0, 0)) - self.connect((self.analog_wfm_rcv_0_0, 0), (self.qtgui_freq_sink_x_0_0, 1)) - self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0_0, 0)) - self.connect((self.low_pass_filter_0_0, 0), (self.audio_sink_0, 0)) - self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_freq_sink_x_0, 1)) - self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) - self.connect((self.rational_resampler_xxx_0_0, 0), (self.analog_wfm_rcv_0, 0)) - self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0)) - self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_0_0, 0)) + ################################################## + # Connections + ################################################## + self.connect((self.analog_wfm_rcv_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) + self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_0, 0)) + self.connect((self.analog_wfm_rcv_0_0, 0), (self.low_pass_filter_0_0, 0)) + self.connect((self.analog_wfm_rcv_0_0, 0), (self.qtgui_freq_sink_x_0_0, 1)) + self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0_0, 0)) + self.connect((self.low_pass_filter_0_0, 0), (self.audio_sink_0, 0)) + self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_freq_sink_x_0, 1)) + self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) + self.connect((self.rational_resampler_xxx_0_0, 0), (self.analog_wfm_rcv_0, 0)) + self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0)) + self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_0_0, 0)) - def closeEvent(self, event): - self.settings = Qt.QSettings("GNU Radio", "fm_radio_comp_decim_lpf") - self.settings.setValue("geometry", self.saveGeometry()) - event.accept() + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "fm_radio_comp_decim_lpf") + self.settings.setValue("geometry", self.saveGeometry()) + event.accept() - def get_samp_rate(self): - return self.samp_rate + def get_samp_rate(self): + return self.samp_rate - def set_samp_rate(self, samp_rate): - self.samp_rate = samp_rate - self.rtlsdr_source_0.set_sample_rate(self.samp_rate*10*4) - self.qtgui_freq_sink_x_0_0.set_frequency_range(0, self.samp_rate*10) - self.qtgui_freq_sink_x_0.set_frequency_range(0, self.samp_rate) - self.low_pass_filter_0_0.set_taps(firdes.low_pass(1, self.samp_rate*10, self.samp_rate, 1e3, firdes.WIN_HAMMING, 6.76)) - self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.samp_rate*10*4, self.samp_rate*10/4, 1e3, firdes.WIN_HAMMING, 6.76)) + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + self.rtlsdr_source_0.set_sample_rate(self.samp_rate*10*4) + self.qtgui_freq_sink_x_0_0.set_frequency_range(0, self.samp_rate*10) + self.qtgui_freq_sink_x_0.set_frequency_range(0, self.samp_rate) + self.low_pass_filter_0_0.set_taps(firdes.low_pass(1, self.samp_rate*10, self.samp_rate, 1e3, firdes.WIN_HAMMING, 6.76)) + self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.samp_rate*10*4, self.samp_rate*10/4, 1e3, firdes.WIN_HAMMING, 6.76)) - def get_freq(self): - return self.freq + def get_freq(self): + return self.freq - def set_freq(self, freq): - self.freq = freq - self.rtlsdr_source_0.set_center_freq(self.freq, 0) + def set_freq(self, freq): + self.freq = freq + self.rtlsdr_source_0.set_center_freq(self.freq, 0) def main(top_block_cls=fm_radio_comp_decim_lpf, 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) + 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() + tb = top_block_cls() + tb.start() + tb.show() - def quitting(): - tb.stop() - tb.wait() - qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) - qapp.exec_() + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() if __name__ == '__main__': - main() + main() -- 2.16.4