W dniu 20.10.2016 o 14:40, Laxman Dewangan pisze:
On Wednesday 19 October 2016 01:01 AM, Paweł Jarosz wrote:
In current version of the driver there is error in temperature
calculation.
So lets fix it using proper linear function.
Signed-off-by: Paweł Jarosz <paweljarosz3691@xxxxxxxxx>
Per my calculation, existing and your equation is same as both are
doing linear interpolation.
Only think I have seen is that I have used 1000 for two consecutive
temp difference and you used (t2 - t1), so your is better in this case
but still the equation is same.
The equation from you is
t1 + (hi -val) * factor.
and existing one is
t2 - (val -lo) * factor
factor is abs((t2-t1)/(hi-lo))
If my analysis is not correct then can you please provide the example
with calculation for better understansing?
Hi
For example if we try to calculate temp for val = 8, i = 1 and table:
<0 9
2 7>
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) * 1000) / (adc_hi - adc_lo);
Your method gives temp = -498
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