Battery level

More
25 Apr 2012 23:16 #52 by PhracturedBlue
Battery level was created by PhracturedBlue
Any ideas on how to get the battery voltage? I don't think they use the STM32 power monitoring capabilities (since that would be after the voltage regulator. So I'm guessing they get it from somewhere else. Since there is an image for the battery level, if I could find where the appropriate image is loaded That would probably help figure out how they do it, but I am not sure how the BMP lookup happens in the firmware.

Please Log in or Create an account to join the conversation.

More
26 Apr 2012 05:06 - 20 Jul 2012 23:05 #53 by PhracturedBlue
Replied by PhracturedBlue on topic Re: Battery level
Ok, after several hours, I'm finally there.

Apparently PC.14 and PC.15 are used to detect whether the Tx is on AC power or not (one displays an 'x' the other the 'plug' icon.
I figured they must use an ADC for the voltage, but not which channel.
No matter, looking at available channels, I tried reading them and noticed that GPIOC.4 is connected underneath the MCU, so I don't know where it goes, but I just read from it, and indeed, it varies with voltage (fresh batteries gave me a value of 0xACD, old batteries around 0x800, and I can watch the value fall over time.
Last edit: 20 Jul 2012 23:05 by PhracturedBlue.

Please Log in or Create an account to join the conversation.

More
26 Apr 2012 09:24 #54 by FDR
Replied by FDR on topic Re: Battery level
So does it mean, that it is possible to give a voltage readout display instead of the battery symbols?
It would be cool, because many people complained about that if one uses 2s LiPo, then the battery indicator shows full (because of the higher voltage of a 2s LiPo) while the LiPo in fact can be flat already...

Please Log in or Create an account to join the conversation.

More
26 Apr 2012 13:26 - 26 Apr 2012 13:27 #58 by PhracturedBlue
Replied by PhracturedBlue on topic Re: Battery level
I think so. I don't have a decent adjustable power supply, but the 5V supply I have is adjustable from 4.4-5.9V and is very accurate. Here is the A/D reading for each voltage I collected:
voltage	value
5.89	2649
5.8	2604
5.7	2558
5.6	2513
5.5	2464
5.4	2416
5.3	2371
5.2	2323
5.1	2270
5	2226
4.9	2180
4.8	2132
4.7	2085
4.6	2037
4.5	1990
4.44	1961
If you plot that, You'll see it makes a very straight line. Assuming that holds across the range, it is easy to determine the actual battery voltage
Last edit: 26 Apr 2012 13:27 by PhracturedBlue.

Please Log in or Create an account to join the conversation.

More
26 Apr 2012 13:39 #59 by FDR
Replied by FDR on topic Re: Battery level
Cool, thanks! :)

Then the fw can even detect the battery type used, and warn when appropriate...

Please Log in or Create an account to join the conversation.

More
26 Apr 2012 15:20 #60 by PhracturedBlue
Replied by PhracturedBlue on topic Re: Battery level
I've updated the test firmware in the downloads section. It will now report battery voltage to 3 decimal places (but with only ~1% accuracy)
The formula used is:
voltage = (x * 1564 / 181 + 1239) >> 12

It should support voltages ~0 to 8.9V

Please Log in or Create an account to join the conversation.

Time to create page: 0.048 seconds
Powered by Kunena Forum