adafruit / Adafruit_ADS1X15

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

ADC_SingleEnded sending fixed values if analog < 0.4V (voltage follower between sensors and ADC) #72

Closed DaniMzT closed 2 years ago

DaniMzT commented 2 years ago

Hello, First of all, thanks for the library :) I'm using it with 3 analog inputs connected to an ADS1115 (with an operation amplifier voltage follower in between), which sends the data to a NodeMCU. I'm using version 2.2.0. My problem is that there is a voltage offset when I read the inputs in NodeMCU, even using the example "singleended" from the library. The voltage of the inputs is around 80-90 mV (measured in relation to ADS1115's GND) but in the serial monitor I'm reading 0.4V, so there are 300 mV offset. In my particular code, I've also tried it with gain = ONE (+-4V reference, so 0.125 mV resolution) but the results are the same. Here a video I've just recorded as an evidence: https://www.youtube.com/watch?v=TMURcEnpoeA As you can see, my multimeter displays around .08 (80 mV) for A0, A1 and A2. Don't pay much attention to A3, because it was connected to an open point. Sorry if my fingers covered the action, by the way. The last measurements are just a check between ADS1115's GND and the GND of the external inputs, as they are connected. Do you know if this is a known issue and if there is a solution? Maybe I'm missing something to take into account. If so, please let it me know. Thanks in advance! Kind regards

DaniMzT commented 2 years ago

I've tested more: now I've adjusted voltage with a potentiometer. It seems the result starts to match the expected values when analog inputs >= 0.4 V. Under 0.4 V, it seems the output is fixed (around 3648-3664 using 0.125 mV/bit). Here is a table with my measurements, supplying 3.27 V to ADS1115 and using GAIN_ONE (0.125 mV):

INPUT VOLTAGE (A1 and A2) -- readADC_SingleEnded -- expected result: 0.12 -- 3648 -- 960 0.188 --3664 -- 1504 0.31 --3648 -- 2480 0.478 --3888 -- 3824 0.627 --5008 -- 5016 0.776 --6192 -- 6208 0.936 --7456 -- 7488 1.08 --8624 -- 8640 1.24 --9904 -- 9920 1.39 --11104 -- 11120

Maybe my problem is that some comparators for low voltage ranges are damaged?

DaniMzT commented 2 years ago

I've realized my problem must be related to the voltage follower (operational amplifier LP324) between the sensors and the ADC. I don't know the reason yet but when I test NodeMCU and ADC directly without voltage follower the results are perfect. I need an oscilloscope to know what's going on. It looks like a reference issue (no GND voltage differences acc to tester, though), because when I measure on an ADC input/op.amplifier output suddenly the ADC prints 0.10V (Serial print). It also seems to depend on the supply from laptop (from mains or from its battery).

Until I can use the oscilosccope, has anybody had this kind of issue? Maybe @soligen2010? Sorry to tag you, I've seen you created an updated library from this one so hopefully you may have heard this issue? Thanks in advance.

soligen2010 commented 2 years ago

I think you found your issue. OP Amps typically have an offset. Some op amps have a way to trim out the offset. Also, if it is not powered with both positive and negative supply, it is very common that the op amp will not go all the way to zero (even if it is "rail to rail") - this fits your observations quite well and I think is what is happening to you. I don't think your issue is with the ADC or the library, but is in the electronics before it. I suggest getting rid of the op-amp unless you want to do the detailed analysis and extra engineering to compensate for the offset and ensure the output can go to zero.

caternuson commented 2 years ago

To verify this is a library issue, you'll need to remove the ADS1115 from the custom setup.

setup

A good test setup would the Feather driving the ADS115 with a trim pot voltage divider going into the ADS, all staged on a breadboard.

DaniMzT commented 2 years ago

I think you found your issue. OP Amps typically have an offset. Some op amps have a way to trim out the offset. Also, if it is not powered with both positive and negative supply, it is very common that the op amp will not go all the way to zero (even if it is "rail to rail") - this fits your observations quite well and I think is what is happening to you. I don't think your issue is with the ADC or the library, but is in the electronics before it. I suggest getting rid of the op-amp unless you want to do the detailed analysis and extra engineering to compensate for the offset and ensure the output can go to zero.

Exactly that, thank you! The problem was my op.amp. wasn't rail to rail. I've set specific voltage on ADS1115 inputs directly and it was working exactly. I'm not expert on electronics so I didn't know this concept of rail-to-rail. The low output voltage of my amp (LP324N) is 0.7V when Vcc is 5V (datasheet). In my case, it was 0.4 V with Vcc=3.3. Sorry for bothering, the library works very well. I'll search a more accurate amp!

caternuson commented 2 years ago

@DaniMzT Thanks for reporting back and closing the issue.

@soligen2010 Good job finding the issue!

DaniMzT commented 2 years ago

@DaniMzT Thanks for reporting back and closing the issue.

@soligen2010 Good job finding the issue!

Thank you guys for helping and developing libraries like this 👍 What a good job!