From a60abb54d7b055deae20ca40231335c3749d0ca6 Mon Sep 17 00:00:00 2001 From: mer0m Date: Wed, 12 Apr 2017 11:22:22 +0200 Subject: [PATCH] prepare to deploy --- .../{gr_rp_blocks => }/gr_add_const_set_offset.xml | 0 .../gr_nco_counter_send_conf.xml | 0 .../client/{gr_rp_blocks => }/gr_source_test.xml | 0 .../{gr_rp_blocks => }/gr_source_test.xml.old | 0 redpitaya/client/{pid_dds.grc => pid_vco.grc} | 302 +++++++++++++++++---- redpitaya/client/{pid_dds.py => pid_vco.py} | 130 ++++++--- .../{gr_rp_blocks => }/redpitaya_gnuradio.py | 0 .../{gr_rp_blocks => }/redpitaya_gnuradio.pyc | Bin redpitaya/client/sourceme.bma | 1 + sdr/fm_radio/fm_radio.py | 2 +- 10 files changed, 348 insertions(+), 87 deletions(-) rename redpitaya/client/{gr_rp_blocks => }/gr_add_const_set_offset.xml (100%) rename redpitaya/client/{gr_rp_blocks => }/gr_nco_counter_send_conf.xml (100%) rename redpitaya/client/{gr_rp_blocks => }/gr_source_test.xml (100%) rename redpitaya/client/{gr_rp_blocks => }/gr_source_test.xml.old (100%) rename redpitaya/client/{pid_dds.grc => pid_vco.grc} (83%) rename redpitaya/client/{pid_dds.py => pid_vco.py} (69%) rename redpitaya/client/{gr_rp_blocks => }/redpitaya_gnuradio.py (100%) rename redpitaya/client/{gr_rp_blocks => }/redpitaya_gnuradio.pyc (100%) create mode 100644 redpitaya/client/sourceme.bma diff --git a/redpitaya/client/gr_rp_blocks/gr_add_const_set_offset.xml b/redpitaya/client/gr_add_const_set_offset.xml similarity index 100% rename from redpitaya/client/gr_rp_blocks/gr_add_const_set_offset.xml rename to redpitaya/client/gr_add_const_set_offset.xml diff --git a/redpitaya/client/gr_rp_blocks/gr_nco_counter_send_conf.xml b/redpitaya/client/gr_nco_counter_send_conf.xml similarity index 100% rename from redpitaya/client/gr_rp_blocks/gr_nco_counter_send_conf.xml rename to redpitaya/client/gr_nco_counter_send_conf.xml diff --git a/redpitaya/client/gr_rp_blocks/gr_source_test.xml b/redpitaya/client/gr_source_test.xml similarity index 100% rename from redpitaya/client/gr_rp_blocks/gr_source_test.xml rename to redpitaya/client/gr_source_test.xml diff --git a/redpitaya/client/gr_rp_blocks/gr_source_test.xml.old b/redpitaya/client/gr_source_test.xml.old similarity index 100% rename from redpitaya/client/gr_rp_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_vco.grc similarity index 83% rename from redpitaya/client/pid_dds.grc rename to redpitaya/client/pid_vco.grc index e6fee53..560392d 100644 --- a/redpitaya/client/pid_dds.grc +++ b/redpitaya/client/pid_vco.grc @@ -46,7 +46,7 @@ id - pid_dds + pid_vco max_nouts @@ -168,7 +168,7 @@ value - "192.168.0.202" + "192.168.0.203" @@ -286,7 +286,7 @@ stop - 2**14-1 + 2**13-1 rangeType @@ -313,7 +313,7 @@ _coordinate - (696, 784) + (696, 668) gui_hint @@ -349,7 +349,7 @@ stop - 2**14-1 + 60000000 rangeType @@ -376,7 +376,7 @@ _coordinate - (696, 272) + (696, 236) gui_hint @@ -439,7 +439,7 @@ _coordinate - (704, 536) + (704, 460) gui_hint @@ -487,7 +487,7 @@ - variable_qtgui_push_button + variable_qtgui_range comment @@ -502,11 +502,11 @@ _coordinate - (392, 800) + (672, 868) gui_hint - 4, 2 + 5, 3 _rotation @@ -514,24 +514,40 @@ id - pid_int_rst + dds_range label - pid_int_rst + dds_range - pressed + min_len + 200 + + + orient + Qt.Horizontal + + + start + -2**13 + + + step 1 - released - 0 + stop + 2**13-1 - type + rangeType int + + widget + counter_slider + variable_qtgui_range @@ -549,7 +565,7 @@ _coordinate - (192, 784) + (192, 668) gui_hint @@ -612,7 +628,7 @@ _coordinate - (192, 536) + (192, 460) gui_hint @@ -675,7 +691,7 @@ _coordinate - (200, 272) + (200, 236) gui_hint @@ -723,7 +739,7 @@ - variable_qtgui_check_box + variable_qtgui_push_button comment @@ -736,17 +752,13 @@ _enabled True - - false - 0 - _coordinate - (400, 544) + (392, 684) gui_hint - 3, 2 + 4, 2 _rotation @@ -754,16 +766,20 @@ id - pid_sign + pid_rst_int label - pid_sign + pid_rst_int - true + pressed 1 + + released + 0 + type int @@ -785,7 +801,7 @@ _coordinate - (400, 272) + (400, 236) gui_hint @@ -797,11 +813,11 @@ id - pid_sp + pid_setpoint label - pid_sp + pid_setpoint min_len @@ -832,6 +848,147 @@ 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_qtgui_check_box + + comment + + + + value + 0 + + + _enabled + True + + + false + 0 + + + _coordinate + (960, 12) + + + gui_hint + 1, 4 + + + _rotation + 0 + + + id + pinc + + + label + pinc + + + true + 1 + + + type + int + + + + variable_qtgui_check_box + + comment + + + + value + 0 + + + _enabled + True + + + false + 0 + + + _coordinate + (952, 164) + + + gui_hint + 2, 4 + + + _rotation + 0 + + + id + poff + + + label + poff + + + true + 1 + + + type + int + + variable @@ -1016,7 +1173,7 @@ _coordinate - (688, 672) + (688, 596) _rotation @@ -1047,7 +1204,7 @@ const - dds_f0 + int(dds_f0/(125e6/2**32)) device @@ -1059,7 +1216,7 @@ _coordinate - (680, 920) + (680, 804) _rotation @@ -1090,11 +1247,11 @@ const - pid_sp + dds_range device - /dev/pid_sp + /dev/dds_range _enabled @@ -1102,7 +1259,50 @@ _coordinate - (384, 408) + (712, 924) + + + _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 @@ -1145,7 +1345,7 @@ _coordinate - (184, 408) + (184, 372) _rotation @@ -1188,7 +1388,7 @@ _coordinate - (176, 672) + (176, 596) _rotation @@ -1231,7 +1431,7 @@ _coordinate - (176, 920) + (176, 804) _rotation @@ -1274,7 +1474,7 @@ _coordinate - (392, 672) + (392, 596) _rotation @@ -1305,11 +1505,11 @@ const - pid_int_rst + pid_rst_int device - /dev/pid_int_rst + /dev/pid_rst_int _enabled @@ -1317,7 +1517,7 @@ _coordinate - (392, 920) + (392, 804) _rotation @@ -1336,7 +1536,7 @@ nco_counter_send_conf acc_size - 28 + 32 addr @@ -1368,7 +1568,7 @@ _coordinate - (672, 384) + (672, 344) _rotation @@ -1382,6 +1582,14 @@ offset 0 + + pinc_sw + pinc + + + poff_sw + poff + port port diff --git a/redpitaya/client/pid_dds.py b/redpitaya/client/pid_vco.py similarity index 69% rename from redpitaya/client/pid_dds.py rename to redpitaya/client/pid_vco.py index 8b5cf1f..4f2ae82 100755 --- a/redpitaya/client/pid_dds.py +++ b/redpitaya/client/pid_vco.py @@ -2,8 +2,8 @@ # -*- coding: utf-8 -*- ################################################## # GNU Radio Python Flow Graph -# Title: Pid Dds -# Generated: Fri Mar 31 15:49:11 2017 +# Title: Pid Vco +# Generated: Tue Apr 11 15:32:11 2017 ################################################## if __name__ == '__main__': @@ -27,12 +27,12 @@ import redpitaya_gnuradio import sys -class pid_dds(gr.top_block, Qt.QWidget): +class pid_vco(gr.top_block, Qt.QWidget): def __init__(self): - gr.top_block.__init__(self, "Pid Dds") + gr.top_block.__init__(self, "Pid Vco") Qt.QWidget.__init__(self) - self.setWindowTitle("Pid Dds") + self.setWindowTitle("Pid Vco") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: @@ -49,33 +49,47 @@ class pid_dds(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", "pid_dds") + self.settings = Qt.QSettings("GNU Radio", "pid_vco") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.port = port = 1001 - self.pid_sp = pid_sp = 0 + self.poff = poff = 0 + self.pinc = pinc = 0 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.pid_int_rst = pid_int_rst = 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.addr = addr = "192.168.0.203" 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) + _poff_check_box = Qt.QCheckBox('poff') + self._poff_choices = {True: 1, False: 0} + self._poff_choices_inv = dict((v,k) for k,v in self._poff_choices.iteritems()) + self._poff_callback = lambda i: Qt.QMetaObject.invokeMethod(_poff_check_box, "setChecked", Qt.Q_ARG("bool", self._poff_choices_inv[i])) + self._poff_callback(self.poff) + _poff_check_box.stateChanged.connect(lambda i: self.set_poff(self._poff_choices[bool(i)])) + self.top_grid_layout.addWidget(_poff_check_box, 2, 4) + _pinc_check_box = Qt.QCheckBox('pinc') + self._pinc_choices = {True: 1, False: 0} + self._pinc_choices_inv = dict((v,k) for k,v in self._pinc_choices.iteritems()) + self._pinc_callback = lambda i: Qt.QMetaObject.invokeMethod(_pinc_check_box, "setChecked", Qt.Q_ARG("bool", self._pinc_choices_inv[i])) + self._pinc_callback(self.pinc) + _pinc_check_box.stateChanged.connect(lambda i: self.set_pinc(self._pinc_choices[bool(i)])) + self.top_grid_layout.addWidget(_pinc_check_box, 1, 4) _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()) @@ -83,6 +97,14 @@ class pid_dds(gr.top_block, Qt.QWidget): 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**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) @@ -92,21 +114,19 @@ class pid_dds(gr.top_block, Qt.QWidget): 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_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, 2**14-1, 1, 0, 200) + 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**14-1, 1, 0, 200) + 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) @@ -121,15 +141,17 @@ class pid_dds(gr.top_block, Qt.QWidget): device='/dev/dds_nco', freq_ref=125000000, freq_dds=dds_nco, - acc_size=28, + acc_size=32, offset=0, + pinc_sw=pinc, + poff_sw=poff, ) 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, + 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( @@ -163,15 +185,22 @@ class pid_dds(gr.top_block, Qt.QWidget): 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, + 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=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( @@ -204,7 +233,7 @@ class pid_dds(gr.top_block, Qt.QWidget): def closeEvent(self, event): - self.settings = Qt.QSettings("GNU Radio", "pid_dds") + self.settings = Qt.QSettings("GNU Radio", "pid_vco") self.settings.setValue("geometry", self.saveGeometry()) event.accept() @@ -214,12 +243,21 @@ class pid_dds(gr.top_block, Qt.QWidget): def set_port(self, port): self.port = port - def get_pid_sp(self): - return self.pid_sp + def get_poff(self): + return self.poff + + def set_poff(self, poff): + self.poff = poff + self._poff_callback(self.poff) + 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.pinc, poff_sw=self.poff) - 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_pinc(self): + return self.pinc + + def set_pinc(self, pinc): + self.pinc = pinc + self._pinc_callback(self.pinc) + 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.pinc, poff_sw=self.poff) def get_pid_sign(self): return self.pid_sign @@ -229,6 +267,20 @@ class pid_dds(gr.top_block, Qt.QWidget): 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 @@ -250,12 +302,12 @@ class pid_dds(gr.top_block, Qt.QWidget): 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 get_dds_range(self): + return self.dds_range - 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 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_offset(self): return self.dds_offset @@ -269,14 +321,14 @@ class pid_dds(gr.top_block, Qt.QWidget): 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) + 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.pinc, poff_sw=self.poff) 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) + 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 @@ -306,7 +358,7 @@ class pid_dds(gr.top_block, Qt.QWidget): 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): +def main(top_block_cls=pid_vco, options=None): from distutils.version import StrictVersion if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"): diff --git a/redpitaya/client/gr_rp_blocks/redpitaya_gnuradio.py b/redpitaya/client/redpitaya_gnuradio.py similarity index 100% rename from redpitaya/client/gr_rp_blocks/redpitaya_gnuradio.py rename to redpitaya/client/redpitaya_gnuradio.py diff --git a/redpitaya/client/gr_rp_blocks/redpitaya_gnuradio.pyc b/redpitaya/client/redpitaya_gnuradio.pyc similarity index 100% rename from redpitaya/client/gr_rp_blocks/redpitaya_gnuradio.pyc rename to redpitaya/client/redpitaya_gnuradio.pyc diff --git a/redpitaya/client/sourceme.bma b/redpitaya/client/sourceme.bma new file mode 100644 index 0000000..23cd7f3 --- /dev/null +++ b/redpitaya/client/sourceme.bma @@ -0,0 +1 @@ +export GRC_BLOCKS_PATH=. diff --git a/sdr/fm_radio/fm_radio.py b/sdr/fm_radio/fm_radio.py index 2898f32..7b21c77 100755 --- a/sdr/fm_radio/fm_radio.py +++ b/sdr/fm_radio/fm_radio.py @@ -3,7 +3,7 @@ ################################################## # GNU Radio Python Flow Graph # Title: Fm Radio -# Generated: Sat Apr 8 11:09:28 2017 +# Generated: Tue Apr 11 17:29:18 2017 ################################################## if __name__ == '__main__': -- 2.16.4