Batteries are notoriously hard to measure, especially when compared to just looking at a transparent gasoline tank. We’ve come a long way from the simple voltage divider in the first batch to reading full voltage and amperage using the ESCs in the later batches. However the battery percent still isn’t as accurate as it could be.
Here’s what an LiPo battery usually looks like:
Notice that its curved a lot on the beginning and the end. Its a lot like a sigmoid function.
Right now the model we use for battery percentage is a straight line. We can be a bit smarter than that.
Below is a function to map out the LiPo battery percentage vs the red straight line.
(sorry, the second graph has the X and Y flipped)
The code was inspired by the work at the battery sense Arduino project. Check out that readme for more detailed info.
So now the fun part: I updated the code to use the new sigmoidal function and display the battery percentage based on the curve. The percentage should now be more linear since it is modeled after the actual battery discharge.
I’m looking for people that want to try it out and update their controller. It should work on batch 4+
Also feel free to comment on the code, its available here ->
Flash file: openppg-battery-curve.uf2 (141.5 KB)