Method for determining battery level, and terminal device

By acquiring charge and discharge data during battery charging and discharging, and combining historical data with preset capacity, the power learning method is optimized, solving the problem of inaccurate power learning for batteries with high electrochemical stability, and achieving efficient and accurate power monitoring of the fuel gauge.

WO2026097934A1PCT designated stage Publication Date: 2026-05-15SHENZHEN PAX SMART NEW TECH CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
SHENZHEN PAX SMART NEW TECH CO LTD
Filing Date
2025-07-22
Publication Date
2026-05-15

Smart Images

  • Figure CN2025109761_15052026_PF_FP_ABST
    Figure CN2025109761_15052026_PF_FP_ABST
Patent Text Reader

Abstract

A method for determining a battery level, and a terminal device. The method comprises: during charging and discharging processes of a first battery currently connected to a terminal device, acquiring charging and discharging data, the charging and discharging data comprising charging data of the first battery during a charging process and / or discharging data thereof during a discharging process (S110); and when it is determined, on the basis of the charging and discharging data, that a data update condition is currently satisfied, determining a current full-charge capacity of the first battery on the basis of at least one of a first capacity, a second capacity and a third capacity, wherein the first capacity is a historical full-charge capacity stored in a flash memory of a fuel gauge of the terminal device, the second capacity is a preset full-charge capacity of the first battery, and the third capacity is equal to a total capacity charged during the charging process or a total capacity discharged during the discharging process (S120). The method can not only improve the accuracy and efficiency of battery level learning of fuel gauges, but also improve the applicability and flexibility of solutions, thereby providing better user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Methods for determining battery capacity and terminal equipment

[0001] This application claims priority to Chinese Patent Application No. 202411577903.6, filed on November 6, 2024, entitled "Method and Terminal Device for Determining Battery Power", the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application belongs to the field of battery technology, and in particular relates to a method for determining battery capacity and a terminal device. Background Technology

[0003] Smart terminal devices are widely used in various industries such as healthcare, finance, retail, education, and entertainment. Portable or mobile terminal devices typically require a rechargeable battery. These devices usually include a fuel gauge to monitor the battery level in real time, enabling better battery management and providing users with necessary battery information. For example, some devices with displays can show the battery level in real time. Considering scenarios involving prolonged use, some terminal devices have removable batteries. For terminal devices with removable batteries, after the device is disconnected from the battery, the reconnected battery may differ from the previously connected battery. Therefore, how the fuel gauge can quickly and accurately learn the connected battery's level after each power-on is a primary concern.

[0004] In existing technologies, battery gauges in terminal devices typically employ a static charge calibration algorithm for charge learning. This means that when the terminal device is powered off or in sleep mode, the battery gauge checks the battery's static state at regular intervals. Each time the battery is determined to be in a static state, the battery gauge measures the open-circuit voltage and estimates the battery's charge level based on this voltage. If the change between two estimated charge levels exceeds a threshold, and the deviation between the calculated full-charge capacity and the recorded full-charge capacity is less than a deviation threshold, the full-charge capacity is updated. Based on the updated full-charge capacity, the battery charge level can be calibrated, thus achieving the purpose of charge learning.

[0005] However, some batteries with high electrochemical stability, such as lithium iron phosphate batteries, are characterized by small voltage changes but large capacity changes. In static capacity calibration algorithms, the open-circuit voltage of the battery collected by the fuel gauge has a significant deviation, leading to inaccurate capacity determination for these batteries and poor capacity learning performance. Technical issues

[0006] This application provides a method, apparatus, terminal device, computer-readable storage medium, and computer program product for determining battery capacity. During battery charging and discharging, when the current data update conditions are met based on charging and discharging data, the current full charge capacity of the battery can be quickly and accurately determined based on at least one of the historical full charge capacity stored in the flash memory of the fuel gauge, the battery's preset full charge capacity, and the total capacity charged or discharged during the charging and discharging process. This significantly improves the efficiency and accuracy of the fuel gauge's capacity learning. Technical solutions

[0007] The first aspect of this application provides a method for determining battery power, including:

[0008] During the charging and discharging process of the first battery currently connected to the terminal device, charging and discharging data is acquired, wherein the charging and discharging data includes charging data of the first battery during the charging process and / or discharging data during the discharging process.

[0009] If the data update conditions are met based on the charging and discharging data, the current full charge capacity of the first battery is determined based on at least one of the first capacity, the second capacity, and the third capacity. The first capacity is the historical full charge capacity stored in the flash memory of the terminal device's fuel gauge, the second capacity is the preset full charge capacity of the first battery, and the third capacity is equal to the total capacity charged during the charging process or the total capacity discharged during the discharging process.

[0010] In one implementation, determining the current full charge capacity of the first battery based on at least one of a first capacity, a second capacity, and a third capacity includes:

[0011] If the current data update conditions are met, the current full charge capacity is determined based on the fuel gauge's power learning information and one of the first capacity, second capacity, or third capacity. The power learning information includes: first information indicating that the fuel gauge has not yet completed the first learning process for the first battery, or second information indicating that the fuel gauge has completed the first learning process for the first battery.

[0012] In one implementation, determining the current full charge capacity based on the battery level learning information from the fuel gauge and one of a first capacity, a second capacity, or a third capacity includes:

[0013] If the battery level information learned by the battery meter is the first information, the current full charge capacity is determined based on the first capacity or the second capacity.

[0014] If the battery level learning information of the battery meter is the second information, the current full charge capacity is determined based on one of the first capacity, the second capacity, or the third capacity.

[0015] In one implementation, when the battery level learning information of the fuel gauge is the first information, determining the current full charge capacity based on the first capacity or the second capacity includes:

[0016] Read the verification data stored in the flash memory of the fuel gauge, wherein the verification data includes: the value of the first capacity and the first verification value determined according to the first capacity;

[0017] If the first check value and the second check value corresponding to the first capacity are equal, the current full charge capacity is determined to be equal to the first capacity.

[0018] If the first check value and the second check value are not equal, or if no check data is read, the current full charge capacity is determined to be equal to the second capacity.

[0019] In one implementation, the method further includes:

[0020] If it is determined that the current data update conditions are met and the power learning information of the fuel gauge is the second information, then it is determined whether the first battery has reached the degradation condition based on the first difference between the third capacity and the second capacity and the first difference threshold.

[0021] If so, then if the second difference between the third capacity and the first capacity is greater than or equal to the second difference threshold, the verification data stored in the flash memory of the fuel meter is updated according to the value of the third capacity and the third verification value corresponding to the third capacity.

[0022] If not, clear the verification data stored in the flash memory of the fuel gauge.

[0023] In one implementation, the method further includes:

[0024] If it is determined that the current data update conditions are met and the fuel gauge's power learning information is the first information, then the fuel gauge's power learning information is updated to the second information; and / or

[0025] If it is determined that the terminal device is disconnected from the first battery, the power learning information of the fuel gauge is updated to the first information.

[0026] In one implementation, before determining the current full charge capacity of the first battery, the method further includes:

[0027] During the charging process, if it is determined from the charging data that the first battery is fully charged, then it is determined that the data update conditions are met; and / or

[0028] During the discharge process, if it is determined from the discharge data that the first battery has been completely discharged, then the data update conditions are met.

[0029] In one implementation, after determining the current full charge capacity of the first battery, the method further includes:

[0030] If, based on charging data, it is determined that the first battery is fully charged, the current remaining capacity and / or current remaining charge of the first battery are determined and updated, wherein the current remaining capacity equals the current full charge capacity, and the current remaining charge equals the full charge capacity; and / or

[0031] If it is determined from the discharge data that the first battery has been completely discharged, the current remaining capacity and / or current remaining charge of the first battery are determined and updated, wherein the current remaining capacity is equal to the discharged capacity and the current remaining charge is equal to the discharged charge.

[0032] In one implementation, the method further includes:

[0033] In response to the power-on command, determine the first battery curve parameters corresponding to the first battery;

[0034] If the first battery curve parameters are different from the second battery curve parameters stored in the fuel gauge, the first battery curve parameters are updated in the fuel gauge so that the fuel gauge can determine the initial charge of the first battery based on the first battery curve parameters.

[0035] Clear the first capacity stored in the flash memory of the fuel gauge.

