diff --git a/redpitaya/gnuradio_blocks/dds_control.grc b/redpitaya/client/dds_gnuradio.grc similarity index 89% rename from redpitaya/gnuradio_blocks/dds_control.grc rename to redpitaya/client/dds_gnuradio.grc index 7ccb78f..0ac2f1a 100644 --- a/redpitaya/gnuradio_blocks/dds_control.grc +++ b/redpitaya/client/dds_gnuradio.grc @@ -46,7 +46,7 @@ id - dds_control + dds_gnuradio max_nouts @@ -97,7 +97,7 @@ _coordinate - (704, 24) + (600, 12) gui_hint @@ -129,11 +129,11 @@ step - 128 + 1 stop - 8191 + 2**13-1 rangeType @@ -156,7 +156,7 @@ _coordinate - (0, 248) + (8, 104) _rotation @@ -168,7 +168,7 @@ value - "192.168.0.201" + "192.168.0.202" @@ -187,7 +187,7 @@ _coordinate - (488, 24) + (384, 12) gui_hint @@ -215,11 +215,11 @@ start - 0 + -60000000 step - 100000 + 1 stop @@ -227,7 +227,7 @@ rangeType - int + float widget @@ -250,7 +250,7 @@ _coordinate - (328, 24) + (224, 12) gui_hint @@ -278,15 +278,15 @@ start - -8192 + -2**13 step - 100 + 1 stop - 8191 + 2**13-1 rangeType @@ -309,7 +309,7 @@ _coordinate - (0, 320) + (8, 176) _rotation @@ -324,33 +324,6 @@ 1001 - - variable - - comment - - - - _enabled - 0 - - - _coordinate - (8, 160) - - - _rotation - 0 - - - id - samp_rate - - - value - 32000 - - add_const_set_offset @@ -379,7 +352,7 @@ _coordinate - (304, 176) + (200, 164) _rotation @@ -422,7 +395,7 @@ _coordinate - (704, 176) + (600, 164) _rotation @@ -473,7 +446,7 @@ _coordinate - (488, 176) + (384, 160) _rotation diff --git a/redpitaya/gnuradio_blocks/dds_control.py b/redpitaya/client/dds_gnuradio.py similarity index 87% rename from redpitaya/gnuradio_blocks/dds_control.py rename to redpitaya/client/dds_gnuradio.py index a48bd5a..eefce8d 100755 --- a/redpitaya/gnuradio_blocks/dds_control.py +++ b/redpitaya/client/dds_gnuradio.py @@ -2,8 +2,8 @@ # -*- coding: utf-8 -*- ################################################## # GNU Radio Python Flow Graph -# Title: Dds Control -# Generated: Tue Mar 21 12:05:52 2017 +# Title: Dds Gnuradio +# Generated: Wed Apr 5 11:34:01 2017 ################################################## if __name__ == '__main__': @@ -27,12 +27,12 @@ import redpitaya_gnuradio import sys -class dds_control(gr.top_block, Qt.QWidget): +class dds_gnuradio(gr.top_block, Qt.QWidget): def __init__(self): - gr.top_block.__init__(self, "Dds Control") + gr.top_block.__init__(self, "Dds Gnuradio") Qt.QWidget.__init__(self) - self.setWindowTitle("Dds Control") + self.setWindowTitle("Dds Gnuradio") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: @@ -49,7 +49,7 @@ class dds_control(gr.top_block, Qt.QWidget): self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) - self.settings = Qt.QSettings("GNU Radio", "dds_control") + self.settings = Qt.QSettings("GNU Radio", "dds_gnuradio") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## @@ -58,19 +58,19 @@ class dds_control(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.201" + self.addr = addr = "192.168.0.202" self.a_dds = a_dds = 0 ################################################## # Blocks ################################################## - self._offset_out1_range = Range(-8192, 8191, 100, 0, 200) + 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, 100000, 0, 200) - self._f_dds_win = RangeWidget(self._f_dds_range, self.set_f_dds, 'DDS frequency', "counter_slider", int) + self._f_dds_range = Range(-60000000, 60000000, 1, 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, 8191, 128, 0, 200) + 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( @@ -99,7 +99,7 @@ class dds_control(gr.top_block, Qt.QWidget): def closeEvent(self, event): - self.settings = Qt.QSettings("GNU Radio", "dds_control") + self.settings = Qt.QSettings("GNU Radio", "dds_gnuradio") self.settings.setValue("geometry", self.saveGeometry()) event.accept() @@ -137,7 +137,7 @@ class dds_control(gr.top_block, Qt.QWidget): self.add_const_set_offset_0_0.set_const(device='/dev/dds_ampl', const=self.a_dds) -def main(top_block_cls=dds_control, options=None): +def main(top_block_cls=dds_gnuradio, options=None): from distutils.version import StrictVersion if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"): diff --git a/redpitaya/gnuradio_blocks/gr_add_const_set_offset.xml b/redpitaya/client/gr_add_const_set_offset.xml similarity index 100% rename from redpitaya/gnuradio_blocks/gr_add_const_set_offset.xml rename to redpitaya/client/gr_add_const_set_offset.xml diff --git a/redpitaya/gnuradio_blocks/gr_nco_counter_send_conf.xml b/redpitaya/client/gr_nco_counter_send_conf.xml similarity index 84% rename from redpitaya/gnuradio_blocks/gr_nco_counter_send_conf.xml rename to redpitaya/client/gr_nco_counter_send_conf.xml index f7d6d0c..5457f74 100644 --- a/redpitaya/gnuradio_blocks/gr_nco_counter_send_conf.xml +++ b/redpitaya/client/gr_nco_counter_send_conf.xml @@ -30,9 +30,11 @@ freq_dds=$freq_dds, acc_size=$acc_size, offset=$offset, + pinc_sw=$pinc_sw, + poff_sw=$poff_sw, ) - set_nco(device=$device, freq_ref=$freq_ref, freq_dds=$freq_dds, acc_size=$acc_size, offset=$offset) + set_nco(device=$device, freq_ref=$freq_ref, freq_dds=$freq_dds, acc_size=$acc_size, offset=$offset, pinc_sw=$pinc_sw, poff_sw=$poff_sw) Address addr @@ -66,7 +68,7 @@ Accumulator size acc_size - 28 + 32 int @@ -75,4 +77,16 @@ 0 int + + Pinc SW + pinc_sw + 1 + int + + + Poff SW + poff_sw + 1 + int + diff --git a/redpitaya/gnuradio_blocks/gr_source_test.xml b/redpitaya/client/gr_source_test.xml similarity index 100% rename from redpitaya/gnuradio_blocks/gr_source_test.xml rename to redpitaya/client/gr_source_test.xml diff --git a/redpitaya/gnuradio_blocks/gr_source_test.xml.old b/redpitaya/client/gr_source_test.xml.old similarity index 100% rename from redpitaya/gnuradio_blocks/gr_source_test.xml.old rename to redpitaya/client/gr_source_test.xml.old diff --git a/redpitaya/client/pid_dds.grc b/redpitaya/client/pid_dds.grc new file mode 100644 index 0000000..e6fee53 --- /dev/null +++ b/redpitaya/client/pid_dds.grc @@ -0,0 +1,1390 @@ + + + + Thu Feb 2 22:54:58 2017 + + options + + author + + + + window_size + + + + category + [GRC Hier Blocks] + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + qt_gui + + + hier_block_src_path + .: + + + id + pid_dds + + + 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.202" + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (400, 8) + + + gui_hint + 1, 2 + + + _rotation + 0 + + + id + dac1_offset + + + label + dac1_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**14-1 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (696, 784) + + + gui_hint + 4, 3 + + + _rotation + 0 + + + id + dds_f0 + + + label + dds_f0 + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 1 + + + stop + 2**14-1 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (696, 272) + + + 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, 536) + + + 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_push_button + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (392, 800) + + + gui_hint + 4, 2 + + + _rotation + 0 + + + id + pid_int_rst + + + label + pid_int_rst + + + pressed + 1 + + + released + 0 + + + type + int + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (192, 784) + + + gui_hint + 4, 1 + + + _rotation + 0 + + + id + pid_kd + + + label + pid_kd + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 1 + + + stop + 2**14-1 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (192, 536) + + + gui_hint + 3, 1 + + + _rotation + 0 + + + id + pid_ki + + + label + pid_ki + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 1 + + + stop + 2**14-1 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (200, 272) + + + gui_hint + 2, 1 + + + _rotation + 0 + + + id + pid_kp + + + label + pid_kp + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 1 + + + stop + 2**14-1 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_check_box + + comment + + + + value + 0 + + + _enabled + True + + + false + 0 + + + _coordinate + (400, 544) + + + gui_hint + 3, 2 + + + _rotation + 0 + + + id + pid_sign + + + label + pid_sign + + + true + 1 + + + type + int + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (400, 272) + + + gui_hint + 2, 2 + + + _rotation + 0 + + + id + pid_sp + + + label + pid_sp + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + -2**13 + + + step + 1 + + + stop + 2**13-1 + + + rangeType + int + + + widget + counter_slider + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 176) + + + _rotation + 0 + + + id + port + + + value + 1001 + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + 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 + dac1_offset + + + device + /dev/dac1_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, 672) + + + _rotation + 0 + + + id + add_const_set_offset_0_0_0_0_1 + + + port + port + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + dds_f0 + + + device + /dev/dds_f0 + + + _enabled + True + + + _coordinate + (680, 920) + + + _rotation + 0 + + + id + add_const_set_offset_0_0_0_0_1_0 + + + port + port + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + pid_sp + + + device + /dev/pid_sp + + + _enabled + True + + + _coordinate + (384, 408) + + + _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, 408) + + + _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, 672) + + + _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, 920) + + + _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, 672) + + + _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_int_rst + + + device + /dev/pid_int_rst + + + _enabled + True + + + _coordinate + (392, 920) + + + _rotation + 0 + + + id + add_const_set_offset_0_0_0_1_0_0_0_0_0 + + + port + port + + + + nco_counter_send_conf + + acc_size + 28 + + + addr + addr + + + alias + + + + comment + + + + device + /dev/dds_nco + + + _enabled + True + + + freq_dds + dds_nco + + + freq_ref + 125000000 + + + _coordinate + (672, 384) + + + _rotation + 0 + + + id + nco_counter_send_conf_0 + + + offset + 0 + + + port + port + + + diff --git a/redpitaya/client/pid_dds.py b/redpitaya/client/pid_dds.py new file mode 100755 index 0000000..8b5cf1f --- /dev/null +++ b/redpitaya/client/pid_dds.py @@ -0,0 +1,329 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +################################################## +# GNU Radio Python Flow Graph +# Title: Pid Dds +# Generated: Fri Mar 31 15:49:11 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 pid_dds(gr.top_block, Qt.QWidget): + + def __init__(self): + gr.top_block.__init__(self, "Pid Dds") + Qt.QWidget.__init__(self) + self.setWindowTitle("Pid 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", "pid_dds") + 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.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.202" + 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**14-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**14-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**14-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._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, 2**14-1, 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**14-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=28, + offset=0, + ) + + 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_1_0 = redpitaya_gnuradio.add_const_set_offset( + addr=addr, + port=port, + device='/dev/dds_f0', + const=dds_f0, + ) + + 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_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_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_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=28, offset=0) + + 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=self.dds_f0) + + 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=pid_dds, options=None): + + from distutils.version import StrictVersion + if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"): + style = gr.prefs().get_string('qtgui', 'style', 'raster') + Qt.QApplication.setGraphicsSystem(style) + qapp = Qt.QApplication(sys.argv) + + tb = top_block_cls() + tb.start() + tb.show() + + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() + + +if __name__ == '__main__': + main() diff --git a/redpitaya/client/pid_only.grc b/redpitaya/client/pid_only.grc new file mode 100644 index 0000000..a5ccc43 --- /dev/null +++ b/redpitaya/client/pid_only.grc @@ -0,0 +1,954 @@ + + + + Thu Feb 2 22:54:58 2017 + + options + + author + + + + window_size + + + + category + [GRC Hier Blocks] + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + qt_gui + + + hier_block_src_path + .: + + + id + pid_only + + + 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.202" + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (400, 8) + + + gui_hint + 1, 2 + + + _rotation + 0 + + + id + dac1_offset + + + label + dac1_offset + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + -2**13 + + + step + 1 + + + stop + 2**13-1 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_push_button + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (920, 288) + + + gui_hint + 4, 2 + + + _rotation + 0 + + + id + pid_int_rst + + + label + pid_int_rst + + + pressed + 1 + + + released + 0 + + + type + int + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (400, 272) + + + 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 + (232, 272) + + + 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 + (56, 272) + + + 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_check_box + + comment + + + + value + 0 + + + _enabled + True + + + false + 0 + + + _coordinate + (752, 288) + + + gui_hint + 3, 2 + + + _rotation + 0 + + + id + pid_sign + + + label + pid_sign + + + true + 1 + + + type + int + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (592, 272) + + + gui_hint + 2, 2 + + + _rotation + 0 + + + id + pid_sp + + + label + pid_sp + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + -2**13 + + + step + 1 + + + stop + 2**13-1 + + + rangeType + int + + + widget + counter_slider + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 176) + + + _rotation + 0 + + + id + port + + + value + 1001 + + + + add_const_set_offset + + addr + addr + + + alias + + + + comment + + + + const + 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 + dac1_offset + + + device + /dev/dac1_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 + pid_sp + + + device + /dev/pid_sp + + + _enabled + True + + + _coordinate + (576, 408) + + + _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 + (40, 408) + + + _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 + (216, 408) + + + _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 + (384, 408) + + + _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 + (744, 408) + + + _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_int_rst + + + device + /dev/pid_int_rst + + + _enabled + True + + + _coordinate + (920, 408) + + + _rotation + 0 + + + id + add_const_set_offset_0_0_0_1_0_0_0_0_0 + + + port + port + + + diff --git a/redpitaya/client/pid_only.py b/redpitaya/client/pid_only.py new file mode 100755 index 0000000..dbb757d --- /dev/null +++ b/redpitaya/client/pid_only.py @@ -0,0 +1,254 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +################################################## +# GNU Radio Python Flow Graph +# Title: Pid Only +# Generated: Fri Mar 31 15:40:54 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 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.202" + 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) + + 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() diff --git a/redpitaya/gnuradio_blocks/redpitaya_gnuradio.py b/redpitaya/client/redpitaya_gnuradio.py similarity index 92% rename from redpitaya/gnuradio_blocks/redpitaya_gnuradio.py rename to redpitaya/client/redpitaya_gnuradio.py index 650fdcf..24a59ba 100644 --- a/redpitaya/gnuradio_blocks/redpitaya_gnuradio.py +++ b/redpitaya/client/redpitaya_gnuradio.py @@ -38,7 +38,7 @@ class add_const_set_offset(gr.hier_block2): class nco_counter_send_conf(gr.hier_block2): - def __init__(self, addr, port, device, freq_ref, freq_dds, acc_size, offset): + 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, @@ -48,10 +48,10 @@ class nco_counter_send_conf(gr.hier_block2): ) 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) + 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): - self.ctrl_sock.send('%s;%s;%i;%i;%i;%i\n'%(self.name, device, freq_ref, freq_dds, acc_size, offset)) + 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): diff --git a/redpitaya/client/redpitaya_gnuradio.pyc b/redpitaya/client/redpitaya_gnuradio.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9b5b02f9a738907a191fe90e9fcaf67e8fc0ec00 GIT binary patch literal 2372 zcmd5;%Z}Vc6uq|lHA4~@AVY?bWD_K3la@fNK!^|p2_YJ(CJWLV%VU>k+_>$=RSgR2 zUGoF{0bj=t@Bwhn_4Fg4ELgOJr|<1skFL6pbFL@)^X75y>W}X;xqc#ie*tkh6eJI% z5}9u8K&FAthf;+yk7OFjyeHG11bHMjl38C0?C8m_B5RQs(}Cpuy@kPcVaUVJ;~_38 z|H3ngLztfGvh@ReT~tl>gY)mgO!GX+n%eoqS)VjTfv>I80XBRIaqmM}xT`M0foaG) zXhdSp_57@lJ(M>fPa*C%DC}B^B)C41StzrJ!#t#(!H9Ie$FRE3I$~7ZyqUo~Cf7j} z_&$?BJy1QAwH}m=^th4Cj%0=VLMcN0KmuNJEGyiJGeRU%kQT;2F`AJc%sQQ0|0ayG zUM!J>^0H3-vb80q#J>gAEd47hF#|NLr-6v)@T#vMzm+_!}6M&F)xD zzeDz|_bkwpuad7P&z|cc=ifd3COLm@o;~^2A7L%?ZIy7Z?nIGln|WPfskCS@6Yd#@ zvsIx63fii%Xj-q=<@TpCv&b8cWTj&mqRLHRjjx)y9be4T@nz{LReHf;YqP7g8ei7S zHqFas+}eCm`t)Tw&Z^SZem9Y9_B>v^G>qyF#JvqA!4dujklVp&csDo=GA52fcN8WM zVRUeq0bYt1AmzG{k({!US~=Ei;+UBa-KYGN$FY`yNxn`(ooi*fd6w1C4f77vVZ*+K z8yJbBmlDLR$u$%RF+kxMGf6UU@@0jg=E?9^JHHNA6Z-TX#L+8Ml#-PMMS5dhR~WLBm=h`jQjt-#_Q#~P#cq)2P6uh0p=JDH zmA+k1)?*iCjfI~(8}qPt=s6UbAHm<(k(rsGFis`&$1q+;=B^QMi&2dJ#clSD4Yxt> z{m&lN4c}WG&9xFcnxAoj?<#Yb>I15KRQI6{n<={f31pxDhAcCuRP2g|dv;!^b%>%7 z&^&z0_ISkG30VCnpy@!iY1;Z0Go*V5aW)IHIb+Y?1GuVS|Ez0?pR=ltp5DQ$;_T$? F!QcOg=Vkx^ literal 0 HcmV?d00001 diff --git a/redpitaya/gnuradio_blocks/sourceme.bma b/redpitaya/client/sourceme.bma similarity index 100% rename from redpitaya/gnuradio_blocks/sourceme.bma rename to redpitaya/client/sourceme.bma diff --git a/redpitaya/client/vco_only.grc b/redpitaya/client/vco_only.grc new file mode 100644 index 0000000..a5e3939 --- /dev/null +++ b/redpitaya/client/vco_only.grc @@ -0,0 +1,994 @@ + + + + Thu Feb 2 22:54:58 2017 + + options + + author + + + + window_size + + + + category + [GRC Hier Blocks] + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + qt_gui + + + hier_block_src_path + .: + + + id + vco_only + + + 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.202" + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (400, 8) + + + gui_hint + 1, 2 + + + _rotation + 0 + + + id + dac1_offset + + + label + dac1_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 + (704, 764) + + + gui_hint + 4, 3 + + + _rotation + 0 + + + id + dds_f0 + + + label + dds_f0 + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 1000 + + + stop + 60000000 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (704, 252) + + + 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 + (712, 516) + + + 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_range + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (896, 788) + + + gui_hint + 5, 3 + + + _rotation + 0 + + + id + dds_range + + + label + dds_range + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 1 + + + stop + 2**13-1 + + + rangeType + int + + + widget + counter_slider + + + + variable_qtgui_check_box + + comment + + + + value + 0 + + + _enabled + True + + + false + 0 + + + _coordinate + (48, 324) + + + gui_hint + 2, 1 + + + _rotation + 0 + + + id + inc_sw + + + label + inc_sw + + + true + 1 + + + type + int + + + + variable_qtgui_check_box + + comment + + + + value + 0 + + + _enabled + True + + + false + 0 + + + _coordinate + (376, 324) + + + gui_hint + 2, 2 + + + _rotation + 0 + + + id + off_sw + + + label + off_sw + + + 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 + dac1_offset + + + device + /dev/dac1_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_range + + + device + /dev/dds_range + + + _enabled + True + + + _coordinate + (880, 924) + + + _rotation + 0 + + + id + add_const_set_offset_0_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 + (696, 652) + + + _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 + (688, 900) + + + _rotation + 0 + + + id + add_const_set_offset_0_0_0_0_1_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 + (680, 360) + + + _rotation + 0 + + + id + nco_counter_send_conf_0 + + + offset + 0 + + + pinc_sw + inc_sw + + + poff_sw + off_sw + + + port + port + + + diff --git a/redpitaya/client/vco_only.py b/redpitaya/client/vco_only.py new file mode 100755 index 0000000..a223059 --- /dev/null +++ b/redpitaya/client/vco_only.py @@ -0,0 +1,266 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +################################################## +# GNU Radio Python Flow Graph +# Title: Vco Only +# Generated: Thu Apr 6 18:24:10 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 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.202" + 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(0, 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) + + 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() diff --git a/redpitaya/gnuradio_blocks/redpitaya_gnuradio.pyc b/redpitaya/gnuradio_blocks/redpitaya_gnuradio.pyc deleted file mode 100644 index 8f6c7b73ecbec66e263c8bae094f8484f7b5802e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1921 zcmd5-%Wl&^6uq{SG%fE}p@75&B(s185-Sj*AdnEENRuugn^EwiI3#xQOprj?l^v1VYqseC6CT0bWw;F6)h%KJ{g7)gh{W_X zf6~Sr+A-K;nEL{USyK^<Z>>L$Mp4bvD*O)UXWo;b z^{4jP#*hEQ3444hGT&@+&%t^l~~avR(rLSsRG>e zlO4ltm~(JP+WkpP=cJ#(yKIXo^1Ii*KjXH>n%E<7L z{307e9X7DDM#J-9NQzN;@hq4VaC-K6-T`c^Gxa!7nC1)}4~9~k*V%hpXZgI5rcN7! zB!L1yWvYheii`2pku-1<^A6JhOQ3OEs)1Vw4%0w$4FR>h^P3o0!@d}xhvv7S3d5Va zQG~)aSHv0zcsrXbbXVbyR2rpy7q%!6!}Dua>8O6gIrC&1{o%qO@0>G}L&Fw%)qg!z r!^Qp`W6&>#dT34p)nxW_EG&EYic0PMM!^pVkn6%-!UeT