Battery State Determination and Capacity Calculation Enhancement
Summary
Currently, a lookup table is used to determine the battery's charge level based on voltage. This feature can be enhanced by allowing the MCU to determine the battery state dynamically.
Existing Implementation
The lookup table for voltage and capacity in percentage:
Enable the MCU to determine the battery state by running a fully charged battery and discharging it down to just before a safe level. The safe level must be user-defined before running the test.
Discharge Functionality:
Discharge could be achieved by either powering all the LEDs or activating the BLE.
The MCU should monitor and record the voltage drop rate at specific voltages.
Improving Capacity Calculation:
Currently, the capacity is determined using linear interpolation:
for (uint16_t i = 0; i < BATTERY_STATES_COUNT - 1; i++)
{
// Find the two points battery_millivolt is between
if (battery_states[i].voltage >= battery_millivolt && battery_millivolt >= battery_states[i + 1].voltage)
{
// Linear interpolation
*battery_percentage = battery_states[i].percentage +
((float)(battery_millivolt - battery_states[i].voltage) *
((float)(battery_states[i + 1].percentage - battery_states[i].percentage) /
(float)(battery_states[i + 1].voltage - battery_states[i].voltage)));
LOG_DBG("%d %%", *battery_percentage);
return 0;
}
}
Expected Outcome
Dynamic Battery State Determination: The MCU can determine the battery state dynamically, improving accuracy.
Enhanced Capacity Calculation: More accurate capacity calculation by considering the actual discharge rate instead of linear interpolation.
Battery State Determination and Capacity Calculation Enhancement
Summary
Currently, a lookup table is used to determine the battery's charge level based on voltage. This feature can be enhanced by allowing the MCU to determine the battery state dynamically.
Existing Implementation
The lookup table for voltage and capacity in percentage:
Proposed Feature
Enable the MCU to determine the battery state by running a fully charged battery and discharging it down to just before a safe level. The safe level must be user-defined before running the test.
Discharge Functionality:
Improving Capacity Calculation: Currently, the capacity is determined using linear interpolation:
Expected Outcome