|
|
@ -1,5 +1,8 @@ |
|
|
|
#!/bin/env python3 |
|
|
|
#!/bin/env python3 |
|
|
|
import time |
|
|
|
import time |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from matplotlib import pyplot as plt |
|
|
|
|
|
|
|
|
|
|
|
import gex |
|
|
|
import gex |
|
|
|
|
|
|
|
|
|
|
|
transport = gex.TrxRawUSB(sn='0029002F-42365711-32353530') |
|
|
|
transport = gex.TrxRawUSB(sn='0029002F-42365711-32353530') |
|
|
@ -24,11 +27,46 @@ with gex.Client(transport) as client: |
|
|
|
if True: |
|
|
|
if True: |
|
|
|
adc = gex.ADC(client, 'adc') |
|
|
|
adc = gex.ADC(client, 'adc') |
|
|
|
|
|
|
|
|
|
|
|
print(adc.set_sample_rate(40000)) |
|
|
|
fs = adc.set_sample_rate(1000) |
|
|
|
|
|
|
|
|
|
|
|
# adc.stream_start(lambda data: print(data)) |
|
|
|
data = None |
|
|
|
# time.sleep(5) |
|
|
|
|
|
|
|
|
|
|
|
def capture(rpt): |
|
|
|
|
|
|
|
global data |
|
|
|
|
|
|
|
print("trig'd, %s" % rpt) |
|
|
|
|
|
|
|
data = rpt.data |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# adc.setup_trigger(channel=1, |
|
|
|
|
|
|
|
# level=500, |
|
|
|
|
|
|
|
# count=100, |
|
|
|
|
|
|
|
# pretrigger=100, |
|
|
|
|
|
|
|
# auto=False, |
|
|
|
|
|
|
|
# edge="rising", |
|
|
|
|
|
|
|
# holdoff=200, |
|
|
|
|
|
|
|
# handler=capture) |
|
|
|
|
|
|
|
# |
|
|
|
|
|
|
|
# adc.arm() |
|
|
|
|
|
|
|
# time.sleep(2) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data = adc.capture(1000) |
|
|
|
|
|
|
|
#plt.hist(data) #, 'r.', lw=1) |
|
|
|
|
|
|
|
plt.magnitude_spectrum(data[:,0], Fs=fs, scale='dB', color='C1') |
|
|
|
|
|
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# def lst(data): |
|
|
|
|
|
|
|
# if data is not None: |
|
|
|
|
|
|
|
# print("Rx OK") #data |
|
|
|
|
|
|
|
# else: |
|
|
|
|
|
|
|
# print("Closed.") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# adc.stream_start(lst) |
|
|
|
|
|
|
|
time.sleep(3) |
|
|
|
# adc.stream_stop() |
|
|
|
# adc.stream_stop() |
|
|
|
|
|
|
|
# print("Done.") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# time.sleep(.1) |
|
|
|
# time.sleep(.1) |
|
|
|
# print(adc.get_sample_rate()) |
|
|
|
# print(adc.get_sample_rate()) |
|
|
|
# time.sleep(.1) |
|
|
|
# time.sleep(.1) |
|
|
@ -38,23 +76,23 @@ with gex.Client(transport) as client: |
|
|
|
|
|
|
|
|
|
|
|
# print(adc.capture(200, 5)) |
|
|
|
# print(adc.capture(200, 5)) |
|
|
|
|
|
|
|
|
|
|
|
adc.setup_trigger(channel=1, |
|
|
|
# adc.setup_trigger(channel=1, |
|
|
|
level=700, |
|
|
|
# level=700, |
|
|
|
count=100, |
|
|
|
# count=100, |
|
|
|
pretrigger=15, |
|
|
|
# pretrigger=15, |
|
|
|
auto=True, |
|
|
|
# auto=True, |
|
|
|
edge="falling", |
|
|
|
# edge="falling", |
|
|
|
holdoff=200, |
|
|
|
# holdoff=200, |
|
|
|
handler=lambda rpt: print("Report: %s" % rpt)) |
|
|
|
# handler=lambda rpt: print("Report: %s" % rpt)) |
|
|
|
|
|
|
|
|
|
|
|
print("Armed") |
|
|
|
|
|
|
|
adc.arm() |
|
|
|
|
|
|
|
print("Sleep...") |
|
|
|
|
|
|
|
# adc.force() |
|
|
|
|
|
|
|
# |
|
|
|
# |
|
|
|
# # adc.disarm() |
|
|
|
# print("Armed") |
|
|
|
time.sleep(5) |
|
|
|
# adc.arm() |
|
|
|
adc.disarm() |
|
|
|
# print("Sleep...") |
|
|
|
|
|
|
|
# # adc.force() |
|
|
|
|
|
|
|
# # |
|
|
|
|
|
|
|
# # # adc.disarm() |
|
|
|
|
|
|
|
# time.sleep(5) |
|
|
|
|
|
|
|
# adc.disarm() |
|
|
|
|
|
|
|
|
|
|
|
# print(adc.capture(200, 50)) |
|
|
|
# print(adc.capture(200, 50)) |
|
|
|
|
|
|
|
|
|
|
|