|
|
|
|
@ -42,7 +42,7 @@ int32_t avg_temp(int16_t val, uint8_t channel) {
|
|
|
|
|
|
|
|
|
|
uint16_t calc_temp(int16_t val, uint8_t channel) {
|
|
|
|
|
float mV = ((float) avg_temp(val, channel))/1000000;
|
|
|
|
|
uint16_t temp;
|
|
|
|
|
uint16_t temp = 0;
|
|
|
|
|
if(mV < 0) {
|
|
|
|
|
/* t in mV
|
|
|
|
|
E = sum(i=0 to n) c_i t^i. ; n=10
|
|
|
|
|
@ -61,9 +61,8 @@ uint16_t calc_temp(int16_t val, uint8_t channel) {
|
|
|
|
|
-0.163226974860E-22
|
|
|
|
|
};
|
|
|
|
|
for(int i=0; i<11; i++) {
|
|
|
|
|
temp += coef[i] * pow(mV, i+1);
|
|
|
|
|
temp += coef[i] * pow(mV, i);
|
|
|
|
|
}
|
|
|
|
|
return temp;
|
|
|
|
|
} else {
|
|
|
|
|
/*
|
|
|
|
|
t in mV
|
|
|
|
|
@ -83,10 +82,13 @@ uint16_t calc_temp(int16_t val, uint8_t channel) {
|
|
|
|
|
};
|
|
|
|
|
float a[] = {0.118597600000E+00, -0.118343200000E-03, 0.126968600000E+03};
|
|
|
|
|
for(int i=0; i<10; i++) {
|
|
|
|
|
temp += coef[i]*pow(mV, i+1) + a[0] * pow(exp(a[1]*(mV - a[2])), 2);
|
|
|
|
|
temp += coef[i]*pow(mV, i)
|
|
|
|
|
}
|
|
|
|
|
// ich glaube das summenzeichen erstreckt sich nicht auf das exp
|
|
|
|
|
temp += a[0] * pow(exp(a[1]*(mV - a[2])), 2);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return temp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* initializes the hardware */
|
|
|
|
|
|