[0036] A second aspect of this application provides a battery power determination device, comprising:

[0037] The acquisition module is used to acquire charging and discharging data during the charging and discharging process of the first battery currently connected to the terminal device, wherein the charging and discharging data includes charging data of the first battery during the charging process and / or discharging data during the discharging process.

[0038] The first determining module is used to determine the current full charge capacity of the first battery based on at least one of the first capacity, the second capacity, and the third capacity, when it is determined from the charging and discharging data that the current data update conditions are met. The first capacity is the historical full charge capacity stored in the flash memory of the terminal device's fuel gauge, the second capacity is the preset full charge capacity of the first battery, and the third capacity is equal to the total capacity charged during the charging process or the total capacity discharged during the discharging process.

[0039] A third aspect of this application provides a terminal device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described method for determining battery power.

[0040] A fourth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method for determining battery power described above.

[0041] The fifth aspect of this application provides a computer program product that, when run on a terminal device, enables the terminal device to implement the steps in the above-described method for determining battery power.

[0042] The battery capacity determination method provided in the first aspect of this application, during the charging and discharging process of a terminal device's battery, when it is determined based on the battery's charging and discharging data that the current data update conditions are met, quickly and accurately determines the battery's current full charge capacity based on at least one of the historical full charge capacity stored in the flash memory of the fuel gauge, the battery's preset full charge capacity, and the total capacity charged or discharged during the charging and discharging process. On the one hand, since the charging and discharging data collected by the fuel gauge during the battery charging and discharging process is more reliable and accurately reflects changes in battery capacity, it can not only accurately determine whether the current data update conditions are met, but also improve the accuracy and efficiency of capacity learning. On the other hand, this solution fully considers various possible scenarios of the battery connected to the terminal device during the capacity learning process, and when it is determined that the current data update conditions are met, it can quickly and accurately determine the battery's full charge capacity in the current scenario based on three different capacity values ​​corresponding to these scenarios. This not only improves the accuracy and efficiency of the fuel gauge's capacity learning, but also enhances the applicability and flexibility of the solution, resulting in a better user experience.

[0043] It is understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here. Attached Figure Description

[0044] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0045] Figure 1 is a flowchart illustrating a method for determining battery power according to an embodiment of this application;

[0046] Figure 2 is a partial structural schematic diagram of a terminal device provided in an embodiment of this application;

[0047] Figure 3 is a flowchart illustrating a method for determining battery power according to another embodiment of this application;

[0048] Figure 4 is a flowchart illustrating a method for determining battery power according to another embodiment of this application;

[0049] Figure 5 is a schematic diagram of the structure of a battery power determination device provided in another embodiment of this application;

[0050] Figure 6 is a schematic diagram of the structure of a terminal device provided in an embodiment of this application. Embodiments of the present invention

[0051] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.

[0052] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.

[0053] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0054] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0055] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0056] As mentioned earlier, in existing technologies, the fuel gauges of terminal devices typically employ a static charge calibration algorithm to learn the battery capacity. That is, when the terminal device is powered off or in sleep mode, the fuel gauge checks whether the battery is in a static state at regular intervals. Each time the battery is determined to be in a static state, the fuel gauge acquires the battery's open-circuit voltage and estimates the battery's charge level based on this voltage. When the change in charge level between two estimates exceeds a threshold, and the deviation between the calculated full-charge capacity and the recorded full-charge capacity is less than a deviation threshold, the full-charge capacity is updated. Based on the updated full-charge capacity, the battery capacity can be calibrated, achieving the purpose of learning the battery capacity.

[0057] However, for some batteries with high electrochemical stability, the traditional static charge calibration algorithm is less effective for learning the charge level, specifically because it is difficult to quickly learn the accurate battery charge level.

[0058] The following explanation uses lithium iron phosphate (LFP) batteries as an example. Firstly, LFP batteries have a flat voltage plateau. Specifically, this means small voltage changes but large capacity changes (a 30% capacity change in the flat plateau corresponds to only about 1mV of voltage change). This necessitates high precision in the fuel gauge's analog-to-digital converter (ADC) to accurately capture minute voltage changes. If the ADC's precision is insufficient, even small measurement errors will be amplified in the capacity calculation, leading to inaccurate capacity data. Secondly, after a load pulls down the voltage, LFP batteries require a relatively long time (usually more than 15 minutes) to recover to a more accurate open-circuit voltage. Due to their relatively slow electrochemical reaction rate, the voltage recovery process is slow. Therefore, when the terminal device is powered off or in sleep mode, the slow voltage recovery of LFP batteries results in a significant deviation in the open-circuit voltage acquired by the fuel gauge's ADC, making it difficult to quickly learn accurate capacity. Therefore, the logic of traditional static capacity calibration algorithms cannot meet the requirements for learning capacity data for LFP batteries.

[0059] To at least partially solve the above-mentioned technical problems, embodiments of this application provide a method for determining battery power. This method is applicable to various terminal devices that require rechargeable battery power, especially those powered by pluggable batteries, including but not limited to: portable terminal devices such as smartphones, laptops, tablets, portable point-of-sale (POS) terminals, walkie-talkies, smartwatches, fitness trackers, cameras, camcorders, and voice recorders, as well as other mobile terminal devices including mobile robots. As shown in Figure 1, the method for determining battery power provided by embodiments of this application includes the following steps:

[0060] Step S110: During the charging and discharging process of the first battery currently connected to the terminal device, charge and discharge data are acquired. The charge and discharge data includes charging data of the first battery during the charging process and / or discharging data during the discharging process.

[0061] In this embodiment, the first battery can be any battery connected to the current terminal device. In one example, the battery in the terminal device is removable, allowing the terminal device to be connected to any matching battery model. Taking a POS terminal as an example, for ease of use, multiple batteries of the same model can be equipped on a single POS terminal. When one battery is depleted, a fully charged spare battery can be replaced, or when the lifespan of one battery reaches a certain limit, a usable battery can be replaced. Of course, the battery in the terminal device can also be non-removable, allowing the terminal device to always be connected to the same battery.

[0062] In this embodiment, the charging and discharging process of the first battery may include a charging process and / or a discharging process. Accordingly, the charging and discharging data may include charging data of the first battery during each charging process, and may also include discharging data of the first battery during each discharging process. Specifically, the charging and discharging data may be relevant data reflecting the charging and discharging status collected and calculated by the battery management module during the battery charging and discharging process. Specifically, the charging data may include: the battery's current, voltage, cumulative charged capacity, battery health status (e.g., battery aging degree, internal resistance change, etc.), charging temperature, charging time, energy conversion efficiency, etc., during the current charging process. Similarly, the discharging data may include: the battery's current, voltage, cumulative discharged capacity, battery health status (e.g., battery aging degree, internal resistance change, etc.), discharging temperature, discharging time, energy conversion efficiency, etc., during the current discharging process.

[0063] In a specific example, the terminal device includes a Central Processing Unit (CPU) and a fuel gauge. Each time the terminal device receives a power-on command (e.g., the user presses the power button), the CPU communicates with the fuel gauge via the I2C bus, sending the battery curve parameters of the first battery currently connected to the terminal device to the fuel gauge and resetting the fuel gauge chip. The battery curve parameters can be a data table of standard parameters related to the capacity of each type of battery, which may be established by the fuel gauge manufacturer based on pre-measured real data of different brands and models of batteries. This data table may specifically include: a table mapping battery temperature to capacity in the battery model, a table mapping open-circuit voltage to capacity in the battery model, an internal resistance table, etc. It is understood that the battery curve parameters may differ for different brands and models of batteries. Next, the fuel gauge acquires the current battery voltage, current, and temperature through an analog-to-digital converter. Based on the current battery temperature and the battery temperature-capacity mapping table in the battery curve parameters, the preset full-charge capacity of the battery can be obtained. Then, using the current battery temperature, current battery voltage, and the internal resistance table in the battery curve parameters, the current battery internal resistance is calculated. Then, based on the current battery internal resistance, current battery voltage, and current battery current, the battery open-circuit voltage (open-circuit voltage = battery voltage + battery current × battery internal resistance) can be calculated. Finally, according to the battery open-circuit voltage and the correspondence table between open-circuit voltage and capacity in the battery curve parameters, the current battery capacity, i.e., the initial capacity of the first battery, is obtained, completing the initialization of the fuel gauge. After initialization, if the battery is being charged, the fuel gauge can collect relevant charging data in real time, such as charging current, charging voltage, and cumulative charging capacity. If the battery is not being charged, it is usually in a discharging state during the use of the terminal device, and the fuel gauge can also collect discharge data in real time, such as discharge voltage and discharge current.

