All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Duan Andy <fugang.duan@freescale.com>,
	Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>
Cc: "stefan@agner.ch" <stefan@agner.ch>,
	"maitysanchayan@gmail.com" <maitysanchayan@gmail.com>,
	"knaack.h@gmx.de" <knaack.h@gmx.de>,
	"lars@metafoo.de" <lars@metafoo.de>,
	"pmeerw@pmeerw.net" <pmeerw@pmeerw.net>,
	"shawn.guo@linaro.org" <shawn.guo@linaro.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] vf610_adc: Fix internal temperature calculation
Date: Sun, 11 Oct 2015 15:07:21 +0100	[thread overview]
Message-ID: <561A6D19.90902@kernel.org> (raw)
In-Reply-To: <561A6CB7.6010700@kernel.org>

On 11/10/15 15:05, Jonathan Cameron wrote:
> On 08/10/15 03:01, Duan Andy wrote:
>> From: Jonathan Cameron <jic23@kernel.org> Sent: Sunday, September 27, 2015 11:53 PM
>>> To: Bhuvanchandra DV; linux-iio@vger.kernel.org
>>> Cc: stefan@agner.ch; maitysanchayan@gmail.com; Duan Fugang-B38611;
>>> knaack.h@gmx.de; lars@metafoo.de; pmeerw@pmeerw.net; shawn.guo@linaro.org;
>>> linux-kernel@vger.kernel.org; Duan Fugang-B38611
>>> Subject: Re: [PATCH] vf610_adc: Fix internal temperature calculation
>>>
>>> On 23/09/15 14:43, Bhuvanchandra DV wrote:
>>>> There is an observed temperature difference of ~20°C with the internal
>>>> temperature reading and the temperature measured on SoC package.
>>>> Existing calculations consider the typical values provided in
>>>> datasheet. Those typical values are valid for VREFH_ADC at 3.0V.
>>>> Voltage at 25°C is different for different VREFH_ADC voltages. With
>>>> VREFH_ADC at 3.3V, voltage at 25°C is 0.699V. Hence update the VTEMP25
>>>> to 0.699V which gives ADCR@Temp25 as 867 and the final temperature
>>>> readings differs with ~5°C from the external readings.
>>>>
>>>> Formula for finding ADCR@Temp25:
>>>> ADCR@Temp25 = (ADCR@Vdd * V@TEMP25 * 10) / VDDconv
>>>>
>>>> ADCR@Vdd for 12-Bit ADC = 4095
>>>> VDDconv = VREFH_ADC * 10
>>>>
>>>> VREFH_ADC@3.3V
>>>> ADCR@Temp25 = (4095 * .699 * 10) / 33
>>>> ADCR@Temp25 ~= 867
>>>>
>>>> | VREFH_ADC | V@TEMP25 | VDDconv | ADCR@Temp25 |
>>>> |   3.0V    | 0.696mV  |    30   |     950     |
>>>> |   3.3V    | 0.699mV  |    33   |     867     |
>>>>
>>>> Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>
>>> Looks fine to me, but I'll need an Ack from Fugang on this one as I don't
>>> know or have the part I'm afraid.
>>>
>>> Jonathan
>>
>> The patch is fine for me. Sorry for the late response due to vacation.
>>
>> Acked-by: Fugang Duan <B38611@freescale.com>
> Applied to the fixes-togreg branch of iio.git and marked for stable.
> Thanks,
> Jonathan
Actually, change of plan.  I'll hold this until Stefan's query is answered.
(naughty me - I hadn't read the whole thread!)
>>
>>>> ---
>>>>  drivers/iio/adc/vf610_adc.c | 19 ++++++++++++++-----
>>>>  1 file changed, 14 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
>>>> index f4df2a7..e7abc13 100644
>>>> --- a/drivers/iio/adc/vf610_adc.c
>>>> +++ b/drivers/iio/adc/vf610_adc.c
>>>> @@ -103,6 +103,13 @@
>>>>
>>>>  #define DEFAULT_SAMPLE_TIME		1000
>>>>
>>>> +/* V at 25°C of 696 mV */
>>>> +#define VF610_VTEMP25_3V0		950
>>>> +/* V at 25°C of 699 mV */
>>>> +#define VF610_VTEMP25_3V3		867
>>>> +/* Typical sensor slope coefficient at all temperatures */
>>>> +#define VF610_TEMP_SLOPE_COEFF		1840
>>>> +
>>>>  enum clk_sel {
>>>>  	VF610_ADCIOC_BUSCLK_SET,
>>>>  	VF610_ADCIOC_ALTCLK_SET,
>>>> @@ -636,11 +643,13 @@ static int vf610_read_raw(struct iio_dev
>>> *indio_dev,
>>>>  			break;
>>>>  		case IIO_TEMP:
>>>>  			/*
>>>> -			* Calculate in degree Celsius times 1000
>>>> -			* Using sensor slope of 1.84 mV/°C and
>>>> -			* V at 25°C of 696 mV
>>>> -			*/
>>>> -			*val = 25000 - ((int)info->value - 864) * 1000000 /
>>> 1840;
>>>> +			 * Calculate in degree Celsius times 1000
>>>> +			 * Using the typical sensor slope of 1.84 mV/°C
>>>> +			 * and VREFH_ADC at 3.3V, V at 25°C of 699 mV
>>>> +			 */
>>>> +			*val = 25000 - ((int)info->value - VF610_VTEMP25_3V3) *
>>>> +					1000000 / VF610_TEMP_SLOPE_COEFF;
>>>> +
>>>>  			break;
>>>>  		default:
>>>>  			mutex_unlock(&indio_dev->mlock);
>>>>
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


  reply	other threads:[~2015-10-11 14:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-23 13:43 [PATCH] vf610_adc: Fix internal temperature calculation Bhuvanchandra DV
2015-09-27 15:53 ` Jonathan Cameron
2015-09-29  4:52   ` Bhuvanchandra
2015-10-08  2:01   ` Duan Andy
2015-10-08  2:01     ` Duan Andy
2015-10-11 14:05     ` Jonathan Cameron
2015-10-11 14:07       ` Jonathan Cameron [this message]
2015-10-08  6:16 ` Stefan Agner
2015-10-13  3:37   ` Bhuvanchandra

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=561A6D19.90902@kernel.org \
    --to=jic23@kernel.org \
    --cc=bhuvanchandra.dv@toradex.com \
    --cc=fugang.duan@freescale.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maitysanchayan@gmail.com \
    --cc=pmeerw@pmeerw.net \
    --cc=shawn.guo@linaro.org \
    --cc=stefan@agner.ch \
    /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.