Application Note TI SoC Estimation Using Smart Battery Charger
Application Note TI SoC Estimation Using Smart Battery Charger
Application Note
State of Charge Estimation Using Smart Battery Charger
Nick Brylski
ABSTRACT
The state of charge (SOC) of a battery is a measurement that represents the remaining capacity of the battery
as a percentage of its usable capacity. A fuel gauge is typically used to calculate the SOC by measuring
battery voltage, current, and temperature as inputs to a gauging algorithm. Using a fuel gauge often results in
an accurate SOC prediction. However, there are drawbacks to using a fuel gauge such as increased system
cost, larger solution size, and additional power consumption. In applications where a high SOC accuracy is not
required, a simple, voltage-based gauging method can be sufficient. This application note discusses a method of
implementing a voltage-based SOC using the built in ADC of a battery charger IC, such as the BQ25155. This
application note is also applicable to other chargers in the same family, including BQ25150 and BQ25157, or any
charger which allows for battery voltage measurements.
Table of Contents
1 Introduction.............................................................................................................................................................................1
2 Battery Characterization........................................................................................................................................................ 2
3 Generating the Lookup Table................................................................................................................................................ 2
4 BQ25155 Register Configuration...........................................................................................................................................3
5 Best Use Cases.......................................................................................................................................................................4
6 Python Lookup Table Generator........................................................................................................................................... 5
7 MSP430 Code Snippet............................................................................................................................................................6
List of Figures
Figure 2-1. Test Setup................................................................................................................................................................. 2
Figure 3-1. Vbat vs SOC..............................................................................................................................................................3
List of Tables
Table 4-1. BQ25155 Registers.....................................................................................................................................................4
Trademarks
All trademarks are the property of their respective owners.
1 Introduction
A simple way to provide battery SOC in your product is through a static lookup table that correlates battery
voltage to SOC. This lookup table can be generated by discharging the battery from full while measuring voltage
and current.
SLUAAA1 – OCTOBER 2021 State of Charge Estimation Using Smart Battery Charger 1
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
Battery Characterization www.ti.com
2 Battery Characterization
The following steps must be taken to generate the voltage versus SOC table. This setup requires a voltmeter,
ammeter, electronic load, and appropriate data logging equipment. Figure 2-1 shows a diagram of the test setup.
m
Qmax = k = 1i k × ∆ t (1)
i[k] is current at reading k, ∆t is the time difference between readings, and m is the total number of readings.
The remaining capacity can be computed at each reading n.
n
RemCap n = Qmax − k = 1i k × ∆ t (2)
RemCap n
SOC n = Qmax × 100 (3)
Graphing the battery voltage against SOC generates the typical SOC curve for one li-ion cell.
2 State of Charge Estimation Using Smart Battery Charger SLUAAA1 – OCTOBER 2021
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com BQ25155 Register Configuration
This method has been used to determine the accuracy of TI fuel gauges as seen here. The curve above
represents the exact SOC for the given discharge.
Example code has been included in the Python Lookup Table Generator section that generates a polynomial
regression based on the data generated from the SOC characterization. This data is then mapped to a 101-pt
hexadecimal lookup table for easy import into an MCU application. Using 16-bit resolution, this table would only
take up 202 bytes of memory.
4 BQ25155 Register Configuration
The BQ25155 is a highly integrated battery charge management IC that integrates the most common functions
for wearable and portable devices, namely a charger, a regulated output voltage rail for system power, 16 bit
ADC for battery and system monitoring, a LDO, and push-button controller. The BQ25155 IC integrates a linear
charger with PowerPath that enables quick and accurate charging for small batteries while providing a regulated
voltage to the system. The regulated system voltage (PMID) output can be configured through I 2C based on the
recommended operating condition of downstream ICs and system loads for optimal system operation.
Tto limit the number of ADC conversions, and hence power consumption, the ADC conversions when in active
battery mode can be limited to a period determined by the ADC_READ_RATE bits. In the case where the
ADC_READ_RATE is set to manual mode, the host has to set the ADC_CONV_START bit to initiate the ADC
conversion. After the ADC conversion is completed and the data is ready, the ADC_READY flag is set and an
interrupt is sent to the host. In low power mode, the ADC remains OFF for minimal IC power consumption. The
host must switch to active battery mode (set LP high) before performing an ADC measurement.
The BQ25155 allows for the creation of advanced battery monitoring and gauging firmware through its registers.
Relevant registers have been listed below in Table 4-1.
Also included in the MSP430 Code Snippet section is an MSP430 code snippet that shows interfacing with the
BQ25155.
SLUAAA1 – OCTOBER 2021 State of Charge Estimation Using Smart Battery Charger 3
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
Best Use Cases www.ti.com
EN_VBAT_READ 0x58 R/W Enable measurement for battery voltage (VBAT) channel.
4 State of Charge Estimation Using Smart Battery Charger SLUAAA1 – OCTOBER 2021
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
www.ti.com Python Lookup Table Generator
#Command Line Arguments: [TI format gauge output csv file], [Polynomial order for regression]
#Output: Plots VBAT vs SOC reported by TI gauge and creates a polynomial regression of the
specified order.
# This regression is plotted on the same graph as the data and is mapped to a 101-pt
hexadecimal lookup table given in the "lookup_table.txt" file.
vbat_arr = []
num_reads = 0
read_arr = []
soc_arr = []
poly4x = []
poly4y = []
poly3y = []
poly3x = []
bin_vals = []
#reads in the TI Gauge csv file and puts the data into the corresponding list.
#Adjust this section if not using TI gauge
with open (sys.argv[1]) as csv_file1:
csv_reader = csv.reader(csv_file1, dialect='excel',delimiter=',')
line_count = 0
for row in csv_reader:
if (line_count > 8): #To get rid of the labels and other unnecessary stuff
vbat_arr.append(float(row[6]))
soc_arr.append(int(row[16]))
num_reads += 1
line_count += 1
#This for loop creates an x and y list from the regression such that it can be plotted later.
#It also calculates the hex values for the battery voltages needed to create the lookup table.
for i in range (0, 101):
poly4y.append(poly4(i))
poly4x.append(i)
vbat_16 = int(round(((poly4(i)/1000)*(2**16))/6)) #Vbat formula found in datasheet
bin_vals.append(hex(vbat_16))
#This for loop outputs the lookup table to the file called "lookup_table.txt"
with open ("lookup_table.txt","w+") as outfile:
for i in range(0, 101):
outfile.write(str(bin_vals[i])[0] + str(bin_vals[i])[1] + str(bin_vals[i])[2].upper() +
str(bin_vals[i])[3].upper() + str(bin_vals[i])[4].upper() + str(bin_vals[i])[5].upper() + ",\n")
#Ensures that hex letters are all uppercase
outfile.close()
#The rest of this is for plotting the data collected and the calculated regression
plt.plot(soc_arr, vbat_arr, 'r', label='Battery Data')
plt.yticks([3000, 3200, 3400, 3600, 3800, 4000, 4200, 4400])
plt.plot(poly4x, poly4y,'b',label='Regression')
plt.xlabel('SOC (%)')
plt.ylabel('Battery Voltage (mV)')
plt.gca().invert_xaxis() #Reverses x axis so that 100% is shown as the leftmost value
plt.title('Battery Voltage vs SOC')
plt.legend()
plt.grid(b=True, which='major', axis='both')
plt.show()
SLUAAA1 – OCTOBER 2021 State of Charge Estimation Using Smart Battery Charger 5
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
MSP430 Code Snippet www.ti.com
// Enable ADC
StdI2C_P_TX_Single(BQ25150_ADDR, BQ25150_ADCCTRL0, 0x80, &Err); //Set ADC to perform conversion
every 1s at 24ms conversion speed
StdI2C_P_TX_Single(BQ25150_ADDR, BQ25150_ADCCTRL1, 0x00, &Err); //Disables comparator channels
//GPIO_setAsInputPinWithPullUpResistor(BQ_INT2);
GPIO_setAsInputPin(BQ_INT2);
GPIO_enableInterrupt(BQ_INT2);
GPIO_selectInterruptEdge(BQ_INT2, GPIO_HIGH_TO_LOW_TRANSITION);
GPIO_clearInterrupt(BQ_INT2);
while(1) {
}
}
for (i = cur_SOC - 1; i >= 0; i--){ //Begins at current SOC so it doesn't have to go through
the whole array each time.
if (VBAT_Meas >= SOC_lookup_table[i]){
return (uint8_t)(i + 1); //Must add 1 to the SOC found because array is zero-indexed.
}
}
6 State of Charge Estimation Using Smart Battery Charger SLUAAA1 – OCTOBER 2021
Submit Document Feedback
Copyright © 2021 Texas Instruments Incorporated
IMPORTANT NOTICE AND DISCLAIMER
TI PROVIDES TECHNICAL AND RELIABILITY DATA (INCLUDING DATA SHEETS), DESIGN RESOURCES (INCLUDING REFERENCE
DESIGNS), APPLICATION OR OTHER DESIGN ADVICE, WEB TOOLS, SAFETY INFORMATION, AND OTHER RESOURCES “AS IS”
AND WITH ALL FAULTS, AND DISCLAIMS ALL WARRANTIES, EXPRESS AND IMPLIED, INCLUDING WITHOUT LIMITATION ANY
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT OF THIRD
PARTY INTELLECTUAL PROPERTY RIGHTS.
These resources are intended for skilled developers designing with TI products. You are solely responsible for (1) selecting the appropriate
TI products for your application, (2) designing, validating and testing your application, and (3) ensuring your application meets applicable
standards, and any other safety, security, regulatory or other requirements.
These resources are subject to change without notice. TI grants you permission to use these resources only for development of an
application that uses the TI products described in the resource. Other reproduction and display of these resources is prohibited. No license
is granted to any other TI intellectual property right or to any third party intellectual property right. TI disclaims responsibility for, and you
will fully indemnify TI and its representatives against, any claims, damages, costs, losses, and liabilities arising out of your use of these
resources.
TI’s products are provided subject to TI’s Terms of Sale or other applicable terms available either on ti.com or provided in conjunction with
such TI products. TI’s provision of these resources does not expand or otherwise alter TI’s applicable warranties or warranty disclaimers for
TI products.
TI objects to and rejects any additional or different terms you may have proposed. IMPORTANT NOTICE
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2022, Texas Instruments Incorporated