[0064] Step S120: If the data update conditions are met based on the charging and discharging data, the current full charge capacity of the first battery is determined based on at least one of the first capacity, the second capacity, and the third capacity. The first capacity is the historical full charge capacity stored in the flash memory of the terminal device's fuel gauge; the second capacity is the preset full charge capacity of the first battery; and the third capacity is equal to the total capacity charged during the charging process or the total capacity discharged during the discharging process.

[0065] In this embodiment, the current data update condition can be determined when the charging or discharging completion rate is determined to be a preset completion rate. The preset completion rate can be set according to actual needs and can be represented by a suitable index. In one example, the preset completion rate can be 100%, which means that the battery is fully charged during charging or fully discharged during discharging. For example, the fuel gauge can determine whether the battery is fully charged based on charging data during charging. If so, it can be determined that the current data update condition is met. In another example, the preset completion rate can also be other suitable values. For example, a voltage reference value table for different battery models can be established in advance through testing, corresponding the battery voltage value to the battery capacity percentage. For example, for lithium iron phosphate batteries, a correspondence table between the battery charging voltage and the battery capacity percentage can be determined through testing. That is, each voltage value corresponds to a capacity percentage. A curve about the relationship between charging voltage and battery capacity can be fitted based on the correspondence table. The preset completion rate can be determined based on the capacity percentage corresponding to the inflection point of the curve. For example, the curve of lithium iron phosphate battery capacity versus open-circuit voltage shows a relatively gentle change in the capacity range of approximately 10% to 94%, while the voltage change is steeper in the capacity range of 95% to 100%. Therefore, a preset completion rate of 95% can be set. Furthermore, during charging, it can be determined whether the battery's open-circuit voltage corresponds to the open-circuit voltage at 95% capacity in the relevant table. If so, it can be determined that the data update conditions are met.

[0066] In this embodiment, the first capacity is the historical full-charge capacity stored in the flash memory of the fuel gauge of the terminal device. This historical full-charge capacity can be the most recently learned full-charge capacity of the battery by the fuel gauge, or it can be the full-charge capacity of the battery learned by the fuel gauge in a previous instance (e.g., the updated full-charge capacity when battery capacity degradation is determined). For example, it could be the full-charge capacity of a battery of the same model as the current battery that was determined and stored by the fuel gauge when the data update conditions were previously met. In this embodiment, the second capacity is the preset full-charge capacity of the first battery. Specifically, it can be the full-charge capacity calculated based on the battery curve parameters of the first battery. As mentioned above, during the initialization process, the fuel gauge can acquire the battery temperature of the first battery through an analog-to-digital converter. The preset full-charge capacity of the first battery can be obtained from the correspondence table between battery temperature and capacity in the battery curve parameters based on the battery temperature. Exemplarily, the third capacity can be the sum of the total charged capacity (unit can be ampere-hours or milliampere-hours) during the entire charging process, or the sum of the total discharged capacity during the discharging process. The charging capacity and discharging capacity can be determined by any suitable method, and this application does not limit them. For example, a coulomb counter can calculate the charging or discharging capacity based on the current and voltage values ​​collected by an analog-to-digital converter.

[0067] In this embodiment, when it is determined that the data update conditions are met, the current full charge capacity of the first battery is determined based on at least one of the first capacity, second capacity, and third capacity. In one example, various suitable filtering methods can be used to select one of the first capacity, second capacity, and third capacity, and the current full charge capacity of the first battery is determined based on the selected one. For example, the selected one can be directly used as the current full charge capacity of the first battery. In another example, the three capacities can also be statistically analyzed to obtain a new capacity, which can be used as the current full charge capacity of the first battery. For example, a weighted average method can also be used to obtain the current full charge capacity of the first battery.

[0068] It's understandable that the scenarios for connecting a terminal device to a battery include the following: The first scenario is that the terminal device is connected to the same battery, and the battery capacity has not decreased compared to the previous charge calibration; the second scenario is that the terminal device is connected to the same battery, but the battery capacity has decreased compared to the previous charge calibration; the third scenario is that the terminal device has been replaced with a new battery. For the first scenario, the first capacity (e.g., the battery's most recently learned full-charge capacity from the fuel gauge) can accurately represent the battery's current full-charge capacity. For the second scenario, the third capacity (the total capacity accumulated during the current charge / discharge process) can accurately determine the battery's current full-charge capacity. For the third scenario, the second capacity (the preset full-charge capacity of the first battery) can accurately represent the battery's current full-charge capacity. Therefore, regardless of the scenario, based on these three factors, the current full-charge capacity of the first battery can be quickly and accurately determined.

[0069] For example, after determining the current full charge capacity of the first battery, the current full charge capacity can be updated in the corresponding storage location in the fuel gauge. For instance, the fuel gauge's flash memory has an erase / write function, and the flash memory has storage partitions A and B. Storage partition A can store the value of the first capacity, and storage partition B can store the value of the second capacity. In one example, each time a new current full charge capacity is determined, the current full charge capacity value can be written to storage partition A (erasing the old first capacity value). In another example, each time a new current full charge capacity is determined, the current full charge capacity can be compared with the preset full charge capacity of the first battery to determine if the battery capacity has decreased. If so, the current full charge capacity value can be written to storage partition A (erasing the old first capacity value). In this example, storage partition A may contain data or may not contain any data (e.g., the battery capacity has not decreased). For example, to facilitate subsequent verification, when the value of the current full capacity is written into storage sub-region A, a verification value corresponding to the current full capacity can also be written into storage sub-region A (this verification value can be obtained by encoding the value of the current full capacity using various suitable data encoding methods), and this verification value and the value of the current full capacity can be used as verification data for subsequent verification.

[0070] For example, after determining the current full charge capacity, the current remaining capacity and current remaining battery level (the percentage between the current remaining capacity and the current full charge capacity) can be updated based on the current full charge capacity, and the current remaining battery level can be displayed on the terminal device's screen. This achieves the purpose of battery level calibration. At least during the charging and discharging process before the next update, the current remaining battery level can be quickly and accurately determined based on the current full charge capacity and the amount of charge and discharge.

[0071] As mentioned earlier, for some batteries with high electrochemical stability, the traditional static charge calibration algorithm is ineffective for learning the battery capacity, specifically, it is difficult to quickly and accurately learn the battery capacity. However, the battery capacity learning method provided in the first aspect of this application, during the charging and discharging process of the battery in the terminal device, after determining that the current data update conditions are met based on the battery's charging and discharging data, quickly and accurately determines the current full charge capacity of the battery based on at least one of the historical full charge capacity stored in the flash memory of the fuel gauge, the battery's preset full charge capacity, and the total capacity charged or discharged during the charging and discharging process. On the one hand, during battery charging and discharging, the charging and discharging data collected by the fuel gauge is more reliable and accurately reflects changes in battery capacity. It can not only accurately determine whether the current data update conditions are met, but also improve the accuracy and efficiency of power learning. On the other hand, this solution fully considers various possible scenarios of the battery connected to the terminal device during power learning. And when it is determined that the current data update conditions are met, it can quickly and accurately determine the full charge capacity of the battery in the current scenario based on three different capacity values ​​corresponding to these scenarios. This not only improves the accuracy and efficiency of the fuel gauge's power learning, but also enhances the applicability and flexibility of the solution, resulting in a better user experience.

[0072] In one embodiment, prior to step S110, the method for determining battery power in this application embodiment further includes the following steps:

[0073] Step S101: In response to the power-on command, determine the first battery curve parameters corresponding to the first battery;

[0074] Step S102: If the first battery curve parameters are different from the second battery curve parameters stored in the fuel gauge, then update the first battery curve parameters to the fuel gauge so that the fuel gauge can determine the initial charge of the first battery based on the first battery curve parameters.

[0075] Step S103: Clear the first capacity stored in the flash memory of the fuel gauge.

