Commit 9d344927ea7cf72107bbf339b94f31f2a7e2c7d2

Authored by bmarechal
0 parents
Exists in master

first commit

Showing 8 changed files with 709 additions and 0 deletions Inline Diff

redpitaya/gnuradio_blocks/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_qtgui_range</key>
149 <param>
150 <key>comment</key>
151 <value></value>
152 </param>
153 <param>
154 <key>value</key>
155 <value>0</value>
156 </param>
157 <param>
158 <key>_enabled</key>
159 <value>True</value>
160 </param>
161 <param>
162 <key>_coordinate</key>
163 <value>(488, 24)</value>
164 </param>
165 <param>
166 <key>gui_hint</key>
167 <value>0, 0</value>
168 </param>
169 <param>
170 <key>_rotation</key>
171 <value>0</value>
172 </param>
173 <param>
174 <key>id</key>
175 <value>f_dds</value>
176 </param>
177 <param>
178 <key>label</key>
179 <value>DDS frequency</value>
180 </param>
181 <param>
182 <key>min_len</key>
183 <value>200</value>
184 </param>
185 <param>
186 <key>orient</key>
187 <value>Qt.Horizontal</value>
188 </param>
189 <param>
190 <key>start</key>
191 <value>0</value>
192 </param>
193 <param>
194 <key>step</key>
195 <value>100000</value>
196 </param>
197 <param>
198 <key>stop</key>
199 <value>60000000</value>
200 </param>
201 <param>
202 <key>rangeType</key>
203 <value>int</value>
204 </param>
205 <param>
206 <key>widget</key>
207 <value>counter_slider</value>
208 </param>
209 </block>
210 <block>
211 <key>variable_qtgui_range</key>
212 <param>
213 <key>comment</key>
214 <value></value>
215 </param>
216 <param>
217 <key>value</key>
218 <value>0</value>
219 </param>
220 <param>
221 <key>_enabled</key>
222 <value>True</value>
223 </param>
224 <param>
225 <key>_coordinate</key>
226 <value>(328, 24)</value>
227 </param>
228 <param>
229 <key>gui_hint</key>
230 <value>2, 0</value>
231 </param>
232 <param>
233 <key>_rotation</key>
234 <value>0</value>
235 </param>
236 <param>
237 <key>id</key>
238 <value>offset_out1</value>
239 </param>
240 <param>
241 <key>label</key>
242 <value>Offset DDS</value>
243 </param>
244 <param>
245 <key>min_len</key>
246 <value>200</value>
247 </param>
248 <param>
249 <key>orient</key>
250 <value>Qt.Horizontal</value>
251 </param>
252 <param>
253 <key>start</key>
254 <value>-8192</value>
255 </param>
256 <param>
257 <key>step</key>
258 <value>100</value>
259 </param>
260 <param>
261 <key>stop</key>
262 <value>8191</value>
263 </param>
264 <param>
265 <key>rangeType</key>
266 <value>int</value>
267 </param>
268 <param>
269 <key>widget</key>
270 <value>counter_slider</value>
271 </param>
272 </block>
273 <block>
274 <key>variable</key>
275 <param>
276 <key>comment</key>
277 <value></value>
278 </param>
279 <param>
280 <key>_enabled</key>
281 <value>True</value>
282 </param>
283 <param>
284 <key>_coordinate</key>
285 <value>(8, 160)</value>
286 </param>
287 <param>
288 <key>_rotation</key>
289 <value>0</value>
290 </param>
291 <param>
292 <key>id</key>
293 <value>samp_rate</value>
294 </param>
295 <param>
296 <key>value</key>
297 <value>32000</value>
298 </param>
299 </block>
300 <block>
301 <key>add_const_set_offset</key>
302 <param>
303 <key>addr</key>
304 <value>192.168.0.201</value>
305 </param>
306 <param>
307 <key>alias</key>
308 <value></value>
309 </param>
310 <param>
311 <key>comment</key>
312 <value></value>
313 </param>
314 <param>
315 <key>const</key>
316 <value>offset_out1</value>
317 </param>
318 <param>
319 <key>device</key>
320 <value>/dev/dds1_offset</value>
321 </param>
322 <param>
323 <key>_enabled</key>
324 <value>True</value>
325 </param>
326 <param>
327 <key>_coordinate</key>
328 <value>(304, 176)</value>
329 </param>
330 <param>
331 <key>_rotation</key>
332 <value>0</value>
333 </param>
334 <param>
335 <key>id</key>
336 <value>add_const_set_offset_0</value>
337 </param>
338 <param>
339 <key>port</key>
340 <value>1001</value>
341 </param>
342 </block>
343 <block>
344 <key>add_const_set_offset</key>
345 <param>
346 <key>addr</key>
347 <value>192.168.0.201</value>
348 </param>
349 <param>
350 <key>alias</key>
351 <value></value>
352 </param>
353 <param>
354 <key>comment</key>
355 <value></value>
356 </param>
357 <param>
358 <key>const</key>
359 <value>a_dds</value>
360 </param>
361 <param>
362 <key>device</key>
363 <value>/dev/dds1_ampl</value>
364 </param>
365 <param>
366 <key>_enabled</key>
367 <value>True</value>
368 </param>
369 <param>
370 <key>_coordinate</key>
371 <value>(704, 176)</value>
372 </param>
373 <param>
374 <key>_rotation</key>
375 <value>0</value>
376 </param>
377 <param>
378 <key>id</key>
379 <value>add_const_set_offset_0_0</value>
380 </param>
381 <param>
382 <key>port</key>
383 <value>1001</value>
384 </param>
385 </block>
386 <block>
387 <key>nco_counter_send_conf</key>
388 <param>
389 <key>acc_size</key>
390 <value>32</value>
391 </param>
392 <param>
393 <key>addr</key>
394 <value>192.168.0.201</value>
395 </param>
396 <param>
397 <key>alias</key>
398 <value></value>
399 </param>
400 <param>
401 <key>comment</key>
402 <value></value>
403 </param>
404 <param>
405 <key>device</key>
406 <value>/dev/dds1_freq</value>
407 </param>
408 <param>
409 <key>_enabled</key>
410 <value>True</value>
411 </param>
412 <param>
413 <key>freq_dds</key>
414 <value>f_dds</value>
415 </param>
416 <param>
417 <key>freq_ref</key>
418 <value>125000000</value>
419 </param>
420 <param>
421 <key>_coordinate</key>
422 <value>(488, 176)</value>
423 </param>
424 <param>
425 <key>_rotation</key>
426 <value>0</value>
427 </param>
428 <param>
429 <key>id</key>
430 <value>nco_counter_send_conf_0</value>
431 </param>
432 <param>
433 <key>offset</key>
434 <value>0</value>
435 </param>
436 <param>
437 <key>port</key>
438 <value>1001</value>
439 </param>
440 </block>
441 </flow_graph>
redpitaya/gnuradio_blocks/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/gnuradio_blocks/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/gnuradio_blocks/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
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)
redpitaya/server/liboscimp_fpga.py
File was created 1 import ctypes
2 lib = ctypes.CDLL('/usr/lib/liboscimp_fpga.so')
3
4 def add_const_set_offset(device, offset):
5 lib.add_const_set_offset(device, offset)
6
redpitaya/server/server.py
File was created 1 #!/usr/bin/env python
2 import socket
3 from thread import start_new_thread
4 import liboscimp_fpga
5
6 ctrl_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
7 ctrl_sock.bind(('', 1001))
8 ctrl_sock.listen(10)
9
10 def clientThread(conn, addr):
11 print('Open connection from ' + addr[0] + ':' + str(addr[1]) + '\n')
12 while True:
13 data = ''
14 while '\n' not in data:
15 data += conn.recv(8)
16 if not data:
17 break
18 recv = data.split(';')
19 if recv[0] == "add_const_set_offset":
20 try:
21 liboscimp_fpga.add_const_set_offset(recv[1], int(recv[2]))
22 except:
23 pass
24 if recv[0] == "nco_counter_send_conf":
25 try:
26 liboscimp_fpga.nco_counter_send_conf(recv[1], int(recv[2]), int(recv[3]), int(recv[4]), int(recv[5]))
27 except:
28 pass
29 conn.close()
30
31 while 1:
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)