W dniu 21.10.2016 o 08:18, Laxman Dewangan pisze:
On Thursday 20 October 2016 10:56 PM, Paweł Jarosz wrote:
It is Negative Coefficient Thermistor (NCT) and so adc reads are
different.
Lower temp gives higher value.
So table should be
<7000 10
9000 8>;
temp1 = gti->lookup_table[2 * i];
temp2 = gti->lookup_table[2 * i - 2];
and then use in following equation.
adc_hi = gti->lookup_table[2 * i - 1];
adc_lo = gti->lookup_table[2 * i + 1];
temp = gti->lookup_table[2 * i];
temp -= (val - adc_lo) * (temp1 - temp2) / (adc_hi - adc_lo);
val = 9
adc_hi = 10
adc_lo = 8
temp = 9000 - (9 - 8)*(7000 - 9000)/(10 - 8)
temp = 9000 - (1)*(-2000)/(2)
temp = 9000 - (-1000) = 10000
still wrong ... temp for val = 9 should be 8000
Your temp1 and temp2 calculation is something wrong.
temp1 = gti->lookup_table[2 * i];
temp2 = gti->lookup_table[2 * i - 2];
so temp1 = 9000, temp2 = 7000
There was nothing wrong with my calculation but you changed the order to
fix your equation.
You can send the patch.
Paweł
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html