[0076] As shown in Figure 2, the terminal device in this embodiment may include a CPU, a battery, and a fuel gauge chip. The fuel gauge chip and the CPU can communicate via an I2C bus. Steps S101 and S102 can be executed by the CPU of the terminal device. Specifically, each time the terminal device receives a power-on command, the CPU can look up and determine the first battery curve parameters corresponding to the first battery based on identification information such as the model of the currently connected first battery. As mentioned earlier, the battery curve parameters for each battery can be a data table of standard parameters related to the capacity of each type of battery, which can be established by the fuel gauge manufacturer based on pre-measured real data of different brands and models of batteries. The second battery curve parameters can be the battery curve parameters stored in the flash memory of the fuel gauge for the battery connected when the terminal device was last powered on (e.g., referred to as the second battery). Then, it can be determined whether the first battery curve parameters and the second curve parameters are the same. For example, a checksum algorithm can be used to determine whether the first battery curve parameters and the second curve parameters are the same. The checksum algorithm is a simple error detection method that obtains a checksum value by adding each byte in the data. Specifically, the CPU first calculates the checksum value of the first battery's curve parameters. Then, it sends a command via the I2C bus to retrieve the checksum value of the second battery's curve parameters, obtaining the checksum value stored in the flash memory of the fuel gauge chip. The two checksum values ​​are compared; if they are not equal, the CPU communicates with the fuel gauge chip via the I2C bus to update the first battery's curve parameters in the fuel gauge. Then, a reset command is sent to the fuel gauge to notify the fuel gauge chip to reset. Next, the fuel gauge chip internally completes its initialization. Specifically, during fuel gauge initialization, the fuel gauge can accurately determine the initial charge of the first battery based on the updated first battery curve parameters. Thus, during charging and discharging after initialization, even when data update conditions are not met, the battery charge can be quickly estimated based on the initial charge. In other words, in this example, if the first battery curve parameters are different from the second battery curve parameters (the two checksum values ​​are different), it indicates that the first battery currently connected to the terminal device is a different battery from the second battery previously connected. Updating the current battery curve parameters of the first battery to the fuel gauge makes the initial battery charge determined by the fuel gauge during initialization more accurate. If the first battery curve parameters are the same as the second battery curve parameters, steps S102 and S103 can be omitted.

[0077] In this embodiment, if it is determined that the first battery curve parameters are different from the second battery curve parameters, the first capacity stored in the flash memory of the fuel gauge is cleared. It can be understood that the difference between the first and second battery curve parameters indicates that the terminal device has been replaced with a different battery. Clearing the full charge capacity of the other battery stored in the flash memory can prevent data errors and improve the accuracy of fuel gauge learning.

[0078] In the above scheme, before receiving the power-on command, the terminal device first determines the battery curve parameters corresponding to the current battery and compares them with the battery curve parameters stored in the fuel gauge. If the two are inconsistent, the battery curve parameters in the fuel gauge are updated, and the initial capacity stored in the fuel gauge's flash memory is cleared. This scheme enables the fuel gauge to accurately determine the initial capacity of the current battery based on the updated battery curve parameters. This adaptability allows the fuel gauge to better adapt to battery replacements, improving the accuracy of power monitoring. Furthermore, if the battery curve parameters are determined to be inconsistent, the data on the full charge capacity of the last connected battery stored in the fuel gauge's flash memory is also cleared. By clearing the old full charge capacity data, the use of mismatched battery parameters for power calculation can be reduced. Clearing old data allows the fuel gauge to relearn and adapt to the replacement of removable batteries based on the new parameters of the current battery, preventing confusion between old and new battery parameters, improving the data accuracy of the fuel gauge, and the effectiveness of battery health management. In summary, the above scheme enables the fuel gauge to use the correct battery parameters in each learning process, further improving the accuracy of power monitoring, optimizing battery capacity, enhancing system robustness, and improving user experience.

[0079] In one embodiment, before determining the current full charge capacity of the first battery in step S120, the battery power determination method of this application embodiment further includes the following steps S104 and / or S105.

[0080] Step S104: During the charging process, if it is determined from the charging data that the first battery is fully charged, then it is determined that the current data update condition is met.

[0081] In this embodiment, various suitable methods can be used to determine whether the first battery is fully charged based on charging data. In one example, during charging, the analog-to-digital converter of the fuel gauge can collect the charging voltage and charging current of the first battery at a preset frequency (e.g., 1 millisecond / time), and determine in real time whether the charging voltage and charging current collected within the current first time window (e.g., 10 seconds, 20 seconds) both meet the preset full-charge conditions. The preset full-charge conditions can be arbitrarily set according to actual needs. For example, the preset full-charge conditions include: the charging voltage collected within the current first time window is always greater than the charging cut-off voltage; the charging current is always greater than the minimum charging current and less than the charging cut-off current. If it is determined that the charging voltage and charging current collected within the current first time window both meet the preset full-charge conditions, then it can be determined that the first battery is fully charged, that is, it is determined that the data update conditions are met.

[0082] Step S105: During the discharge process, if it is determined from the discharge data that the first battery has been completely discharged, then it is determined that the current data update condition is met.

[0083] In this embodiment, various suitable methods can be used to determine whether the first battery has been completely discharged based on discharge data. Similar to step S104 above, during the discharge process, the analog-to-digital converter of the fuel gauge can collect the discharge voltage of the first battery at a preset frequency and determine in real time whether the discharge voltage collected within the current second time window (e.g., 40 seconds, 60 seconds) meets the preset discharge conditions. The preset discharge conditions can be arbitrarily set according to actual needs. For example, the preset discharge conditions include: the discharge voltage collected within the current second time window is always less than the charging zero-point voltage (the voltage when the battery capacity is 0%). If it is determined that the discharge voltage collected within the current second time window meets the preset discharge conditions, it can be determined that the first battery has been completely discharged, that is, it is determined that the current data update conditions are met.

[0084] It's understandable that using battery charge / discharge data allows for relatively accurate monitoring of the battery's full or empty state. Updating battery power data each time the battery is fully charged or discharged improves accuracy, as the battery's power level is relatively easier to measure and determine in these states. Furthermore, at the end of each charge / discharge cycle, the battery's state is relatively stable, and updating the power data at this time helps calibrate the battery's state, reducing errors caused by battery aging or changes in usage conditions. Continuously updating power data during battery use can lead to a significant accumulation of small measurement errors. Updating at the end of a charge / discharge cycle mitigates this accumulated error. During full charge and discharge, the battery's chemical state is relatively consistent, simplifying the power calculation model and making power prediction more reliable. In summary, updating power data when the battery is fully charged or discharged improves the accuracy of power monitoring, optimizes battery usage, enhances user experience, and improves the effectiveness of battery health management and smart device scheduling.

[0085] In one embodiment, after determining the current full charge capacity of the first battery in step S120, the battery power determination method of this application embodiment further includes the following steps S131 and / or S132.

[0086] Step S131: If it is determined from the charging data that the first battery is fully charged, determine and update the current remaining capacity and / or current remaining charge of the first battery, wherein the current remaining capacity is equal to the current full charge capacity and the current remaining charge is equal to the full charge capacity.

[0087] In this embodiment, the fuel gauge can determine the current remaining capacity and / or current remaining charge based on the learned current full charge capacity each time, and can update and store the current remaining capacity and / or current remaining charge in memory. For example, during the charging process, at multiple moments when the full charge condition has not been reached, the remaining capacity and remaining charge of the first battery can be estimated based on the preset full charge capacity of the first battery, the initial charge determined during the initialization process, and charge / discharge data, and updated in the fuel gauge's memory. In this step, when it is determined that the first battery is fully charged, not only can the current full charge capacity of the first battery be determined, but the first capacity can also be updated based on the current full charge capacity. For example, the original first capacity value stored in flash memory storage partition A can be updated to the current full charge capacity value. Furthermore, the value of the current full charge capacity stored in memory can also be used as the current remaining capacity. Similarly, a full charge capacity such as "100%" stored in memory can be used as the current remaining charge. Exemplarily, the terminal device may include a display screen, which can be used to display the current remaining charge. For example, when the first battery is fully charged, the screen can display a message indicating 100% charge, or it can display a message saying "Charging complete, please remove from power source".

[0088] Step S132: If it is determined from the discharge data that the first battery has been completely discharged, determine and update the current remaining capacity and / or current remaining charge of the first battery, wherein the current remaining capacity is equal to the discharged capacity and the current remaining charge is equal to the discharged charge.

