Commit 2fb9efd6c6f8cb6cf77a4dd16f419466c0b54cc3
1 parent
510e052b89
Exists in
master
-
Showing 2 changed files with 6 additions and 6 deletions Inline Diff
redpitaya/client/double_dds.py
#!/usr/bin/env python2 | 1 | 1 | #!/usr/bin/env python2 | |
# -*- coding: utf-8 -*- | 2 | 2 | # -*- coding: utf-8 -*- | |
################################################## | 3 | 3 | ################################################## | |
# GNU Radio Python Flow Graph | 4 | 4 | # GNU Radio Python Flow Graph | |
# Title: Double Dds | 5 | 5 | # Title: Double Dds | |
# Generated: Thu May 11 08:24:36 2017 | 6 | 6 | # Generated: Fri May 12 18:35:16 2017 | |
################################################## | 7 | 7 | ################################################## | |
8 | 8 | |||
if __name__ == '__main__': | 9 | 9 | if __name__ == '__main__': | |
import ctypes | 10 | 10 | import ctypes | |
import sys | 11 | 11 | import sys | |
if sys.platform.startswith('linux'): | 12 | 12 | if sys.platform.startswith('linux'): | |
try: | 13 | 13 | try: | |
x11 = ctypes.cdll.LoadLibrary('libX11.so') | 14 | 14 | x11 = ctypes.cdll.LoadLibrary('libX11.so') | |
x11.XInitThreads() | 15 | 15 | x11.XInitThreads() | |
except: | 16 | 16 | except: | |
print "Warning: failed to XInitThreads()" | 17 | 17 | print "Warning: failed to XInitThreads()" | |
18 | 18 | |||
from PyQt4 import Qt | 19 | 19 | from PyQt4 import Qt | |
from gnuradio import eng_notation | 20 | 20 | from gnuradio import eng_notation | |
from gnuradio import gr | 21 | 21 | from gnuradio import gr | |
from gnuradio.eng_option import eng_option | 22 | 22 | from gnuradio.eng_option import eng_option | |
from gnuradio.filter import firdes | 23 | 23 | from gnuradio.filter import firdes | |
from gnuradio.qtgui import Range, RangeWidget | 24 | 24 | from gnuradio.qtgui import Range, RangeWidget | |
from optparse import OptionParser | 25 | 25 | from optparse import OptionParser | |
import redpitaya_gnuradio | 26 | 26 | import redpitaya_gnuradio | |
import sys | 27 | 27 | import sys | |
28 | 28 | |||
29 | 29 | |||
class double_dds(gr.top_block, Qt.QWidget): | 30 | 30 | class double_dds(gr.top_block, Qt.QWidget): | |
31 | 31 | |||
def __init__(self): | 32 | 32 | def __init__(self): | |
gr.top_block.__init__(self, "Double Dds") | 33 | 33 | gr.top_block.__init__(self, "Double Dds") | |
Qt.QWidget.__init__(self) | 34 | 34 | Qt.QWidget.__init__(self) | |
self.setWindowTitle("Double Dds") | 35 | 35 | self.setWindowTitle("Double Dds") | |
try: | 36 | 36 | try: | |
self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) | 37 | 37 | self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) | |
except: | 38 | 38 | except: | |
pass | 39 | 39 | pass | |
self.top_scroll_layout = Qt.QVBoxLayout() | 40 | 40 | self.top_scroll_layout = Qt.QVBoxLayout() | |
self.setLayout(self.top_scroll_layout) | 41 | 41 | self.setLayout(self.top_scroll_layout) | |
self.top_scroll = Qt.QScrollArea() | 42 | 42 | self.top_scroll = Qt.QScrollArea() | |
self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) | 43 | 43 | self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) | |
self.top_scroll_layout.addWidget(self.top_scroll) | 44 | 44 | self.top_scroll_layout.addWidget(self.top_scroll) | |
self.top_scroll.setWidgetResizable(True) | 45 | 45 | self.top_scroll.setWidgetResizable(True) | |
self.top_widget = Qt.QWidget() | 46 | 46 | self.top_widget = Qt.QWidget() | |
self.top_scroll.setWidget(self.top_widget) | 47 | 47 | self.top_scroll.setWidget(self.top_widget) | |
self.top_layout = Qt.QVBoxLayout(self.top_widget) | 48 | 48 | self.top_layout = Qt.QVBoxLayout(self.top_widget) | |
self.top_grid_layout = Qt.QGridLayout() | 49 | 49 | self.top_grid_layout = Qt.QGridLayout() | |
self.top_layout.addLayout(self.top_grid_layout) | 50 | 50 | self.top_layout.addLayout(self.top_grid_layout) | |
51 | 51 | |||
self.settings = Qt.QSettings("GNU Radio", "double_dds") | 52 | 52 | self.settings = Qt.QSettings("GNU Radio", "double_dds") | |
self.restoreGeometry(self.settings.value("geometry").toByteArray()) | 53 | 53 | self.restoreGeometry(self.settings.value("geometry").toByteArray()) | |
54 | 54 | |||
################################################## | 55 | 55 | ################################################## | |
# Variables | 56 | 56 | # Variables | |
################################################## | 57 | 57 | ################################################## | |
self.port = port = 1001 | 58 | 58 | self.port = port = 1001 | |
self.dds2_phase = dds2_phase = 0 | 59 | 59 | self.dds2_phase = dds2_phase = 0 | |
self.dds2_offset = dds2_offset = 0 | 60 | 60 | self.dds2_offset = dds2_offset = 0 | |
self.dds2_nco = dds2_nco = 0 | 61 | 61 | self.dds2_nco = dds2_nco = 0 | |
self.dds2_ampl = dds2_ampl = 0 | 62 | 62 | self.dds2_ampl = dds2_ampl = 0 | |
self.dds1_phase = dds1_phase = 0 | 63 | 63 | self.dds1_phase = dds1_phase = 0 | |
self.dds1_offset = dds1_offset = 0 | 64 | 64 | self.dds1_offset = dds1_offset = 0 | |
self.dds1_nco = dds1_nco = 0 | 65 | 65 | self.dds1_nco = dds1_nco = 0 | |
self.dds1_ampl = dds1_ampl = 0 | 66 | 66 | self.dds1_ampl = dds1_ampl = 0 | |
self.addr = addr = "192.168.0.204" | 67 | 67 | self.addr = addr = "192.168.0.204" | |
68 | 68 | |||
################################################## | 69 | 69 | ################################################## | |
# Blocks | 70 | 70 | # Blocks | |
################################################## | 71 | 71 | ################################################## | |
self._dds2_phase_range = Range(-2**13, 2**13-1, 1, 0, 200) | 72 | 72 | self._dds2_phase_range = Range(-2**13, 2**13-1, 1, 0, 200) | |
self._dds2_phase_win = RangeWidget(self._dds2_phase_range, self.set_dds2_phase, 'dds2_phase', "counter_slider", int) | 73 | 73 | self._dds2_phase_win = RangeWidget(self._dds2_phase_range, self.set_dds2_phase, 'dds2_phase', "counter_slider", int) | |
self.top_grid_layout.addWidget(self._dds2_phase_win, 3, 1) | 74 | 74 | self.top_grid_layout.addWidget(self._dds2_phase_win, 3, 1) | |
self._dds2_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) | 75 | 75 | self._dds2_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) | |
self._dds2_offset_win = RangeWidget(self._dds2_offset_range, self.set_dds2_offset, 'dds2_offset', "counter_slider", int) | 76 | 76 | self._dds2_offset_win = RangeWidget(self._dds2_offset_range, self.set_dds2_offset, 'dds2_offset', "counter_slider", int) | |
self.top_grid_layout.addWidget(self._dds2_offset_win, 2, 1) | 77 | 77 | self.top_grid_layout.addWidget(self._dds2_offset_win, 2, 1) | |
self._dds2_nco_range = Range(0, 60000000, 1000, 0, 200) | 78 | 78 | self._dds2_nco_range = Range(0, 60000000, 1000, 0, 200) | |
self._dds2_nco_win = RangeWidget(self._dds2_nco_range, self.set_dds2_nco, 'dds2_nco', "counter_slider", float) | 79 | 79 | self._dds2_nco_win = RangeWidget(self._dds2_nco_range, self.set_dds2_nco, 'dds2_nco', "counter_slider", float) | |
self.top_grid_layout.addWidget(self._dds2_nco_win, 0, 1) | 80 | 80 | self.top_grid_layout.addWidget(self._dds2_nco_win, 0, 1) | |
self._dds2_ampl_range = Range(0, 2**13-1, 1, 0, 200) | 81 | 81 | self._dds2_ampl_range = Range(0, 2**13-1, 1, 0, 200) | |
self._dds2_ampl_win = RangeWidget(self._dds2_ampl_range, self.set_dds2_ampl, 'dds2_ampl', "counter_slider", int) | 82 | 82 | self._dds2_ampl_win = RangeWidget(self._dds2_ampl_range, self.set_dds2_ampl, 'dds2_ampl', "counter_slider", int) | |
self.top_grid_layout.addWidget(self._dds2_ampl_win, 1, 1) | 83 | 83 | self.top_grid_layout.addWidget(self._dds2_ampl_win, 1, 1) | |
self._dds1_phase_range = Range(-2**13, 2**13-1, 1, 0, 200) | 84 | 84 | self._dds1_phase_range = Range(-2**13, 2**13-1, 1, 0, 200) | |
self._dds1_phase_win = RangeWidget(self._dds1_phase_range, self.set_dds1_phase, 'dds1_phase', "counter_slider", int) | 85 | 85 | self._dds1_phase_win = RangeWidget(self._dds1_phase_range, self.set_dds1_phase, 'dds1_phase', "counter_slider", int) | |
self.top_grid_layout.addWidget(self._dds1_phase_win, 3, 0) | 86 | 86 | self.top_grid_layout.addWidget(self._dds1_phase_win, 3, 0) | |
self._dds1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) | 87 | 87 | self._dds1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) | |
self._dds1_offset_win = RangeWidget(self._dds1_offset_range, self.set_dds1_offset, 'dds1_offset', "counter_slider", int) | 88 | 88 | self._dds1_offset_win = RangeWidget(self._dds1_offset_range, self.set_dds1_offset, 'dds1_offset', "counter_slider", int) | |
self.top_grid_layout.addWidget(self._dds1_offset_win, 2, 0) | 89 | 89 | self.top_grid_layout.addWidget(self._dds1_offset_win, 2, 0) | |
self._dds1_nco_range = Range(0, 60000000, 1000, 0, 200) | 90 | 90 | self._dds1_nco_range = Range(0, 60000000, 1000, 0, 200) | |
self._dds1_nco_win = RangeWidget(self._dds1_nco_range, self.set_dds1_nco, 'dds1_nco', "counter_slider", float) | 91 | 91 | self._dds1_nco_win = RangeWidget(self._dds1_nco_range, self.set_dds1_nco, 'dds1_nco', "counter_slider", float) | |
self.top_grid_layout.addWidget(self._dds1_nco_win, 0, 0) | 92 | 92 | self.top_grid_layout.addWidget(self._dds1_nco_win, 0, 0) | |
self._dds1_ampl_range = Range(0, 2**13-1, 1, 0, 200) | 93 | 93 | self._dds1_ampl_range = Range(0, 2**13-1, 1, 0, 200) | |
self._dds1_ampl_win = RangeWidget(self._dds1_ampl_range, self.set_dds1_ampl, 'dds1_ampl', "counter_slider", int) | 94 | 94 | self._dds1_ampl_win = RangeWidget(self._dds1_ampl_range, self.set_dds1_ampl, 'dds1_ampl', "counter_slider", int) | |
self.top_grid_layout.addWidget(self._dds1_ampl_win, 1, 0) | 95 | 95 | self.top_grid_layout.addWidget(self._dds1_ampl_win, 1, 0) | |
self.nco_counter_send_conf_0_0 = redpitaya_gnuradio.nco_counter_send_conf( | 96 | 96 | self.nco_counter_send_conf_0_0 = redpitaya_gnuradio.nco_counter_send_conf( | |
addr=addr, | 97 | 97 | addr=addr, | |
port=port, | 98 | 98 | port=port, | |
device='/dev/dds2_nco', | 99 | 99 | device='/dev/dds2_nco', | |
freq_ref=125000000, | 100 | 100 | freq_ref=125000000, | |
freq_dds=dds2_nco, | 101 | 101 | freq_dds=dds2_nco, | |
acc_size=32, | 102 | 102 | acc_size=32, | |
offset=0, | 103 | 103 | offset=0, | |
pinc_sw=1, | 104 | 104 | pinc_sw=1, | |
poff_sw=0, | 105 | 105 | poff_sw=0, | |
) | 106 | 106 | ) | |
107 | 107 | |||
self.nco_counter_send_conf_0 = redpitaya_gnuradio.nco_counter_send_conf( | 108 | 108 | self.nco_counter_send_conf_0 = redpitaya_gnuradio.nco_counter_send_conf( | |
addr=addr, | 109 | 109 | addr=addr, | |
port=port, | 110 | 110 | port=port, | |
device='/dev/dds1_nco', | 111 | 111 | device='/dev/dds1_nco', | |
freq_ref=125000000, | 112 | 112 | freq_ref=125000000, | |
freq_dds=dds1_nco, | 113 | 113 | freq_dds=dds1_nco, | |
acc_size=32, | 114 | 114 | acc_size=32, | |
offset=0, | 115 | 115 | offset=0, | |
pinc_sw=1, | 116 | 116 | pinc_sw=1, | |
poff_sw=0, | 117 | 117 | poff_sw=0, | |
) | 118 | 118 | ) | |
119 | 119 | |||
self.add_const_set_offset_0_2 = redpitaya_gnuradio.add_const_set_offset( | 120 | 120 | self.add_const_set_offset_0_2 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 121 | 121 | addr=addr, | |
port=port, | 122 | 122 | port=port, | |
device='/dev/dds1_phase', | 123 | 123 | device='/dev/dds1_phase', | |
const=dds1_phase, | 124 | 124 | const=dds1_phase, | |
) | 125 | 125 | ) | |
126 | 126 | |||
self.add_const_set_offset_0_1_0 = redpitaya_gnuradio.add_const_set_offset( | 127 | 127 | self.add_const_set_offset_0_1_0 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 128 | 128 | addr=addr, | |
port=port, | 129 | 129 | port=port, | |
device='/dev/dds2_phase', | 130 | 130 | device='/dev/dds2_phase', | |
const=dds2_phase, | 131 | 131 | const=dds2_phase, | |
) | 132 | 132 | ) | |
133 | 133 | |||
self.add_const_set_offset_0_1 = redpitaya_gnuradio.add_const_set_offset( | 134 | 134 | self.add_const_set_offset_0_1 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 135 | 135 | addr=addr, | |
port=port, | 136 | 136 | port=port, | |
device='/dev/dds2_offset', | 137 | 137 | device='/dev/dds2_offset', | |
const=dds2_offset, | 138 | 138 | const=dds2_offset, | |
) | 139 | 139 | ) | |
140 | 140 | |||
self.add_const_set_offset_0_0_0 = redpitaya_gnuradio.add_const_set_offset( | 141 | 141 | self.add_const_set_offset_0_0_0 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 142 | 142 | addr=addr, | |
port=port, | 143 | 143 | port=port, | |
device='/dev/dds2_ampl', | 144 | 144 | device='/dev/dds2_ampl', | |
const=dds2_ampl, | 145 | 145 | const=dds2_ampl, | |
) | 146 | 146 | ) | |
147 | 147 | |||
self.add_const_set_offset_0_0 = redpitaya_gnuradio.add_const_set_offset( | 148 | 148 | self.add_const_set_offset_0_0 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 149 | 149 | addr=addr, | |
port=port, | 150 | 150 | port=port, | |
device='/dev/dds1_ampl', | 151 | 151 | device='/dev/dds1_ampl', | |
const=dds1_ampl, | 152 | 152 | const=dds1_ampl, | |
) | 153 | 153 | ) | |
154 | 154 | |||
self.add_const_set_offset_0 = redpitaya_gnuradio.add_const_set_offset( | 155 | 155 | self.add_const_set_offset_0 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 156 | 156 | addr=addr, | |
port=port, | 157 | 157 | port=port, | |
device='/dev/dds1_offset', | 158 | 158 | device='/dev/dds1_offset', | |
const=dds1_offset, | 159 | 159 | const=dds1_offset, | |
) | 160 | 160 | ) | |
161 | 161 | |||
162 | 162 | |||
def closeEvent(self, event): | 163 | 163 | def closeEvent(self, event): | |
self.settings = Qt.QSettings("GNU Radio", "double_dds") | 164 | 164 | self.settings = Qt.QSettings("GNU Radio", "double_dds") | |
self.settings.setValue("geometry", self.saveGeometry()) | 165 | 165 | self.settings.setValue("geometry", self.saveGeometry()) | |
event.accept() | 166 | 166 | event.accept() | |
167 | 167 | |||
def get_port(self): | 168 | 168 | def get_port(self): | |
return self.port | 169 | 169 | return self.port | |
170 | 170 | |||
def set_port(self, port): | 171 | 171 | def set_port(self, port): | |
self.port = port | 172 | 172 | self.port = port | |
173 | 173 | |||
def get_dds2_phase(self): | 174 | 174 | def get_dds2_phase(self): | |
return self.dds2_phase | 175 | 175 | return self.dds2_phase | |
176 | 176 | |||
def set_dds2_phase(self, dds2_phase): | 177 | 177 | def set_dds2_phase(self, dds2_phase): | |
self.dds2_phase = dds2_phase | 178 | 178 | self.dds2_phase = dds2_phase | |
self.add_const_set_offset_0_1_0.set_const(device='/dev/dds2_phase', const=self.dds2_phase) | 179 | 179 | self.add_const_set_offset_0_1_0.set_const(device='/dev/dds2_phase', const=self.dds2_phase) | |
180 | 180 | |||
def get_dds2_offset(self): | 181 | 181 | def get_dds2_offset(self): | |
return self.dds2_offset | 182 | 182 | return self.dds2_offset | |
183 | 183 | |||
def set_dds2_offset(self, dds2_offset): | 184 | 184 | def set_dds2_offset(self, dds2_offset): | |
self.dds2_offset = dds2_offset | 185 | 185 | self.dds2_offset = dds2_offset | |
self.add_const_set_offset_0_1.set_const(device='/dev/dds2_offset', const=self.dds2_offset) | 186 | 186 | self.add_const_set_offset_0_1.set_const(device='/dev/dds2_offset', const=self.dds2_offset) | |
187 | 187 | |||
def get_dds2_nco(self): | 188 | 188 | def get_dds2_nco(self): | |
return self.dds2_nco | 189 | 189 | return self.dds2_nco | |
190 | 190 | |||
def set_dds2_nco(self, dds2_nco): | 191 | 191 | def set_dds2_nco(self, dds2_nco): | |
self.dds2_nco = dds2_nco | 192 | 192 | self.dds2_nco = dds2_nco | |
self.nco_counter_send_conf_0_0.set_nco(device='/dev/dds2_nco', freq_ref=125000000, freq_dds=self.dds2_nco, acc_size=32, offset=0, pinc_sw=1, poff_sw=0) | 193 | 193 | self.nco_counter_send_conf_0_0.set_nco(device='/dev/dds2_nco', freq_ref=125000000, freq_dds=self.dds2_nco, acc_size=32, offset=0, pinc_sw=1, poff_sw=0) | |
194 | 194 | |||
def get_dds2_ampl(self): | 195 | 195 | def get_dds2_ampl(self): | |
return self.dds2_ampl | 196 | 196 | return self.dds2_ampl | |
197 | 197 | |||
def set_dds2_ampl(self, dds2_ampl): | 198 | 198 | def set_dds2_ampl(self, dds2_ampl): | |
self.dds2_ampl = dds2_ampl | 199 | 199 | self.dds2_ampl = dds2_ampl | |
self.add_const_set_offset_0_0_0.set_const(device='/dev/dds2_ampl', const=self.dds2_ampl) | 200 | 200 | self.add_const_set_offset_0_0_0.set_const(device='/dev/dds2_ampl', const=self.dds2_ampl) | |
201 | 201 | |||
def get_dds1_phase(self): | 202 | 202 | def get_dds1_phase(self): | |
return self.dds1_phase | 203 | 203 | return self.dds1_phase | |
204 | 204 | |||
def set_dds1_phase(self, dds1_phase): | 205 | 205 | def set_dds1_phase(self, dds1_phase): | |
self.dds1_phase = dds1_phase | 206 | 206 | self.dds1_phase = dds1_phase | |
self.add_const_set_offset_0_2.set_const(device='/dev/dds1_phase', const=self.dds1_phase) | 207 | 207 | self.add_const_set_offset_0_2.set_const(device='/dev/dds1_phase', const=self.dds1_phase) | |
208 | 208 | |||
def get_dds1_offset(self): | 209 | 209 | def get_dds1_offset(self): | |
return self.dds1_offset | 210 | 210 | return self.dds1_offset | |
211 | 211 | |||
def set_dds1_offset(self, dds1_offset): | 212 | 212 | def set_dds1_offset(self, dds1_offset): | |
self.dds1_offset = dds1_offset | 213 | 213 | self.dds1_offset = dds1_offset | |
self.add_const_set_offset_0.set_const(device='/dev/dds1_offset', const=self.dds1_offset) | 214 | 214 | self.add_const_set_offset_0.set_const(device='/dev/dds1_offset', const=self.dds1_offset) |
redpitaya/client/pid_vco_pid_only.py
#!/usr/bin/env python2 | 1 | 1 | #!/usr/bin/env python2 | |
# -*- coding: utf-8 -*- | 2 | 2 | # -*- coding: utf-8 -*- | |
################################################## | 3 | 3 | ################################################## | |
# GNU Radio Python Flow Graph | 4 | 4 | # GNU Radio Python Flow Graph | |
# Title: Pid Vco Pid Only | 5 | 5 | # Title: Pid Vco Pid Only | |
# Generated: Sat May 6 09:57:38 2017 | 6 | 6 | # Generated: Fri May 12 18:35:52 2017 | |
################################################## | 7 | 7 | ################################################## | |
8 | 8 | |||
if __name__ == '__main__': | 9 | 9 | if __name__ == '__main__': | |
import ctypes | 10 | 10 | import ctypes | |
import sys | 11 | 11 | import sys | |
if sys.platform.startswith('linux'): | 12 | 12 | if sys.platform.startswith('linux'): | |
try: | 13 | 13 | try: | |
x11 = ctypes.cdll.LoadLibrary('libX11.so') | 14 | 14 | x11 = ctypes.cdll.LoadLibrary('libX11.so') | |
x11.XInitThreads() | 15 | 15 | x11.XInitThreads() | |
except: | 16 | 16 | except: | |
print "Warning: failed to XInitThreads()" | 17 | 17 | print "Warning: failed to XInitThreads()" | |
18 | 18 | |||
from PyQt4 import Qt | 19 | 19 | from PyQt4 import Qt | |
from gnuradio import eng_notation | 20 | 20 | from gnuradio import eng_notation | |
from gnuradio import gr | 21 | 21 | from gnuradio import gr | |
from gnuradio.eng_option import eng_option | 22 | 22 | from gnuradio.eng_option import eng_option | |
from gnuradio.filter import firdes | 23 | 23 | from gnuradio.filter import firdes | |
from gnuradio.qtgui import Range, RangeWidget | 24 | 24 | from gnuradio.qtgui import Range, RangeWidget | |
from optparse import OptionParser | 25 | 25 | from optparse import OptionParser | |
import redpitaya_gnuradio | 26 | 26 | import redpitaya_gnuradio | |
import sys | 27 | 27 | import sys | |
28 | 28 | |||
29 | 29 | |||
class pid_vco_pid_only(gr.top_block, Qt.QWidget): | 30 | 30 | class pid_vco_pid_only(gr.top_block, Qt.QWidget): | |
31 | 31 | |||
def __init__(self): | 32 | 32 | def __init__(self): | |
gr.top_block.__init__(self, "Pid Vco Pid Only") | 33 | 33 | gr.top_block.__init__(self, "Pid Vco Pid Only") | |
Qt.QWidget.__init__(self) | 34 | 34 | Qt.QWidget.__init__(self) | |
self.setWindowTitle("Pid Vco Pid Only") | 35 | 35 | self.setWindowTitle("Pid Vco Pid Only") | |
try: | 36 | 36 | try: | |
self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) | 37 | 37 | self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) | |
except: | 38 | 38 | except: | |
pass | 39 | 39 | pass | |
self.top_scroll_layout = Qt.QVBoxLayout() | 40 | 40 | self.top_scroll_layout = Qt.QVBoxLayout() | |
self.setLayout(self.top_scroll_layout) | 41 | 41 | self.setLayout(self.top_scroll_layout) | |
self.top_scroll = Qt.QScrollArea() | 42 | 42 | self.top_scroll = Qt.QScrollArea() | |
self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) | 43 | 43 | self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) | |
self.top_scroll_layout.addWidget(self.top_scroll) | 44 | 44 | self.top_scroll_layout.addWidget(self.top_scroll) | |
self.top_scroll.setWidgetResizable(True) | 45 | 45 | self.top_scroll.setWidgetResizable(True) | |
self.top_widget = Qt.QWidget() | 46 | 46 | self.top_widget = Qt.QWidget() | |
self.top_scroll.setWidget(self.top_widget) | 47 | 47 | self.top_scroll.setWidget(self.top_widget) | |
self.top_layout = Qt.QVBoxLayout(self.top_widget) | 48 | 48 | self.top_layout = Qt.QVBoxLayout(self.top_widget) | |
self.top_grid_layout = Qt.QGridLayout() | 49 | 49 | self.top_grid_layout = Qt.QGridLayout() | |
self.top_layout.addLayout(self.top_grid_layout) | 50 | 50 | self.top_layout.addLayout(self.top_grid_layout) | |
51 | 51 | |||
self.settings = Qt.QSettings("GNU Radio", "pid_vco_pid_only") | 52 | 52 | self.settings = Qt.QSettings("GNU Radio", "pid_vco_pid_only") | |
self.restoreGeometry(self.settings.value("geometry").toByteArray()) | 53 | 53 | self.restoreGeometry(self.settings.value("geometry").toByteArray()) | |
54 | 54 | |||
################################################## | 55 | 55 | ################################################## | |
# Variables | 56 | 56 | # Variables | |
################################################## | 57 | 57 | ################################################## | |
self.port = port = 1001 | 58 | 58 | self.port = port = 1001 | |
self.pid2_sign = pid2_sign = 0 | 59 | 59 | self.pid2_sign = pid2_sign = 0 | |
self.pid2_setpoint = pid2_setpoint = 0 | 60 | 60 | self.pid2_setpoint = pid2_setpoint = 0 | |
self.pid2_rst_int = pid2_rst_int = 0 | 61 | 61 | self.pid2_rst_int = pid2_rst_int = 0 | |
self.pid2_offset = pid2_offset = 0 | 62 | 62 | self.pid2_offset = pid2_offset = 0 | |
self.pid2_kp = pid2_kp = 0 | 63 | 63 | self.pid2_kp = pid2_kp = 0 | |
self.pid2_ki = pid2_ki = 0 | 64 | 64 | self.pid2_ki = pid2_ki = 0 | |
self.pid2_kd = pid2_kd = 0 | 65 | 65 | self.pid2_kd = pid2_kd = 0 | |
self.pid1_sign = pid1_sign = 0 | 66 | 66 | self.pid1_sign = pid1_sign = 0 | |
self.pid1_setpoint = pid1_setpoint = 0 | 67 | 67 | self.pid1_setpoint = pid1_setpoint = 0 | |
self.pid1_rst_int = pid1_rst_int = 0 | 68 | 68 | self.pid1_rst_int = pid1_rst_int = 0 | |
self.pid1_kp = pid1_kp = 0 | 69 | 69 | self.pid1_kp = pid1_kp = 0 | |
self.pid1_ki = pid1_ki = 0 | 70 | 70 | self.pid1_ki = pid1_ki = 0 | |
self.pid1_kd = pid1_kd = 0 | 71 | 71 | self.pid1_kd = pid1_kd = 0 | |
self.dds1_range = dds1_range = 0 | 72 | 72 | self.dds1_range = dds1_range = 0 | |
self.dds1_poff_sw = dds1_poff_sw = 1 | 73 | 73 | self.dds1_poff_sw = dds1_poff_sw = 1 | |
self.dds1_pinc_sw = dds1_pinc_sw = 1 | 74 | 74 | self.dds1_pinc_sw = dds1_pinc_sw = 1 | |
self.dds1_offset = dds1_offset = 0 | 75 | 75 | self.dds1_offset = dds1_offset = 0 | |
self.dds1_nco = dds1_nco = 39500000 | 76 | 76 | self.dds1_nco = dds1_nco = 40000000 | |
self.dds1_f0 = dds1_f0 = 39500000 | 77 | 77 | self.dds1_f0 = dds1_f0 = 40000000 | |
self.dds1_ampl = dds1_ampl = 0 | 78 | 78 | self.dds1_ampl = dds1_ampl = 0 | |
self.addr = addr = "192.168.0.201" | 79 | 79 | self.addr = addr = "192.168.0.201" | |
self.adc1_offset = adc1_offset = 0 | 80 | 80 | self.adc1_offset = adc1_offset = 0 | |
81 | 81 | |||
################################################## | 82 | 82 | ################################################## | |
# Blocks | 83 | 83 | # Blocks | |
################################################## | 84 | 84 | ################################################## | |
_pid2_sign_check_box = Qt.QCheckBox('pid2_sign') | 85 | 85 | _pid2_sign_check_box = Qt.QCheckBox('pid2_sign') | |
self._pid2_sign_choices = {True: 1, False: 0} | 86 | 86 | self._pid2_sign_choices = {True: 1, False: 0} | |
self._pid2_sign_choices_inv = dict((v,k) for k,v in self._pid2_sign_choices.iteritems()) | 87 | 87 | self._pid2_sign_choices_inv = dict((v,k) for k,v in self._pid2_sign_choices.iteritems()) | |
self._pid2_sign_callback = lambda i: Qt.QMetaObject.invokeMethod(_pid2_sign_check_box, "setChecked", Qt.Q_ARG("bool", self._pid2_sign_choices_inv[i])) | 88 | 88 | self._pid2_sign_callback = lambda i: Qt.QMetaObject.invokeMethod(_pid2_sign_check_box, "setChecked", Qt.Q_ARG("bool", self._pid2_sign_choices_inv[i])) | |
self._pid2_sign_callback(self.pid2_sign) | 89 | 89 | self._pid2_sign_callback(self.pid2_sign) | |
_pid2_sign_check_box.stateChanged.connect(lambda i: self.set_pid2_sign(self._pid2_sign_choices[bool(i)])) | 90 | 90 | _pid2_sign_check_box.stateChanged.connect(lambda i: self.set_pid2_sign(self._pid2_sign_choices[bool(i)])) | |
self.top_grid_layout.addWidget(_pid2_sign_check_box, 10,1) | 91 | 91 | self.top_grid_layout.addWidget(_pid2_sign_check_box, 10,1) | |
self._pid2_setpoint_range = Range(-2**13, 2**13-1, 1, 0, 200) | 92 | 92 | self._pid2_setpoint_range = Range(-2**13, 2**13-1, 1, 0, 200) | |
self._pid2_setpoint_win = RangeWidget(self._pid2_setpoint_range, self.set_pid2_setpoint, 'pid2_setpoint', "counter_slider", int) | 93 | 93 | self._pid2_setpoint_win = RangeWidget(self._pid2_setpoint_range, self.set_pid2_setpoint, 'pid2_setpoint', "counter_slider", int) | |
self.top_grid_layout.addWidget(self._pid2_setpoint_win, 9,1) | 94 | 94 | self.top_grid_layout.addWidget(self._pid2_setpoint_win, 9,1) | |
_pid2_rst_int_push_button = Qt.QPushButton('pid2_rst_int') | 95 | 95 | _pid2_rst_int_push_button = Qt.QPushButton('pid2_rst_int') | |
self._pid2_rst_int_choices = {'Pressed': 1, 'Released': 0} | 96 | 96 | self._pid2_rst_int_choices = {'Pressed': 1, 'Released': 0} | |
_pid2_rst_int_push_button.pressed.connect(lambda: self.set_pid2_rst_int(self._pid2_rst_int_choices['Pressed'])) | 97 | 97 | _pid2_rst_int_push_button.pressed.connect(lambda: self.set_pid2_rst_int(self._pid2_rst_int_choices['Pressed'])) | |
_pid2_rst_int_push_button.released.connect(lambda: self.set_pid2_rst_int(self._pid2_rst_int_choices['Released'])) | 98 | 98 | _pid2_rst_int_push_button.released.connect(lambda: self.set_pid2_rst_int(self._pid2_rst_int_choices['Released'])) | |
self.top_grid_layout.addWidget(_pid2_rst_int_push_button, 11,1) | 99 | 99 | self.top_grid_layout.addWidget(_pid2_rst_int_push_button, 11,1) | |
self._pid2_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) | 100 | 100 | self._pid2_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) | |
self._pid2_offset_win = RangeWidget(self._pid2_offset_range, self.set_pid2_offset, 'pid2_offset', "counter_slider", int) | 101 | 101 | self._pid2_offset_win = RangeWidget(self._pid2_offset_range, self.set_pid2_offset, 'pid2_offset', "counter_slider", int) | |
self.top_grid_layout.addWidget(self._pid2_offset_win, 4,1) | 102 | 102 | self.top_grid_layout.addWidget(self._pid2_offset_win, 4,1) | |
self._pid2_kp_range = Range(0, 2**13-1, 1, 0, 200) | 103 | 103 | self._pid2_kp_range = Range(0, 2**13-1, 1, 0, 200) | |
self._pid2_kp_win = RangeWidget(self._pid2_kp_range, self.set_pid2_kp, 'pid2_kp', "counter_slider", int) | 104 | 104 | self._pid2_kp_win = RangeWidget(self._pid2_kp_range, self.set_pid2_kp, 'pid2_kp', "counter_slider", int) | |
self.top_grid_layout.addWidget(self._pid2_kp_win, 6,1) | 105 | 105 | self.top_grid_layout.addWidget(self._pid2_kp_win, 6,1) | |
self._pid2_ki_range = Range(0, 2**13-1, 1, 0, 200) | 106 | 106 | self._pid2_ki_range = Range(0, 2**13-1, 1, 0, 200) | |
self._pid2_ki_win = RangeWidget(self._pid2_ki_range, self.set_pid2_ki, 'pid2_ki', "counter_slider", int) | 107 | 107 | self._pid2_ki_win = RangeWidget(self._pid2_ki_range, self.set_pid2_ki, 'pid2_ki', "counter_slider", int) | |
self.top_grid_layout.addWidget(self._pid2_ki_win, 7,1) | 108 | 108 | self.top_grid_layout.addWidget(self._pid2_ki_win, 7,1) | |
self._pid2_kd_range = Range(0, 2**13-1, 1, 0, 200) | 109 | 109 | self._pid2_kd_range = Range(0, 2**13-1, 1, 0, 200) | |
self._pid2_kd_win = RangeWidget(self._pid2_kd_range, self.set_pid2_kd, 'pid2_kd', "counter_slider", int) | 110 | 110 | self._pid2_kd_win = RangeWidget(self._pid2_kd_range, self.set_pid2_kd, 'pid2_kd', "counter_slider", int) | |
self.top_grid_layout.addWidget(self._pid2_kd_win, 8,1) | 111 | 111 | self.top_grid_layout.addWidget(self._pid2_kd_win, 8,1) | |
_pid1_sign_check_box = Qt.QCheckBox('pid1_sign') | 112 | 112 | _pid1_sign_check_box = Qt.QCheckBox('pid1_sign') | |
self._pid1_sign_choices = {True: 1, False: 0} | 113 | 113 | self._pid1_sign_choices = {True: 1, False: 0} | |
self._pid1_sign_choices_inv = dict((v,k) for k,v in self._pid1_sign_choices.iteritems()) | 114 | 114 | self._pid1_sign_choices_inv = dict((v,k) for k,v in self._pid1_sign_choices.iteritems()) | |
self._pid1_sign_callback = lambda i: Qt.QMetaObject.invokeMethod(_pid1_sign_check_box, "setChecked", Qt.Q_ARG("bool", self._pid1_sign_choices_inv[i])) | 115 | 115 | self._pid1_sign_callback = lambda i: Qt.QMetaObject.invokeMethod(_pid1_sign_check_box, "setChecked", Qt.Q_ARG("bool", self._pid1_sign_choices_inv[i])) | |
self._pid1_sign_callback(self.pid1_sign) | 116 | 116 | self._pid1_sign_callback(self.pid1_sign) | |
_pid1_sign_check_box.stateChanged.connect(lambda i: self.set_pid1_sign(self._pid1_sign_choices[bool(i)])) | 117 | 117 | _pid1_sign_check_box.stateChanged.connect(lambda i: self.set_pid1_sign(self._pid1_sign_choices[bool(i)])) | |
self.top_grid_layout.addWidget(_pid1_sign_check_box, 10,0) | 118 | 118 | self.top_grid_layout.addWidget(_pid1_sign_check_box, 10,0) | |
self._pid1_setpoint_range = Range(-2**13, 2**13-1, 1, 0, 200) | 119 | 119 | self._pid1_setpoint_range = Range(-2**13, 2**13-1, 1, 0, 200) | |
self._pid1_setpoint_win = RangeWidget(self._pid1_setpoint_range, self.set_pid1_setpoint, 'pid1_setpoint', "counter_slider", int) | 120 | 120 | self._pid1_setpoint_win = RangeWidget(self._pid1_setpoint_range, self.set_pid1_setpoint, 'pid1_setpoint', "counter_slider", int) | |
self.top_grid_layout.addWidget(self._pid1_setpoint_win, 9,0) | 121 | 121 | self.top_grid_layout.addWidget(self._pid1_setpoint_win, 9,0) | |
_pid1_rst_int_push_button = Qt.QPushButton('pid1_rst_int') | 122 | 122 | _pid1_rst_int_push_button = Qt.QPushButton('pid1_rst_int') | |
self._pid1_rst_int_choices = {'Pressed': 1, 'Released': 0} | 123 | 123 | self._pid1_rst_int_choices = {'Pressed': 1, 'Released': 0} | |
_pid1_rst_int_push_button.pressed.connect(lambda: self.set_pid1_rst_int(self._pid1_rst_int_choices['Pressed'])) | 124 | 124 | _pid1_rst_int_push_button.pressed.connect(lambda: self.set_pid1_rst_int(self._pid1_rst_int_choices['Pressed'])) | |
_pid1_rst_int_push_button.released.connect(lambda: self.set_pid1_rst_int(self._pid1_rst_int_choices['Released'])) | 125 | 125 | _pid1_rst_int_push_button.released.connect(lambda: self.set_pid1_rst_int(self._pid1_rst_int_choices['Released'])) | |
self.top_grid_layout.addWidget(_pid1_rst_int_push_button, 11,0) | 126 | 126 | self.top_grid_layout.addWidget(_pid1_rst_int_push_button, 11,0) | |
self._pid1_kp_range = Range(0, 2**13-1, 1, 0, 200) | 127 | 127 | self._pid1_kp_range = Range(0, 2**13-1, 1, 0, 200) | |
self._pid1_kp_win = RangeWidget(self._pid1_kp_range, self.set_pid1_kp, 'pid1_kp', "counter_slider", int) | 128 | 128 | self._pid1_kp_win = RangeWidget(self._pid1_kp_range, self.set_pid1_kp, 'pid1_kp', "counter_slider", int) | |
self.top_grid_layout.addWidget(self._pid1_kp_win, 6,0) | 129 | 129 | self.top_grid_layout.addWidget(self._pid1_kp_win, 6,0) | |
self._pid1_ki_range = Range(0, 2**13-1, 1, 0, 200) | 130 | 130 | self._pid1_ki_range = Range(0, 2**13-1, 1, 0, 200) | |
self._pid1_ki_win = RangeWidget(self._pid1_ki_range, self.set_pid1_ki, 'pid1_ki', "counter_slider", int) | 131 | 131 | self._pid1_ki_win = RangeWidget(self._pid1_ki_range, self.set_pid1_ki, 'pid1_ki', "counter_slider", int) | |
self.top_grid_layout.addWidget(self._pid1_ki_win, 7,0) | 132 | 132 | self.top_grid_layout.addWidget(self._pid1_ki_win, 7,0) | |
self._pid1_kd_range = Range(0, 2**13-1, 1, 0, 200) | 133 | 133 | self._pid1_kd_range = Range(0, 2**13-1, 1, 0, 200) | |
self._pid1_kd_win = RangeWidget(self._pid1_kd_range, self.set_pid1_kd, 'pid1_kd', "counter_slider", int) | 134 | 134 | self._pid1_kd_win = RangeWidget(self._pid1_kd_range, self.set_pid1_kd, 'pid1_kd', "counter_slider", int) | |
self.top_grid_layout.addWidget(self._pid1_kd_win, 8,0) | 135 | 135 | self.top_grid_layout.addWidget(self._pid1_kd_win, 8,0) | |
self._dds1_range_range = Range(-2**13, 2**13-1, 1, 0, 200) | 136 | 136 | self._dds1_range_range = Range(-2**13, 2**13-1, 1, 0, 200) | |
self._dds1_range_win = RangeWidget(self._dds1_range_range, self.set_dds1_range, 'dds1_range', "counter_slider", int) | 137 | 137 | self._dds1_range_win = RangeWidget(self._dds1_range_range, self.set_dds1_range, 'dds1_range', "counter_slider", int) | |
self.top_grid_layout.addWidget(self._dds1_range_win, 13,0) | 138 | 138 | self.top_grid_layout.addWidget(self._dds1_range_win, 13,0) | |
_dds1_poff_sw_check_box = Qt.QCheckBox('dds1_poff_sw') | 139 | 139 | _dds1_poff_sw_check_box = Qt.QCheckBox('dds1_poff_sw') | |
self._dds1_poff_sw_choices = {True: 1, False: 0} | 140 | 140 | self._dds1_poff_sw_choices = {True: 1, False: 0} | |
self._dds1_poff_sw_choices_inv = dict((v,k) for k,v in self._dds1_poff_sw_choices.iteritems()) | 141 | 141 | self._dds1_poff_sw_choices_inv = dict((v,k) for k,v in self._dds1_poff_sw_choices.iteritems()) | |
self._dds1_poff_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds1_poff_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds1_poff_sw_choices_inv[i])) | 142 | 142 | self._dds1_poff_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds1_poff_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds1_poff_sw_choices_inv[i])) | |
self._dds1_poff_sw_callback(self.dds1_poff_sw) | 143 | 143 | self._dds1_poff_sw_callback(self.dds1_poff_sw) | |
_dds1_poff_sw_check_box.stateChanged.connect(lambda i: self.set_dds1_poff_sw(self._dds1_poff_sw_choices[bool(i)])) | 144 | 144 | _dds1_poff_sw_check_box.stateChanged.connect(lambda i: self.set_dds1_poff_sw(self._dds1_poff_sw_choices[bool(i)])) | |
self.top_grid_layout.addWidget(_dds1_poff_sw_check_box, 2, 0) | 145 | 145 | self.top_grid_layout.addWidget(_dds1_poff_sw_check_box, 2, 0) | |
_dds1_pinc_sw_check_box = Qt.QCheckBox('dds1_pinc_sw') | 146 | 146 | _dds1_pinc_sw_check_box = Qt.QCheckBox('dds1_pinc_sw') | |
self._dds1_pinc_sw_choices = {True: 1, False: 0} | 147 | 147 | self._dds1_pinc_sw_choices = {True: 1, False: 0} | |
self._dds1_pinc_sw_choices_inv = dict((v,k) for k,v in self._dds1_pinc_sw_choices.iteritems()) | 148 | 148 | self._dds1_pinc_sw_choices_inv = dict((v,k) for k,v in self._dds1_pinc_sw_choices.iteritems()) | |
self._dds1_pinc_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds1_pinc_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds1_pinc_sw_choices_inv[i])) | 149 | 149 | self._dds1_pinc_sw_callback = lambda i: Qt.QMetaObject.invokeMethod(_dds1_pinc_sw_check_box, "setChecked", Qt.Q_ARG("bool", self._dds1_pinc_sw_choices_inv[i])) | |
self._dds1_pinc_sw_callback(self.dds1_pinc_sw) | 150 | 150 | self._dds1_pinc_sw_callback(self.dds1_pinc_sw) | |
_dds1_pinc_sw_check_box.stateChanged.connect(lambda i: self.set_dds1_pinc_sw(self._dds1_pinc_sw_choices[bool(i)])) | 151 | 151 | _dds1_pinc_sw_check_box.stateChanged.connect(lambda i: self.set_dds1_pinc_sw(self._dds1_pinc_sw_choices[bool(i)])) | |
self.top_grid_layout.addWidget(_dds1_pinc_sw_check_box, 1,0) | 152 | 152 | self.top_grid_layout.addWidget(_dds1_pinc_sw_check_box, 1,0) | |
self._dds1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) | 153 | 153 | self._dds1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) | |
self._dds1_offset_win = RangeWidget(self._dds1_offset_range, self.set_dds1_offset, 'dds1_offset', "counter_slider", int) | 154 | 154 | self._dds1_offset_win = RangeWidget(self._dds1_offset_range, self.set_dds1_offset, 'dds1_offset', "counter_slider", int) | |
self.top_grid_layout.addWidget(self._dds1_offset_win, 4,0) | 155 | 155 | self.top_grid_layout.addWidget(self._dds1_offset_win, 4,0) | |
self._dds1_nco_range = Range(0, 60000000, 1, 39500000, 200) | 156 | 156 | self._dds1_nco_range = Range(0, 60000000, 1, 40000000, 200) | |
self._dds1_nco_win = RangeWidget(self._dds1_nco_range, self.set_dds1_nco, 'dds1_nco', "counter_slider", int) | 157 | 157 | self._dds1_nco_win = RangeWidget(self._dds1_nco_range, self.set_dds1_nco, 'dds1_nco', "counter_slider", int) | |
self.top_grid_layout.addWidget(self._dds1_nco_win, 0,0) | 158 | 158 | self.top_grid_layout.addWidget(self._dds1_nco_win, 0,0) | |
self._dds1_f0_range = Range(0, 60000000, 1, 39500000, 200) | 159 | 159 | self._dds1_f0_range = Range(0, 60000000, 1, 40000000, 200) | |
self._dds1_f0_win = RangeWidget(self._dds1_f0_range, self.set_dds1_f0, 'dds1_f0', "counter_slider", int) | 160 | 160 | self._dds1_f0_win = RangeWidget(self._dds1_f0_range, self.set_dds1_f0, 'dds1_f0', "counter_slider", int) | |
self.top_grid_layout.addWidget(self._dds1_f0_win, 12,0) | 161 | 161 | self.top_grid_layout.addWidget(self._dds1_f0_win, 12,0) | |
self._dds1_ampl_range = Range(0, 2**13-1, 1, 0, 200) | 162 | 162 | self._dds1_ampl_range = Range(0, 2**13-1, 1, 0, 200) | |
self._dds1_ampl_win = RangeWidget(self._dds1_ampl_range, self.set_dds1_ampl, 'dds1_ampl', "counter_slider", int) | 163 | 163 | self._dds1_ampl_win = RangeWidget(self._dds1_ampl_range, self.set_dds1_ampl, 'dds1_ampl', "counter_slider", int) | |
self.top_grid_layout.addWidget(self._dds1_ampl_win, 3,0) | 164 | 164 | self.top_grid_layout.addWidget(self._dds1_ampl_win, 3,0) | |
self._adc1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) | 165 | 165 | 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) | 166 | 166 | self._adc1_offset_win = RangeWidget(self._adc1_offset_range, self.set_adc1_offset, 'adc1_offset', "counter_slider", int) | |
self.top_grid_layout.addWidget(self._adc1_offset_win, 5,0) | 167 | 167 | self.top_grid_layout.addWidget(self._adc1_offset_win, 5,0) | |
self.nco_counter_send_conf_0 = redpitaya_gnuradio.nco_counter_send_conf( | 168 | 168 | self.nco_counter_send_conf_0 = redpitaya_gnuradio.nco_counter_send_conf( | |
addr=addr, | 169 | 169 | addr=addr, | |
port=port, | 170 | 170 | port=port, | |
device='/dev/dds1_nco', | 171 | 171 | device='/dev/dds1_nco', | |
freq_ref=125000000, | 172 | 172 | freq_ref=125000000, | |
freq_dds=dds1_nco, | 173 | 173 | freq_dds=dds1_nco, | |
acc_size=32, | 174 | 174 | acc_size=32, | |
offset=0, | 175 | 175 | offset=0, | |
pinc_sw=dds1_pinc_sw, | 176 | 176 | pinc_sw=dds1_pinc_sw, | |
poff_sw=dds1_poff_sw, | 177 | 177 | poff_sw=dds1_poff_sw, | |
) | 178 | 178 | ) | |
179 | 179 | |||
self.add_const_set_offset_0_0_0_1_1 = redpitaya_gnuradio.add_const_set_offset( | 180 | 180 | self.add_const_set_offset_0_0_0_1_1 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 181 | 181 | addr=addr, | |
port=port, | 182 | 182 | port=port, | |
device='/dev/pid2_setpoint', | 183 | 183 | device='/dev/pid2_setpoint', | |
const=pid2_setpoint, | 184 | 184 | const=pid2_setpoint, | |
) | 185 | 185 | ) | |
186 | 186 | |||
self.add_const_set_offset_0_0_0_1_0_1 = redpitaya_gnuradio.add_const_set_offset( | 187 | 187 | self.add_const_set_offset_0_0_0_1_0_1 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 188 | 188 | addr=addr, | |
port=port, | 189 | 189 | port=port, | |
device='/dev/pid2_kp', | 190 | 190 | device='/dev/pid2_kp', | |
const=pid2_kp, | 191 | 191 | const=pid2_kp, | |
) | 192 | 192 | ) | |
193 | 193 | |||
self.add_const_set_offset_0_0_0_1_0_0_1 = redpitaya_gnuradio.add_const_set_offset( | 194 | 194 | self.add_const_set_offset_0_0_0_1_0_0_1 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 195 | 195 | addr=addr, | |
port=port, | 196 | 196 | port=port, | |
device='/dev/pid2_ki', | 197 | 197 | device='/dev/pid2_ki', | |
const=pid2_ki, | 198 | 198 | const=pid2_ki, | |
) | 199 | 199 | ) | |
200 | 200 | |||
self.add_const_set_offset_0_0_0_1_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( | 201 | 201 | self.add_const_set_offset_0_0_0_1_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 202 | 202 | addr=addr, | |
port=port, | 203 | 203 | port=port, | |
device='/dev/pid2_kd', | 204 | 204 | device='/dev/pid2_kd', | |
const=pid2_kd, | 205 | 205 | const=pid2_kd, | |
) | 206 | 206 | ) | |
207 | 207 | |||
self.add_const_set_offset_0_0_0_1_0_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( | 208 | 208 | self.add_const_set_offset_0_0_0_1_0_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 209 | 209 | addr=addr, | |
port=port, | 210 | 210 | port=port, | |
device='/dev/pid2_sign', | 211 | 211 | device='/dev/pid2_sign', | |
const=pid2_sign, | 212 | 212 | const=pid2_sign, | |
) | 213 | 213 | ) | |
214 | 214 | |||
self.add_const_set_offset_0_0_0_1_0_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( | 215 | 215 | self.add_const_set_offset_0_0_0_1_0_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 216 | 216 | addr=addr, | |
port=port, | 217 | 217 | port=port, | |
device='/dev/pid2_rst_int', | 218 | 218 | device='/dev/pid2_rst_int', | |
const=pid2_rst_int, | 219 | 219 | const=pid2_rst_int, | |
) | 220 | 220 | ) | |
221 | 221 | |||
self.add_const_set_offset_0_0_0_1_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( | 222 | 222 | self.add_const_set_offset_0_0_0_1_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 223 | 223 | addr=addr, | |
port=port, | 224 | 224 | port=port, | |
device='/dev/pid1_rst_int', | 225 | 225 | device='/dev/pid1_rst_int', | |
const=pid1_rst_int, | 226 | 226 | const=pid1_rst_int, | |
) | 227 | 227 | ) | |
228 | 228 | |||
self.add_const_set_offset_0_0_0_1_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( | 229 | 229 | self.add_const_set_offset_0_0_0_1_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 230 | 230 | addr=addr, | |
port=port, | 231 | 231 | port=port, | |
device='/dev/pid1_sign', | 232 | 232 | device='/dev/pid1_sign', | |
const=pid1_sign, | 233 | 233 | const=pid1_sign, | |
) | 234 | 234 | ) | |
235 | 235 | |||
self.add_const_set_offset_0_0_0_1_0_0_0 = redpitaya_gnuradio.add_const_set_offset( | 236 | 236 | self.add_const_set_offset_0_0_0_1_0_0_0 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 237 | 237 | addr=addr, | |
port=port, | 238 | 238 | port=port, | |
device='/dev/pid1_kd', | 239 | 239 | device='/dev/pid1_kd', | |
const=pid1_kd, | 240 | 240 | const=pid1_kd, | |
) | 241 | 241 | ) | |
242 | 242 | |||
self.add_const_set_offset_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( | 243 | 243 | self.add_const_set_offset_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 244 | 244 | addr=addr, | |
port=port, | 245 | 245 | port=port, | |
device='/dev/pid1_ki', | 246 | 246 | device='/dev/pid1_ki', | |
const=pid1_ki, | 247 | 247 | const=pid1_ki, | |
) | 248 | 248 | ) | |
249 | 249 | |||
self.add_const_set_offset_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( | 250 | 250 | self.add_const_set_offset_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 251 | 251 | addr=addr, | |
port=port, | 252 | 252 | port=port, | |
device='/dev/pid1_kp', | 253 | 253 | device='/dev/pid1_kp', | |
const=pid1_kp, | 254 | 254 | const=pid1_kp, | |
) | 255 | 255 | ) | |
256 | 256 | |||
self.add_const_set_offset_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( | 257 | 257 | self.add_const_set_offset_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 258 | 258 | addr=addr, | |
port=port, | 259 | 259 | port=port, | |
device='/dev/pid1_setpoint', | 260 | 260 | device='/dev/pid1_setpoint', | |
const=pid1_setpoint, | 261 | 261 | const=pid1_setpoint, | |
) | 262 | 262 | ) | |
263 | 263 | |||
self.add_const_set_offset_0_0_0_0_1_1 = redpitaya_gnuradio.add_const_set_offset( | 264 | 264 | self.add_const_set_offset_0_0_0_0_1_1 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 265 | 265 | addr=addr, | |
port=port, | 266 | 266 | port=port, | |
device='/dev/pid2_offset', | 267 | 267 | device='/dev/pid2_offset', | |
const=pid2_offset, | 268 | 268 | const=pid2_offset, | |
) | 269 | 269 | ) | |
270 | 270 | |||
self.add_const_set_offset_0_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( | 271 | 271 | self.add_const_set_offset_0_0_0_0_1_0_0 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 272 | 272 | addr=addr, | |
port=port, | 273 | 273 | port=port, | |
device='/dev/dds1_range', | 274 | 274 | device='/dev/dds1_range', | |
const=dds1_range, | 275 | 275 | const=dds1_range, | |
) | 276 | 276 | ) | |
277 | 277 | |||
self.add_const_set_offset_0_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( | 278 | 278 | self.add_const_set_offset_0_0_0_0_1_0 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 279 | 279 | addr=addr, | |
port=port, | 280 | 280 | port=port, | |
device='/dev/dds1_f0', | 281 | 281 | device='/dev/dds1_f0', | |
const=int(dds1_f0/(125e6/2**32)), | 282 | 282 | const=int(dds1_f0/(125e6/2**32)), | |
) | 283 | 283 | ) | |
284 | 284 | |||
self.add_const_set_offset_0_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( | 285 | 285 | self.add_const_set_offset_0_0_0_0_1 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 286 | 286 | addr=addr, | |
port=port, | 287 | 287 | port=port, | |
device='/dev/dds1_offset', | 288 | 288 | device='/dev/dds1_offset', | |
const=dds1_offset, | 289 | 289 | const=dds1_offset, | |
) | 290 | 290 | ) | |
291 | 291 | |||
self.add_const_set_offset_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( | 292 | 292 | self.add_const_set_offset_0_0_0_0_0 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 293 | 293 | addr=addr, | |
port=port, | 294 | 294 | port=port, | |
device='/dev/dds1_ampl', | 295 | 295 | device='/dev/dds1_ampl', | |
const=dds1_ampl, | 296 | 296 | const=dds1_ampl, | |
) | 297 | 297 | ) | |
298 | 298 | |||
self.add_const_set_offset_0_0_0 = redpitaya_gnuradio.add_const_set_offset( | 299 | 299 | self.add_const_set_offset_0_0_0 = redpitaya_gnuradio.add_const_set_offset( | |
addr=addr, | 300 | 300 | addr=addr, | |
port=port, | 301 | 301 | port=port, | |
device='/dev/adc1_offset', | 302 | 302 | device='/dev/adc1_offset', | |
const=adc1_offset, | 303 | 303 | const=adc1_offset, | |
) | 304 | 304 | ) | |
305 | 305 | |||
306 | 306 | |||
def closeEvent(self, event): | 307 | 307 | def closeEvent(self, event): | |
self.settings = Qt.QSettings("GNU Radio", "pid_vco_pid_only") | 308 | 308 | self.settings = Qt.QSettings("GNU Radio", "pid_vco_pid_only") | |
self.settings.setValue("geometry", self.saveGeometry()) | 309 | 309 | self.settings.setValue("geometry", self.saveGeometry()) | |
event.accept() | 310 | 310 | event.accept() | |
311 | 311 | |||
def get_port(self): | 312 | 312 | def get_port(self): | |
return self.port | 313 | 313 | return self.port | |
314 | 314 | |||
def set_port(self, port): | 315 | 315 | def set_port(self, port): | |
self.port = port | 316 | 316 | self.port = port | |
317 | 317 | |||
def get_pid2_sign(self): | 318 | 318 | def get_pid2_sign(self): | |
return self.pid2_sign | 319 | 319 | return self.pid2_sign | |
320 | 320 | |||
def set_pid2_sign(self, pid2_sign): | 321 | 321 | def set_pid2_sign(self, pid2_sign): | |
self.pid2_sign = pid2_sign | 322 | 322 | self.pid2_sign = pid2_sign | |
self._pid2_sign_callback(self.pid2_sign) | 323 | 323 | self._pid2_sign_callback(self.pid2_sign) | |
self.add_const_set_offset_0_0_0_1_0_0_0_0_1.set_const(device='/dev/pid2_sign', const=self.pid2_sign) | 324 | 324 | self.add_const_set_offset_0_0_0_1_0_0_0_0_1.set_const(device='/dev/pid2_sign', const=self.pid2_sign) | |
325 | 325 | |||
def get_pid2_setpoint(self): | 326 | 326 | def get_pid2_setpoint(self): | |
return self.pid2_setpoint | 327 | 327 | return self.pid2_setpoint | |
328 | 328 | |||
def set_pid2_setpoint(self, pid2_setpoint): | 329 | 329 | def set_pid2_setpoint(self, pid2_setpoint): | |
self.pid2_setpoint = pid2_setpoint | 330 | 330 | self.pid2_setpoint = pid2_setpoint | |
self.add_const_set_offset_0_0_0_1_1.set_const(device='/dev/pid2_setpoint', const=self.pid2_setpoint) | 331 | 331 | self.add_const_set_offset_0_0_0_1_1.set_const(device='/dev/pid2_setpoint', const=self.pid2_setpoint) | |
332 | 332 | |||
def get_pid2_rst_int(self): | 333 | 333 | def get_pid2_rst_int(self): | |
return self.pid2_rst_int | 334 | 334 | return self.pid2_rst_int | |
335 | 335 | |||
def set_pid2_rst_int(self, pid2_rst_int): | 336 | 336 | def set_pid2_rst_int(self, pid2_rst_int): | |
self.pid2_rst_int = pid2_rst_int | 337 | 337 | self.pid2_rst_int = pid2_rst_int | |
self.add_const_set_offset_0_0_0_1_0_0_0_0_0_0.set_const(device='/dev/pid2_rst_int', const=self.pid2_rst_int) | 338 | 338 | self.add_const_set_offset_0_0_0_1_0_0_0_0_0_0.set_const(device='/dev/pid2_rst_int', const=self.pid2_rst_int) | |
339 | 339 | |||
def get_pid2_offset(self): | 340 | 340 | def get_pid2_offset(self): | |
return self.pid2_offset | 341 | 341 | return self.pid2_offset | |
342 | 342 | |||
def set_pid2_offset(self, pid2_offset): | 343 | 343 | def set_pid2_offset(self, pid2_offset): | |
self.pid2_offset = pid2_offset | 344 | 344 | self.pid2_offset = pid2_offset | |
self.add_const_set_offset_0_0_0_0_1_1.set_const(device='/dev/pid2_offset', const=self.pid2_offset) | 345 | 345 | self.add_const_set_offset_0_0_0_0_1_1.set_const(device='/dev/pid2_offset', const=self.pid2_offset) | |
346 | 346 | |||
def get_pid2_kp(self): | 347 | 347 | def get_pid2_kp(self): | |
return self.pid2_kp | 348 | 348 | return self.pid2_kp | |
349 | 349 | |||
def set_pid2_kp(self, pid2_kp): | 350 | 350 | def set_pid2_kp(self, pid2_kp): | |
self.pid2_kp = pid2_kp | 351 | 351 | self.pid2_kp = pid2_kp | |
self.add_const_set_offset_0_0_0_1_0_1.set_const(device='/dev/pid2_kp', const=self.pid2_kp) | 352 | 352 | self.add_const_set_offset_0_0_0_1_0_1.set_const(device='/dev/pid2_kp', const=self.pid2_kp) | |
353 | 353 | |||
def get_pid2_ki(self): | 354 | 354 | def get_pid2_ki(self): | |
return self.pid2_ki | 355 | 355 | return self.pid2_ki | |
356 | 356 | |||
def set_pid2_ki(self, pid2_ki): | 357 | 357 | def set_pid2_ki(self, pid2_ki): | |
self.pid2_ki = pid2_ki | 358 | 358 | self.pid2_ki = pid2_ki | |
self.add_const_set_offset_0_0_0_1_0_0_1.set_const(device='/dev/pid2_ki', const=self.pid2_ki) | 359 | 359 | self.add_const_set_offset_0_0_0_1_0_0_1.set_const(device='/dev/pid2_ki', const=self.pid2_ki) | |
360 | 360 | |||
def get_pid2_kd(self): | 361 | 361 | def get_pid2_kd(self): | |
return self.pid2_kd | 362 | 362 | return self.pid2_kd | |
363 | 363 | |||
def set_pid2_kd(self, pid2_kd): | 364 | 364 | def set_pid2_kd(self, pid2_kd): | |
self.pid2_kd = pid2_kd | 365 | 365 | self.pid2_kd = pid2_kd | |
self.add_const_set_offset_0_0_0_1_0_0_0_1.set_const(device='/dev/pid2_kd', const=self.pid2_kd) | 366 | 366 | self.add_const_set_offset_0_0_0_1_0_0_0_1.set_const(device='/dev/pid2_kd', const=self.pid2_kd) | |
367 | 367 | |||
def get_pid1_sign(self): | 368 | 368 | def get_pid1_sign(self): | |
return self.pid1_sign | 369 | 369 | return self.pid1_sign | |
370 | 370 | |||
def set_pid1_sign(self, pid1_sign): | 371 | 371 | def set_pid1_sign(self, pid1_sign): | |
self.pid1_sign = pid1_sign | 372 | 372 | self.pid1_sign = pid1_sign | |
self._pid1_sign_callback(self.pid1_sign) | 373 | 373 | self._pid1_sign_callback(self.pid1_sign) | |
self.add_const_set_offset_0_0_0_1_0_0_0_0.set_const(device='/dev/pid1_sign', const=self.pid1_sign) | 374 | 374 | self.add_const_set_offset_0_0_0_1_0_0_0_0.set_const(device='/dev/pid1_sign', const=self.pid1_sign) | |
375 | 375 | |||
def get_pid1_setpoint(self): | 376 | 376 | def get_pid1_setpoint(self): | |
return self.pid1_setpoint | 377 | 377 | return self.pid1_setpoint | |
378 | 378 | |||
def set_pid1_setpoint(self, pid1_setpoint): | 379 | 379 | def set_pid1_setpoint(self, pid1_setpoint): | |
self.pid1_setpoint = pid1_setpoint | 380 | 380 | self.pid1_setpoint = pid1_setpoint | |
self.add_const_set_offset_0_0_0_1.set_const(device='/dev/pid1_setpoint', const=self.pid1_setpoint) | 381 | 381 | self.add_const_set_offset_0_0_0_1.set_const(device='/dev/pid1_setpoint', const=self.pid1_setpoint) | |
382 | 382 | |||
def get_pid1_rst_int(self): | 383 | 383 | def get_pid1_rst_int(self): | |
return self.pid1_rst_int | 384 | 384 | return self.pid1_rst_int | |
385 | 385 | |||
def set_pid1_rst_int(self, pid1_rst_int): | 386 | 386 | def set_pid1_rst_int(self, pid1_rst_int): | |
self.pid1_rst_int = pid1_rst_int | 387 | 387 | self.pid1_rst_int = pid1_rst_int | |
self.add_const_set_offset_0_0_0_1_0_0_0_0_0.set_const(device='/dev/pid1_rst_int', const=self.pid1_rst_int) | 388 | 388 | self.add_const_set_offset_0_0_0_1_0_0_0_0_0.set_const(device='/dev/pid1_rst_int', const=self.pid1_rst_int) | |
389 | 389 | |||
def get_pid1_kp(self): | 390 | 390 | def get_pid1_kp(self): | |
return self.pid1_kp | 391 | 391 | return self.pid1_kp | |
392 | 392 | |||
def set_pid1_kp(self, pid1_kp): | 393 | 393 | def set_pid1_kp(self, pid1_kp): | |
self.pid1_kp = pid1_kp | 394 | 394 | self.pid1_kp = pid1_kp | |
self.add_const_set_offset_0_0_0_1_0.set_const(device='/dev/pid1_kp', const=self.pid1_kp) | 395 | 395 | self.add_const_set_offset_0_0_0_1_0.set_const(device='/dev/pid1_kp', const=self.pid1_kp) | |
396 | 396 | |||
def get_pid1_ki(self): | 397 | 397 | def get_pid1_ki(self): | |
return self.pid1_ki | 398 | 398 | return self.pid1_ki | |
399 | 399 | |||
def set_pid1_ki(self, pid1_ki): | 400 | 400 | def set_pid1_ki(self, pid1_ki): | |
self.pid1_ki = pid1_ki | 401 | 401 | self.pid1_ki = pid1_ki | |
self.add_const_set_offset_0_0_0_1_0_0.set_const(device='/dev/pid1_ki', const=self.pid1_ki) | 402 | 402 | self.add_const_set_offset_0_0_0_1_0_0.set_const(device='/dev/pid1_ki', const=self.pid1_ki) | |
403 | 403 | |||
def get_pid1_kd(self): | 404 | 404 | def get_pid1_kd(self): | |
return self.pid1_kd | 405 | 405 | return self.pid1_kd | |
406 | 406 | |||
def set_pid1_kd(self, pid1_kd): | 407 | 407 | def set_pid1_kd(self, pid1_kd): | |
self.pid1_kd = pid1_kd | 408 | 408 | self.pid1_kd = pid1_kd | |
self.add_const_set_offset_0_0_0_1_0_0_0.set_const(device='/dev/pid1_kd', const=self.pid1_kd) | 409 | 409 | self.add_const_set_offset_0_0_0_1_0_0_0.set_const(device='/dev/pid1_kd', const=self.pid1_kd) | |
410 | 410 | |||
def get_dds1_range(self): | 411 | 411 | def get_dds1_range(self): | |
return self.dds1_range | 412 | 412 | return self.dds1_range | |
413 | 413 | |||
def set_dds1_range(self, dds1_range): | 414 | 414 | def set_dds1_range(self, dds1_range): | |
self.dds1_range = dds1_range | 415 | 415 | self.dds1_range = dds1_range | |
self.add_const_set_offset_0_0_0_0_1_0_0.set_const(device='/dev/dds1_range', const=self.dds1_range) | 416 | 416 | self.add_const_set_offset_0_0_0_0_1_0_0.set_const(device='/dev/dds1_range', const=self.dds1_range) | |
417 | 417 | |||
def get_dds1_poff_sw(self): | 418 | 418 | def get_dds1_poff_sw(self): | |
return self.dds1_poff_sw | 419 | 419 | return self.dds1_poff_sw | |
420 | 420 |