Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve kchal_get_bat_pct() estimation #15

Open
rorosaurus opened this issue Jul 13, 2018 · 3 comments
Open

Improve kchal_get_bat_pct() estimation #15

rorosaurus opened this issue Jul 13, 2018 · 3 comments

Comments

@rorosaurus
Copy link
Contributor

Improve kchal_get_bat_pct() state of charge estimation.

Right now we assume a linear relationship between voltage and state of charge.
LiPo batteries follow somewhat predictable curve, based on the rate of discharge.
image
We should compare the recorded rough average rate of discharge, to determine the C rating for average use, then update the kchal_get_bat_pct() to approximate this curve.

Absolutely accuracy is not the goal, just something roughly within 5% should be good enough, I think.

@rorosaurus
Copy link
Contributor Author

Also would be a good idea to smooth the reading of the voltage to begin with.
@Spritetm mentioned lowpass or hysteresis function might be good options. I'm wondering if something like a rolling average would be easiest?

@rorosaurus
Copy link
Contributor Author

To cheaply map V to a rough battery %, I did some curve fitting trial and error and eventually came up with these two curves, using a piecewise.

image

I'm content with these, and they certainly hit the goal of being within ~5%.

if v > 3.66 y = -11940.85 + 7812.571*x - 1676.957*x^2 + 118.9048*x^3
if v <= 3.66 y = 1.621552 + 7.644802e-17*e^(+10.92907*x)

Full list of mapped values:
batteryEstimator.txt

@rorosaurus
Copy link
Contributor Author

As mentioned above, we also need to stabilize kchal_get_bat_mv() in some way, to get less erratic readings across small time frames.

A good example of lowpass filter which we could mimic: https://github.com/JonHub/Filters/blob/master/FilterOnePole.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant