1
\$\begingroup\$

I am using an ADS1241 to measure thermocouple signals.

I have applied a millivolt signal differentially to channel AIN4 and AIN5 using a stable and accurate millivolt source.

The thermocouple signal ranges from -8.9 mV to 70 mV. I want to cover the whole millivolt range using this ADC.

I have set the PGA to 1.

How can I measure the negative millivolts?

I applied -10mV to the input and getting counts FF47D3 in hex. The reference is 1.235V and the format is bipolar. I am not able to decode these ADC counts.

Datasheet for the ADS1241.

\$\endgroup\$
  • \$\begingroup\$ (1) Circuit schematic? Link to datasheet? (2) Is the device supposed to be able to read negative input voltages? (3) What is "the whole millivolt range"? \$\endgroup\$ – Transistor May 28 at 6:58
  • \$\begingroup\$ (1) I have provided the link to datasheet. (2) Yes the device can read differential negative millivolts but the absolute value of the voltage cannot be negative. (3) It can read millivolts from +-Vref/2 in bipolar mode. \$\endgroup\$ – akashk May 28 at 8:09
2
\$\begingroup\$

I've never done this or worked with 24-bit numbers and a quick search reveals little. The datasheet is quiet on the topic too.

I assume that the ADC would count down past zero in the sequence

0000 0000  0000 0000  0000 0011 = 3
0000 0000  0000 0000  0000 0010 = 2
0000 0000  0000 0000  0000 0001 = 1
0000 0000  0000 0000  0000 0000 = 0
ffff ffff  ffff ffff  ffff ffff =-1

Wikipedia's gives the following example:

The following Python code shows a simple function which will convert an unsigned input integer to a two's complement signed integer using the above logic with bitwise operators:

def twos_complement(input_value, num_bits):
    '''Calculates a two's complement integer from the given input value's bits'''
    mask = 2**(num_bits - 1)
    return -(input_value & mask) + (input_value & ~mask)

Trying this in a Python console ...

mask = 2**(24 - 1)
decimal = -(0xff47d3 & mask) + (0xff47d3 & ~mask)
print decimal
print decimal * 1.235 / 2**23
>>> 
-47149
-0.00694143950939
>>>

... which is about 7 mV.


A simpler solution depending on your microcontroller would be to left shift the number by four bits. This will preserve the two's complement but make it available to a 32-bit calculator.

0xff47d3 << 4  // results in 0xff47d300 = -12070144
Oxff47d300 / 256 = -47149

which is the same number we got using the Python method.

This seems a little odd in that the 4-bit left shift is usually considered a x 256 multiplication and then we're following it by a / 256 division so why bother? The answer is that the left shift preserves the two's compliment and the sign of the number for use by a 32-bit arithmetic logic unit. The division can then proceed correctly.

\$\endgroup\$
  • \$\begingroup\$ Looks about right. \$\endgroup\$ – JRE May 28 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.