All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Stephan Gerhold <stephan@gerhold.net>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
	linux-iio <linux-iio@vger.kernel.org>,
	"Hartmut Knaack" <knaack.h@gmx.de>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Peter Meerwald-Stadler" <pmeerw@pmeerw.net>,
	"Linux Input" <linux-input@vger.kernel.org>,
	"Nick Reitemeyer" <nick.reitemeyer@web.de>,
	"Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Subject: Re: [PATCH 2/2 v2] iio: magnetometer: ak8974: Provide scaling
Date: Thu, 16 Apr 2020 19:19:43 +0200	[thread overview]
Message-ID: <CACRpkdY9-QPAVT=WgbsWWzLeB5k-7JWB_YnppqeZ_OHr5kssNw@mail.gmail.com> (raw)
In-Reply-To: <20200416153200.GA897@gerhold.net>

On Thu, Apr 16, 2020 at 5:32 PM Stephan Gerhold <stephan@gerhold.net> wrote:
> On Thu, Apr 16, 2020 at 04:09:17PM +0200, Linus Walleij wrote:

> > The manual for the HSCDTD008A gives us a scaling for the
> > three axis as +/- 2.4mT per axis.
>
> I wonder if we can really assume that this applies to
> the other models (e.g. AK8974) as well?

Patches are for testing :D

I have a Ux500 reference board with the AK8974 vanilla
variant mounted so I will check with that one.

> > +     case IIO_CHAN_INFO_SCALE:
> > +             /*
> > +              * The datasheet for HSCDTF008A, page 3 specifies the
> > +              * range of the sensor as +/- 2.4 mT per axis, which corresponds
> > +              * to +/- 2400 uT = +/- 24 Gauss. So 0x7fff is 24 Gauss and
> > +              * 0xffff is -24 Gauss. To account for the one missing value if
> > +              * we multiply by 1/S16_MAX, instead multiply with 2/U16_MAX.
> > +              */
>
> I just want to note that (according to the datasheet), HSCDTD008A
> produces either 14-bit or 15-bit measurements (depending on
> the HSCDTD008A_CTRL4_RANGE bit that we set by default).

Argh OK I will fix this. I try to get an AMI datasheet as well.

> I think this isn't exposed correctly in the AK8974_AXIS_CHANNEL() macro
> (realbits is 16 instead of 15), so this might need special casing for
> hscdt008a?

Yes definately. It's a bug. I'll make a separate patch for this.

> The reason I mention this is because I think it would also affect the
> scaling that you implement here. With 15-bit output it produces values
> from +16383 (0x3fff) (= 2.4 mT?) to -16384 (0xc000) (= -2.4 mT?).
>
> So it would never reach the 0x7fff and 0xffff you mention
> in your comment.

You're right. What I need to do is put the HSCDTD008A and
AK8974 side by side and compare.

Yours,
Linus Walleij

  reply	other threads:[~2020-04-16 17:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-16 14:09 [PATCH 1/2 v2] iio: magnetometer: ak8974: Break out measurement Linus Walleij
2020-04-16 14:09 ` [PATCH 2/2 v2] iio: magnetometer: ak8974: Provide scaling Linus Walleij
2020-04-16 15:32   ` Stephan Gerhold
2020-04-16 17:19     ` Linus Walleij [this message]
2020-04-16 18:17   ` Michał Mirosław
2020-04-16 18:29     ` Michał Mirosław
2020-04-16 17:25 ` [PATCH 1/2 v2] iio: magnetometer: ak8974: Break out measurement Michał Mirosław

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='CACRpkdY9-QPAVT=WgbsWWzLeB5k-7JWB_YnppqeZ_OHr5kssNw@mail.gmail.com' \
    --to=linus.walleij@linaro.org \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=mirq-linux@rere.qmqm.pl \
    --cc=nick.reitemeyer@web.de \
    --cc=pmeerw@pmeerw.net \
    --cc=stephan@gerhold.net \
    /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.