[0089] Similar to step S131 above, in this step, when it is determined that the first battery has been completely discharged, the original first capacity value stored in storage partition A can be updated to the current full charge capacity value. The current discharged capacity value (e.g., storing "0") can be stored in the fuel gauge's memory as the current remaining capacity; and a discharged capacity value such as "0%" can be stored in the fuel gauge's memory as the current remaining capacity.

[0090] Updating battery power data when the battery is fully charged or completely discharged improves the accuracy of battery level display. At these specific moments, the battery's state of charge is most clearly defined, providing more accurate information. Updating data at both extremes simplifies the power calculation algorithm and reduces errors that may accumulate during continuous monitoring. Furthermore, accurate power display increases user confidence in the device's battery level indication, enhancing the user experience. This approach, by updating data at both extremes, makes battery management more efficient and accurate, contributing to improved battery usage, extended battery life, and enhanced device safety and reliability.

[0091] In one implementation, step S120, determining the current full charge capacity of the first battery based on at least one of the first capacity, the second capacity, and the third capacity, includes:

[0092] Step S120a: If it is determined that the current data update conditions are met, the current full charge capacity is determined according to the power learning information of the fuel gauge and one of the first capacity, second capacity or third capacity. The power learning information includes: first information indicating that the fuel gauge has not yet completed the first learning process for the first battery or second information indicating that the fuel gauge has completed the first learning process for the first battery.

[0093] In this embodiment, when it is determined that the data update conditions are met, the current battery learning information of the fuel gauge can be obtained first. The battery learning information can represent the fuel gauge's battery learning information for the currently connected first battery. It can also indicate whether the fuel gauge has previously calibrated the current battery level of the first battery, i.e., whether the fuel gauge has completed its initial learning process for the first battery. In this embodiment, the battery learning information may be either first information indicating that the fuel gauge has not yet completed its initial learning process for the first battery, or second information indicating that the fuel gauge has completed its initial learning process for the first battery. For example, the fuel gauge's memory stores data related to the battery learning information, such as an initial learning completion flag. For example, the memory stores strings such as "0" or "1", "True" or "False". For example, the string "True" represents the first information, and "False" represents the second information. For example, in the example where the data update condition is that the first battery is fully charged or fully discharged, if the terminal device is connected to the first battery for a period of time, and the first battery has been fully charged or discharged, and the fuel gauge updates the current full charge capacity when the battery is fully charged or discharged, then the fuel gauge's power learning information is the second information, such as storing "True" in memory; while if the terminal device connects to the first battery, but the first battery has not been fully charged or discharged, then the fuel gauge's power learning information is the first information, and storing "False" in memory.

[0094] In this embodiment, when it is determined that the data update conditions are met, the current full charge capacity can be determined by selecting one of the first, second, or third capacities based on the current battery level learning information. For example, different battery level learning information corresponds to different selection results. After obtaining the selection result, the selected one can be directly used as the current full charge capacity. Alternatively, after obtaining the selection result, the current full charge capacity can be further calculated.

[0095] It is understandable that considering whether the fuel gauge has completed its initial learning process for the current battery can more accurately determine the completeness of each charge / discharge learning process. For example, in the example where the data update condition is that the first battery is fully charged or fully discharged, the fuel gauge's learning information can more accurately determine whether the current charging or discharging process is complete. This provides a more accurate reference for subsequently determining the battery's current full charge capacity, enabling the fuel gauge to learn the accurate charge level more quickly and accurately.

[0096] In the above solution, by considering whether the power meter has completed the initial learning process for the current battery, the current full charge capacity of the battery can be determined based on one of the first capacity, the second capacity, or the third capacity. This can significantly improve the accuracy and reliability of power monitoring, optimize battery usage, extend battery life, and enhance the user experience.

[0097] In one implementation, step S120a determines the current full charge capacity based on the power learning information of the fuel meter and one of the first capacity, the second capacity, or the third capacity, including the following steps S120a.1 and S120a.2.

[0098] Step S120a.1: If the battery learning information of the battery meter is the first information, determine the current full charge capacity based on the first capacity or the second capacity.

[0099] The following explanation uses the conditions that the data update condition is either that the first battery is fully charged or that the first battery is completely discharged as an example.

[0100] For example, during the charging process of the first battery, if it is detected that the battery is fully charged, the initial learning completion flag of the fuel gauge stored in its memory can be read. If it is "False", it can be determined that the fuel gauge has not completed the initial learning process for the currently connected first battery. In other words, if the battery has not been fully charged or discharged since the terminal device connected the first battery, it indicates that the current charging process is likely not a complete charging process (meaning the first battery may be a new battery that has never been used, or the first battery may have been unplugged and plugged back in). The accumulated charge is likely to be a portion of the battery's capacity. Therefore, the current full charge capacity can be determined based on either a first capacity (e.g., the battery's most recently learned full charge capacity, corresponding to the scenario where the first battery was unplugged and plugged back in) or a second capacity (a preset full charge capacity determined based on the battery curve parameters of the first battery, corresponding to the scenario where the first battery is a new battery).

[0101] Step S120a.2: If the battery learning information of the battery meter is the second information, determine the current full charge capacity based on one of the first capacity, the second capacity, or the third capacity.

[0102] For example, during the first battery charging process, if the battery is detected to be fully charged, the initial learning completion flag of the fuel gauge stored in its memory can be read. If it is "True", it can be determined that the fuel gauge has completed the initial learning process for the currently connected first battery, or for other batteries of the same model as the currently connected first battery. Typically, the terminal device maintains a "fully charged - discharged - fully charged" charging pattern, indicating that the first battery was discharged before this charging process, meaning the current charging process can be a complete charging cycle. In this case, the current full charge capacity can be determined based on one of the first capacity, second capacity, or third capacity.

[0103] In one implementation, the current full charge capacity can be determined directly based on the third capacity. For example, the third capacity can be directly used as the current full charge capacity. If the battery is detected to be fully charged during charging, the accumulated charge during the current charging process can be used as the current full charge capacity. Another example is that during charging, it can be determined whether the battery's open-circuit voltage is the same as the open-circuit voltage at 95% charge in the corresponding relationship table. If so, it can be determined that the data update conditions are met, and then, based on the completion of the initial learning process of the fuel gauge, the third capacity can be calculated (e.g., the quotient of the third capacity and 85%) to obtain the current full charge capacity.

[0104] In another implementation, various suitable screening criteria can be used to further select one from the first capacity, second capacity, and third capacity to determine the current full charge capacity. For example, it can be further determined whether the first battery meets the degradation condition, i.e., whether the battery capacity has decreased. If so, the current full charge capacity can be determined based on the third capacity (e.g., if the battery has reached the full charge condition, the fuel gauge has completed the first capacity learning process, and the battery capacity has decreased, the accumulated charge capacity is taken as the current full charge capacity). If not, the current full charge capacity can be determined based on the second capacity (e.g., if the battery has reached the full charge condition, the fuel gauge has completed the first capacity learning process, and the battery capacity has not decreased, the preset full charge capacity of the first battery is taken as the current full charge capacity). In this way, the battery's full charge capacity can be updated in a timely manner when the battery capacity decreases, improving the accuracy of the capacity learning calibration, while also fully considering the impact of data errors and reducing unnecessary update calculations. In another example, if the first battery meets the degradation condition as determined by the above method, and the flash memory of the fuel gauge stores the value of the first capacity, the third capacity can be compared with the first capacity. If the difference between the two is small, the first capacity can be used as the current full charge capacity; if the difference between the two is large, the third capacity can be used as the current full charge capacity, and the first capacity can be updated based on the third capacity. In this way, the full charge capacity of the battery can be updated in a timely manner when the battery capacity further degrades, improving the accuracy of the power learning calibration, while also fully considering the impact of data errors and reducing unnecessary update calculations.

[0105] The above solution considers different scenarios regarding whether the battery has completed its initial learning process and uses different capacity references accordingly to quickly and accurately determine the current full charge capacity. This further improves the accuracy and efficiency of power monitoring and learning.

[0106] In one implementation, step S120a.1, when the battery level learning information of the fuel gauge is the first information, determines the current full charge capacity based on the first capacity or the second capacity, including the following steps:

