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.

# TMP61-Q1: What does " return THRM_TEMP * 32; // multiply by 32 for GC to divide later" in code

Part Number: TMP61-Q1

In thermistor.c there is code that ends with "// multiply by 32 for GC to divide later" in code"

which I suspect is unnecessary to get degrees C, and something don by whatever GC is?

```float thermistor_calc_temperature(int raw_ADC)
{
// THRM calculations via regression
// Copied from TI Thermistor Design Tool Excel Doc
VTEMP          = 0.0;

float THRM_A0 = -4.232811E+02;
float THRM_A1 = 4.728797E+02;
float THRM_A2 = -1.988841E+02;
float THRM_A3 = 4.869521E+01;
float THRM_A4 = -1.158754E+00;

VTEMP =
THRM_ADC;  // calculate volts per bit then multiply that times the ADV value
THRM_TEMP = (THRM_A4 * powf(VTEMP, 4)) + (THRM_A3 * powf(VTEMP, 3)) +
(THRM_A2 * powf(VTEMP, 2)) + (THRM_A1 * VTEMP) +
THRM_A0;    // 4th order regression to get temperature
return THRM_TEMP * 32;  // multiply by 32 for GC to divide later
}```

• Hello,

Usually when I write something like this, I'm typically trying to get higher accuracy out of some Fixed point math.  Like I shift everything over a few bits, effectively multiplying by a power of 2, do my math, then shift back at the end.  Maybe something similar is happening here?

Ultimately, it's multiplying it by 32 here and then "gc" which is probably another function later in the program adjusts for this by dividing it out.

I feel like my response isn't very helpful but I'm sure there are multiple ways to write the software to fine the temp.

Thanks,

JD

• Dropping the multiply gives reasonable temperatures.

• Malcolm - I have no idea who put that in there, GC is probably GUI Composer -  the original example is found here: https://www.ti.com/tool/TMP6-THERMISTOR-DESIGN , in 4th order polynomial TMP vs VDC tab

Be advised to also look at and use the low pass filter firmware example, too.

See this app note, too for optimizing any application with the TMP6 as well.