* [PATCH v2] vf610_adc: Fix internal temperature calculation
@ 2015-10-19 15:54 Bhuvanchandra DV
2015-10-25 12:14 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Bhuvanchandra DV @ 2015-10-19 15:54 UTC (permalink / raw)
To: stefan, jic23, linux-iio
Cc: B38611, knaack.h, lars, pmeerw, shawn.guo, linux-kernel,
maitysanchayan, Bhuvanchandra DV
Calculate ADCR_VTEMP25 using VTEMP25 at VREFH_ADC 3V3. Existing
calculations consider the typical values provided in datasheet.
Those typical values are valid for VREFH_ADC at 3.0V. VTEMP25
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.
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 |
Acked-by: Fugang Duan <B38611@freescale.com>
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.6.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] vf610_adc: Fix internal temperature calculation
2015-10-19 15:54 [PATCH v2] vf610_adc: Fix internal temperature calculation Bhuvanchandra DV
@ 2015-10-25 12:14 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2015-10-25 12:14 UTC (permalink / raw)
To: Bhuvanchandra DV, stefan, linux-iio
Cc: B38611, knaack.h, lars, pmeerw, shawn.guo, linux-kernel, maitysanchayan
On 19/10/15 16:54, Bhuvanchandra DV wrote:
> Calculate ADCR_VTEMP25 using VTEMP25 at VREFH_ADC 3V3. Existing
> calculations consider the typical values provided in datasheet.
> Those typical values are valid for VREFH_ADC at 3.0V. VTEMP25
> 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.
>
> 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 |
>
> Acked-by: Fugang Duan <B38611@freescale.com>
>
> Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>
Applied to the fixes-togreg branch of iio.git and marked for stable.
Note these won't now go anywhere until after the release occurs
(to close for a fix for something that has been true a while)
Note standard ordering of signed-off by etc is
Author sign off
Reviewer acked by
My sign off (though I add this).
> ---
> 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] 2+ messages in thread
end of thread, other threads:[~2015-10-25 12:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-19 15:54 [PATCH v2] vf610_adc: Fix internal temperature calculation Bhuvanchandra DV
2015-10-25 12:14 ` Jonathan Cameron
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).