From: "Stefan Brüns" <stefan.bruens@rwth-aachen.de>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Maciej Purski <m.purski@samsung.com>,
Jonathan Cameron <jic23@kernel.org>, <linux-iio@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-hwmon@vger.kernel.org>,
Javier Martinez Canillas <javier@osg.samsung.com>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Lars-Peter Clausen <lars@metafoo.de>,
Hartmut Knaack <knaack.h@gmx.de>,
"Jean Delvare" <jdelvare@suse.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Subject: Re: [PATCH 2/2] hwmon: (ina2xx) Make calibration register value fixed
Date: Sat, 25 Nov 2017 21:49:14 +0100 [thread overview]
Message-ID: <1765425.OcFVFKOaMc@pebbles> (raw)
In-Reply-To: <90ceee91-de0e-456f-b0c9-9274973ac02b@roeck-us.net>
[-- Attachment #1: Type: text/plain, Size: 1881 bytes --]
On Saturday, November 25, 2017 7:50:16 PM CET Guenter Roeck wrote:
> On 11/22/2017 07:32 AM, Maciej Purski wrote:
> > Calibration register is used for calculating current register in
> > hardware according to datasheet:
> > current = shunt_volt * calib_register / 2048 (ina 226)
> > current = shunt_volt * calib_register / 4096 (ina 219)
> >
> > Fix calib_register value to 2048 for ina226 and 4096 for ina 219 in
> > order to avoid truncation error and provide best precision allowed
> > by shunt_voltage measurement. Make current scale value follow changes
> > of shunt_resistor from sysfs as calib_register value is now fixed.
> >
> > Power_lsb value should also follow shunt_resistor changes as stated in
> > datasheet:
> > power_lsb = 25 * current_lsb (ina 226)
> > power_lsb = 20 * current_lsb (ina 219)
> >
> > Signed-off-by: Maciej Purski <m.purski@samsung.com>
>
> Setting the calibration register to a specific value may optimize precision,
> but limits the supported value range, which is the whole point of providing
> a calibration register. What am I missing here ?
For the current register, any different calibration register value is
completely useless - smaller values just truncate the register value, larger
values adds noise in the lsbs. Both registers (current/shunt voltage) are
16bit, and nothing is going to change that.
There is a *very* small allowed power operating area where scaling down would
be of any use:
1. Bus voltage exceeds 25 (20) Volts
2. Shunt voltage is about 82 (320) mV
In this case the power register overflows. More specifically, if:
(shunt_voltage [mv] / 81.92) * (bus_voltage [V] / 25) > 1
Maximum allowed bus voltage is 36 V resp 26 V. (ina226/219).
Kind regards,
Stefan
--
Stefan Brüns / Bergstraße 21 / 52062 Aachen
home: +49 241 53809034 mobile: +49 151 50412019
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
next prev parent reply other threads:[~2017-11-25 20:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20171122153241eucas1p26b8796ba5427a64c2e742a728666e4b2@eucas1p2.samsung.com>
2017-11-22 15:32 ` [PATCH 0/2] Make calibration register value fixed for ina2xx drivers Maciej Purski
2017-11-22 15:32 ` [PATCH 1/2] iio: adc: ina2xx: Make calibration register value fixed Maciej Purski
2017-11-25 16:41 ` Jonathan Cameron
2017-11-25 22:27 ` Stefan Brüns
2017-11-22 15:32 ` [PATCH 2/2] hwmon: (ina2xx) " Maciej Purski
2017-11-25 18:50 ` Guenter Roeck
2017-11-25 20:49 ` Stefan Brüns [this message]
2017-11-29 21:23 ` [2/2] " Guenter Roeck
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=1765425.OcFVFKOaMc@pebbles \
--to=stefan.bruens@rwth-aachen.de \
--cc=b.zolnierkie@samsung.com \
--cc=javier@osg.samsung.com \
--cc=jdelvare@suse.com \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=m.purski@samsung.com \
--cc=m.szyprowski@samsung.com \
--cc=pmeerw@pmeerw.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox