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.

CCS/UCD3138HSFBEVM-029: Unable to understand current temperature compensation

Part Number: UCD3138HSFBEVM-029
Other Parts Discussed in Thread: UCD3138

Tool/software: Code Composer Studio

Part Number: UCD3138HSFBEVM-029
Tool/software: Code Composer Studio
Now I'm studying temperature compensation, and I have some doubts about the program.Here is the code for temperature compensation of current:
int handle_iout_temp_comp(int iout_adc_count, int temperature)
{
   instant_resistance_negative =  R0_23C  - (temperature - ADC_COUNT_23C) * FACTOR; //multipled by 100000
 adc_count_factor_negative = (instant_resistance_negative << 10) / R0_23C;
 instant_resistance_positive =  R0_23C  + (temperature - ADC_COUNT_23C) * FACTOR; //multipled by 100000
 adc_count_factor_positive = (instant_resistance_positive << 10) / R0_23C;
 //  instant_resistance =  2720  + (temperature - 1041) * 1.22; //multipled by 100000
    return ((iout_adc_count * adc_count_factor_negative) >>10);
  // We can switch to a multi segment linearization later on 
}

As far as I know, PCB copper is a material with positive temperature coefficient(400ppm/℃), So we can get the resistance value of PCB copper with the change of temperature from the following formula:
Rt=R0*[1+α*(t-T0]
Where RT is the resistance at t ℃,R0 is the resistance at room temperature,α is the temperature coefficient,T0 is room temperature.
instant_resistance_negative =  R0_23C  - (temperature - ADC_COUNT_23C) * FACTOR
You can find that the code and the formula don't match.
Besides, I have another question.I think FACTOR should be calculated according to the following three formulas:
Rt=(R0*10^5)+[R0*10^5*α*0.00625*(t-T0)*(1/3.3)*2^12*m];
(1/3.3)*2^12*0.00625*m=1;
FACTOR=R0*10^5*α*0.00625*m;
Then,FACTOR=2.13129.
But,it is 1.15 in the program:
#define FACTOR (1.15)
I can't understand this function.
  • Hello Qiang,

    Sorry for the confusion caused. I can see why it may look like the formula and the code do not match.

    But, I will try to explain why the code does match the formula.

    First we should appreciate that we do not have the temperature in engineering units, just an ADC count that is proportional to temperature.

    Also we should realize that in UCD3138 the ADC count representing temperature decreases when temperature increases (inversely proportional).

    Now, let's start with the formula that you provided : Rt=R0*[1+α*(t-T0)]  

    We can develop this formula to look like this Rt=R0+α*R0*(t-T0)

    In the code Rt is called instant_resistance_negative, and α*R0 is replaced with FACTOR

    Therefore instant_resistance_negative = R0 + FACTOR* (t-T0)

    But as previously mentioned (temperature - ADC_COUNT_23C) is inversely proportional to (t-T0),

    therefore instant_resistance_negative = R0 + FACTOR* (temperature - ADC_COUNT_23C)*(-1) = R0 - FACTOR* (temperature - ADC_COUNT_23C)

    Please also note that the temperature coefficient of 400ppm/℃ is an approximation, and copper actually does not change linearly with temperature.

    For that reason, we could have two FACTORs (FACTOR1 and FACTOR2) for colder than room temperature and warmer than room temperature in our conversion function. That is why in the code we have two formulas, but at the end only one is in use. The other one (positive one) is for future use, if better accuracy is required.

    Also the >>10 and <<10 are used for better resolution when fixed point arithmetic(not floating point) is used.

    Hope this makes sense now.

    Regards,

  • Thank you for your answer!I got it.