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.

• Resolved

Tool/software: Code Composer Studio

Hello,

I have a question regarding the example code provided on "ADS1118.c" in 430BOOST-ADS1118-SFT.

```/******************************************************************************
* function: local_compensation(int local_code)
* introduction:
* this function transform internal temperature sensor code to compensation code, which is added to thermocouple code.
* local_data is at the first 14bits of the 16bits data register.
* So we let the result data to be divided by 4 to replace right shifting 2 bits
* for internal temperature sensor, 32 LSBs is equal to 1 Celsius Degree.
* We use local_code/4 to transform local data to n* 1/32 degree.
* the local temperature is transformed to compensation code for thermocouple directly.
*                                                                                  (Tin -T[n-1])
* comp codes = Code[n-1] + (Code[n] - Code[n-1])* {---------------}
*										     (T[n] - T[n-1])
* for example: 5-10 degree the equation is as below
*
* tmp = (0x001A*(local_temp - 5))/5 + 0x0019;
*
* 0x0019 is the 'Code[n-1]' for 5 Degrees; 	0x001A = (Code[n] - Code[n-1])
* (local_temp - 5) is (Tin -T[n-1]);			denominator '5' is (T[n] - T[n-1])
*
* the compensation range of local temperature is 0-125.
* parameters: local_code, internal sensor result
* return value: compensation codes
******************************************************************************/My question is how are values 0x0019 and 0x001A determined? Is there a lookup table I can reference to? 5degC K-type thermocouple produces a mV of 0.198 and 10deg k-type thermocouple produces a mV of 0.397Also I will ultimately use an ADS1018 for my project, how are the result data divided and shifted?Thank you```
• I figured it out

• In reply to Shubham Tandon:

Shubham,

I'm glad you were able to figure out your problem. If you don't mind, what was the problem?

Regardless, if you have any other questions, feel free to post back.

Joseph Wu

• In reply to Joseph Wu:

I just couldn't understand how those codes were prepared. turns out it is simply (mV of temperature)*32*4.

I know why you multiply by 32 [1/0.03125 = 32] but I am still not sure why we are multiplying by 4. Could you explain that please?

• In reply to Shubham Tandon:

Shubham,

In the ADS1118.c, I didn't see a multiply by 4 in the code. There is however a divide by 4 in the local_compensation portion that you had mentioned. Is that what you were asking about?

For the output data for the temperature sensor, the device puts out a 2byte (16bit) number that represents the temperature data. However, of these 16 bits, the 14 most significant bits are used (and I believe that the 2 least significant bits are zeros). To get the data, you could either truncate the last two bits, or you could divide by four. Both would mathematically get you the same result with the correct 14 bits of data. Dividing by four right shifts the data by two bits.

Hopefully that answers your question. If I've misunderstood, you post back with a little more detail about the question.

Joseph Wu

• In reply to Joseph Wu:

Thank you for the explaination.

In the case of the ADS1018, where the device puts out a 16-bit number which represents the temperature. On that device the 12 MSBs are used. How would I truncate that data? Would I still divide by 4 in this case?

That was my ultimate question.

Thank you so much

• In reply to Shubham Tandon:

Shubham,

For the ADS1018, the temperature sensor data still comes out as a 16-bit word, but the upper 12 bits are used for the temperature sensing data. You can see this in Table 2 in the datasheet.

In that case you could either truncate the last four bits, or you could divide by 16 to remove the last four bits of data.

Joseph Wu