[0107] Step S120a.11: Read the verification data stored in the flash memory of the fuel gauge, wherein the verification data includes: the value of the first capacity and the first verification value determined according to the first capacity;

[0108] Step S120a.12: If the first check value and the second check value corresponding to the first capacity are equal, determine that the current full charge capacity is equal to the first capacity.

[0109] Step S120a.13: If the first check value and the second check value are not equal, or if no check data is read, determine that the current full charge capacity is equal to the second capacity.

[0110] As mentioned earlier, each time the fuel gauge learns a new current full charge capacity, the current full charge capacity value can be written into the corresponding storage partition (e.g., the aforementioned storage partition A) (erasing the old first capacity value). For convenient subsequent verification, a verification value corresponding to the current full charge capacity can also be written into storage partition A (this verification value can be obtained by encoding the current full charge capacity value using various suitable data encoding methods). This verification value and the current full charge capacity value can be used as verification data. In other words, if the fuel gauge of the terminal device has previously calibrated the full charge capacity for the previously connected battery or the currently connected battery, the flash memory of the fuel gauge can store the full charge capacity value calibrated at that time, i.e., the historical full charge capacity value, and also store the first verification value determined based on this value.

[0111] In a specific example, during the charging process of the first battery, if it is detected that the battery is fully charged, the initial learning completion flag of the fuel gauge stored in the fuel gauge's memory can be read. If it is "False", it can be determined that the fuel gauge has not completed the initial learning process for the currently connected first battery. Then, the historical full charge capacity value and the first verification value stored in the flash memory storage partition A of the fuel gauge can be read. A second verification value corresponding to the historical full charge capacity value can be determined according to a preset verification value determination method (e.g., a preset data encoding method). Afterwards, the first verification value and the second verification value can be compared. If they are equal, it can be determined that the current full charge capacity is equal to the first capacity. Conversely, if they are not equal, or if the historical full charge capacity value and the first verification value are not read from storage partition A (e.g., in step S103, if the battery curve parameters of the current first battery are different from the battery curve parameters of the battery previously connected to the terminal device, these data are cleared), it can be determined that the current full charge capacity is equal to the second capacity.

[0112] In the example above, if the historical full-charge capacity and first verification value of the battery previously learned by the fuel gauge can be read from storage partition A, it indicates that the first battery is the same battery connected when the fuel gauge was last calibrated for full-charge capacity. Therefore, the full-charge capacity obtained from the last calibration can be used as the current full-charge capacity, allowing the fuel gauge to quickly and accurately learn the battery's full-charge capacity even after the same battery has been plugged in, unplugged, and re-powered. However, if the historical full-charge capacity and first verification value of the battery previously learned by the fuel gauge cannot be read from storage partition A, it indicates that the first battery is a different battery from the one connected when the fuel gauge was last calibrated for full-charge capacity. In this case, the preset full-charge capacity determined based on the battery curve parameters of the first battery can be used as the current full-charge capacity of the first battery. This allows the fuel gauge to quickly and accurately learn the current battery's full-charge capacity even when the terminal device is equipped with a different battery. Furthermore, if the historical full-charge capacity and first checksum of the battery learned from the last time can be read from storage partition A, but there is a significant difference between the first checksum and the second checksum corresponding to the historical full-charge capacity, the stored data may be corrupted, and the historical full-charge capacity value stored in storage partition A may be problematic. In this case, the preset full-charge capacity of the first battery can be used as the current full-charge capacity of the first battery, which can improve the accuracy of battery learning.

[0113] The above-mentioned method for calibrating the full charge capacity of the first battery fully considers a variety of possible scenarios, the determined full charge capacity is more accurate, and the computational load is also smaller, thereby further improving the accuracy and efficiency of the fuel gauge's power learning.

[0114] In one implementation, after step S110, the battery power learning method provided in this application embodiment further includes the following steps:

[0115] Step S111: If it is determined that the current data update conditions are met and the power learning information of the fuel gauge is the second information, determine whether the first battery has reached the degradation condition based on the first difference between the third capacity and the second capacity and the first difference threshold.

[0116] Step S112, if yes, then if the second difference between the third capacity and the first capacity is greater than or equal to the second difference threshold, update the verification data stored in the flash memory of the power meter according to the value of the third capacity and the third verification value corresponding to the third capacity.

[0117] Step S113: If not, clear the verification data stored in the flash memory of the fuel gauge.

[0118] In a specific example, the first difference can be the absolute value of the first capacity difference between the third capacity and the second capacity, and the first difference threshold can be a first capacity difference threshold (which can be set according to actual needs, for example, the first capacity difference threshold is 5% of the second capacity). If the absolute value of the first capacity difference between the third capacity and the second capacity is greater than the first capacity difference threshold, it can be determined that the first battery has reached the degradation condition, i.e., the first battery capacity has decreased. Otherwise, it can be determined that the first battery has not reached the degradation condition, i.e., the battery capacity has not decreased relative to the last calibration.

[0119] For example, if it is determined that the first battery has not reached the degradation condition, the current full charge capacity can be determined based on the second capacity (the preset full charge capacity of the first battery). For instance, if the battery has reached the full charge condition, the fuel gauge has completed the first power learning process, and the battery capacity has not degraded, the preset full charge capacity of the first battery is used as the current full charge capacity. For at least a period of time thereafter, the battery's power can be estimated based on the preset full charge capacity. This fully considers the impact of data errors and reduces unnecessary update calculations. Furthermore, in this embodiment, if the first battery has not reached the degradation condition, and the fuel gauge's flash memory stores the value of the first capacity (for example, after replacing the first battery of the same model, the fuel gauge stores the full charge capacity data of the previously connected battery with degraded capacity), this value can be cleared to reduce interference from this data on the fuel gauge's learning process.

[0120] For example, if it is determined that the first battery has reached the degradation condition, the value of the first capacity can be read first (e.g., reading the verification data in storage partition A). If no data is read, the third capacity can be directly used as the current full charge capacity. If the value of the first capacity is read, the first capacity and the third capacity can be further compared, and the current full charge capacity can be determined based on one of the two. Specifically, a second capacity difference between the first capacity and the third capacity can be calculated. If the absolute value of the second capacity difference is greater than a second capacity difference threshold (e.g., 5% of the third capacity), it can be determined that the capacity of the first battery has further degraded. In this case, the third capacity can be determined as the current full charge capacity. Furthermore, the value of the third capacity and the corresponding verification value (third verification value) can be written to the power learning storage area in the flash memory of the fuel gauge. For example, the existing data in storage partition A can be erased, and the value of the third capacity and the third verification value can be written to storage partition A. In this way, the full charge capacity of the battery can be accurately calibrated, and the battery power can be determined based on the third capacity stored in storage partition A for at least a period of time thereafter. If the absolute value of the second capacity difference is less than or equal to the second capacity difference threshold, it indicates that the first battery's capacity has not decreased or has decreased only slightly compared to the time point when the first capacity was last updated. Therefore, the first capacity can be taken as the current full charge capacity. This also allows the existing data in the current storage partition A to remain unchanged. This reduces frequent data updates caused by data calculation errors and reduces the computational load.

[0121] In one embodiment, after step S110, the method for determining battery power provided in this application embodiment further includes the following steps S114 and / or S115.

[0122] Step S114: If it is determined that the current data update conditions are met and the power learning information of the fuel meter is the first information, the power learning information of the fuel meter is updated to the second information.

[0123] For example, during charging, if it is determined that the battery is fully charged and the initial learning completion flag of the fuel gauge stored in the fuel gauge's memory is "False", the current full charge capacity can be determined based on the first capacity or the second capacity, and the initial learning completion flag of the fuel gauge stored in memory can be updated to "True". In step S115, if it is determined that the terminal device is disconnected from the first battery, the battery learning information of the fuel gauge is updated to the first information.

[0124] For example, if the first battery is disconnected from the terminal device, the first learning completion flag of the fuel gauge stored in memory is updated to "False".

[0125] The above solution enables the power learning information to accurately reflect the fuel gauge's learning status of the currently connected battery's power level, thereby improving the accuracy of the fuel gauge's power learning.

