[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1765425.OcFVFKOaMc@pebbles>
Date: Sat, 25 Nov 2017 21:49:14 +0100
From: Stefan Brüns <stefan.bruens@...h-aachen.de>
To: Guenter Roeck <linux@...ck-us.net>
CC: Maciej Purski <m.purski@...sung.com>,
Jonathan Cameron <jic23@...nel.org>,
<linux-iio@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-hwmon@...r.kernel.org>,
Javier Martinez Canillas <javier@....samsung.com>,
Peter Meerwald-Stadler <pmeerw@...erw.net>,
Lars-Peter Clausen <lars@...afoo.de>,
Hartmut Knaack <knaack.h@....de>,
"Jean Delvare" <jdelvare@...e.com>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>
Subject: Re: [PATCH 2/2] hwmon: (ina2xx) Make calibration register value fixed
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@...sung.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
Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)
Powered by blists - more mailing lists