我需要在Beaglebone Black上通过(50-60Hz)
采样模拟信号AIN0
。
我需要的是样本大小为10,000
,采样率为1毫秒(should run for 10 secs)
。
我在beaglebone_pru_adc库中找到的python示例如下 -
import beaglebone_pru_adc as adc
import time
numsamples = 10000 # how many samples to capture
capture = adc.Capture()
capture.oscilloscope_init(adc.OFF_VALUES, numsamples) # captures AIN0 - the first elt in AIN array
capture.cap_delay = 200000 # I don't understand how to write this part to achieve desired sampling rate
capture.start()
for _ in range(10):
if capture.oscilloscope_is_complete():
break
print '.'
time.sleep(0.1)
capture.stop()
capture.wait()
print 'Saving oscilloscope values to "data.csv"'
with open('data.csv', 'w') as f:
for x in capture.oscilloscope_data(numsamples):
f.write(str(x) + '\n')
print 'done'
capture.close()
我认为我错了,因为我不希望收购在10 secs
之前完成。有关如何以特定采样率为BB ADC实现特定样本量的任何帮助都将是非常有用的。