Browse Source

lightnings demo

Ondřej Hruška 1 year ago
parent
commit
5f3e47bcaa
Signed by: Ondřej Hruška <ondra@ondrovo.com> GPG key ID: 2C5FD5035250423D
4 changed files with 58 additions and 32 deletions
  1. 2 0
      .gitignore
  2. 41 0
      demo_adc_lightnings.py
  3. 15 0
      show_nparray.py
  4. 0 32
      test_adc_trig.py

+ 2 - 0
.gitignore View File

@@ -7,6 +7,8 @@ __javascript__/
7 7
 
8 8
 *.wav
9 9
 .idea/
10
+*.npy
11
+*.npz
10 12
 
11 13
 # C extensions
12 14
 *.so

+ 41 - 0
demo_adc_lightnings.py View File

@@ -0,0 +1,41 @@
1
+#!/bin/env python3
2
+import time
3
+
4
+import gex
5
+import numpy as np
6
+from matplotlib import pyplot as plt
7
+import datetime
8
+
9
+from scipy.io import wavfile
10
+
11
+# ADC channel 1 -> 100n -> o -> long wire (antenna)
12
+#                          |
13
+#                          '-> 10k -> GND
14
+
15
+def capture(tr):
16
+    now=datetime.datetime.now()
17
+    now.isoformat()
18
+    data = tr.data
19
+    print("Capture! ")
20
+    print(data)
21
+    np.save("lightning-%s"%now.isoformat(), data)
22
+
23
+with gex.Client(gex.TrxRawUSB()) as client:
24
+    adc = gex.ADC(client, 'adc')
25
+
26
+    adc.on_trigger(capture)
27
+    adc.setup_trigger(1,
28
+                      level=500,
29
+                      count=1000,
30
+                      edge='rising',
31
+                      pretrigger=250,
32
+                      holdoff=500,
33
+                      auto=True)
34
+
35
+    adc.arm()
36
+
37
+    sec = 0
38
+    while True:
39
+        print('%d s' % sec)
40
+        sec += 1
41
+        time.sleep(1)

+ 15 - 0
show_nparray.py View File

@@ -0,0 +1,15 @@
1
+#!/bin/env python3
2
+import time
3
+
4
+import sys
5
+
6
+import gex
7
+import numpy as np
8
+from matplotlib import pyplot as plt
9
+import datetime
10
+
11
+from scipy.io import wavfile
12
+
13
+data = np.load(sys.argv[1])
14
+plt.plot(data, 'r-', lw=1)
15
+plt.show()

+ 0 - 32
test_adc_trig.py View File

@@ -1,32 +0,0 @@
1
-#!/bin/env python3
2
-import time
3
-
4
-import gex
5
-import numpy as np
6
-from matplotlib import pyplot as plt
7
-
8
-from scipy.io import wavfile
9
-
10
-# def show(tr):
11
-#     data = tr.data
12
-#     data = np.add(data / 4096, -0.5)
13
-#     plt.plot(data, 'r-', lw=1)
14
-#     plt.show()
15
-
16
-with gex.Client(gex.TrxRawUSB()) as client:
17
-    adc = gex.ADC(client, 'adc')
18
-
19
-    adc.on_trigger(lambda tr: print(tr.data))
20
-    adc.setup_trigger(1,
21
-                      level=3500,
22
-                      count=500,
23
-                      edge='rising',
24
-                      pretrigger=100,
25
-                      holdoff=100,
26
-                      auto=True)
27
-
28
-    adc.arm()
29
-
30
-    while True:
31
-        print('tick')
32
-        time.sleep(1)