From a5351be4a28c03be677a9da8ebac17d8f7f855b9 Mon Sep 17 00:00:00 2001 From: mer0m Date: Tue, 25 Apr 2017 08:32:43 +0200 Subject: [PATCH] add double_pid_vco and iq_pid_vco --- redpitaya/client/dds_gnuradio.grc | 2 +- redpitaya/client/dds_gnuradio.py | 4 +- redpitaya/client/double_pid_vco.py | 2 +- redpitaya/client/iq_pid_vco.grc | 1724 ++++++++++++++++++++++++++++++++++++ redpitaya/client/iq_pid_vco.py | 404 +++++++++ 5 files changed, 2132 insertions(+), 4 deletions(-) create mode 100644 redpitaya/client/iq_pid_vco.grc create mode 100755 redpitaya/client/iq_pid_vco.py diff --git a/redpitaya/client/dds_gnuradio.grc b/redpitaya/client/dds_gnuradio.grc index 44ecb46..f5b2899 100644 --- a/redpitaya/client/dds_gnuradio.grc +++ b/redpitaya/client/dds_gnuradio.grc @@ -168,7 +168,7 @@ value - "192.168.0.203" + "192.168.0.201" diff --git a/redpitaya/client/dds_gnuradio.py b/redpitaya/client/dds_gnuradio.py index 744ce4b..5d71152 100755 --- a/redpitaya/client/dds_gnuradio.py +++ b/redpitaya/client/dds_gnuradio.py @@ -3,7 +3,7 @@ ################################################## # GNU Radio Python Flow Graph # Title: Dds Gnuradio -# Generated: Fri Apr 21 12:30:52 2017 +# Generated: Fri Apr 21 17:59:20 2017 ################################################## if __name__ == '__main__': @@ -58,7 +58,7 @@ class dds_gnuradio(gr.top_block, Qt.QWidget): self.port = port = 1001 self.offset_out1 = offset_out1 = 0 self.f_dds = f_dds = 0 - self.addr = addr = "192.168.0.203" + self.addr = addr = "192.168.0.201" self.a_dds = a_dds = 0 ################################################## diff --git a/redpitaya/client/double_pid_vco.py b/redpitaya/client/double_pid_vco.py index dee0b21..3753960 100755 --- a/redpitaya/client/double_pid_vco.py +++ b/redpitaya/client/double_pid_vco.py @@ -3,7 +3,7 @@ ################################################## # GNU Radio Python Flow Graph # Title: Double Pid Vco -# Generated: Fri Apr 21 14:54:08 2017 +# Generated: Fri Apr 21 15:21:06 2017 ################################################## if __name__ == '__main__': diff --git a/redpitaya/client/iq_pid_vco.grc b/redpitaya/client/iq_pid_vco.grc new file mode 100644 index 0000000..37e5420 --- /dev/null +++ b/redpitaya/client/iq_pid_vco.grc @@ -0,0 +1,1724 @@ + + + + Thu Feb 2 22:54:58 2017 + + options + + author + + + + window_size + 2000, 2000 + + + category + [GRC Hier Blocks] + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + qt_gui + + + hier_block_src_path + .: + + + id + iq_pid_vco + + + max_nouts + 0 + + + qt_qss_theme + + + + realtime_scheduling + + + + run_command + {python} -u {filename} + + + run_options + prompt + + + run + True + + + thread_safe_setters + + + + title + + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (216, 8) + + + gui_hint + 1, 1 + + + _rotation + 0 + + + id + adc1_offset + + + label + adc1_offset + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + -2**13 + + + step + 1 + + + stop + 2**13-1 + + + rangeType + int + + + widget + counter_slider + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 104) + + + _rotation + 0 + + + id + addr + + + value + "192.168.0.201" + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (400, 8) + + + gui_hint + 1, 2 + + + _rotation + 0 + + + id + dac2_offset + + + label + dac2_offset + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + -2**13 + + + step + 1 + + + stop + 2**13-1 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (704, 8) + + + gui_hint + 1, 3 + + + _rotation + 0 + + + id + dds_ampl + + + label + dds_ampl + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 1 + + + stop + 2**13-1 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (696, 668) + + + gui_hint + 4, 3 + + + _rotation + 0 + + + id + dds_f0 + + + label + dds_f0 + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 1 + + + stop + 60000000 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (696, 236) + + + gui_hint + 2, 3 + + + _rotation + 0 + + + id + dds_nco + + + label + dds_nco + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 1 + + + stop + 60000000 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (704, 460) + + + gui_hint + 3, 3 + + + _rotation + 0 + + + id + dds_offset + + + label + dds_offset + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + -2**13 + + + step + 1 + + + stop + 2**13-1 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_check_box + + comment + + + + value + 1 + + + _enabled + True + + + false + 0 + + + _coordinate + (960, 12) + + + gui_hint + 1, 4 + + + _rotation + 0 + + + id + dds_pinc_sw + + + label + dds_pinc_sw + + + true + 1 + + + type + int + + + + variable_qtgui_check_box + + comment + + + + value + 1 + + + _enabled + True + + + false + 0 + + + _coordinate + (952, 204) + + + gui_hint + 2, 4 + + + _rotation + 0 + + + id + dds_poff_sw + + + label + dds_poff_sw + + + true + 1 + + + type + int + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (672, 908) + + + gui_hint + 5, 3 + + + _rotation + 0 + + + id + dds_range + + + label + dds_range + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + -2**13 + + + step + 1 + + + stop + 2**13-1 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (952, 476) + + + gui_hint + 3, 4 + + + _rotation + 0 + + + id + demod_nco + + + label + demod_nco + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 1 + + + stop + 60000000 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (192, 668) + + + gui_hint + 4, 1 + + + _rotation + 0 + + + id + pid_kd + + + label + pid_kd + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 1 + + + stop + 2**13-1 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (192, 460) + + + gui_hint + 3, 1 + + + _rotation + 0 + + + id + pid_ki + + + label + pid_ki + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 1 + + + stop + 2**13-1 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (200, 236) + + + gui_hint + 2, 1 + + + _rotation + 0 + + + id + pid_kp + + + label + pid_kp + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 1 + + + stop + 2**13-1 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_push_button + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (392, 684) + + + gui_hint + 4, 2 + + + _rotation + 0 + + + id + pid_rst_int + + + label + pid_rst_int + + + pressed + 1 + + + released + 0 + + + type + int + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (400, 236) + + + gui_hint + 2, 2 + + + _rotation + 0 + + + id + pid_setpoint + + + label + pid_setpoint + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + -2**13 + + + step + 1 + + + stop + 2**13-1 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_check_box + + comment + + + + value + 0 + + + _enabled + True + + + false + 0 + + + _coordinate + (400, 468) + + + gui_hint + 3, 2 + + + _rotation + 0 + + + id + pid_sign + + + label + pid_sign + + + true + 1 + + + type + int + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 176) + + + _rotation + 0 + + + id + port + + + value + 1001 + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + adc1_offset + + + device + /dev/adc1_offset + + + _enabled + True + + + _coordinate + (200, 144) + + + _rotation + 0 + + + id + add_const_set_offset_0_0_0 + + + port + port + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + dac2_offset + + + device + /dev/dac2_offset + + + _enabled + True + + + _coordinate + (384, 144) + + + _rotation + 0 + + + id + add_const_set_offset_0_0_0_0 + + + port + port + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + dds_ampl + + + device + /dev/dds_ampl + + + _enabled + True + + + _coordinate + (688, 144) + + + _rotation + 0 + + + id + add_const_set_offset_0_0_0_0_0 + + + port + port + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + dds_offset + + + device + /dev/dds_offset + + + _enabled + True + + + _coordinate + (688, 596) + + + _rotation + 0 + + + id + add_const_set_offset_0_0_0_0_1 + + + port + port + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + int(dds_f0/(125e6/2**32)) + + + device + /dev/dds_f0 + + + _enabled + True + + + _coordinate + (680, 804) + + + _rotation + 0 + + + id + add_const_set_offset_0_0_0_0_1_0 + + + port + port + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + dds_range + + + device + /dev/dds_range + + + _enabled + True + + + _coordinate + (664, 1036) + + + _rotation + 0 + + + id + add_const_set_offset_0_0_0_0_1_0_0 + + + port + port + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + pid_setpoint + + + device + /dev/pid_setpoint + + + _enabled + True + + + _coordinate + (384, 372) + + + _rotation + 0 + + + id + add_const_set_offset_0_0_0_1 + + + port + port + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + pid_kp + + + device + /dev/pid_kp + + + _enabled + True + + + _coordinate + (184, 372) + + + _rotation + 0 + + + id + add_const_set_offset_0_0_0_1_0 + + + port + port + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + pid_ki + + + device + /dev/pid_ki + + + _enabled + True + + + _coordinate + (176, 596) + + + _rotation + 0 + + + id + add_const_set_offset_0_0_0_1_0_0 + + + port + port + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + pid_kd + + + device + /dev/pid_kd + + + _enabled + True + + + _coordinate + (176, 804) + + + _rotation + 0 + + + id + add_const_set_offset_0_0_0_1_0_0_0 + + + port + port + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + pid_sign + + + device + /dev/pid_sign + + + _enabled + True + + + _coordinate + (392, 596) + + + _rotation + 0 + + + id + add_const_set_offset_0_0_0_1_0_0_0_0 + + + port + port + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + pid_rst_int + + + device + /dev/pid_rst_int + + + _enabled + True + + + _coordinate + (392, 804) + + + _rotation + 0 + + + id + add_const_set_offset_0_0_0_1_0_0_0_0_0 + + + port + port + + + + nco_counter_send_conf + + acc_size + 32 + + + addr + addr + + + alias + + + + comment + + + + device + /dev/dds_nco + + + _enabled + True + + + freq_dds + dds_nco + + + freq_ref + 125000000 + + + _coordinate + (672, 344) + + + _rotation + 0 + + + id + nco_counter_send_conf_0 + + + offset + 0 + + + pinc_sw + dds_pinc_sw + + + poff_sw + dds_poff_sw + + + port + port + + + + nco_counter_send_conf + + acc_size + 32 + + + addr + addr + + + alias + + + + comment + + + + device + /dev/demod_nco + + + _enabled + True + + + freq_dds + demod_nco + + + freq_ref + 125000000 + + + _coordinate + (928, 576) + + + _rotation + 0 + + + id + nco_counter_send_conf_0_0 + + + offset + 0 + + + pinc_sw + 1 + + + poff_sw + 1 + + + port + port + + + diff --git a/redpitaya/client/iq_pid_vco.py b/redpitaya/client/iq_pid_vco.py new file mode 100755 index 0000000..73c1071 --- /dev/null +++ b/redpitaya/client/iq_pid_vco.py @@ -0,0 +1,404 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +################################################## +# GNU Radio Python Flow Graph +# Title: Iq Pid Vco +# Generated: Fri Apr 21 18:49:00 2017 +################################################## + +if __name__ == '__main__': + import ctypes + import sys + if sys.platform.startswith('linux'): + try: + x11 = ctypes.cdll.LoadLibrary('libX11.so') + x11.XInitThreads() + except: + print "Warning: failed to XInitThreads()" + +from PyQt4 import Qt +from gnuradio import eng_notation +from gnuradio import gr +from gnuradio.eng_option import eng_option +from gnuradio.filter import firdes +from gnuradio.qtgui import Range, RangeWidget +from optparse import OptionParser +import redpitaya_gnuradio +import sys + + +class 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 = 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.dac2_offset = dac2_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._demod_nco_range = Range(0, 60000000, 1, 0, 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, 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._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 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 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.dds_pinc_sw, poff_sw=self.dds_poff_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_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 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=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) + + tb = top_block_cls() + tb.start() + tb.show() + + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() + + +if __name__ == '__main__': + main() -- 2.16.4