This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADC count conversion using bipolar signal

Other Parts Discussed in Thread: ADS1248

Hi,

I'm using an ADS1248EVM board for a pH sensor, my settings are AVDD +2.5 AVSS -2.5  PGA 1, using internal reference, single ended with the  AIN0 to pH sensor and AN1-AIN7 to AGND; since the sensor gives -voltage under pH 7, I'm using the formula vref/pga/2^23-1 for the positive +7 pH with encouraging results, but using the same formula as (with also -vref/pga/2^23-1) I have wrong numbers. I'm using a Stellaris Cortex M4 as controller.

Our sensor has a an increment of 57 mV/1 pH for the record I can say that I having for example:

with pH  ~4.6        16026313 counts, 

               ~6.6       16704756 counts 

and         ~8          220,00 counts, 

Which in some way sense ADS1248 uses signed two's complement any help to convert the counts or any other suggestion will be very appreciated.

Cheers

German

  • Hi German,

    As you've stated the ADS1248 uses binary two's complement, so what you state as counts is really not valid.  You can only have 8388607 counts in either direction.  In hex the positive full scale range is 0x000000 through 0x7fffff.  However it becomes a bit more confusing going the other direction as 0xffffff is only 1 lsb below 0.  This means that the maximum output in the negative direction yields 0x800000.

    At the transition point from 0x7fffff to 0x800000 you go from positive full scale to negative full scale.  The way we look at things seems to be backwards from our point of view, but for languages, such as C, it is much easier. Generally what is done is to use a long (signed) integer value as the capture variable when the data is read.  This is 32 bits, but the data returned is 24 bits.  There is no issue with positive values, but with negative values you need to sign extend the value so that the MSB of the 32 bit value is also reflecting the negative value. 

    For example, if the return value is one below 0, which is 0xffffff, and you save the result to your long, then the contents of the long will be 0x00ffffff.  But this would be incorrect until you signed extend the most significant byte appropriately.  For the variable to have the correct numerical representation you need to OR the contents of the variable with 0xff000000.  The variable result when then become 0xffffffff, and represents the value of -1 decimal.

    The calculation now is one single calculation for the resultant voltage which is the captured variable times VREF/PGA/(223 - 1).  The result will be positive or negative depending on the value of the variable contents.

    How and when you decide to sign extend is up to you and can be done a couple of different ways.  I normally sign extend when I capture the data.  You can create an 'if' statement looking at bit 23 (with bit 23 being the highest  bit returned and 0 is the lowest) and if it is high you sign extend, otherwise you do nothing.

    Best regards,

    Bob B