[0126] The method for determining battery capacity according to another embodiment of this application will be described below with reference to Figures 3 and 4. First, when the previous battery is removed from the terminal device (e.g., a lithium iron phosphate battery is unplugged), the fuel gauge learning flag is set to 0. Then, after the terminal device is powered on with the battery installed, the CPU identifies the first battery curve parameters corresponding to the current battery and determines whether an update is needed. If so, the battery curve parameters are updated in the fuel gauge so that the fuel gauge initializes and learns its capacity based on the updated battery curve parameters, and the full charge capacity data (such as the aforementioned first capacity value and corresponding check value) in the flash memory is cleared. Then, fuel gauge initialization is performed to obtain the initial capacity.

[0127] During battery charging and discharging, the fuel gauge performs capacity learning. During discharge, the fuel gauge collects battery discharge data and determines whether the battery is fully discharged based on this data. If the battery voltage is below the zero-point voltage (the voltage at 0% battery capacity) within the zero-point time window, the battery is considered fully discharged. Otherwise, data collection and judgment continue. If the battery is fully discharged, the fuel gauge obtains its initial learning completion flag. If the initial learning completion flag is "0", the current full charge capacity can be determined based on the full charge capacity (first capacity) stored in the fuel gauge's flash memory or the full charge capacity (preset full charge capacity) in the battery curve parameters. The current full charge capacity is then updated in the fuel gauge. Specifically, the full charge capacity (first capacity) and corresponding verification value can be read from the fuel gauge's flash memory; the read data is verified; if the verification passes, the full charge capacity stored in the flash memory is updated in the fuel gauge's full charge capacity; if the verification fails, the full charge capacity in the battery curve parameters is updated in the fuel gauge's full charge capacity. The initial learning completion flag can also be updated to "1". If the battery is completely discharged and the initial learning completion flag is "1", the current full charge capacity is determined to be equal to the cumulative discharge capacity (third capacity). Then, the deviation between the discharge capacity and the full charge capacity in the battery curve parameters can be calculated. Based on this deviation, it can be determined whether the battery capacity has degraded, and the full charge capacity and verification value in the flash memory are erased or rewritten accordingly. Specifically, if the deviation is less than the battery degradation deviation threshold, the full charge capacity data stored in the fuel gauge flash memory is cleared (a deviation less than the degradation deviation threshold indicates no battery degradation, so the data stored in the flash memory is cleared, allowing the initial learning to directly use the full charge capacity in the battery curve parameters). If the full charge capacity deviation is greater than the battery degradation deviation threshold (the degradation deviation threshold is, for example, a parameter in the battery curve parameters), it is further determined whether the battery capacity has further degraded. Specifically, the difference between the discharge capacity (third capacity) and the full charge capacity (first capacity) stored in the flash memory and the difference threshold can be compared. If the difference is greater than the difference threshold, it can be determined that the battery performance has further degraded. The verification value of the current full charge capacity can then be calculated. Furthermore, the current full charge capacity and verification value can be written together to the learning data partition of the fuel gauge's flash memory. It is also possible to update the fuel gauge's remaining capacity to 0 and the current remaining battery level to 0%.

[0128] During battery charging, battery charging data is collected, and the system determines whether the full charge condition has been reached based on this data. Specifically, the battery charging voltage and charging current are collected, and the system checks whether the full charge time window continuously meets the following conditions: <1> The battery voltage is greater than the charging cutoff voltage; <2> If the charging current is less than the cutoff current but greater than the minimum charging current, the battery is considered fully charged. Otherwise, the data collection and judgment process continues. If the battery is fully charged, the initial learning completion flag of the fuel gauge is obtained. If the initial learning completion flag is "0", the current full charge capacity can be determined based on the full charge capacity stored in the fuel gauge's flash memory (first capacity) or the full charge capacity in the battery curve parameters (preset full charge capacity). The current full charge capacity is then updated in the fuel gauge. Specifically, the full charge capacity (first capacity) and the corresponding verification value can be read from the fuel gauge's flash memory; the read data is verified; if the verification passes, the full charge capacity stored in the flash memory is updated to the full charge capacity of the fuel gauge; if the verification fails, the full charge capacity in the battery curve parameters is updated to the full charge capacity of the fuel gauge. The initial learning completion flag can also be updated to "1". If the battery is completely discharged and the initial learning completion flag is "1", the current full charge capacity is determined to be equal to the cumulative charging capacity (third capacity). Then, the full charge capacity deviation between the charged capacity and the full charge capacity in the battery curve parameters can be calculated. Based on the deviation from the full charge capacity, it can be determined whether the battery capacity has degraded. Depending on the degree of degradation, the full charge capacity and verification value in the flash memory are erased and rewritten. Specifically, if the deviation value is less than the battery degradation deviation threshold, the full charge capacity data stored in the fuel gauge's flash memory is cleared (a deviation less than the degradation deviation threshold indicates no battery degradation, so the data stored in the flash memory is cleared, allowing the initial learning to directly use the full charge capacity from the battery curve parameters). If the full charge capacity deviation value is greater than the battery degradation deviation threshold (the degradation deviation threshold is, for example, a parameter in the battery curve parameters), it is further determined whether the battery capacity has further degraded. Specifically, the difference between the amount of electricity charged (third capacity) and the full charge capacity stored in the flash memory (first capacity) and the difference threshold can be compared. If the difference is greater than the difference threshold, it can be determined that the battery performance has further degraded. A verification value can be calculated from the current full charge capacity. Then, the current full charge capacity value and the verification value can be written together into the learning data partition of the fuel gauge's flash memory. The remaining capacity of the fuel gauge can also be updated to the current full charge capacity, and the current remaining charge capacity can be updated to 100%.

[0129] In the above scheme, during the learning process of the fuel gauge, if the battery is fully charged or discharged for the first time, the full-charge capacity from the battery curve parameters can be updated to the fuel gauge, allowing the fuel gauge to quickly learn an accurate capacity. Furthermore, the initial calculation of a large capacity error is calibrated. Strict control over discharge and full-charge conditions ensures accurate judgment of full charge and discharge in various usage scenarios. By controlling various algorithm parameters (zero-point voltage, zero-point time window, battery cutoff voltage, battery cutoff current, minimum battery charging current, full-charge time window, etc.) through battery curve parameters, the flexibility of the algorithm is ensured. The static capacity calibration algorithm in traditional fuel gauge learning algorithms is removed, resolving the error introduced by deviations in the voltage acquisition during static capacity calculations. Moreover, the learning calibration after each full charge and discharge ensures the accuracy of the capacity calculation as the battery ages and degrades.

[0130] A second aspect of this application provides a battery power determination device. As shown in FIG5, the battery power determination device 500 includes:

[0131] The acquisition module 510 is used to acquire charging and discharging data during the charging and discharging process of the first battery currently connected to the terminal device, wherein the charging and discharging data includes charging data of the first battery during the charging process and / or discharging data during the discharging process.

[0132] The first determining module 520 is used to determine the current full charge capacity of the first battery based on at least one of the first capacity, the second capacity, and the third capacity, when it is determined from the charging and discharging data that the current data update conditions are met. The first capacity is the historical full charge capacity stored in the flash memory of the terminal device's fuel gauge, the second capacity is the preset full charge capacity of the first battery, and the third capacity is equal to the total capacity charged during the charging process or the total capacity discharged during the discharging process.

[0133] In one embodiment, the first determining module 520 includes:

[0134] The first determining submodule is used to determine the current full charge capacity based on the power learning information of the fuel gauge and one of the first capacity, second capacity or third capacity, when it is determined that the current data update conditions are met. The power learning information includes: first information indicating that the fuel gauge has not yet completed the first learning process for the first battery or second information indicating that the fuel gauge has completed the first learning process for the first battery.

[0135] In one implementation, the first determining submodule includes:

[0136] The first determining unit is used to determine the current full charge capacity based on the first capacity or the second capacity when the power learning information of the fuel meter is the first information.

[0137] The second determining unit is used to determine the current full charge capacity based on one of the first capacity, the second capacity, or the third capacity when the energy learning information of the fuel meter is the second information.

[0138] In one embodiment, the first determining unit includes:

[0139] The read subunit is used to read the verification data stored in the flash memory of the fuel gauge, wherein the verification data includes: the value of the first capacity and a first verification value determined according to the first capacity;

[0140] The first determining subunit is used to determine that the current full charge capacity is equal to the first capacity when the first check value and the second check value corresponding to the first capacity are equal.

