From: "Brüns, Stefan" <Stefan.Bruens@rwth-aachen.de>
To: Nicolin Chen <nicoleotsuka@gmail.com>
Cc: "jdelvare@suse.com" <jdelvare@suse.com>,
"linux@roeck-us.net" <linux@roeck-us.net>,
"linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"corbet@lwn.net" <corbet@lwn.net>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
"m.purski@samsung.com" <m.purski@samsung.com>
Subject: Re: [RFC][PATCH] hwmon: (ina2xx) Improve current and power reading precision
Date: Wed, 21 Nov 2018 16:13:01 +0000 [thread overview]
Message-ID: <2863036.QIPGp1Eqjm@sbruens-linux.lcs.intern> (raw)
In-Reply-To: <20181121012629.5432-1-nicoleotsuka@gmail.com>
On Mittwoch, 21. November 2018 02:26:29 CET Nicolin Chen wrote:
> === Background ===
[...]
>
> === Problem ===
> Both methods simplify software routine by fixing one factor, which
> sacrifices the precision of the hardware measurement results.
>
> Using ina226 for example, with method A, the current scale was 1mA
> and the power scale was 25mA.
>
> With method B, calibration value is fixed at 2048 so the precision
> is decided by shunt resistor value. It sounds reasonable since the
> hardware engineers can use a larger shunt resistor when they need
> higher resolution. However, they often concern power burning across
> the resistor as well, so the resistor usually won't be so large: a
> typical value 1000 micro-ohms, which results in a current scale at
> 2.5 mA and a power sacle at 62.5 mW.
Power loss surely is a concern, but figures should be kept reasonable.
1. You mention 1.8V bus voltage, and currents in the 30mA range. Using the
1mOhm current shunt:
U_S = R_S * I_S 1e-3 Ohm * 30e-3 A = 30e-6 V (30uV)
P_S = U_S * I_S = 30e-6V * 30e-3 A = 900e-9W = 0.9 uW
INA219 Power Supply (Datasheet)
Min operating Voltage: 3V
Quiescent Current: 0.7mA
-> Min power: 2.1mW
So the INA219 alone uses 2.1mW, 1000 times more than the shunt.
Another concern may be voltage drop over the shunt, but for this case you have
a nominal voltage of 1.8V, so 30uV are 0.001%.
> When measuring a 1.8v voltage running a small current (e.g. 33 mA),
> the power value (that's supposed to be 59.4 mW) becomes inaccurate
> due to the larger scale (25mA for method A; 62.5 mA for method B).
Another look into the datasheet reveals, even at full gain (PGA=1), the LSB is
40mV / 2^12 = 40mV / 4096 ~ 10uV. So when the current ADC reads out as 3*LSB,
this anything between 25mA and 35mA. This is the best case figure.
On top of quantisation error, you have the ADC offset voltage (V_OS), which is
given as (for PGA=1, best case): (+-) 10uV typical, (+-) 100uV max.
So, if you want to have meaningful readouts adjust your shunt to a reasonable
value. Even 100 times the current value will have no measurable effect on you
system (power loss: 90uW, voltage drop: 3mV).
Kind regards,
Stefan
next prev parent reply other threads:[~2018-11-21 16:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-21 1:26 [RFC][PATCH] hwmon: (ina2xx) Improve current and power reading precision Nicolin Chen
2018-11-21 16:13 ` Brüns, Stefan [this message]
2018-11-21 19:40 ` Nicolin Chen
2018-11-21 19:40 ` Nicolin Chen
2018-11-21 22:16 ` Brüns, Stefan
2018-11-21 22:57 ` Guenter Roeck
2019-01-05 1:26 ` Nicolin Chen
2019-01-05 1:26 ` Nicolin Chen
2019-01-17 22:38 ` Nicolin Chen
2019-01-17 23:13 ` Guenter Roeck
2019-01-17 23:16 ` Nicolin Chen
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=2863036.QIPGp1Eqjm@sbruens-linux.lcs.intern \
--to=stefan.bruens@rwth-aachen.de \
--cc=corbet@lwn.net \
--cc=jdelvare@suse.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=m.purski@samsung.com \
--cc=nicoleotsuka@gmail.com \
/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.