All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jerome Oufella <jerome.oufella@savoirfairelinux.com>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH] hwmon: sht15: Fix sht15_calc_temp
Date: Mon, 29 Mar 2010 16:23:56 +0000	[thread overview]
Message-ID: <919663887.2141269879836780.JavaMail.root@mail.savoirfairelinux.com> (raw)
In-Reply-To: <1269639013-26029-1-git-send-email-jerome.oufella@savoirfairelinux.com>

Hi,

My conclusion is that the measurements are biased everytime.

I wrote a small test suite testing measurements at the manufacturer-supplied reference points.
As you can see the bias is substantial.

Jonathan, any objection ?



==> Test #1
  Supply: 2500000uV, raw reading: 7000, 
  original calc_temp: 31599mC;
  patched calc_temp: 30600mC
  hand-made calc gives: 30600

==> Test #2
  Supply: 3000000uV, raw reading: 6800, 
  original calc_temp: 29598mC;
  patched calc_temp: 28400mC
  hand-made calc gives: 28400

==> Test #3
  Supply: 3500000uV, raw reading: 6400, 
  original calc_temp: 25598mC;
  patched calc_temp: 24300mC
  hand-made calc gives: 24300

==> Test #4
  Supply: 4000000uV, raw reading: 6000, 
  original calc_temp: 21598mC;
  patched calc_temp: 20200mC
  hand-made calc gives: 20200

==> Test #5
  Supply: 5000000uV, raw reading: 5400, 
  original calc_temp: 15598mC;
  patched calc_temp: 13900mC
  hand-made calc gives: 13900

Jerome

> I discovered two issues.
> First the previous sht15_calc_temp() loop did not iterate through the
> temppoints array since the (data->supply_uV > temppoints[i - 1].vdd)
> test is always true in this direction.
> 
> Also the two-points linear interpolation function was returning
> biased
> values which I adressed using a different form of interpolation.
> 
> Signed-off-by: Jerome Oufella <jerome.oufella at
> savoirfairelinux.com>
> ---
> 
>  drivers/hwmon/sht15.c |   14 +++++++-------
>  1 files changed, 7 insertions(+), 7 deletions(-)
> 
> 
> diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
> index 864a371..a6ad93b 100644
> --- a/drivers/hwmon/sht15.c
> +++ b/drivers/hwmon/sht15.c
> @@ -303,15 +303,15 @@ error_ret:
>  static inline int sht15_calc_temp(struct sht15_data *data)
>  {
>  	int d1 = 0;
> -	int i;
> +	int i, t;
>  
> -	for (i = 1; i < ARRAY_SIZE(temppoints); i++)
> +	for (i = ARRAY_SIZE(temppoints) - 1; i > 0; i--)
>  		/* Find pointer to interpolate */
> -		if (data->supply_uV > temppoints[i - 1].vdd) {
> -			d1 = (data->supply_uV/1000 - temppoints[i - 1].vdd)
> -				* (temppoints[i].d1 - temppoints[i - 1].d1)
> -				/ (temppoints[i].vdd - temppoints[i - 1].vdd)
> -				+ temppoints[i - 1].d1;
> +		if (data->supply_uV >= temppoints[i - 1].vdd) {
> +			t = (data->supply_uV - temppoints[i-1].vdd) / 
> +				((temppoints[i].vdd - temppoints[i-1].vdd) / 10000);
> +
> +			d1 = (temppoints[i].d1 * t + (10000 - t) * temppoints[i-1].d1) /
> 10000;
>  			break;
>  		}
>  
> -- 
> 1.6.3.3

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

  reply	other threads:[~2010-03-29 16:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-26 21:30 [lm-sensors] [PATCH] hwmon: sht15: Fix sht15_calc_temp Jerome Oufella
2010-03-29 16:23 ` Jerome Oufella [this message]
2010-03-29 18:42 ` Jonathan Cameron
2010-03-29 19:58 ` Jerome Oufella
2010-03-30 11:36 ` Jonathan Cameron
2010-03-30 14:00 ` Jerome Oufella
2010-03-30 14:00 ` Jerome Oufella
2010-04-01 12:01 ` Jean Delvare
2010-04-01 12:01   ` [lm-sensors] [PATCH] hwmon: sht15: Fix sht15_calc_temp interpolation function Jean Delvare
2010-04-01 12:54 ` [lm-sensors] [PATCH] hwmon: sht15: Fix sht15_calc_temp Jerome Oufella
2010-04-01 12:54   ` [lm-sensors] [PATCH] hwmon: sht15: Fix sht15_calc_temp interpolation function Jerome Oufella
2010-04-01 13:49   ` [lm-sensors] [PATCH] hwmon: sht15: Fix sht15_calc_temp Jonathan Cameron
2010-04-01 13:49     ` [lm-sensors] [PATCH] hwmon: sht15: Fix sht15_calc_temp interpolation function Jonathan Cameron
  -- strict thread matches above, loose matches on Subject: below --
2010-04-01 15:02 [lm-sensors] [PATCH] hwmon: (sht15) Fix sht15_calc_temp Jean Delvare

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=919663887.2141269879836780.JavaMail.root@mail.savoirfairelinux.com \
    --to=jerome.oufella@savoirfairelinux.com \
    --cc=lm-sensors@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.