This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to calculate battery voltage into percentage for AA 2 batteries without fluctuations?

Hello,

I am using 10 bit ADC read VDD voltage convert into mv without using any external voltage divider circuit, as per following function:

static void adc_configure_battery(void) { ret_code_t err_code = nrf_drv_saadc_init(NULL, saadc_event_handler); APP_ERROR_CHECK(err_code);

nrf_saadc_channel_config_t config =
    NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_VDD);
err_code = nrf_drv_saadc_channel_init(3, &config);
APP_ERROR_CHECK(err_code);

err_code = nrf_drv_saadc_buffer_convert(&adc_battery_buf[0], 1);
APP_ERROR_CHECK(err_code);

err_code = nrf_drv_saadc_buffer_convert(&adc_battery_buf[1], 1);
APP_ERROR_CHECK(err_code);

}

And following function is use for conversion battery mv into percentage:

/* - Section 1: 3.0V - 2.9V = 100% - 42% (58% drop on 100 mV)

    • Section 2: 2.9V - 2.74V = 42% - 18% (24% drop on 160 mV)
    • Section 3: 2.74V - 2.44V = 18% - 6% (12% drop on 300 mV)
    • Section 4: 2.44V - 2.1V = 6% - 0% (6% drop on 340 mV)*/

static uint8_t battery_level_in_percentage(const uint16_t mvolts) { uint8_t battery_level;

if (mvolts >= 3000)
{
	battery_level = 100;
}
else if (mvolts > 2900)
{
	battery_level = 100 - ((3000 - mvolts) * 58) / 100;
}
else if (mvolts > 2740)
{
	battery_level = 42 - ((2900 - mvolts) * 24) / 160;
}
else if (mvolts > 2440)
{
	battery_level = 18 - ((2740 - mvolts) * 12) / 300;
}
else if (mvolts > 2100)
{
	battery_level = 6 - ((2440 - mvolts) * 6) / 340;
}
else
{
	battery_level = 0;
}
return battery_level;

}

But problem is when i measure battery volatge it get sometime 58% sometime 70% means its variation in battery percentage. So how i can stable this battery percentage and i need this percentage is decrease as per battery voltage drain. So please suggest me any specific formula for AA battery. I am using two AA battery for my device is 1.5*2= 3V.

  • How did you come up with the lookup table above? Are you using rechargeable AA batteries? Did you do a discharge & charge test to figure out the relationship between Open Circuit Voltage (i.e. battery voltage) and State of Charge (i.e. remaining battery energy given as a %)?

  • NO i am not using AA rechargeable battery using simple AA non rechargeable battery e.g. nippo, every day like this. for this AA battery non rechargeable battery in above formula which parameter i need to change or set for calculating voltage in percentage.

  • I still do not understand how you calculated the formula above for calculating the state of charge (%) of the battery? Did you find it on the internet?

  • Ideally, you want to do a discharge test to find the "formula" you are referring to.

    If you take a look at this picture, you can see the Open Circuit Voltage of the battery compared to the state of charge of the battery. What you want to do is to do a constant current discharge test, where you discharge the battery with a C/30 A discharge for example. That means that it would take 30 hours to fully discharge (i.e. 0% SoC) one battery from a full charge (100% SoC). This is done to minimize cell hysteresis. But you could also do a C/10 discharge test for example if you want to save a bit of time (i.e. will be done in 10 hours). The discharge test is normally done in professional battery testing chambers ideally with a constant temperature of about 25 degrees Celsius. These tests are then repeated at different temperatures to get a SoC vs OCV relationship for different temperature regions (e.g. -10, 0, 10, 20, 30, 40 Celsius). While discharging the cell, you want to measure the voltage every 1 second for example, as well as the Ampere hours discharged (Ah, i.e. current*time).

    This should give you a curve similar to this figure:

    image description

    The figure can be found in Gregory Plett's lecture notes here. Then you can assume that the coulombic efficiency eta is approximately equal to 1. This leaves you with the formula SoC(t) = 1- Ah discharged(t)/cell capacity Q, where t refers to number of seconds the discharge test has been run and the cell capacity Q is given in Ah. Then, SoC is given as a decimal, where 0 refers to 0% and 1 is 100% SoC. The formula shown is often referred to as coulomb counting.

    If you do not have lab equipment (or do not want to spend this much time to get a relationship between SoC and the open circuit voltage), you could talk to the cell manufacturer and ask for a lookup table comparing OCV with SoC at every 1% SoC for example. They have most likely performed this exact test. I am not sure whether they would be willing to give you the data though unfortunately ...

    If you are very interested, you could have a look at the lecture notes from Prof. Gregory Plett. Have a look at Chapter 2.7 Determining temperature-dependent OCV. This chapter explains things much more thoroughly. You can also download the lecture video if you prefer to hear him talk. Might be easier. Hope that helps!

  • For a similar answer that gives an even more detailed look at this, you can have a look at this devzone case.

Related