ul-gh / PiPyADC

Python classes for interfacing Texas Instruments analog-to-digital converters with the Raspberry Pi
GNU Lesser General Public License v2.1
69 stars 27 forks source link

Lower Voltage value readings when increasing samping rate #13

Closed gabrielecostante closed 6 years ago

gabrielecostante commented 6 years ago

Hi,

I successfully installed your code and I am able to run your example.py script without any problem (I only needed to switch to the pigpio branch, since the wiringpi gave me segmentation fault issues).

However, when I tried to increase the sampling rate by inserting the line ads2.drate = DRATE_100 in the example.py file, I noticed that the voltage value readings are lower (and wrong) with respect to the ones given by the original example with the default sampling rate. Am I missing something? Is there something that needs to be done when increasing the drate parameter?

Thanks for your help

ul-gh commented 6 years ago

Hi,

this can happen if the analog inputs are subjected to noise voltages, very high source impedances or especially if they are left unconnected and floating. Otherwise, this is an error.

What do you have connected to the inputs?

gabrielecostante commented 6 years ago

Hi,

this happens both when using the built-in potenziometer for testing (I am using the Raspberry Pi AD/DA Expansion board with the ADS1256 chip) and by connecting an external power supply. The voltage measured, in both cases, seems to be nearly halved.

ul-gh commented 6 years ago

OK, do you have the jumper on header no. 2 set, connecting GND and AINCOM? That jumper is necessary for the default configuration.

gabrielecostante commented 6 years ago

Yes, the jumper is connecting AGND to AINCOM. I noticed that if I call the function ads.cal_self() to perform gain calibration after ads.drate=DRATE_100 the voltages measured get better (the difference between the readings with and without the increased sampling rate is 0.03 V) If I increase the sample rate to DRATE_1000 the difference increases a bit (it measures 3.95 V with DRATE_1000 and 4.042 V with the default sampling rate). I also noticed that the difference between the measurements seems to increase at higher voltages. The difference is almost zero around 2.0V for example

leloup314 commented 6 years ago

I have also seen this for voltages which come close to the 5 V region when using the ADS1256_default_config.py without any changes. For example for 4.7 V input the ADC reads 3.9 V, the voltage even seems to decrease over time for constant input voltage. For me this was only the case for high voltages (> 4 V) in the lowest resolution e.g. gain_flags = GAIN_1! For other internal gain I did not see this. Since I need to use th full +-5V range I tried fixing the issue. What worked for me was to set the status from BUFFER_ENABLE to AUTOCAL_ENABLE.

ul-gh commented 6 years ago

Many thanks to Pascal Wolf, this seems to be the crucial bit of information:

Indeed, the ADS1256 has a limited input voltage range of 0V...3.0V for a 5V supply when the input buffer is enabled: Image ADS1256 input voltage range

You must disable the BUFFER_ENABLE flag for voltages above 3.0 V to work reliably.