robert-hh / ads1x15

Micropython driver for ADS1115 and ADS1015
90 stars 25 forks source link

Parallel sampling #6

Closed MarcoSaba closed 5 years ago

MarcoSaba commented 5 years ago

Hi Robert, I'm using your library with a Pycom Wipy 3.0 in order to catch data from 3 sensors.

Sensor1 must be read every 10ms, sensor2 and sensor3 every 100ms. I'm using 4 as a rate (_DR_1600SPS, # 1600/128 samples per second) and the conversion time is more or less 10ms. When i reach 100ms I got a delay since every conversion time is accumulated for the 3 sensors. In fact, sensor1 is sampled every 11ms, but at the tenth sampling it loses 30ms. Sensor2 and 3 are sampled every 130ms. Could you suggest me a way to reduce this delay?

Thank you!

robert-hh commented 5 years ago

Use a faster sampling rate, like 6, because it must be possible to sample all three values in the 10 ms time frame. And use a timer handler to ensure a regular timing for reading. Since the ADC1115 has just a single ADC, it is not possible to interleave the sampling. For that, you would need three ADCs.