* [PATCH] vf610_adc: Fix internal temperature calculation
@ 2015-09-23 13:43 Bhuvanchandra DV
2015-09-27 15:53 ` Jonathan Cameron
2015-10-08 6:16 ` Stefan Agner
0 siblings, 2 replies; 8+ messages in thread
From: Bhuvanchandra DV @ 2015-09-23 13:43 UTC (permalink / raw)
To: linux-iio, jic23
Cc: stefan, maitysanchayan, B38611, knaack.h, lars, pmeerw, shawn.guo,
linux-kernel, Bhuvanchandra DV
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>
---
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);
--
2.5.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] vf610_adc: Fix internal temperature calculation
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 6:16 ` Stefan Agner
1 sibling, 2 replies; 8+ messages in thread
From: Jonathan Cameron @ 2015-09-27 15:53 UTC (permalink / raw)
To: Bhuvanchandra DV, linux-iio
Cc: stefan, maitysanchayan, B38611, knaack.h, lars, pmeerw, shawn.guo,
linux-kernel, fugang.duan@freescale.com
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
> ---
> 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);
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] vf610_adc: Fix internal temperature calculation
2015-09-27 15:53 ` Jonathan Cameron
@ 2015-09-29 4:52 ` Bhuvanchandra
2015-10-08 2:01 ` Duan Andy
1 sibling, 0 replies; 8+ messages in thread
From: Bhuvanchandra @ 2015-09-29 4:52 UTC (permalink / raw)
To: fugang.duan, linux-iio
Cc: stefan, maitysanchayan, B38611, knaack.h, lars, pmeerw, shawn.guo,
linux-kernel, Jonathan Cameron
Hi Fugang,
On 09/27/2015 09:23 PM, Jonathan Cameron wrote:
> 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.
Can you please give your ACK if the patch looks fine.
Best regards,
Bhuvan
>
> Jonathan
>> ---
>> 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);
>>
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH] vf610_adc: Fix internal temperature calculation
2015-09-27 15:53 ` Jonathan Cameron
2015-09-29 4:52 ` Bhuvanchandra
@ 2015-10-08 2:01 ` Duan Andy
2015-10-11 14:05 ` Jonathan Cameron
1 sibling, 1 reply; 8+ messages in thread
From: Duan Andy @ 2015-10-08 2:01 UTC (permalink / raw)
To: Jonathan Cameron, Bhuvanchandra DV, linux-iio@vger.kernel.org
Cc: stefan@agner.ch, maitysanchayan@gmail.com, knaack.h@gmx.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paW5mby0+dmFs
dWUgLSBWRjYxMF9WVEVNUDI1XzNWMykgKg0KPiA+ICsJCQkJCTEwMDAwMDAgLyBWRjYxMF9URU1Q
X1NMT1BFX0NPRUZGOw0KPiA+ICsNCj4gPiAgCQkJYnJlYWs7DQo+ID4gIAkJZGVmYXVsdDoNCj4g
PiAgCQkJbXV0ZXhfdW5sb2NrKCZpbmRpb19kZXYtPm1sb2NrKTsNCj4gPg0K
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] vf610_adc: Fix internal temperature calculation
2015-09-23 13:43 [PATCH] vf610_adc: Fix internal temperature calculation Bhuvanchandra DV
2015-09-27 15:53 ` Jonathan Cameron
@ 2015-10-08 6:16 ` Stefan Agner
2015-10-13 3:37 ` Bhuvanchandra
1 sibling, 1 reply; 8+ messages in thread
From: Stefan Agner @ 2015-10-08 6:16 UTC (permalink / raw)
To: Bhuvanchandra DV
Cc: linux-iio, jic23, maitysanchayan, B38611, knaack.h, lars, pmeerw,
shawn.guo, linux-kernel
Hi Bhuvan,
On 2015-09-23 06: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.
I am not entirely happy with the message. The proposed changes seem not
to alter the offset which would explain a ~20°C difference... Where do
this 20°C come from?
--
Stefan
>
> 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>
> ---
> 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);
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] vf610_adc: Fix internal temperature calculation
2015-10-08 2:01 ` Duan Andy
@ 2015-10-11 14:05 ` Jonathan Cameron
2015-10-11 14:07 ` Jonathan Cameron
0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Cameron @ 2015-10-11 14:05 UTC (permalink / raw)
To: Duan Andy, Bhuvanchandra DV, linux-iio@vger.kernel.org
Cc: stefan@agner.ch, maitysanchayan@gmail.com, knaack.h@gmx.de,
lars@metafoo.de, pmeerw@pmeerw.net, shawn.guo@linaro.org,
linux-kernel@vger.kernel.org
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
>
>>> ---
>>> 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);
>>>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] vf610_adc: Fix internal temperature calculation
2015-10-11 14:05 ` Jonathan Cameron
@ 2015-10-11 14:07 ` Jonathan Cameron
0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2015-10-11 14:07 UTC (permalink / raw)
To: Duan Andy, Bhuvanchandra DV, linux-iio@vger.kernel.org
Cc: stefan@agner.ch, maitysanchayan@gmail.com, knaack.h@gmx.de,
lars@metafoo.de, pmeerw@pmeerw.net, shawn.guo@linaro.org,
linux-kernel@vger.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
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] vf610_adc: Fix internal temperature calculation
2015-10-08 6:16 ` Stefan Agner
@ 2015-10-13 3:37 ` Bhuvanchandra
0 siblings, 0 replies; 8+ messages in thread
From: Bhuvanchandra @ 2015-10-13 3:37 UTC (permalink / raw)
To: Stefan Agner
Cc: linux-iio, jic23, maitysanchayan, B38611, knaack.h, lars, pmeerw,
shawn.guo, linux-kernel, bhuvanchandra.dv
Hi Stefan,
Sorry! for the delay.
On 10/08/2015 11:46 AM, Stefan Agner wrote:
> Hi Bhuvan,
>
> On 2015-09-23 06: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.
> I am not entirely happy with the message. The proposed changes seem not
> to alter the offset which would explain a ~20°C difference... Where do
> this 20°C come from?
The ~20°C difference is observed at higher temperatures when VTEMP25
at VREDH_ADC of 3V0 is considered. Will update the comment according
to the updated VTEMP25 constant instead of the 20°C difference which
is confusing wrt the changes done here.
Best regards,
Bhuvan
> --
> Stefan
>
>> 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>
>> ---
>> 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);
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-10-13 3:37 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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-11 14:05 ` Jonathan Cameron
2015-10-11 14:07 ` Jonathan Cameron
2015-10-08 6:16 ` Stefan Agner
2015-10-13 3:37 ` Bhuvanchandra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).