Other Parts Discussed in Thread: ADS1018, , ADS1118
I wanted to understand how to calculate temperature from ADC counts , when we are configuring ADS1018 in ADC mode.
also I wanted to understand how ADC counts are co-related to ADC counts.
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.
I wanted to understand how to calculate temperature from ADC counts , when we are configuring ADS1018 in ADC mode.
also I wanted to understand how ADC counts are co-related to ADC counts.
Hello Varsha,
Thanks for posting on data converter forums!
Unfortunately, this question is a little vague so I'm going to make some assumptions in order to answer your question thoroughly.
The assumptions are:
I'd say understanding the whole conversion chain from temperature to code needs two parts: the temperature to voltage equation from the sensor, and the voltage to code conversion.
Temperature to voltage:
The temperature to sensor voltage doesn't depend on the device, so you'll need this info from the sensor datasheet. As such, you might find an equation or a table in the sensor datasheet that shows the minimum differential and common mode voltage for the sensor outputs.
Using this info, we can refer to table 1 in the datasheet and pick a PGA setting:
Typically, the full scale range (FSR) is determined by an equation that includes the PGA gain and the reference voltage, but the datasheet tries to make it easier for the user since the reference is fixed and PGA is internal. More info on that can be found in this post if you're interested: https://e2e.ti.com/support/data-converters-group/data-converters/f/data-converters-forum/907372/ads1018-q1-ads1018-q1 As a result, the user just needs to use the smallest FSR value that encompasses the voltage range (and therefore temperature range) that needs to be sensed.
The one thing I need to stress is that if the higher FSR values are picked, then the VDD and absolute maximum specs need to still be observed. Just because the table says 6.144V, doesn't mean that 6.144V can be applied to the inputs as VDD can't go to 6.144V. Its for scenarios where, for example, the sensor can go to 5V where the 6.144V can never be achieved, but 5V would never be sensed using the 4.096V FSR setting.
I'll also note that using LSB = FSR / 2^12 to derive the LSB size column could result in some confusion. If you have never worked with negative numbers in context of ADC codes, I would recommend to keep reading as it'll be explained later.
Voltage to code:
Table 3 in the datasheet gives us an equation to go from voltage to codes but there are two key ideas to understand beforehand.
The first is that codes can only be pulled from the device at 2 or 4 bytes (8 or 16 bits) at a time. This means the final code will have 16 bits or 8+8bits. Note, this is a 12 bit ADC which means the last 4 bits (or last byte) is worthless, always 0b, and does not convey real data. In other words, 0x7FF may be the equivalent largest positive code that utilizes all 12 bits, but a controller will have to receive 0x7FF0 because the packet has to be 16 bits long.
The second idea is that the codes are in twos complement, left justified format. This means, AIN_P - AIN_N can result in a negative number and to represent that negative number, we designate the MSB to be the sign where 0b = positive number and 1b means a negative number. So using 2's complement conversion, you can understand the true value and add the sign after. These are reasons why we use 2^11 in the equation below and why the LSB calculation is twice the expected amount in table 1.
.
What the table and figure is trying to say is that the sequence from voltage to code is V_input = n_code*(FSR/2^11) -> 2's complement if negative -> add 0x0 to end -> get final code to be sent to controller.
Going through an example, let's use FSR = +/-1.024 where the LSB is 0.5mV, and the input or AINP - AINN will be -0.5mV.
n_code = (-0.5mV)*(2^11/(-1.024))
n_code = 1 = 0b0000 0000 0001
n_code_2s = 0b1111 1111 1111 = 0xFFF
n_code_final = 0xFFF0
Which equals the value in the table.
Final note about errors and things
The table doesn't account for errors, as determined by the footnote. If you need to review how errors get added into the final result, then please review the TIPL ADC series on errors and noise and check out the design section of the TI reference design Precision Thermocouple Measurement with the ADS1118 (which similar to the ADS1018-Q1 but 16 bits and with lower temp range) https://www.ti.com/lit/ug/slau509/slau509.pdf
Best,
-Cole
Hello Cole
thanks for the reply.
Please do consider below points
1. I have configured ADS1018 in ADC mode.
2. below configurations I have done
Mode = ADC
010 = FSR is ±2.048 V (default)
Pull Up enable
Data rate = 2400
supply voltage for ADS1018 is 5V
I am performing 32 bit SPI communication and getting below response for config write 0x44AB 44AB
0x64E0 44AA
MSB is 0x64E0 (16 bit ADC counts ) LSB 44AA which config register read back.
my question is how to convert ADC counts 0x64E0 to temperature value.
I understand its 16 bit result buffer and 12bit will be result only so actual 12 bit result is 0x64E
if I convert this to decimal it will be 1614
0.125* 1614 = 210.75 deg (which is invalid)
please guide me how ADC counts 0x64E0 will be calculated to temperature value.
Hello Varsha,
Here's my math:
0x64e0
0x64e
0110 0100 1110b
1614
V_input = n_code*(FSR/2^11)
V_input = (1614)*(2.048/2^11)
V_input = 1.614V
You haven't given me an equation for the temperature equation (you also didn't specify which kind of degrees, though C is the industry standard).
I think we throw out the degrees to voltage conversion for now. Can you probe the appropriate input pins and see if you approximately have 1.614V for AINP - AINN? I just want to make sure our equation is right.
Best,
-Cole
Thanks Cole
This will help. again one more question.
I am giving 5V supply to ADS1018 , and default ±2.048 V. This is ok right?
also as below above formula if I give 5V voltage then I am getting 0x7FF0
if I go reverse with above formula
then
I will result into
0x7FF = 2047 (decimal)
V_input = 2047 * (2.048 / 2048) = 2.047V
is it due to FSR range?
what FSR is suggested for 5V input supply?
what I mean to say is if I am giving 5V as input voltage to ADs1018 then I am getting 0x7FF0 as counts is it valid? with above formula it will be 2.047V.
so is that means I am selecting incorrect FSR? as I am giving 5V input supply to ADS1018
Hey Varsha,
There's two bits here. The first is that the ADS1018-Q1 has a true differential input and the V_input is calculated as AINP - AINN. So, to be extra clear, when you're applying 5V, I assume you're saying that AINP = 5V and AINN = 0V or GND.
The second, is that this input exceeds the positive FSR. If we go look at table 3 again. When V_input > +FS(2^11-1)/2^11, or we're exceeding the positive FSR (which is V_input > 2.048V) we expect the code 0x7FF0. That's exactly what we're seeing because 5V > 2.048V.
Is there anything wrong with this? From a device damage perspective, no. Your VDD is 5V, and applying 5V to AINP will not cause any device damage. But its clear the device can't measure 5V in this configuration because you need a positive FSR > 5V to measure AINP = 5V and AINN = 0V.
As a result, if you would like to measure the AINP = 5V and AINN = 0V case, you'll need to change the FSR range to +/-6.144V. Something like this:
Alternatively, if you're confident that AINP only changes from 0V to 5V and AINN can stay constant, then you can set AINN = 2.5V and use the +/-4.096 FSR and work out the math when AINN = 2.5V and AINP = 0V (or V_input = -2.5V) on the controller side. Something like this:
However, this is not how most real temperature sensors work. Most temperature sensors a differential so AINN cannot be held constant. Something like this:
So, take into account what your temperature sensor actually needs.
By the way, these pictures are directly lifted from the ADC TI Precision labs series. It seems like you might benefit from watching these videos so I'll throw a link for you to explore:
Best,
-Cole