* Re: generic-adc-battery volatge-to-percent formula
[not found] ` <20160222172009.GA7393@earth>
@ 2016-10-24 12:34 ` Pavel Machek
2016-10-24 13:09 ` H. Nikolaus Schaller
0 siblings, 1 reply; 3+ messages in thread
From: Pavel Machek @ 2016-10-24 12:34 UTC (permalink / raw)
To: Sebastian Reichel, pali.rohar, kernel list, ivo.g.dimitrov.75,
patrikbachan, serge, abcloriens
Cc: H. Nikolaus Schaller, Belisko Marek, Linux PM mailing list
[-- Attachment #1: Type: text/plain, Size: 641 bytes --]
Hi!
> On Mon, Feb 22, 2016 at 06:58:13AM +0100, H. Nikolaus Schaller wrote:
> > >> static inline int fuel_level_LiIon(int mV, int mA, int mOhm) {
> > >> ...
> > >> }
> >
> > To which header file should this go?
>
> I think it should get its own header file in include/linux/power/.
> Maybe something like "generic-fuel-gauge.h". I'm open to other
> solutions, though.
I'd like to use use this formula in my own code. Is it somewhere in
the kernel already?
Thanks,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: generic-adc-battery volatge-to-percent formula
2016-10-24 12:34 ` generic-adc-battery volatge-to-percent formula Pavel Machek
@ 2016-10-24 13:09 ` H. Nikolaus Schaller
2017-04-11 17:31 ` Pavel Machek
0 siblings, 1 reply; 3+ messages in thread
From: H. Nikolaus Schaller @ 2016-10-24 13:09 UTC (permalink / raw)
To: Pavel Machek
Cc: Sebastian Reichel, pali.rohar, kernel list, ivo.g.dimitrov.75,
patrikbachan, serge, abcloriens, Belisko Marek,
Linux PM mailing list
[-- Attachment #1: Type: text/plain, Size: 1941 bytes --]
Hi Pavel,
> Am 24.10.2016 um 14:34 schrieb Pavel Machek <pavel@ucw.cz>:
>
> Hi!
>
>> On Mon, Feb 22, 2016 at 06:58:13AM +0100, H. Nikolaus Schaller wrote:
>>>>> static inline int fuel_level_LiIon(int mV, int mA, int mOhm) {
>>>>> ...
>>>>> }
>>>
>>> To which header file should this go?
>>
>> I think it should get its own header file in include/linux/power/.
>> Maybe something like "generic-fuel-gauge.h". I'm open to other
>> solutions, though.
>
> I'd like to use use this formula in my own code. Is it somewhere in
> the kernel already?
Not that I am aware of. Marek is still working on the generic-adc-battery
driver augmented by DT + iio-ADC + formula before publication.
Here is the latest draft so you can cherry-pick it into your work:
http://git.goldelico.com/?p=gta04-kernel.git;a=patch;h=22ab047ae296e998379c1aa29fe1210043cfa040
But beware: I think it is quite wrong using the sqrt() function above 19.66%
and doing linear interpolation below.
By using the sqrt() function it has a steepness that goes to infinity when reaching
19.66% from above. This makes a quite non-realistic curve with a sharp bend at 19.66%
(which is equivalent to 3.756 V).
No real battery I have seen and measured with a coulomb counter has such a strange
bend at 3.756 V...
IMHO it would be a better approximation to adjust the factors so that e.g. a realistic
voltage for "empty" (e.g. 3.3 V) is taken as the 0% point where steepness goes through
the roof.
It should then be something like:
SOC = sqrt((Volt - 3.3 V) / (4.2 V - 3.3 V))
This goes more smoothly between 100% and 0%.
Or we could even use an exponential function with an exponent different from 1/2
(1 being linear interpolation):
SOC = pow((Volt - 3.3 V) / (4.2 V - 3.3 V), factor)
But this would probably need floating point arithmetic in the kernel or some numeric
approximation algorithm.
BR,
Nikolaus
[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: generic-adc-battery volatge-to-percent formula
2016-10-24 13:09 ` H. Nikolaus Schaller
@ 2017-04-11 17:31 ` Pavel Machek
0 siblings, 0 replies; 3+ messages in thread
From: Pavel Machek @ 2017-04-11 17:31 UTC (permalink / raw)
To: H. Nikolaus Schaller
Cc: Sebastian Reichel, pali.rohar, kernel list, ivo.g.dimitrov.75,
patrikbachan, serge, abcloriens, Belisko Marek,
Linux PM mailing list
[-- Attachment #1: Type: text/plain, Size: 2259 bytes --]
On Mon 2016-10-24 15:09:26, H. Nikolaus Schaller wrote:
> Hi Pavel,
>
> > Am 24.10.2016 um 14:34 schrieb Pavel Machek <pavel@ucw.cz>:
> >
> > Hi!
> >
> >> On Mon, Feb 22, 2016 at 06:58:13AM +0100, H. Nikolaus Schaller wrote:
> >>>>> static inline int fuel_level_LiIon(int mV, int mA, int mOhm) {
> >>>>> ...
> >>>>> }
> >>>
> >>> To which header file should this go?
> >>
> >> I think it should get its own header file in include/linux/power/.
> >> Maybe something like "generic-fuel-gauge.h". I'm open to other
> >> solutions, though.
> >
> > I'd like to use use this formula in my own code. Is it somewhere in
> > the kernel already?
>
> Not that I am aware of. Marek is still working on the generic-adc-battery
> driver augmented by DT + iio-ADC + formula before publication.
>
> Here is the latest draft so you can cherry-pick it into your work:
>
> http://git.goldelico.com/?p=gta04-kernel.git;a=patch;h=22ab047ae296e998379c1aa29fe1210043cfa040
>
> But beware: I think it is quite wrong using the sqrt() function above 19.66%
> and doing linear interpolation below.
>
> By using the sqrt() function it has a steepness that goes to infinity when reaching
> 19.66% from above. This makes a quite non-realistic curve with a sharp bend at 19.66%
> (which is equivalent to 3.756 V).
>
> No real battery I have seen and measured with a coulomb counter has such a strange
> bend at 3.756 V...
>
> IMHO it would be a better approximation to adjust the factors so that e.g. a realistic
> voltage for "empty" (e.g. 3.3 V) is taken as the 0% point where steepness goes through
> the roof.
>
> It should then be something like:
>
> SOC = sqrt((Volt - 3.3 V) / (4.2 V - 3.3 V))
>
> This goes more smoothly between 100% and 0%.
>
> Or we could even use an exponential function with an exponent different from 1/2
> (1 being linear interpolation):
>
> SOC = pow((Volt - 3.3 V) / (4.2 V - 3.3 V), factor)
>
> But this would probably need floating point arithmetic in the kernel or some numeric
> approximation algorithm.
Thanks!
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-04-11 17:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CAAfyv37rjchL=FtvgGhjrfXnCvhfbYCext48QmSuOgJ5RjTwAQ@mail.gmail.com>
[not found] ` <20160212085157.GA16326@amd>
[not found] ` <CAAfyv34=C5NSTuqR9Pf4MT2Z42XvT_1Gw+kyjZZh12zC2cBoFA@mail.gmail.com>
[not found] ` <20160215115304.GA5014@amd>
[not found] ` <20160221200653.GD15242@earth>
[not found] ` <0BD7A329-A8BE-4B3E-B98F-CAB7A25F643F@goldelico.com>
[not found] ` <20160221211257.GA26418@amd>
[not found] ` <7720041C-DFEC-4592-A5AE-0C2BEEFB6049@goldelico.com>
[not found] ` <20160222172009.GA7393@earth>
2016-10-24 12:34 ` generic-adc-battery volatge-to-percent formula Pavel Machek
2016-10-24 13:09 ` H. Nikolaus Schaller
2017-04-11 17:31 ` Pavel Machek
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).