* [PATCH 0/2] iio: ak8975: Fix calculation formula and add device name
@ 2014-01-29 5:05 Beomho Seo
2014-01-29 8:53 ` Peter Meerwald
0 siblings, 1 reply; 3+ messages in thread
From: Beomho Seo @ 2014-01-29 5:05 UTC (permalink / raw)
To: linux-iio
Cc: Jonathan Cameron, Lars-Peter Clausen, Myungjoo Ham, Jaehoon Chung,
ldewangan
Three months ago Lars-Peter revised description of device driver[1].
Correctly, device's sensitivity is 0.3 uT/LSB typ and One micro tesla equal 0.01 gauss[2].
So I have fixed calculation formula,And then add RAW_TO_GAUSS macro.
Scale are returned as VAL_INT_PLUS_MICRO.
Additionally, I have add device name.
Tested on exynos4412 board, with following result:
-sh-4.1# cat name
ak8975
-sh-4.1# cat in_magn_x_raw
80
-sh-4.1# cat in_magn_x_scale
0.003609
Calculate the result 80 x 0.003609 = 0.28872 Gauss.
0.28872 G equal 288.72 mG
I think this magnitude value is proper level[3].
[1] http://marc.info/?l=linux-iio&m=138220306822747&w=2
[2] http://en.wikipedia.org/wiki/Gauss_(unit)
[3] http://en.wikipedia.org/wiki/Orders_of_magnitude_(magnetic_field)
Beomho Seo (2):
iio: ak8975: Fix calculation formula for microtesla to gauss unit
iio: ak8975: Add device name
drivers/iio/magnetometer/ak8975.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
--
Best Regards,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 0/2] iio: ak8975: Fix calculation formula and add device name
2014-01-29 5:05 [PATCH 0/2] iio: ak8975: Fix calculation formula and add device name Beomho Seo
@ 2014-01-29 8:53 ` Peter Meerwald
2014-02-04 5:52 ` Beomho Seo
0 siblings, 1 reply; 3+ messages in thread
From: Peter Meerwald @ 2014-01-29 8:53 UTC (permalink / raw)
To: Beomho Seo
Cc: linux-iio, Jonathan Cameron, Lars-Peter Clausen, Myungjoo Ham,
Jaehoon Chung, ldewangan
Hello,
> Three months ago Lars-Peter revised description of device driver[1].
me, not Lars-Peter
> Correctly, device's sensitivity is 0.3 uT/LSB typ and One micro tesla equal 0.01 gauss[2].
> So I have fixed calculation formula,And then add RAW_TO_GAUSS macro.
> Scale are returned as VAL_INT_PLUS_MICRO.
> Additionally, I have add device name.
+#define RAW_TO_GAUSS(asa) ((((asa) + 128) * 3000) / 256)
*
* Since 1uT = 0.01 gauss, our final scale factor becomes:
*
- * Hadj = H * ((ASA + 128) / 256) * 3/10 * 100
- * Hadj = H * ((ASA + 128) * 30 / 256
+ * Hadj = H * ((ASA + 128) / 256) * 3/10 * 1/100
+ * Hadj = H * ((ASA + 128) * 0.003) / 256
*
* Since ASA doesn't change, we cache the resultant scale factor into the
* device context in ak8975_setup().
*/
- data->raw_to_gauss[0] = ((data->asa[0] + 128) * 30) >> 8;
+ data->raw_to_gauss[0] = RAW_TO_GAUSS(data->asa[0]);
thank you for following up on this; I don't have the hardware, so I didn't
dare to change the driver...
the RAW_TO_GAUSS() macro doesn't match the comment Hadj = H * ... anymore
maybe put this explanation in the patch comment, not the cover letter?
regards, p.
--
Peter Meerwald
+43-664-2444418 (mobile)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 0/2] iio: ak8975: Fix calculation formula and add device name
2014-01-29 8:53 ` Peter Meerwald
@ 2014-02-04 5:52 ` Beomho Seo
0 siblings, 0 replies; 3+ messages in thread
From: Beomho Seo @ 2014-02-04 5:52 UTC (permalink / raw)
Cc: linux-iio, Peter Meerwald, Jonathan Cameron
On 01/29/2014 05:53 PM, Peter Meerwald wrote:
> Hello,
>
>> Three months ago Lars-Peter revised description of device driver[1].
>
> me, not Lars-Peter
>
I'm really sorry, my mistake.
>> Correctly, device's sensitivity is 0.3 uT/LSB typ and One micro tesla equal 0.01 gauss[2].
>> So I have fixed calculation formula,And then add RAW_TO_GAUSS macro.
>> Scale are returned as VAL_INT_PLUS_MICRO.
>> Additionally, I have add device name.
>
> +#define RAW_TO_GAUSS(asa) ((((asa) + 128) * 3000) / 256)
>
> *
> * Since 1uT = 0.01 gauss, our final scale factor becomes:
> *
> - * Hadj = H * ((ASA + 128) / 256) * 3/10 * 100
> - * Hadj = H * ((ASA + 128) * 30 / 256
> + * Hadj = H * ((ASA + 128) / 256) * 3/10 * 1/100
> + * Hadj = H * ((ASA + 128) * 0.003) / 256
> *
> * Since ASA doesn't change, we cache the resultant scale factor into the
> * device context in ak8975_setup().
> */
> - data->raw_to_gauss[0] = ((data->asa[0] + 128) * 30) >> 8;
> + data->raw_to_gauss[0] = RAW_TO_GAUSS(data->asa[0]);
>
> thank you for following up on this; I don't have the hardware, so I didn't
> dare to change the driver...
>
> the RAW_TO_GAUSS() macro doesn't match the comment Hadj = H * ... anymore
>
> maybe put this explanation in the patch comment, not the cover letter?
>
OK. I will resend explanation in the patch comment.
> regards, p.
>
--
Best Regards,
Beomho Seo, Assistant Engineer
System S/W Lab., Software Center, Samsung Electronics
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-02-04 5:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-29 5:05 [PATCH 0/2] iio: ak8975: Fix calculation formula and add device name Beomho Seo
2014-01-29 8:53 ` Peter Meerwald
2014-02-04 5:52 ` Beomho Seo
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.