py-ads1256 icon indicating copy to clipboard operation
py-ads1256 copied to clipboard

Datalogger example

Open renderit opened this issue 7 years ago • 2 comments

Hi, great work here. I'm trying to wrap my head around using some values/conversion used. Like in the datalogger example, you use:

for x in range(0, 8):
    chv[x] = (((ch[x] * 100) /167.0)/int(gain))/1000000.0 

I understand this is converting raw values into voltages.. But any idea how is this working? Any references? Since I'm using a pressure sensor, I'm looking to use psi for example..

renderit avatar May 28 '17 20:05 renderit

Hi renderit,

In this code you have quoted, I just derivated from the C original code from Waveshare, from where the py-ads1256 is based. The source code is available here: http://www.waveshare.com/w/upload/5/5e/High-Precision-AD-DA-Board-Code.7z

Take a look into the line 858 from the ads1256_test.c file:

volt[i] = (adc[i] * 100) / 167;

About the "167" value, I suppose this has to do with the 2^24 bits to calculate it's LSB (Less Significant Bit). But, honestly, i haven't figured out why the int number 167, and why not a float like 167,77216. As my knowledge in electronics is a bit limited, in the time I was writing the library I've compared the Volts output from the Waveshare 24 Bits ADC with other 17 Bits ADC (ADC Pi Plus, from Ab eletronics) and other 16 Bits ADC (ADS1115, from the Adafruit's ADS1115 breakout) and, despite the obvious difference in resolution, the output values are very close from one to another, so it just looks to be ok with using the converting formula from the Waveshare's C code.

Besides, there's some theory about ADC's LSB, in the section "2.1 Analog-to-Digital Converter (ADC)" from this link: http://www.ti.com/lit/an/slaa013/slaa013.pdf

About the pressure sensor you are going to use, i've not understood: you mean that you need to make a conversion from Volts to PSI ? In this case, you just need to take a look into the datasheet from the chip used in your pressure sensor, to figure out how much Volts are equal to 1 PSI value. If you don't have this information, then you are going to need to test this sensor in a university's laboratory or some kind of facility that can give you a exactly value with 1 PSI, so you can read the voltage with the ADC and then you can make you own formula on it modifying the Python datalogger example code.

I hope it helps...


Fábio

fabiovix avatar May 28 '17 21:05 fabiovix

Hi fabiovix, Appreciate the work! This one helped me a lot! Is there a wrapper included for dac8532 as well?

Thank you!

punith1991 avatar Dec 03 '17 12:12 punith1991