From: "Paweł Jarosz" <paweljarosz3691@gmail.com>
To: Laxman Dewangan <ldewangan@nvidia.com>
Cc: linux-iio@vger.kernel.org, rui.zhang@intel.com, edubezval@gmail.com
Subject: Re: [PATCH] thermal: generic-adc: Fix linear temperature approximation
Date: Fri, 21 Oct 2016 09:00:08 +0200 [thread overview]
Message-ID: <fffb9c61-7331-7907-b856-57cb31dff313@gmail.com> (raw)
In-Reply-To: <5809B34C.6040301@nvidia.com>
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ł
prev parent reply other threads:[~2016-10-21 6:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-18 19:31 [PATCH] thermal: generic-adc: Fix linear temperature approximation Paweł Jarosz
2016-10-20 12:40 ` Laxman Dewangan
2016-10-20 14:56 ` Paweł Jarosz
2016-10-20 15:49 ` Laxman Dewangan
2016-10-20 16:14 ` Paweł Jarosz
2016-10-20 16:01 ` Laxman Dewangan
2016-10-20 17:10 ` Paweł Jarosz
2016-10-20 17:01 ` Laxman Dewangan
2016-10-20 17:26 ` Paweł Jarosz
2016-10-21 6:18 ` Laxman Dewangan
2016-10-21 7:00 ` Paweł Jarosz [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fffb9c61-7331-7907-b856-57cb31dff313@gmail.com \
--to=paweljarosz3691@gmail.com \
--cc=edubezval@gmail.com \
--cc=ldewangan@nvidia.com \
--cc=linux-iio@vger.kernel.org \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox