From: Pavel Machek <pavel@ucw.cz>
To: "H. Nikolaus Schaller" <hns@goldelico.com>
Cc: Sebastian Reichel <sre@kernel.org>,
Belisko Marek <marek.belisko@gmail.com>,
Linux PM mailing list <linux-pm@vger.kernel.org>
Subject: Re: generic-adc-battery volatge-to-percent formula
Date: Sun, 21 Feb 2016 22:12:57 +0100 [thread overview]
Message-ID: <20160221211257.GA26418@amd> (raw)
In-Reply-To: <0BD7A329-A8BE-4B3E-B98F-CAB7A25F643F@goldelico.com>
Hi!
>
> it could be something similar to (I might have made a mistake when applying scaling):
>
> /* calculate remaining fuel level (in %) of a LiIon battery assuming
> * a standard chemistry model
> * http://cseweb.ucsd.edu/~trosing/lectures/battery.pdf
> *
> * @mV: voltage measured outside the battery
> * @mA: current flowing out of the battery
> * @mOhm: assumed series resitance of the battery
> *
> * returns value between 0 and 100
> */
>
> static inline int fuel_level_LiIon(int mV, int mA, int mOhm) {
> int u;
> /* internal battery voltage is higher than measured */
add " when discharging".
> mV += (mOhm * mA) /1000;
>
> /* apply formula */
> u = 3870000 - (14523 * (37835 - 10 * mV));
/* linear approximation between 3.756V */
> if (u < 0)
> return ((mV - 3300) * ((3756 - 3300) * 1966)) / 100000;
> return (1966 + sqrt(u))/100;
> }
>
Thanks,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
next prev parent reply other threads:[~2016-02-21 21:13 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-11 20:38 generic-adc-battery volatge-to-percent formula Belisko Marek
2016-02-12 8:51 ` Pavel Machek
2016-02-15 8:52 ` Belisko Marek
2016-02-15 11:53 ` Pavel Machek
2016-02-21 20:06 ` Sebastian Reichel
2016-02-21 20:36 ` H. Nikolaus Schaller
2016-02-21 21:12 ` Pavel Machek [this message]
2016-02-22 5:58 ` H. Nikolaus Schaller
2016-02-22 17:20 ` Sebastian Reichel
2016-10-24 12:34 ` Pavel Machek
2016-10-24 13:09 ` H. Nikolaus Schaller
2017-04-11 17:31 ` Pavel Machek
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=20160221211257.GA26418@amd \
--to=pavel@ucw.cz \
--cc=hns@goldelico.com \
--cc=linux-pm@vger.kernel.org \
--cc=marek.belisko@gmail.com \
--cc=sre@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).