Commit ed4b2fee689f33cd9982c130724c107e96dbb08f

Authored by bmarechal
1 parent ac6ebf3310
Exists in master

minor fixes

Showing 18 changed files with 1284 additions and 19 deletions Inline Diff

redpitaya/client/dds_control.grc
File was created 1 <?xml version='1.0' encoding='utf-8'?>
2 <?grc format='1' created='3.7.10'?>
3 <flow_graph>
4 <timestamp>Thu Feb 2 22:54:58 2017</timestamp>
5 <block>
6 <key>options</key>
7 <param>
8 <key>author</key>
9 <value></value>
10 </param>
11 <param>
12 <key>window_size</key>
13 <value></value>
14 </param>
15 <param>
16 <key>category</key>
17 <value>[GRC Hier Blocks]</value>
18 </param>
19 <param>
20 <key>comment</key>
21 <value></value>
22 </param>
23 <param>
24 <key>description</key>
25 <value></value>
26 </param>
27 <param>
28 <key>_enabled</key>
29 <value>True</value>
30 </param>
31 <param>
32 <key>_coordinate</key>
33 <value>(8, 8)</value>
34 </param>
35 <param>
36 <key>_rotation</key>
37 <value>0</value>
38 </param>
39 <param>
40 <key>generate_options</key>
41 <value>qt_gui</value>
42 </param>
43 <param>
44 <key>hier_block_src_path</key>
45 <value>.:</value>
46 </param>
47 <param>
48 <key>id</key>
49 <value>top_block</value>
50 </param>
51 <param>
52 <key>max_nouts</key>
53 <value>0</value>
54 </param>
55 <param>
56 <key>qt_qss_theme</key>
57 <value></value>
58 </param>
59 <param>
60 <key>realtime_scheduling</key>
61 <value></value>
62 </param>
63 <param>
64 <key>run_command</key>
65 <value>{python} -u {filename}</value>
66 </param>
67 <param>
68 <key>run_options</key>
69 <value>prompt</value>
70 </param>
71 <param>
72 <key>run</key>
73 <value>True</value>
74 </param>
75 <param>
76 <key>thread_safe_setters</key>
77 <value></value>
78 </param>
79 <param>
80 <key>title</key>
81 <value></value>
82 </param>
83 </block>
84 <block>
85 <key>variable_qtgui_range</key>
86 <param>
87 <key>comment</key>
88 <value></value>
89 </param>
90 <param>
91 <key>value</key>
92 <value>0</value>
93 </param>
94 <param>
95 <key>_enabled</key>
96 <value>True</value>
97 </param>
98 <param>
99 <key>_coordinate</key>
100 <value>(704, 24)</value>
101 </param>
102 <param>
103 <key>gui_hint</key>
104 <value>1, 0</value>
105 </param>
106 <param>
107 <key>_rotation</key>
108 <value>0</value>
109 </param>
110 <param>
111 <key>id</key>
112 <value>a_dds</value>
113 </param>
114 <param>
115 <key>label</key>
116 <value>DDS amplitude</value>
117 </param>
118 <param>
119 <key>min_len</key>
120 <value>200</value>
121 </param>
122 <param>
123 <key>orient</key>
124 <value>Qt.Horizontal</value>
125 </param>
126 <param>
127 <key>start</key>
128 <value>0</value>
129 </param>
130 <param>
131 <key>step</key>
132 <value>128</value>
133 </param>
134 <param>
135 <key>stop</key>
136 <value>8191</value>
137 </param>
138 <param>
139 <key>rangeType</key>
140 <value>int</value>
141 </param>
142 <param>
143 <key>widget</key>
144 <value>counter_slider</value>
145 </param>
146 </block>
147 <block>
148 <key>variable</key>
149 <param>
150 <key>comment</key>
151 <value></value>
152 </param>
153 <param>
154 <key>_enabled</key>
155 <value>True</value>
156 </param>
157 <param>
158 <key>_coordinate</key>
159 <value>(0, 248)</value>
160 </param>
161 <param>
162 <key>_rotation</key>
163 <value>0</value>
164 </param>
165 <param>
166 <key>id</key>
167 <value>addr</value>
168 </param>
169 <param>
170 <key>value</key>
171 <value>"192.168.0.202"</value>
172 </param>
173 </block>
174 <block>
175 <key>variable_qtgui_range</key>
176 <param>
177 <key>comment</key>
178 <value></value>
179 </param>
180 <param>
181 <key>value</key>
182 <value>0</value>
183 </param>
184 <param>
185 <key>_enabled</key>
186 <value>True</value>
187 </param>
188 <param>
189 <key>_coordinate</key>
190 <value>(488, 24)</value>
191 </param>
192 <param>
193 <key>gui_hint</key>
194 <value>0, 0</value>
195 </param>
196 <param>
197 <key>_rotation</key>
198 <value>0</value>
199 </param>
200 <param>
201 <key>id</key>
202 <value>f_dds</value>
203 </param>
204 <param>
205 <key>label</key>
206 <value>DDS frequency</value>
207 </param>
208 <param>
209 <key>min_len</key>
210 <value>200</value>
211 </param>
212 <param>
213 <key>orient</key>
214 <value>Qt.Horizontal</value>
215 </param>
216 <param>
217 <key>start</key>
218 <value>0</value>
219 </param>
220 <param>
221 <key>step</key>
222 <value>100000</value>
223 </param>
224 <param>
225 <key>stop</key>
226 <value>60000000</value>
227 </param>
228 <param>
229 <key>rangeType</key>
230 <value>int</value>
231 </param>
232 <param>
233 <key>widget</key>
234 <value>counter_slider</value>
235 </param>
236 </block>
237 <block>
238 <key>variable_qtgui_range</key>
239 <param>
240 <key>comment</key>
241 <value></value>
242 </param>
243 <param>
244 <key>value</key>
245 <value>0</value>
246 </param>
247 <param>
248 <key>_enabled</key>
249 <value>True</value>
250 </param>
251 <param>
252 <key>_coordinate</key>
253 <value>(328, 24)</value>
254 </param>
255 <param>
256 <key>gui_hint</key>
257 <value>2, 0</value>
258 </param>
259 <param>
260 <key>_rotation</key>
261 <value>0</value>
262 </param>
263 <param>
264 <key>id</key>
265 <value>offset_out1</value>
266 </param>
267 <param>
268 <key>label</key>
269 <value>Offset DDS</value>
270 </param>
271 <param>
272 <key>min_len</key>
273 <value>200</value>
274 </param>
275 <param>
276 <key>orient</key>
277 <value>Qt.Horizontal</value>
278 </param>
279 <param>
280 <key>start</key>
281 <value>-8192</value>
282 </param>
283 <param>
284 <key>step</key>
285 <value>100</value>
286 </param>
287 <param>
288 <key>stop</key>
289 <value>8191</value>
290 </param>
291 <param>
292 <key>rangeType</key>
293 <value>int</value>
294 </param>
295 <param>
296 <key>widget</key>
297 <value>counter_slider</value>
298 </param>
299 </block>
300 <block>
301 <key>variable</key>
302 <param>
303 <key>comment</key>
304 <value></value>
305 </param>
306 <param>
307 <key>_enabled</key>
308 <value>True</value>
309 </param>
310 <param>
311 <key>_coordinate</key>
312 <value>(0, 320)</value>
313 </param>
314 <param>
315 <key>_rotation</key>
316 <value>0</value>
317 </param>
318 <param>
319 <key>id</key>
320 <value>port</value>
321 </param>
322 <param>
323 <key>value</key>
324 <value>1001</value>
325 </param>
326 </block>
327 <block>
328 <key>variable</key>
329 <param>
330 <key>comment</key>
331 <value></value>
332 </param>
333 <param>
334 <key>_enabled</key>
335 <value>True</value>
336 </param>
337 <param>
338 <key>_coordinate</key>
339 <value>(8, 160)</value>
340 </param>
341 <param>
342 <key>_rotation</key>
343 <value>0</value>
344 </param>
345 <param>
346 <key>id</key>
347 <value>samp_rate</value>
348 </param>
349 <param>
350 <key>value</key>
351 <value>32000</value>
352 </param>
353 </block>
354 <block>
355 <key>add_const_set_offset</key>
356 <param>
357 <key>addr</key>
358 <value>addr</value>
359 </param>
360 <param>
361 <key>alias</key>
362 <value></value>
363 </param>
364 <param>
365 <key>comment</key>
366 <value></value>
367 </param>
368 <param>
369 <key>const</key>
370 <value>offset_out1</value>
371 </param>
372 <param>
373 <key>device</key>
374 <value>/dev/dds_offset</value>
375 </param>
376 <param>
377 <key>_enabled</key>
378 <value>True</value>
379 </param>
380 <param>
381 <key>_coordinate</key>
382 <value>(304, 176)</value>
383 </param>
384 <param>
385 <key>_rotation</key>
386 <value>0</value>
387 </param>
388 <param>
389 <key>id</key>
390 <value>add_const_set_offset_0</value>
391 </param>
392 <param>
393 <key>port</key>
394 <value>port</value>
395 </param>
396 </block>
397 <block>
398 <key>add_const_set_offset</key>
399 <param>
400 <key>addr</key>
401 <value>addr</value>
402 </param>
403 <param>
404 <key>alias</key>
405 <value></value>
406 </param>
407 <param>
408 <key>comment</key>
409 <value></value>
410 </param>
411 <param>
412 <key>const</key>
413 <value>a_dds</value>
414 </param>
415 <param>
416 <key>device</key>
417 <value>/dev/dds_ampl</value>
418 </param>
419 <param>
420 <key>_enabled</key>
421 <value>True</value>
422 </param>
423 <param>
424 <key>_coordinate</key>
425 <value>(704, 176)</value>
426 </param>
427 <param>
428 <key>_rotation</key>
429 <value>0</value>
430 </param>
431 <param>
432 <key>id</key>
433 <value>add_const_set_offset_0_0</value>
434 </param>
435 <param>
436 <key>port</key>
437 <value>port</value>
438 </param>
439 </block>
440 <block>
441 <key>nco_counter_send_conf</key>
442 <param>
443 <key>acc_size</key>
444 <value>32</value>
445 </param>
446 <param>
447 <key>addr</key>
448 <value>addr</value>
449 </param>
450 <param>
451 <key>alias</key>
452 <value></value>
453 </param>
454 <param>
455 <key>comment</key>
456 <value></value>
457 </param>
458 <param>
459 <key>device</key>
460 <value>/dev/dds_freq</value>
461 </param>
462 <param>
463 <key>_enabled</key>
464 <value>True</value>
465 </param>
466 <param>
467 <key>freq_dds</key>
468 <value>f_dds</value>
469 </param>
470 <param>
471 <key>freq_ref</key>
472 <value>125000000</value>
473 </param>
474 <param>
475 <key>_coordinate</key>
476 <value>(488, 176)</value>
477 </param>
478 <param>
479 <key>_rotation</key>
480 <value>0</value>
481 </param>
482 <param>
483 <key>id</key>
484 <value>nco_counter_send_conf_0</value>
485 </param>
486 <param>
487 <key>offset</key>
488 <value>0</value>
489 </param>
490 <param>
491 <key>port</key>
492 <value>port</value>
493 </param>
494 </block>
495 </flow_graph>
redpitaya/client/gr_add_const_set_offset.xml
File was created 1 <?xml version="1.0"?>
2 <!--
3 # GNU Radio blocks for the Red Pitaya transceiver
4 # Copyright (C) 2015 Renzo Davoli
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 -->
20 <block>
21 <name>add_const_set_offset</name>
22 <key>add_const_set_offset</key>
23 <category>Red Pitaya</category>
24 <import>import redpitaya_gnuradio</import>
25 <make>redpitaya_gnuradio.add_const_set_offset(
26 addr=$addr,
27 port=$port,
28 device=$device,
29 const=$const,
30 )
31 </make>
32 <callback>set_const(device=$device, const=$const)</callback>
33 <param>
34 <name>Address</name>
35 <key>addr</key>
36 <value>192.168.0.201</value>
37 <type>string</type>
38 </param>
39 <param>
40 <name>Port</name>
41 <key>port</key>
42 <value>1001</value>
43 <type>int</type>
44 </param>
45 <param>
46 <name>Device</name>
47 <key>device</key>
48 <value>/dev/add_const_0</value>
49 <type>string</type>
50 </param>
51 <param>
52 <name>Constant</name>
53 <key>const</key>
54 <value>0</value>
55 <type>int</type>
56 </param>
57 </block>
redpitaya/client/gr_nco_counter_send_conf.xml
File was created 1 <?xml version="1.0"?>
2 <!--
3 # GNU Radio blocks for the Red Pitaya transceiver
4 # Copyright (C) 2015 Renzo Davoli
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 -->
20 <block>
21 <name>nco_counter_send_conf</name>
22 <key>nco_counter_send_conf</key>
23 <category>Red Pitaya</category>
24 <import>import redpitaya_gnuradio</import>
25 <make>redpitaya_gnuradio.nco_counter_send_conf(
26 addr=$addr,
27 port=$port,
28 device=$device,
29 freq_ref=$freq_ref,
30 freq_dds=$freq_dds,
31 acc_size=$acc_size,
32 offset=$offset,
33 )
34 </make>
35 <callback>set_nco(device=$device, freq_ref=$freq_ref, freq_dds=$freq_dds, acc_size=$acc_size, offset=$offset)</callback>
36 <param>
37 <name>Address</name>
38 <key>addr</key>
39 <value>192.168.0.201</value>
40 <type>string</type>
41 </param>
42 <param>
43 <name>Port</name>
44 <key>port</key>
45 <value>1001</value>
46 <type>int</type>
47 </param>
48 <param>
49 <name>Device</name>
50 <key>device</key>
51 <value>/dev/dds1</value>
52 <type>string</type>
53 </param>
54 <param>
55 <name>Frequency ref</name>
56 <key>freq_ref</key>
57 <value>125000000</value>
58 <type>int</type>
59 </param>
60 <param>
61 <name>Frequency DDS</name>
62 <key>freq_dds</key>
63 <value>0</value>
64 <type>int</type>
65 </param>
66 <param>
67 <name>Accumulator size</name>
68 <key>acc_size</key>
69 <value>28</value>
70 <type>int</type>
71 </param>
72 <param>
73 <name>Offset</name>
74 <key>offset</key>
75 <value>0</value>
76 <type>int</type>
77 </param>
78 </block>
redpitaya/client/gr_source_test.xml
File was created 1 <?xml version="1.0"?>
2 <!--
3 # GNU Radio blocks for the Red Pitaya transceiver
4 # Copyright (C) 2015 Renzo Davoli
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 -->
20 <block>
21 <name>source_test</name>
22 <key>source_test</key>
23 <category>Red Pitaya</category>
24 <import>import redpitaya_gnuradio</import>
25 <make>redpitaya_gnuradio.source_test()</make>
26 <source>
27 <name>out</name>
28 <type>complex</type>
29 </source>
30 </block>
redpitaya/client/gr_source_test.xml.old
File was created 1 <?xml version="1.0"?>
2 <!--
3 # GNU Radio blocks for the Red Pitaya transceiver
4 # Copyright (C) 2015 Renzo Davoli
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 -->
20 <block>
21 <name>source_test</name>
22 <key>source_test</key>
23 <category>Red Pitaya</category>
24 <import>import redpitaya_gnuradio</import>
25 <make>redpitaya_gnuradio.source_test()</make>
26 <source>
27 <name>out</name>
28 <type>complex</type>
29 </source>
30 </block>
redpitaya/client/redpitaya_gnuradio.py
File was created 1 #!/usr/bin/env python
2
3 # GNU Radio blocks for the Red Pitaya transceiver
4 # Copyright (C) 2015 Renzo Davoli
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20 import socket, os
21 from gnuradio import gr, blocks
22
23 class add_const_set_offset(gr.hier_block2):
24 def __init__(self, addr, port, device, const):
25 self.name = "add_const_set_offset"
26 gr.hier_block2.__init__(
27 self,
28 name = self.name,
29 input_signature = gr.io_signature(0, 0, 0),
30 output_signature = gr.io_signature(0, 0, 0)
31 )
32 self.ctrl_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
33 self.ctrl_sock.connect((addr, port))
34 self.set_const(device, const)
35
36 def set_const(self, device, const):
37 self.ctrl_sock.send('%s;%s;%i\n'%(self.name, device, const))
38
39
40 class nco_counter_send_conf(gr.hier_block2):
41 def __init__(self, addr, port, device, freq_ref, freq_dds, acc_size, offset):
42 self.name = "nco_counter_send_conf"
43 gr.hier_block2.__init__(
44 self,
45 name = self.name,
46 input_signature = gr.io_signature(0, 0, 0),
47 output_signature = gr.io_signature(0, 0, 0)
48 )
49 self.ctrl_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
50 self.ctrl_sock.connect((addr, port))
51 self.set_nco(device, freq_ref, freq_dds, acc_size, offset)
52
53 def set_nco(self, device, freq_ref, freq_dds, acc_size, offset):
54 self.ctrl_sock.send('%s;%s;%i;%i;%i;%i\n'%(self.name, device, freq_ref, freq_dds, acc_size, offset))
55
56 '''~
57 class source_test(gr.hier_block2):
58 def __init__(self):
59 self.name = "source_test"
60 gr.hier_block2.__init__(
61 self,
62 name = self.name,
63 input_signature = gr.io_signature(0, 0, 0),
redpitaya/client/redpitaya_gnuradio.pyc
No preview for this file type
redpitaya/client/sourceme.bma
File was created 1 export GRC_BLOCKS_PATH=.
redpitaya/client/top_block.py
File was created 1 #!/usr/bin/env python2
2 # -*- coding: utf-8 -*-
3 ##################################################
4 # GNU Radio Python Flow Graph
5 # Title: Top Block
6 # Generated: Mon Feb 13 22:24:05 2017
7 ##################################################
8
9 if __name__ == '__main__':
10 import ctypes
11 import sys
12 if sys.platform.startswith('linux'):
13 try:
14 x11 = ctypes.cdll.LoadLibrary('libX11.so')
15 x11.XInitThreads()
16 except:
17 print "Warning: failed to XInitThreads()"
18
19 from PyQt4 import Qt
20 from gnuradio import eng_notation
21 from gnuradio import gr
22 from gnuradio.eng_option import eng_option
23 from gnuradio.filter import firdes
24 from gnuradio.qtgui import Range, RangeWidget
25 from optparse import OptionParser
26 import redpitaya_gnuradio
27 import sys
28
29
30 class top_block(gr.top_block, Qt.QWidget):
31
32 def __init__(self):
33 gr.top_block.__init__(self, "Top Block")
34 Qt.QWidget.__init__(self)
35 self.setWindowTitle("Top Block")
36 try:
37 self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
38 except:
39 pass
40 self.top_scroll_layout = Qt.QVBoxLayout()
41 self.setLayout(self.top_scroll_layout)
42 self.top_scroll = Qt.QScrollArea()
43 self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
44 self.top_scroll_layout.addWidget(self.top_scroll)
45 self.top_scroll.setWidgetResizable(True)
46 self.top_widget = Qt.QWidget()
47 self.top_scroll.setWidget(self.top_widget)
48 self.top_layout = Qt.QVBoxLayout(self.top_widget)
49 self.top_grid_layout = Qt.QGridLayout()
50 self.top_layout.addLayout(self.top_grid_layout)
51
52 self.settings = Qt.QSettings("GNU Radio", "top_block")
53 self.restoreGeometry(self.settings.value("geometry").toByteArray())
54
55 ##################################################
56 # Variables
57 ##################################################
58 self.samp_rate = samp_rate = 32000
59 self.port = port = 1001
60 self.offset_out1 = offset_out1 = 0
61 self.f_dds = f_dds = 0
62 self.addr = addr = "192.168.0.202"
63 self.a_dds = a_dds = 0
64
65 ##################################################
66 # Blocks
67 ##################################################
68 self._offset_out1_range = Range(-8192, 8191, 100, 0, 200)
69 self._offset_out1_win = RangeWidget(self._offset_out1_range, self.set_offset_out1, 'Offset DDS', "counter_slider", int)
70 self.top_grid_layout.addWidget(self._offset_out1_win, 2, 0)
71 self._f_dds_range = Range(0, 60000000, 100000, 0, 200)
72 self._f_dds_win = RangeWidget(self._f_dds_range, self.set_f_dds, 'DDS frequency', "counter_slider", int)
73 self.top_grid_layout.addWidget(self._f_dds_win, 0, 0)
74 self._a_dds_range = Range(0, 8191, 128, 0, 200)
75 self._a_dds_win = RangeWidget(self._a_dds_range, self.set_a_dds, 'DDS amplitude', "counter_slider", int)
76 self.top_grid_layout.addWidget(self._a_dds_win, 1, 0)
77 self.nco_counter_send_conf_0 = redpitaya_gnuradio.nco_counter_send_conf(
78 addr=addr,
79 port=port,
80 device='/dev/dds_freq',
81 freq_ref=125000000,
82 freq_dds=f_dds,
83 acc_size=32,
84 offset=0,
85 )
86
87 self.add_const_set_offset_0_0 = redpitaya_gnuradio.add_const_set_offset(
88 addr=addr,
89 port=port,
90 device='/dev/dds_ampl',
91 const=a_dds,
92 )
93
94 self.add_const_set_offset_0 = redpitaya_gnuradio.add_const_set_offset(
95 addr=addr,
96 port=port,
97 device='/dev/dds_offset',
98 const=offset_out1,
99 )
100
101
102 def closeEvent(self, event):
103 self.settings = Qt.QSettings("GNU Radio", "top_block")
104 self.settings.setValue("geometry", self.saveGeometry())
105 event.accept()
106
107 def get_samp_rate(self):
108 return self.samp_rate
109
110 def set_samp_rate(self, samp_rate):
111 self.samp_rate = samp_rate
112
113 def get_port(self):
114 return self.port
115
116 def set_port(self, port):
117 self.port = port
118
119 def get_offset_out1(self):
120 return self.offset_out1
121
122 def set_offset_out1(self, offset_out1):
123 self.offset_out1 = offset_out1
124 self.add_const_set_offset_0.set_const(device='/dev/dds_offset', const=self.offset_out1)
125
126 def get_f_dds(self):
127 return self.f_dds
128
129 def set_f_dds(self, f_dds):
130 self.f_dds = f_dds
131 self.nco_counter_send_conf_0.set_nco(device='/dev/dds_freq', freq_ref=125000000, freq_dds=self.f_dds, acc_size=32, offset=0)
132
133 def get_addr(self):
134 return self.addr
135
136 def set_addr(self, addr):
redpitaya/gnuradio_blocks/dds_control.grc
<?xml version='1.0' encoding='utf-8'?> 1 1 <?xml version='1.0' encoding='utf-8'?>
<?grc format='1' created='3.7.10'?> 2 2 <?grc format='1' created='3.7.10'?>
<flow_graph> 3 3 <flow_graph>
<timestamp>Thu Feb 2 22:54:58 2017</timestamp> 4 4 <timestamp>Thu Feb 2 22:54:58 2017</timestamp>
<block> 5 5 <block>
<key>options</key> 6 6 <key>options</key>
<param> 7 7 <param>
<key>author</key> 8 8 <key>author</key>
<value></value> 9 9 <value></value>
</param> 10 10 </param>
<param> 11 11 <param>
<key>window_size</key> 12 12 <key>window_size</key>
<value></value> 13 13 <value></value>
</param> 14 14 </param>
<param> 15 15 <param>
<key>category</key> 16 16 <key>category</key>
<value>[GRC Hier Blocks]</value> 17 17 <value>[GRC Hier Blocks]</value>
</param> 18 18 </param>
<param> 19 19 <param>
<key>comment</key> 20 20 <key>comment</key>
<value></value> 21 21 <value></value>
</param> 22 22 </param>
<param> 23 23 <param>
<key>description</key> 24 24 <key>description</key>
<value></value> 25 25 <value></value>
</param> 26 26 </param>
<param> 27 27 <param>
<key>_enabled</key> 28 28 <key>_enabled</key>
<value>True</value> 29 29 <value>True</value>
</param> 30 30 </param>
<param> 31 31 <param>
<key>_coordinate</key> 32 32 <key>_coordinate</key>
<value>(8, 8)</value> 33 33 <value>(8, 8)</value>
</param> 34 34 </param>
<param> 35 35 <param>
<key>_rotation</key> 36 36 <key>_rotation</key>
<value>0</value> 37 37 <value>0</value>
</param> 38 38 </param>
<param> 39 39 <param>
<key>generate_options</key> 40 40 <key>generate_options</key>
<value>qt_gui</value> 41 41 <value>qt_gui</value>
</param> 42 42 </param>
<param> 43 43 <param>
<key>hier_block_src_path</key> 44 44 <key>hier_block_src_path</key>
<value>.:</value> 45 45 <value>.:</value>
</param> 46 46 </param>
<param> 47 47 <param>
<key>id</key> 48 48 <key>id</key>
<value>top_block</value> 49 49 <value>top_block</value>
</param> 50 50 </param>
<param> 51 51 <param>
<key>max_nouts</key> 52 52 <key>max_nouts</key>
<value>0</value> 53 53 <value>0</value>
</param> 54 54 </param>
<param> 55 55 <param>
<key>qt_qss_theme</key> 56 56 <key>qt_qss_theme</key>
<value></value> 57 57 <value></value>
</param> 58 58 </param>
<param> 59 59 <param>
<key>realtime_scheduling</key> 60 60 <key>realtime_scheduling</key>
<value></value> 61 61 <value></value>
</param> 62 62 </param>
<param> 63 63 <param>
<key>run_command</key> 64 64 <key>run_command</key>
<value>{python} -u {filename}</value> 65 65 <value>{python} -u {filename}</value>
</param> 66 66 </param>
<param> 67 67 <param>
<key>run_options</key> 68 68 <key>run_options</key>
<value>prompt</value> 69 69 <value>prompt</value>
</param> 70 70 </param>
<param> 71 71 <param>
<key>run</key> 72 72 <key>run</key>
<value>True</value> 73 73 <value>True</value>
</param> 74 74 </param>
<param> 75 75 <param>
<key>thread_safe_setters</key> 76 76 <key>thread_safe_setters</key>
<value></value> 77 77 <value></value>
</param> 78 78 </param>
<param> 79 79 <param>
<key>title</key> 80 80 <key>title</key>
<value></value> 81 81 <value></value>
</param> 82 82 </param>
</block> 83 83 </block>
<block> 84 84 <block>
<key>variable_qtgui_range</key> 85 85 <key>variable_qtgui_range</key>
<param> 86 86 <param>
<key>comment</key> 87 87 <key>comment</key>
<value></value> 88 88 <value></value>
</param> 89 89 </param>
<param> 90 90 <param>
<key>value</key> 91 91 <key>value</key>
<value>0</value> 92 92 <value>0</value>
</param> 93 93 </param>
<param> 94 94 <param>
<key>_enabled</key> 95 95 <key>_enabled</key>
<value>True</value> 96 96 <value>True</value>
</param> 97 97 </param>
<param> 98 98 <param>
<key>_coordinate</key> 99 99 <key>_coordinate</key>
<value>(704, 24)</value> 100 100 <value>(704, 24)</value>
</param> 101 101 </param>
<param> 102 102 <param>
<key>gui_hint</key> 103 103 <key>gui_hint</key>
<value>1, 0</value> 104 104 <value>1, 0</value>
</param> 105 105 </param>
<param> 106 106 <param>
<key>_rotation</key> 107 107 <key>_rotation</key>
<value>0</value> 108 108 <value>0</value>
</param> 109 109 </param>
<param> 110 110 <param>
<key>id</key> 111 111 <key>id</key>
<value>a_dds</value> 112 112 <value>a_dds</value>
</param> 113 113 </param>
<param> 114 114 <param>
<key>label</key> 115 115 <key>label</key>
<value>DDS amplitude</value> 116 116 <value>DDS amplitude</value>
</param> 117 117 </param>
<param> 118 118 <param>
<key>min_len</key> 119 119 <key>min_len</key>
<value>200</value> 120 120 <value>200</value>
</param> 121 121 </param>
<param> 122 122 <param>
<key>orient</key> 123 123 <key>orient</key>
<value>Qt.Horizontal</value> 124 124 <value>Qt.Horizontal</value>
</param> 125 125 </param>
<param> 126 126 <param>
<key>start</key> 127 127 <key>start</key>
<value>0</value> 128 128 <value>0</value>
</param> 129 129 </param>
<param> 130 130 <param>
<key>step</key> 131 131 <key>step</key>
<value>128</value> 132 132 <value>128</value>
</param> 133 133 </param>
<param> 134 134 <param>
<key>stop</key> 135 135 <key>stop</key>
<value>8191</value> 136 136 <value>8191</value>
</param> 137 137 </param>
<param> 138 138 <param>
<key>rangeType</key> 139 139 <key>rangeType</key>
<value>int</value> 140 140 <value>int</value>
</param> 141 141 </param>
<param> 142 142 <param>
<key>widget</key> 143 143 <key>widget</key>
<value>counter_slider</value> 144 144 <value>counter_slider</value>
</param> 145 145 </param>
</block> 146 146 </block>
<block> 147 147 <block>
148 <key>variable</key>
149 <param>
150 <key>comment</key>
151 <value></value>
152 </param>
153 <param>
154 <key>_enabled</key>
155 <value>True</value>
156 </param>
157 <param>
158 <key>_coordinate</key>
159 <value>(0, 248)</value>
160 </param>
161 <param>
162 <key>_rotation</key>
163 <value>0</value>
164 </param>
165 <param>
166 <key>id</key>
167 <value>addr</value>
168 </param>
169 <param>
170 <key>value</key>
171 <value>"192.168.0.202"</value>
172 </param>
173 </block>
174 <block>
<key>variable_qtgui_range</key> 148 175 <key>variable_qtgui_range</key>
<param> 149 176 <param>
<key>comment</key> 150 177 <key>comment</key>
<value></value> 151 178 <value></value>
</param> 152 179 </param>
<param> 153 180 <param>
<key>value</key> 154 181 <key>value</key>
<value>0</value> 155 182 <value>0</value>
</param> 156 183 </param>
<param> 157 184 <param>
<key>_enabled</key> 158 185 <key>_enabled</key>
<value>True</value> 159 186 <value>True</value>
</param> 160 187 </param>
<param> 161 188 <param>
<key>_coordinate</key> 162 189 <key>_coordinate</key>
<value>(488, 24)</value> 163 190 <value>(488, 24)</value>
</param> 164 191 </param>
<param> 165 192 <param>
<key>gui_hint</key> 166 193 <key>gui_hint</key>
<value>0, 0</value> 167 194 <value>0, 0</value>
</param> 168 195 </param>
<param> 169 196 <param>
<key>_rotation</key> 170 197 <key>_rotation</key>
<value>0</value> 171 198 <value>0</value>
</param> 172 199 </param>
<param> 173 200 <param>
<key>id</key> 174 201 <key>id</key>
<value>f_dds</value> 175 202 <value>f_dds</value>
</param> 176 203 </param>
<param> 177 204 <param>
<key>label</key> 178 205 <key>label</key>
<value>DDS frequency</value> 179 206 <value>DDS frequency</value>
</param> 180 207 </param>
<param> 181 208 <param>
<key>min_len</key> 182 209 <key>min_len</key>
<value>200</value> 183 210 <value>200</value>
</param> 184 211 </param>
<param> 185 212 <param>
<key>orient</key> 186 213 <key>orient</key>
<value>Qt.Horizontal</value> 187 214 <value>Qt.Horizontal</value>
</param> 188 215 </param>
<param> 189 216 <param>
<key>start</key> 190 217 <key>start</key>
<value>0</value> 191 218 <value>0</value>
</param> 192 219 </param>
<param> 193 220 <param>
<key>step</key> 194 221 <key>step</key>
<value>100000</value> 195 222 <value>100000</value>
</param> 196 223 </param>
<param> 197 224 <param>
<key>stop</key> 198 225 <key>stop</key>
<value>60000000</value> 199 226 <value>60000000</value>
</param> 200 227 </param>
<param> 201 228 <param>
<key>rangeType</key> 202 229 <key>rangeType</key>
<value>int</value> 203 230 <value>int</value>
</param> 204 231 </param>
<param> 205 232 <param>
<key>widget</key> 206 233 <key>widget</key>
<value>counter_slider</value> 207 234 <value>counter_slider</value>
</param> 208 235 </param>
</block> 209 236 </block>
<block> 210 237 <block>
<key>variable_qtgui_range</key> 211 238 <key>variable_qtgui_range</key>
<param> 212 239 <param>
<key>comment</key> 213 240 <key>comment</key>
<value></value> 214 241 <value></value>
</param> 215 242 </param>
<param> 216 243 <param>
<key>value</key> 217 244 <key>value</key>
<value>0</value> 218 245 <value>0</value>
</param> 219 246 </param>
<param> 220 247 <param>
<key>_enabled</key> 221 248 <key>_enabled</key>
<value>True</value> 222 249 <value>True</value>
</param> 223 250 </param>
<param> 224 251 <param>
<key>_coordinate</key> 225 252 <key>_coordinate</key>
<value>(328, 24)</value> 226 253 <value>(328, 24)</value>
</param> 227 254 </param>
<param> 228 255 <param>
<key>gui_hint</key> 229 256 <key>gui_hint</key>
<value>2, 0</value> 230 257 <value>2, 0</value>
</param> 231 258 </param>
<param> 232 259 <param>
<key>_rotation</key> 233 260 <key>_rotation</key>
<value>0</value> 234 261 <value>0</value>
</param> 235 262 </param>
<param> 236 263 <param>
<key>id</key> 237 264 <key>id</key>
<value>offset_out1</value> 238 265 <value>offset_out1</value>
</param> 239 266 </param>
<param> 240 267 <param>
<key>label</key> 241 268 <key>label</key>
<value>Offset DDS</value> 242 269 <value>Offset DDS</value>
</param> 243 270 </param>
<param> 244 271 <param>
<key>min_len</key> 245 272 <key>min_len</key>
<value>200</value> 246 273 <value>200</value>
</param> 247 274 </param>
<param> 248 275 <param>
<key>orient</key> 249 276 <key>orient</key>
<value>Qt.Horizontal</value> 250 277 <value>Qt.Horizontal</value>
</param> 251 278 </param>
<param> 252 279 <param>
<key>start</key> 253 280 <key>start</key>
<value>-8192</value> 254 281 <value>-8192</value>
</param> 255 282 </param>
<param> 256 283 <param>
<key>step</key> 257 284 <key>step</key>
<value>100</value> 258 285 <value>100</value>
</param> 259 286 </param>
<param> 260 287 <param>
<key>stop</key> 261 288 <key>stop</key>
<value>8191</value> 262 289 <value>8191</value>
</param> 263 290 </param>
<param> 264 291 <param>
<key>rangeType</key> 265 292 <key>rangeType</key>
<value>int</value> 266 293 <value>int</value>
</param> 267 294 </param>
<param> 268 295 <param>
<key>widget</key> 269 296 <key>widget</key>
<value>counter_slider</value> 270 297 <value>counter_slider</value>
</param> 271 298 </param>
</block> 272 299 </block>
<block> 273 300 <block>
<key>variable</key> 274 301 <key>variable</key>
<param> 275 302 <param>
<key>comment</key> 276 303 <key>comment</key>
<value></value> 277 304 <value></value>
</param> 278 305 </param>
<param> 279 306 <param>
<key>_enabled</key> 280 307 <key>_enabled</key>
<value>True</value> 281 308 <value>True</value>
</param> 282 309 </param>
<param> 283 310 <param>
<key>_coordinate</key> 284 311 <key>_coordinate</key>
312 <value>(0, 320)</value>
313 </param>
314 <param>
315 <key>_rotation</key>
316 <value>0</value>
317 </param>
318 <param>
319 <key>id</key>
320 <value>port</value>
321 </param>
322 <param>
323 <key>value</key>
324 <value>1001</value>
325 </param>
326 </block>
327 <block>
328 <key>variable</key>
329 <param>
330 <key>comment</key>
331 <value></value>
332 </param>
333 <param>
334 <key>_enabled</key>
335 <value>True</value>
336 </param>
337 <param>
338 <key>_coordinate</key>
<value>(8, 160)</value> 285 339 <value>(8, 160)</value>
</param> 286 340 </param>
<param> 287 341 <param>
<key>_rotation</key> 288 342 <key>_rotation</key>
<value>0</value> 289 343 <value>0</value>
</param> 290 344 </param>
<param> 291 345 <param>
<key>id</key> 292 346 <key>id</key>
<value>samp_rate</value> 293 347 <value>samp_rate</value>
</param> 294 348 </param>
<param> 295 349 <param>
<key>value</key> 296 350 <key>value</key>
<value>32000</value> 297 351 <value>32000</value>
</param> 298 352 </param>
</block> 299 353 </block>
<block> 300 354 <block>
<key>add_const_set_offset</key> 301 355 <key>add_const_set_offset</key>
<param> 302 356 <param>
<key>addr</key> 303 357 <key>addr</key>
<value>192.168.0.201</value> 304 358 <value>addr</value>
</param> 305 359 </param>
<param> 306 360 <param>
<key>alias</key> 307 361 <key>alias</key>
<value></value> 308 362 <value></value>
</param> 309 363 </param>
<param> 310 364 <param>
<key>comment</key> 311 365 <key>comment</key>
<value></value> 312 366 <value></value>
</param> 313 367 </param>
<param> 314 368 <param>
<key>const</key> 315 369 <key>const</key>
<value>offset_out1</value> 316 370 <value>offset_out1</value>
</param> 317 371 </param>
<param> 318 372 <param>
<key>device</key> 319 373 <key>device</key>
<value>/dev/dds1_offset</value> 320 374 <value>/dev/dds_offset</value>
</param> 321 375 </param>
<param> 322 376 <param>
<key>_enabled</key> 323 377 <key>_enabled</key>
<value>True</value> 324 378 <value>True</value>
</param> 325 379 </param>
<param> 326 380 <param>
<key>_coordinate</key> 327 381 <key>_coordinate</key>
<value>(304, 176)</value> 328 382 <value>(304, 176)</value>
</param> 329 383 </param>
<param> 330 384 <param>
<key>_rotation</key> 331 385 <key>_rotation</key>
<value>0</value> 332 386 <value>0</value>
</param> 333 387 </param>
<param> 334 388 <param>
<key>id</key> 335 389 <key>id</key>
<value>add_const_set_offset_0</value> 336 390 <value>add_const_set_offset_0</value>
</param> 337 391 </param>
<param> 338 392 <param>
<key>port</key> 339 393 <key>port</key>
<value>1001</value> 340 394 <value>port</value>
</param> 341 395 </param>
</block> 342 396 </block>
<block> 343 397 <block>
<key>add_const_set_offset</key> 344 398 <key>add_const_set_offset</key>
<param> 345 399 <param>
<key>addr</key> 346 400 <key>addr</key>
<value>192.168.0.201</value> 347 401 <value>addr</value>
</param> 348 402 </param>
<param> 349 403 <param>
<key>alias</key> 350 404 <key>alias</key>
<value></value> 351 405 <value></value>
</param> 352 406 </param>
<param> 353 407 <param>
<key>comment</key> 354 408 <key>comment</key>
<value></value> 355 409 <value></value>
</param> 356 410 </param>
<param> 357 411 <param>
<key>const</key> 358 412 <key>const</key>
<value>a_dds</value> 359 413 <value>a_dds</value>
</param> 360 414 </param>
<param> 361 415 <param>
<key>device</key> 362 416 <key>device</key>
<value>/dev/dds1_ampl</value> 363 417 <value>/dev/dds_ampl</value>
</param> 364 418 </param>
<param> 365 419 <param>
<key>_enabled</key> 366 420 <key>_enabled</key>
<value>True</value> 367 421 <value>True</value>
</param> 368 422 </param>
<param> 369 423 <param>
<key>_coordinate</key> 370 424 <key>_coordinate</key>
<value>(704, 176)</value> 371 425 <value>(704, 176)</value>
</param> 372 426 </param>
<param> 373 427 <param>
<key>_rotation</key> 374 428 <key>_rotation</key>
<value>0</value> 375 429 <value>0</value>
</param> 376 430 </param>
<param> 377 431 <param>
<key>id</key> 378 432 <key>id</key>
<value>add_const_set_offset_0_0</value> 379 433 <value>add_const_set_offset_0_0</value>
</param> 380 434 </param>
<param> 381 435 <param>
<key>port</key> 382 436 <key>port</key>
<value>1001</value> 383 437 <value>port</value>
</param> 384 438 </param>
</block> 385 439 </block>
<block> 386 440 <block>
<key>nco_counter_send_conf</key> 387 441 <key>nco_counter_send_conf</key>
<param> 388 442 <param>
<key>acc_size</key> 389 443 <key>acc_size</key>
<value>32</value> 390 444 <value>32</value>
</param> 391 445 </param>
<param> 392 446 <param>
<key>addr</key> 393 447 <key>addr</key>
<value>192.168.0.201</value> 394 448 <value>addr</value>
</param> 395 449 </param>
<param> 396 450 <param>
<key>alias</key> 397 451 <key>alias</key>
<value></value> 398 452 <value></value>
</param> 399 453 </param>
<param> 400 454 <param>
<key>comment</key> 401 455 <key>comment</key>
<value></value> 402 456 <value></value>
</param> 403 457 </param>
<param> 404 458 <param>
<key>device</key> 405 459 <key>device</key>
<value>/dev/dds1_freq</value> 406 460 <value>/dev/dds_freq</value>
</param> 407 461 </param>
<param> 408 462 <param>
<key>_enabled</key> 409 463 <key>_enabled</key>
<value>True</value> 410 464 <value>True</value>
</param> 411 465 </param>
<param> 412 466 <param>
<key>freq_dds</key> 413 467 <key>freq_dds</key>
<value>f_dds</value> 414 468 <value>f_dds</value>
</param> 415 469 </param>
<param> 416 470 <param>
<key>freq_ref</key> 417 471 <key>freq_ref</key>
<value>125000000</value> 418 472 <value>125000000</value>
</param> 419 473 </param>
<param> 420 474 <param>
<key>_coordinate</key> 421 475 <key>_coordinate</key>
<value>(488, 176)</value> 422 476 <value>(488, 176)</value>
</param> 423 477 </param>
<param> 424 478 <param>
<key>_rotation</key> 425 479 <key>_rotation</key>
<value>0</value> 426 480 <value>0</value>
</param> 427 481 </param>
<param> 428 482 <param>
<key>id</key> 429 483 <key>id</key>
<value>nco_counter_send_conf_0</value> 430 484 <value>nco_counter_send_conf_0</value>
</param> 431 485 </param>
<param> 432 486 <param>
<key>offset</key> 433 487 <key>offset</key>
<value>0</value> 434 488 <value>0</value>
</param> 435 489 </param>
<param> 436 490 <param>
<key>port</key> 437 491 <key>port</key>
<value>1001</value> 438 492 <value>port</value>
</param> 439 493 </param>
</block> 440 494 </block>
</flow_graph> 441 495 </flow_graph>
442 496
redpitaya/gnuradio_blocks/gr_source_test.xml
File was created 1 <?xml version="1.0"?>
2 <!--
3 # GNU Radio blocks for the Red Pitaya transceiver
4 # Copyright (C) 2015 Renzo Davoli
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 -->
20 <block>
21 <name>source_test</name>
22 <key>source_test</key>
23 <category>Red Pitaya</category>
24 <import>import redpitaya_gnuradio</import>
25 <make>redpitaya_gnuradio.source_test()</make>
26 <source>
27 <name>out</name>
28 <type>complex</type>
29 </source>
30 </block>
redpitaya/gnuradio_blocks/gr_source_test.xml.old
File was created 1 <?xml version="1.0"?>
2 <!--
3 # GNU Radio blocks for the Red Pitaya transceiver
4 # Copyright (C) 2015 Renzo Davoli
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 -->
20 <block>
21 <name>source_test</name>
22 <key>source_test</key>
23 <category>Red Pitaya</category>
24 <import>import redpitaya_gnuradio</import>
25 <make>redpitaya_gnuradio.source_test()</make>
26 <source>
27 <name>out</name>
28 <type>complex</type>
29 </source>
30 </block>
redpitaya/gnuradio_blocks/redpitaya_gnuradio.py
#!/usr/bin/env python 1 1 #!/usr/bin/env python
2 2
# GNU Radio blocks for the Red Pitaya transceiver 3 3 # GNU Radio blocks for the Red Pitaya transceiver
# Copyright (C) 2015 Renzo Davoli 4 4 # Copyright (C) 2015 Renzo Davoli
# 5 5 #
# This program is free software; you can redistribute it and/or 6 6 # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License 7 7 # modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2 8 8 # as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. 9 9 # of the License, or (at your option) any later version.
# 10 10 #
# This program is distributed in the hope that it will be useful, 11 11 # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of 12 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. 14 14 # GNU General Public License for more details.
# 15 15 #
# You should have received a copy of the GNU General Public License 16 16 # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software 17 17 # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 19
import socket 20 20 import socket, os
from gnuradio import gr, blocks 21 21 from gnuradio import gr, blocks
22 22
class add_const_set_offset(gr.hier_block2): 23 23 class add_const_set_offset(gr.hier_block2):
def __init__(self, addr, port, device, const): 24 24 def __init__(self, addr, port, device, const):
self.name = "add_const_set_offset" 25 25 self.name = "add_const_set_offset"
gr.hier_block2.__init__( 26 26 gr.hier_block2.__init__(
self, 27 27 self,
name = self.name, 28 28 name = self.name,
input_signature = gr.io_signature(0, 0, 0), 29 29 input_signature = gr.io_signature(0, 0, 0),
output_signature = gr.io_signature(0, 0, 0) 30 30 output_signature = gr.io_signature(0, 0, 0)
) 31 31 )
self.ctrl_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 32 32 self.ctrl_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.ctrl_sock.connect((addr, port)) 33 33 self.ctrl_sock.connect((addr, port))
self.set_const(device, const) 34 34 self.set_const(device, const)
35 35
def set_const(self, device, const): 36 36 def set_const(self, device, const):
self.ctrl_sock.send('%s;%s;%i\n'%(self.name, device, const)) 37 37 self.ctrl_sock.send('%s;%s;%i\n'%(self.name, device, const))
38 38
39 39
class nco_counter_send_conf(gr.hier_block2): 40 40 class nco_counter_send_conf(gr.hier_block2):
def __init__(self, addr, port, device, freq_ref, freq_dds, acc_size, offset): 41 41 def __init__(self, addr, port, device, freq_ref, freq_dds, acc_size, offset):
self.name = "nco_counter_send_conf" 42 42 self.name = "nco_counter_send_conf"
gr.hier_block2.__init__( 43 43 gr.hier_block2.__init__(
self, 44 44 self,
name = self.name, 45 45 name = self.name,
input_signature = gr.io_signature(0, 0, 0), 46 46 input_signature = gr.io_signature(0, 0, 0),
output_signature = gr.io_signature(0, 0, 0) 47 47 output_signature = gr.io_signature(0, 0, 0)
) 48 48 )
self.ctrl_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 49 49 self.ctrl_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.ctrl_sock.connect((addr, port)) 50 50 self.ctrl_sock.connect((addr, port))
self.set_nco(device, freq_ref, freq_dds, acc_size, offset) 51 51 self.set_nco(device, freq_ref, freq_dds, acc_size, offset)
52 52
def set_nco(self, device, freq_ref, freq_dds, acc_size, offset): 53 53 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)) 54 54 self.ctrl_sock.send('%s;%s;%i;%i;%i;%i\n'%(self.name, device, freq_ref, freq_dds, acc_size, offset))
55
56 '''~
57 class source_test(gr.hier_block2):
58 def __init__(self):
59 self.name = "source_test"
60 gr.hier_block2.__init__(
61 self,
62 name = self.name,
63 input_signature = gr.io_signature(0, 0, 0),
64 output_signature = gr.io_signature(1, 1, gr.sizeof_gr_complex)
65 )
redpitaya/gnuradio_blocks/redpitaya_gnuradio.pyc
No preview for this file type
redpitaya/gnuradio_blocks/top_block.py
File was created 1 #!/usr/bin/env python2
2 # -*- coding: utf-8 -*-
3 ##################################################
4 # GNU Radio Python Flow Graph
5 # Title: Top Block
6 # Generated: Mon Feb 13 22:24:05 2017
7 ##################################################
8
9 if __name__ == '__main__':
10 import ctypes
11 import sys
12 if sys.platform.startswith('linux'):
13 try:
14 x11 = ctypes.cdll.LoadLibrary('libX11.so')
15 x11.XInitThreads()
16 except:
17 print "Warning: failed to XInitThreads()"
18
19 from PyQt4 import Qt
20 from gnuradio import eng_notation
21 from gnuradio import gr
22 from gnuradio.eng_option import eng_option
23 from gnuradio.filter import firdes
24 from gnuradio.qtgui import Range, RangeWidget
25 from optparse import OptionParser
26 import redpitaya_gnuradio
27 import sys
28
29
30 class top_block(gr.top_block, Qt.QWidget):
31
32 def __init__(self):
33 gr.top_block.__init__(self, "Top Block")
34 Qt.QWidget.__init__(self)
35 self.setWindowTitle("Top Block")
36 try:
37 self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
38 except:
39 pass
40 self.top_scroll_layout = Qt.QVBoxLayout()
41 self.setLayout(self.top_scroll_layout)
42 self.top_scroll = Qt.QScrollArea()
43 self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
44 self.top_scroll_layout.addWidget(self.top_scroll)
45 self.top_scroll.setWidgetResizable(True)
46 self.top_widget = Qt.QWidget()
47 self.top_scroll.setWidget(self.top_widget)
48 self.top_layout = Qt.QVBoxLayout(self.top_widget)
49 self.top_grid_layout = Qt.QGridLayout()
50 self.top_layout.addLayout(self.top_grid_layout)
51
52 self.settings = Qt.QSettings("GNU Radio", "top_block")
53 self.restoreGeometry(self.settings.value("geometry").toByteArray())
54
55 ##################################################
56 # Variables
57 ##################################################
58 self.samp_rate = samp_rate = 32000
59 self.port = port = 1001
60 self.offset_out1 = offset_out1 = 0
61 self.f_dds = f_dds = 0
62 self.addr = addr = "192.168.0.202"
63 self.a_dds = a_dds = 0
64
65 ##################################################
66 # Blocks
67 ##################################################
68 self._offset_out1_range = Range(-8192, 8191, 100, 0, 200)
69 self._offset_out1_win = RangeWidget(self._offset_out1_range, self.set_offset_out1, 'Offset DDS', "counter_slider", int)
70 self.top_grid_layout.addWidget(self._offset_out1_win, 2, 0)
71 self._f_dds_range = Range(0, 60000000, 100000, 0, 200)
72 self._f_dds_win = RangeWidget(self._f_dds_range, self.set_f_dds, 'DDS frequency', "counter_slider", int)
73 self.top_grid_layout.addWidget(self._f_dds_win, 0, 0)
74 self._a_dds_range = Range(0, 8191, 128, 0, 200)
75 self._a_dds_win = RangeWidget(self._a_dds_range, self.set_a_dds, 'DDS amplitude', "counter_slider", int)
76 self.top_grid_layout.addWidget(self._a_dds_win, 1, 0)
77 self.nco_counter_send_conf_0 = redpitaya_gnuradio.nco_counter_send_conf(
78 addr=addr,
79 port=port,
80 device='/dev/dds_freq',
81 freq_ref=125000000,
82 freq_dds=f_dds,
83 acc_size=32,
84 offset=0,
85 )
86
87 self.add_const_set_offset_0_0 = redpitaya_gnuradio.add_const_set_offset(
88 addr=addr,
89 port=port,
90 device='/dev/dds_ampl',
91 const=a_dds,
92 )
93
94 self.add_const_set_offset_0 = redpitaya_gnuradio.add_const_set_offset(
95 addr=addr,
96 port=port,
97 device='/dev/dds_offset',
98 const=offset_out1,
99 )
100
101
102 def closeEvent(self, event):
103 self.settings = Qt.QSettings("GNU Radio", "top_block")
104 self.settings.setValue("geometry", self.saveGeometry())
105 event.accept()
106
107 def get_samp_rate(self):
108 return self.samp_rate
109
110 def set_samp_rate(self, samp_rate):
111 self.samp_rate = samp_rate
112
113 def get_port(self):
114 return self.port
115
116 def set_port(self, port):
117 self.port = port
118
119 def get_offset_out1(self):
120 return self.offset_out1
121
122 def set_offset_out1(self, offset_out1):
123 self.offset_out1 = offset_out1
124 self.add_const_set_offset_0.set_const(device='/dev/dds_offset', const=self.offset_out1)
125
126 def get_f_dds(self):
127 return self.f_dds
128
129 def set_f_dds(self, f_dds):
130 self.f_dds = f_dds
131 self.nco_counter_send_conf_0.set_nco(device='/dev/dds_freq', freq_ref=125000000, freq_dds=self.f_dds, acc_size=32, offset=0)
132
133 def get_addr(self):
134 return self.addr
135
136 def set_addr(self, addr):
redpitaya/server/server.py
#!/usr/bin/env python 1 1 #!/usr/bin/env python
2
import socket 2 3 import socket
from thread import start_new_thread 3 4 from thread import start_new_thread
import liboscimp_fpga 4 5 import liboscimp_fpga
5 6
ctrl_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 6
ctrl_sock.bind(('', 1001)) 7
ctrl_sock.listen(10) 8
9
def clientThread(conn, addr): 10 7 def clientThread(conn, addr):
print('Open connection from ' + addr[0] + ':' + str(addr[1]) + '\n') 11 8 print('Open connection from ' + addr[0] + ':' + str(addr[1]) + '\n')
while True: 12 9 while True:
data = '' 13 10 data = ''
while '\n' not in data: 14 11 while '\n' not in data:
data += conn.recv(8) 15 12 data += conn.recv(8)
recv = data.split(';') 16 13 recv = data.split(';')
if recv[0] == "add_const_set_offset": 17 14 if recv[0] == "add_const_set_offset":
try: 18 15 try:
liboscimp_fpga.add_const_set_offset(recv[1], int(recv[2])) 19 16 liboscimp_fpga.add_const_set_offset(recv[1], int(recv[2]))
except: 20 17 except:
pass 21 18 pass
if recv[0] == "nco_counter_send_conf": 22 19 if recv[0] == "nco_counter_send_conf":
try: 23 20 try:
liboscimp_fpga.nco_counter_send_conf(recv[1], int(recv[2]), int(recv[3]), int(recv[4]), int(recv[5])) 24 21 liboscimp_fpga.nco_counter_send_conf(recv[1], int(recv[2]), int(recv[3]), int(recv[4]), int(recv[5]))
except: 25 22 except:
pass 26 23 pass
conn.close() 27 24 conn.close()
28 25
while 1: 29 26 ctrl_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
conn, addr = ctrl_sock.accept() 30 27 ctrl_sock.bind(('', 1001))
start_new_thread(clientThread ,(conn, addr,)) 31 28 ctrl_sock.listen(10)
32 29
ctrl_sock.close() 33 30 try:
31 while True:
32 conn, addr = ctrl_sock.accept()
33 start_new_thread(clientThread ,(conn, addr,))
34 except KeyboardInterrupt:
35 ctrl_sock.close()
34 36
redpitaya/server/test.py
File was created 1 import time
2
3 with open('/dev/data16_adc12', 'r') as f:
4 for line in f:
5 print(line.encode('bin'))
redpitaya/server/test_emb.py
File was created 1 #!/usr/bin/env python
2 import ctypes, argparse
3 import liboscimp_fpga
4
5 def parse():
6 parser = argparse.ArgumentParser(description = 'Set offsets to DAC1 and DAC2')
7 parser.add_argument('-of1',
8 action='store',
9 dest='of1',
10 default=0,
11 help='DAC1 offset (bits)')
12 parser.add_argument('-of2',
13 action='store',
14 dest='of2',
15 default=0,
16 help='DAC2 offset (bits)')
17 args = parser.parse_args()
18 return args
19
20 def main():
21 args = parse()
22 of1 = int(args.of1)
23 of2 = int(args.of2)
24 liboscimp_fpga.add_const_set_offset("/dev/add_const_0", of1)
25 liboscimp_fpga.add_const_set_offset("/dev/add_const_1", of2)
26 print('offset DAC1 : %i'%of1)
27 print('offset DAC2 : %i'%of2)