You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
733 B
39 lines
733 B
7 years ago
|
#!/bin/env python3
|
||
|
import time
|
||
|
|
||
|
import gex
|
||
|
import numpy as np
|
||
|
from matplotlib import pyplot as plt
|
||
|
|
||
|
from scipy.io import wavfile
|
||
|
|
||
|
with gex.Client(gex.TrxRawUSB()) as client:
|
||
7 years ago
|
adc = gex.ADC(client, 'adc')
|
||
7 years ago
|
|
||
7 years ago
|
print(adc.get_calibration_data())
|
||
|
print(adc.get_channels())
|
||
|
|
||
|
adc.set_active_channels([1])
|
||
7 years ago
|
rate=50000
|
||
7 years ago
|
fs = adc.set_sample_rate(rate)
|
||
|
|
||
7 years ago
|
time.sleep(0.1)
|
||
|
count = 5000
|
||
7 years ago
|
data = adc.capture(count)
|
||
7 years ago
|
|
||
7 years ago
|
print("rx, %d samples" % len(data))
|
||
|
data = np.add(data / 4096, -0.5)
|
||
|
|
||
7 years ago
|
adc.set_sample_rate(1000)
|
||
|
|
||
7 years ago
|
#
|
||
7 years ago
|
if data is not None:
|
||
|
# wavfile.write('file.wav', rate, data)
|
||
|
# print("Ok")
|
||
|
|
||
7 years ago
|
plt.plot(data, 'r-', lw=1)
|
||
7 years ago
|
plt.show()
|
||
|
else:
|
||
|
print("Nothing rx")
|
||
|
|