The problems:
1. Running the a python script (modified from the Adafruit example and based on SMBus) with a 1 second total sampling time results in anywhere between 230 and 260 samples being collected. I.e., running the same script over and over produces different effective sampling rates.
2. Samples are lost in the collection.
The evidence:
I observe SCL on a scope, and the missing data are commensurate with loss of the clock signal. I am using a 5 Vpp triangle waveform, cycling at 1 Hz with 2.5 VDC offset.
Some notes: Take a look at . Looks pretty good, right? I thought so, until I plotted the data with points: . Note the missing data around 0.8 sec, 4.5 sec, 5.5 sec and 9.5 sec. I need an explanation for this. And it's not just individual points. See . From about 118.5 to 119 seconds, there is no data.
Here is the core of the Python script I was using to collect the data:
Code: Select all
adc = ADS1115()
INTERVAL = 1/340.0
COLLECT_INTERVAL = 1000
counter = 0
time_last_read = time.time()
adc.configADCSingleEnded()
start_time = time.time()
while (time.time() - start_time < COLLECT_INTERVAL):
etime = time.time() - time_last_read
if (etime > INTERVAL):
counter = counter + 1
result = adc.readADCSingleEnded()
print time.time() - start_time, "\t %.6f" % ((result * 0.1875) / 1000.0), "\t", counter, etime
time_last_read = time.time()
# print num, "\t", result
etime = time.time()
print etime - start_time
The request:
In summary, here are my questions:
1. Why does there appear to be dropped data?
2. How (or Can) the timing be controlled to sample exactly 256 times per second?
Thanks in advance for any/all the help.
PS - I buy lots of stuff from Adafruit, and as an educator, am delighted to see a business that also cares about education and is willing to help its customers. Thanks for all you do!
PPS - this is my first post, so I apologize in advance if I have done something wrong.