[0141] The second determining subunit is used to determine that the current full charge capacity is equal to the second capacity when the first check value and the second check value are not equal, or when no check data is read.

[0142] In one embodiment, the battery charge determination device 500 further includes:

[0143] The attenuation determination module is used to determine whether the first battery has reached the attenuation condition when it is determined that the current data update condition is met and the power learning information of the fuel gauge is the second information, based on the first difference and the first difference threshold between the third capacity and the second capacity.

[0144] The verification data update module is used to update the verification data stored in the flash memory of the fuel meter according to the value of the third capacity and the third verification value corresponding to the third capacity if the second difference between the third capacity and the first capacity is greater than or equal to the second difference threshold.

[0145] The first clearing module is used to clear the verification data stored in the flash memory of the fuel gauge if no error occurs.

[0146] In one embodiment, the battery charge determination device 500 further includes:

[0147] The first update module is used to update the battery level learning information of the battery meter to second information when it is determined that the current data update conditions are met and the battery level learning information of the battery meter is the first information; and / or

[0148] The second update module is used to update the battery level learning information of the fuel gauge to the first information when it is determined that the terminal device is disconnected from the first battery.

[0149] In one embodiment, the battery charge determination device 500 further includes:

[0150] The full charge determination module is used to determine, during the charging process, if it is determined from the charging data that the first battery is fully charged, that the current data update conditions are met; and / or

[0151] The discharge determination module is used to determine whether the data update conditions are met if the discharge data indicates that the first battery has been completely discharged during the discharge process.

[0152] In one embodiment, the battery charge determination device 500 further includes:

[0153] The first power update module is used to determine and update the current remaining capacity and / or current remaining power of the first battery when it is determined from charging data that the first battery is fully charged, wherein the current remaining capacity is equal to the current full charge capacity, and the current remaining power is equal to the full charge capacity; and / or

[0154] The second power update module is used to determine and update the current remaining capacity and / or current remaining power of the first battery when it is determined from the discharge data that the power of the first battery has been discharged, wherein the current remaining capacity is equal to the discharged capacity and the current remaining power is equal to the discharged power.

[0155] In one embodiment, the battery charge determination device 500 further includes:

[0156] The second determining module is used to determine the first battery curve parameters corresponding to the first battery in response to the power-on command;

[0157] The third update module is used to update the first battery curve parameters to the fuel gauge if the first battery curve parameters are different from the second battery curve parameters stored in the fuel gauge, so that the fuel gauge can determine the initial charge of the first battery based on the first battery curve parameters.

[0158] The second clearing module is used to clear the first capacity stored in the flash memory of the fuel gauge.

[0159] This application also provides a terminal device. As shown in FIG6, the terminal device 600 includes: at least one processor 610, at least one memory 620, and a computer program 630 stored in the memory 620 and executable on the at least one processor 610. When the processor 610 executes the computer program 630, it implements the steps of the above-described method for determining battery power. Specifically, the terminal device 600 may include a fuel gauge, which includes the processor 610 and the memory 620.

[0160] Figure 6 is merely an example of a terminal device and does not constitute a limitation on the terminal device. It may include more components than shown, or combine certain components, or use different components. The processor may be a Central Processing Unit (CPU), but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.

[0161] It should be noted that the information interaction and execution process between the above-mentioned devices / modules are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.

[0162] Those skilled in the art will understand that, for the sake of convenience and brevity, the above-described division of functional modules is merely an example. In practical applications, the functions described above can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. The functional modules in the embodiments can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules can be implemented in hardware or as software functional modules. Furthermore, the specific names of the functional modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0163] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can implement the steps in the above-described method for determining battery power.

[0164] This application provides a computer program product that, when run on a terminal device, enables the terminal device to implement the steps in the above-described method for determining battery power.

[0165] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A method for determining battery capacity, characterized in that, include: During the charging and discharging process of the first battery currently connected to the terminal device, charging and discharging data is acquired, wherein the charging and discharging data includes charging data of the first battery during the charging process and / or discharging data during the discharging process. If the data update conditions are met based on the charging and discharging data, the current full charge capacity of the first battery is determined based on at least one of the first capacity, the second capacity, and the third capacity. The first capacity is the historical full charge capacity stored in the flash memory of the battery meter of the terminal device, the second capacity is the preset full charge capacity of the first battery, and the third capacity is equal to the total capacity charged during the charging process or the total capacity discharged during the discharging process.

2. The method for determining battery capacity as described in claim 1, characterized in that, Determining the current full charge capacity of the first battery based on at least one of the first capacity, second capacity, and third capacity includes: If the current data update conditions are met, the current full charge capacity is determined based on the power learning information of the fuel gauge and one of the first capacity, second capacity, or third capacity. The power learning information includes: first information indicating that the fuel gauge has not yet completed the first learning process for the first battery, or second information indicating that the fuel gauge has completed the first learning process for the first battery.

3. The method for determining battery capacity as described in claim 2, characterized in that, Determining the current full charge capacity based on the battery level learning information from the battery meter, and one of the first capacity, the second capacity, or the third capacity, includes: If the battery level learning information of the battery meter is the first information, the current full charge capacity is determined based on the first capacity or the second capacity. If the battery level learning information of the battery meter is the second information, the current full charge capacity is determined based on one of the first capacity, the second capacity, or the third capacity.

4. The method for determining battery capacity as described in claim 3, characterized in that, When the battery level learning information of the fuel gauge is the first information, determining the current full charge capacity based on the first capacity or the second capacity includes: Read the verification data stored in the flash memory of the fuel gauge, wherein the verification data includes: the value of the first capacity and a first verification value determined according to the first capacity; If the first verification value and the second verification value corresponding to the first capacity are equal, it is determined that the current full charge capacity is equal to the first capacity. If the first verification value and the second verification value are not equal, or if the verification data is not read, the current full charge capacity is determined to be equal to the second capacity.

5. The method for determining battery capacity as described in claim 4, characterized in that, The method further includes: If it is determined that the current data update conditions are met and the power learning information of the fuel gauge is the second information, then it is determined whether the first battery has reached the degradation condition based on the first difference and the first difference threshold between the third capacity and the second capacity. If so, then if the second difference between the third capacity and the first capacity is greater than or equal to the second difference threshold, the verification data stored in the flash memory of the power meter is updated according to the value of the third capacity and the third verification value corresponding to the third capacity. If not, then clear the verification data stored in the flash memory of the power meter.

6. The method for determining battery capacity as described in claim 3, characterized in that, The method further includes: If it is determined that the current data update conditions are met and the fuel gauge's power learning information is the first information, then the fuel gauge's power learning information is updated to the second information; and / or If it is determined that the terminal device is disconnected from the first battery, the power learning information of the fuel gauge is updated to the first information.

7. The method for determining battery capacity as described in any one of claims 1-6, characterized in that, Before determining the current full charge capacity of the first battery, the method further includes: During the charging process, if it is determined from the charging data that the first battery is fully charged, then it is determined that the data update condition is currently met; and / or During the discharge process, if it is determined from the discharge data that the first battery has been completely discharged, then it is determined that the data update condition is met.

8. The method for determining battery capacity as described in claim 7, characterized in that, After determining the current full charge capacity of the first battery, the method further includes: If, based on the charging data, it is determined that the first battery is fully charged, the current remaining capacity and / or current remaining charge of the first battery are determined and updated, wherein the current remaining capacity is equal to the current full charge capacity, and the current remaining charge is equal to the full charge capacity; and / or If it is determined from the discharge data that the first battery has been completely discharged, the current remaining capacity and / or current remaining charge of the first battery are determined and updated, wherein the current remaining capacity is equal to the discharged capacity and the current remaining charge is equal to the discharged charge.

9. The method for determining battery capacity as described in any one of claims 1-6, characterized in that, The method further includes: In response to the power-on command, determine the first battery curve parameters corresponding to the first battery; If the first battery curve parameter is different from the second battery curve parameter stored in the fuel gauge, the first battery curve parameter is updated in the fuel gauge so that the fuel gauge determines the initial charge of the first battery based on the first battery curve parameter. Clear the first capacity stored in the flash memory of the fuel gauge.

10. A terminal device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the steps of the method for determining battery charge as described in any one of claims 1 to 8.