adafruit / Adafruit-Raspberry-Pi-Python-Code

Adafruit library code for Raspberry Pi
1.43k stars 686 forks source link

Bug fix: signed differential sample values are ignored in ADS1015 (12 bi... #115

Closed omryn closed 9 years ago

omryn commented 9 years ago

When using ADS1015, ADS1x15.readADCDifferential method ignores signed inputs, So positive samples make sense, but negative samples are returned as high values. This is especially frustrating in samples that oscillate around 0mV. The fix is checking the most significant bit (11) and subtract the max value (0xFFF) from the signed sample if necessary, much like the 16 bit version. Enjoy

ladyada commented 9 years ago

thx!