adafruit / Adafruit_ADS1X15

Driver for TI's ADS1015: 12-bit Differential or Single-Ended ADC with PGA and Comparator
Other
289 stars 301 forks source link

increase ADS1115_CONVERSIONDELAY to 9ms #46

Closed ant32t closed 4 years ago

ant32t commented 4 years ago

It actually takes almost 9ms, this makes the code work on newer 32bit MCUs

caternuson commented 4 years ago

As the library is currently written, the data rate is fixed at 128 sample per second. So the 8ms probably came from 1 / 128 = 0.0078125 and rounding up to 8ms.

@ant32t How did you determine it took longer?

ant32t commented 4 years ago

We had a problem with the readings on our chip being unpredictable after upgrading the chip on the board to stm32 from atmega. After googling I found some people that had the same issue. It was fixed by increasing to 9ms. https://forums.adafruit.com/viewtopic.php?f=22&t=76452 https://forum.arduino.cc/index.php?topic=561546.0 https://www.google.com/search?q=ADS1115_CONVERSIONDELAY+9ms

caternuson commented 4 years ago

Thanks for the additional info.

It might be better in the long run to check the conversion ready bit like the CircuitPython library does: https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15/blob/master/adafruit_ads1x15/ads1x15.py#L166 As an added benefit, that approach would adapt as needed for different data rates.

But until then, if just bumping the hard coded delay a bit helps things, then that's fine.