lkml.org 
[lkml]   [2017]   [Nov]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 2/2] hwmon: (ina2xx) Make calibration register value fixed
Date
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[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2017-11-25 21:50    [W:0.113 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site