Electric quantity calculation method and electronic equipment
By copying and calibrating the initial discharge depth before and after the firmware upgrade, the problem of inaccurate power calculation after the firmware upgrade is solved, ensuring the stability and accuracy of the power value, and improving the user experience.
Patent Information
- Application Number
- CN202311847756.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-28
- Publication Date
- 2025-07-08
AI Technical Summary
After the firmware upgrade, the update of the initial discharge depth results in inaccurate calculation of the residual power in real time, resulting in significant changes in the power value before and after power on or restarting, affecting the user experience.
Copy the real-time discharge depth to external memory before firmware upgrade, write it back to the power meter after restart and update the initial discharge depth, and calibrate the initial discharge depth in combination with open circuit voltage and internal resistance drop to ensure accurate calculation of real-time residual power.
The power value is stable after the firmware is upgraded, and the power value changes less than 1% before and after the startup or restart, improving the accuracy of power calculation and user experience.
Smart Images

Figure CN120276571A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of terminals, and in particular, to a power consumption calculation method and an electronic device. Background Art
[0002] The power meter of an electronic device can be used to periodically measure the real-time remaining power of the battery. The power estimation algorithm used to measure the real-time remaining power is placed in the firmware of the power meter. After the electronic device leaves the factory, the firmware of the power meter can be upgraded to fix errors or vulnerabilities in the firmware, thereby improving the performance of the power meter.
[0003] However, after the firmware is upgraded, the power meter needs to be restarted to make the upgraded firmware take effect. During the restart process, the power estimation algorithm in the upgraded firmware is initialized. Initializing the power estimation algorithm includes: updating the initial depth of discharge in the power estimation algorithm. So that this initial depth of discharge can reflect the power that has been consumed by the battery before the power meter starts to be used. Here, starting to be used is the time when parameter A is measured after the power meter is restarted or powered on, and this parameter A is the parameter required for updating the initial depth of discharge.
[0004] The initial depth of discharge plays an important role in calculating the real-time remaining power. Therefore, how to make the initial depth of discharge still be used to accurately calculate the real-time remaining power after the update is worthy of discussion. Summary of the Invention
[0005] This application provides a power consumption calculation method and an electronic device, which can be used to accurately update the initial depth of discharge in the upgraded firmware, and then determine the real-time remaining power of the battery based on the updated initial depth of discharge.
[0006] In a first aspect, this application provides a power consumption calculation method. An electronic device determines to upgrade a first firmware of a power meter to a second firmware at a first time; before notifying the power meter to upgrade the first firmware, the electronic device copies the real-time depth of discharge corresponding to the first time from a first memory of the power meter to a second memory outside the power meter; the data in the first memory will be cleared when the power meter is restarted; after upgrading the first firmware to the second firmware, the electronic device controls the power meter to restart, and the restart includes: when writing the real-time depth of discharge back to the power meter, the electronic device updates the initial depth of discharge in the second firmware by using the real-time depth of discharge; the electronic device determines the battery power of the electronic device at a second time through the updated initial depth of discharge; the second time is later than the first time.
[0007] In the above embodiments, the first firmware may be the firmware before the upgrade (old firmware) involved in the embodiments. The second firmware may be the upgraded firmware (new firmware) in the embodiments. The first time may be Time 1 in the embodiments, and the second time may be Time 2 in the embodiments. The battery power at the second time may be the remaining real-time power at Time 2 in the embodiments. The time for firmware upgrade is relatively short. The initial depth of discharge in the second firmware is updated using the real-time depth of discharge before the upgrade, and then the "coulomb integral charge / battery chemical capacity" in formula (4) is cleared. After the firmware upgrade, the "coulomb integral charge / battery chemical capacity" starts to accumulate from 0 to obtain the power consumed after the firmware upgrade. That is, the initial state after the power meter is restarted after the firmware upgrade is regarded as the start time of the power meter's use. Then, based on the real-time depth of discharge before the upgrade and the "coulomb integral charge / battery chemical capacity", the remaining real-time power can be obtained.
[0008] In combination with the first aspect, in some embodiments, the restart further includes: when the real-time depth of discharge is not written back from the second memory to the power meter, the electronic device updates the initial depth of discharge using the open-circuit voltage of the battery and the voltage drop across the battery internal resistance.
[0009] In combination with the first aspect, in some embodiments, the electronic device determines the battery power of the electronic device at the second time through the updated initial depth of discharge, specifically including: when the time for the electronic device to be in a stationary state is less than a first preset time, the electronic device subtracts the power consumed from the third time to the second time from the updated initial depth of discharge as the battery power at the second time; the third time is the time when the power meter first measures the battery power after the upgrade is completed; the third time is later than the first time but earlier than the second time.
[0010] In the above embodiments, the third time may be Time 3 in the embodiments. The stationary state is a state where the current of the battery is less than or equal to the current threshold before the electronic device enters scenarios such as power-on or restart. The stationary state being less than the preset time a means that the time before the electronic device enters power-on or restart is short and the power loss is small and can be ignored. Then, at this time, when subtracting the power consumed from the third time to the second time from the updated initial depth of discharge as the battery power at the second time, the obtained battery power at the second time is accurate.
[0011] In combination with the first aspect, in some embodiments, the electronic device determines the battery power at the second time based on the updated initial depth of discharge, which specifically includes: when the time that the electronic device is in a stationary state is greater than or equal to a first preset time, the electronic device calibrates the updated initial depth of discharge by using the open-circuit voltage at rest; the open-circuit voltage at rest is the open-circuit voltage measured when the time in the stationary state is greater than or equal to the first preset time; the electronic device determines the battery power at the second time based on the calibrated initial depth of discharge.
[0012] In the above embodiments, that the stationary state is greater than the preset time a means that the time before the battery enters the power-on or restart state is relatively long and the power loss is large, which cannot be ignored. At this time, when calibrating the updated initial depth of discharge and using the calibrated initial depth of discharge minus the power consumed from the third time to the second time as the battery power at the second time, the obtained battery power at the second time is accurate.
[0013] In combination with the first aspect, in some embodiments, the first memory is the internal memory in the fuel gauge; the second memory is the internal memory in the processor of the electronic device.
[0014] In combination with the first aspect, in some embodiments, after controlling the fuel gauge to restart and before updating the initial depth of discharge in the second firmware by using the real-time depth of discharge, the method further includes: after the restart, the fuel gauge starts to wait for the processor to send the real-time depth of discharge; before the fuel gauge waits for a second preset time, if the fuel gauge determines that it has received the real-time depth of discharge, it writes the real-time depth of discharge back to the first memory of the fuel gauge.
[0015] In combination with the first aspect, in some embodiments, after controlling the fuel gauge to restart and before updating the initial depth of discharge by using the battery open-circuit voltage and the battery internal resistance voltage drop, the method further includes: after the restart, the fuel gauge starts to wait for the processor to send the real-time depth of discharge; when the fuel gauge waits for the second preset time, the fuel gauge determines that it has not received the real-time depth of discharge.
[0016] In combination with the first aspect, in some embodiments, the method further includes: before the electronic device determines to upgrade the first firmware of the fuel gauge to the second firmware at the first time, in response to a power-on operation, the electronic device starts the electronic device in the shutdown state; after the second time, the electronic device completes the startup.
[0017] In the above embodiments, when the electronic device is in the boot-up scenario, it determines to upgrade the firmware at time 1. Before notifying the fuel gauge to upgrade the firmware, the electronic device may record the real-time depth of discharge corresponding to time 1. Then, after the firmware upgrade is completed, when updating the initial depth of discharge in the upgraded firmware during the restart of the fuel gauge, the real-time depth of discharge at time 1 is used as the updated initial depth of discharge. Furthermore, the real-time remaining battery power is calculated using the updated initial depth of discharge. Then, based on the real-time remaining battery power, the battery power value after boot-up is determined. In this way, the initial depth of discharge can be accurately updated, and then the real-time depth of discharge can be accurately calculated based on the updated initial depth of discharge. When the time that the electronic device is in the static state before boot-up is less than the preset time a, the battery power values displayed by the electronic device before and after boot-up are made equal or close.
[0018] In combination with the first aspect, in some embodiments, the method further includes: before the electronic device determines to upgrade the first firmware of the fuel gauge to the second firmware at the first time, in response to an operation of restarting the electronic device, the electronic device restarts itself in the boot-up state; after the second time, the electronic device completes the restart.
[0019] In the above embodiments, when the electronic device is in the restart scenario, it determines to upgrade the firmware at time 1. Before notifying the fuel gauge to upgrade the firmware, the electronic device may record the real-time depth of discharge corresponding to time 1. Then, after the firmware upgrade is completed, when updating the initial depth of discharge in the upgraded firmware during the restart of the fuel gauge, the real-time depth of discharge at time 1 is used as the updated initial depth of discharge. Furthermore, the real-time remaining battery power is calculated using the updated initial depth of discharge. Then, based on the real-time remaining battery power, the battery power value after restart is determined. In this way, the initial depth of discharge can be accurately updated, and then the real-time depth of discharge can be accurately calculated based on the updated initial depth of discharge. When the time that the electronic device is in the static state before restart is less than the preset time a, the battery power values displayed by the electronic device before and after restart are made equal or close.
[0020] In combination with the first aspect, in some embodiments, the method further includes: after the second time, the electronic device displays a battery power value in the electronic device based on the battery power at the second time; the greater the battery power at the second time, the greater the battery power value.
[0021] In a second aspect, an embodiment of the present application provides an electronic device, which includes: one or more processors and a memory; the memory is coupled to the one or more processors, and the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the method implemented in the first aspect.
[0022] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, including instructions that, when running on an electronic device, cause the electronic device to execute the method implemented in the first aspect.
[0023] In a fourth aspect, an embodiment of the present application provides a chip system, which is applied to an electronic device. The chip system includes one or more processors that are used to call computer instructions to cause the electronic device to execute the method implemented in the first aspect.
[0024] In a fifth aspect, an embodiment of the present application provides a computer program product containing instructions that, when running on an electronic device, cause the electronic device to execute the method implemented in the first aspect.
[0025] It can be understood that the electronic device provided in the second aspect, the computer storage medium provided in the third aspect, the chip system provided in the fourth aspect, and the computer program product provided in the fifth aspect are all used to execute the method provided in the embodiments of the present application. Therefore, the other beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method, and will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 A schematic diagram showing the relationship between the open-circuit voltage, internal resistance voltage drop, and actual voltage of a battery;
[0027] Figure 2 A schematic diagram showing that when the firmware is upgraded and restarted, the internal resistance voltage drop is too large, resulting in a small real-time remaining battery level;
[0028] Figure 3 A schematic diagram showing a large change in the battery level value before and after the electronic device is powered on;
[0029] Figure 4 An exemplary flowchart showing that the electronic device updates the initial discharge depth and calculates the real-time remaining battery level;
[0030] Figure 5 A schematic diagram showing a small change or no change in the battery level value before and after the electronic device is powered on;
[0031] Figure 6 Another exemplary flowchart showing that the electronic device updates the initial discharge depth and calculates the real-time remaining battery level;
[0032] Figure 7 An exemplary flowchart showing the interaction between the processor and the circuit meter to update the initial discharge depth and calculate the real-time remaining battery level;
[0033] Figure 8 An exemplary fuel gauge provided by an embodiment of the present application;
[0034] Figure 9 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Specific implementation manners
[0035] In one solution, after the firmware of the fuel gauge is upgraded, it is necessary to restart the fuel gauge to make the upgraded firmware take effect. During the restart process, the initial discharge depth in the upgraded firmware will be updated. At this time, the internal resistance voltage drop of the battery can be used to calculate the updated initial discharge depth.
[0036] However, in some scenarios, the internal resistance voltage drop measured during the firmware restart process may be too large, resulting in an overestimated initial discharge depth. As a result, the real-time remaining battery power calculated by the fuel gauge using the overestimated initial discharge depth after the firmware upgrade is too small.
[0037] In the foregoing content, the reason for the overestimated initial discharge depth due to the overestimated internal resistance voltage drop can be referred to the following Figure 1 , Formula (1) and Formula (2). Among them, Formula (1) and Formula (2) are used to calculate the updated initial discharge depth in the scenario of restarting the fuel gauge after the firmware upgrade. Among them, Formula (1) and Formula (2) are as follows.
[0038] Initial discharge depth = 100 - initial remaining battery power corresponding to the actual voltage Formula (1)
[0039] Actual voltage = battery open-circuit voltage - internal resistance voltage drop Formula (2)
[0040] As Figure 1 shown, the battery open-circuit voltage in Formula (2) is usually the voltage of the battery cell. This battery open-circuit voltage (OCV) describes the voltage of the battery when no load is connected. The internal resistance voltage drop is the voltage generated due to the internal resistance when the battery open-circuit voltage (abbreviated as the open-circuit voltage) provided by the battery cell passes through the circuit between the battery cell and the battery housing. Continuing to refer to Figure 1 , the actual voltage involved in Formula (2) refers to the voltage actually transmitted to the load. This open-circuit voltage can also be referred to as the battery open-circuit voltage. The internal resistance voltage drop can also be referred to as the battery internal resistance voltage drop.
[0041] The initial discharge depth can reflect the power that has been consumed by the battery before the fuel gauge starts to be used. Starting to be used includes the time when the fuel gauge is powered on or when parameter A is first measured after restart. For example, this parameter A is the parameter required to update the initial discharge depth. For example, in the scenario of updating the initial discharge depth caused by firmware upgrade, parameter A can be the battery open-circuit voltage or the internal resistance voltage drop. The initial remaining battery power of the battery reflects the remaining battery power when the fuel gauge starts to be used.
[0042] In formula (1), the initial remaining power corresponding to the actual voltage is obtained through the voltage-to-power correspondence table. The voltage-to-power correspondence table records the corresponding relationship between the actual voltage and the initial remaining power. Generally speaking, as the real-time remaining power of the battery decreases, the actual voltage of the battery will also decrease, and its corresponding initial remaining power will also decrease.
[0043] In the above content, the reason why the initial discharge depth is too large and the real-time remaining power is too small can be referred to the following formula (3) and formula (4). Among them, formula (3) and formula (4) are used for the fuel gauge to estimate the real-time remaining power using the initial discharge depth.
[0044] Real-time remaining power = 100 - real-time discharge depth (DodCal) formula (3)
[0045] Real-time discharge depth = initial discharge depth (Dod0) - coulomb integrated charge / battery chemical capacity formula (4)
[0046] Referring to formula (4), a larger initial discharge depth leads to a larger real-time discharge depth, which in turn leads to a smaller real-time remaining capacity.
[0047] The real-time discharge depth reflects the amount of electricity consumed by the electronic device before the start of use, plus the amount of electricity consumed by the electronic device after the start of use. The amount of electricity consumed before the start of use is reflected by the initial discharge depth (Dod0), and the amount of electricity consumed by the electronic device after the start of use is reflected by adding the negative "-coulomb integrated charge / battery chemical capacity".
[0048] Among them, the method of using "Coulomb integral charge / battery chemical capacity" to calculate the consumed power can be called the Coulomb integral method (coulomb counter, CC).
[0049] Among them, the coulomb integral power / battery chemical capacity represents the difference between the cumulative power consumed and the cumulative power charged after the power meter is entered into use. Among them, the power consumed is a negative value, and the power charged is a positive value. If the absolute value of the cumulative power consumed is greater than the cumulative power charged, the coulomb integral power / battery chemical capacity is a negative number, the real-time discharge depth increases, and the real-time remaining power decreases. Conversely, if the absolute value of the cumulative power consumed is less than the cumulative power charged, the coulomb integral power / battery chemical capacity is a positive number, indicating that the battery is in the charging process, resulting in a decrease in the real-time discharge depth and an increase in the real-time remaining power.
[0050] It should be noted here that after the coulomb meter starts to work, formulas (3) and (4) are executed periodically (for example, once every 1 s or once every 2 s, etc.). The "coulomb integral charge / battery chemical capacity" calculated in this cycle includes the sum of the "coulomb integral charge / battery chemical capacity" calculated in the previous cycle and the "coulomb integral charge / battery chemical capacity" in this cycle. That is, the "coulomb integral charge / battery chemical capacity" is an accumulated value. However, after the initial state of charge update, the coulomb integral charge / battery chemical capacity will be cleared to 0 and start accumulating from 0 again.
[0051] Among them, the scenarios where the internal resistance voltage drop measured during the firmware restart process is relatively large include, but are not limited to, the following two scenarios.
[0052] Internal resistance voltage drop large scenario 1: Performing a firmware restart during the startup process of the electronic device will cause the internal resistance voltage drop to increase. The reason is that during the startup process, there are many loads connected to the battery, and multiple loads need to be powered on to achieve startup. Therefore, the current flowing out of the battery cell when powering on the loads is relatively large, and the relatively large current will cause the internal resistance voltage drop to be relatively large. The current flowing out of the battery cell when powering on the loads is a current (instantaneous current) in a relatively short period of time. After the loads are powered on, the current flowing out of the battery cell is usually smaller than the instantaneous current.
[0053] Internal resistance voltage drop large scenario 2: Performing a firmware restart during the restart process of the electronic device will cause the internal resistance voltage drop to increase. The reason is the same as the case where the internal resistance voltage drop is relatively large during startup, and will not be elaborated here.
[0054] Reference Figure 2 As shown, combining the foregoing formulas (1)-(4) and their related content to describe the reasons for the relatively small measurement of the real-time remaining battery power when the electronic device is powered on or restarted: When the electronic device is powered on or restarted and powers on the loads, the current flowing out of the battery cell is large, resulting in a relatively large internal resistance voltage drop of the battery. The relatively large internal resistance voltage drop of the battery causes the actual voltage to be relatively small, and the relatively small actual voltage causes the initial remaining battery power to be relatively small, thereby resulting in a relatively large initial state of charge, and further resulting in a relatively large real-time state of charge, and ultimately resulting in a relatively small real-time remaining battery power estimated by the coulomb meter.
[0055] There will be a relatively large change between the real-time remaining battery power measured after the coulomb meter is upgraded and the real-time remaining battery power measured in the last measurement before the upgrade. Then, there is a relatively large change in the real-time remaining battery power of the battery before and after the firmware upgrade (there is a change of about 3% before and after the upgrade). In some cases, if the electronic device visualizes the battery power value, the user will notice this relatively large change. The scenarios where the user will notice include: the scenario of upgrading the firmware when the electronic device is powered on again shortly after being powered off, or the scenario of upgrading the firmware when restarting. Reference Figure 3 As shown, Figure 3(1) in shows an exemplary user interface in an electronic device before power-on. At this time, a battery level identifier 111 can be displayed in the status bar. At this time, the battery level identifier 111 indicates that the battery level value is 23%. As Figure 3 As shown in (2) therein, when the shutdown time is short and the device is powered on again after shutdown, after the device is powered on, the battery level identifier 111 indicates that the battery level value is 20%. The battery level value decreases from 23% to 20%, and the change is obvious, which is easy for users to perceive. In fact, when the device is powered on again after shutdown, the battery level value should be greater than 20%, equal to 23% or differ by 1% to be normal.
[0056] Among them, the level value is related to the real-time remaining battery level. The greater the real-time remaining battery level at a certain time, the greater the level value at that time. Alternatively, the level value at a certain time can be the average value of the real-time remaining battery levels in N cycles. Where N is an integer greater than or equal to 2 and less than a preset value. The preset value can be 60 or 30, or other values such as 10, etc. The embodiments of the present application do not limit this.
[0057] It should be noted here that in addition to the aforementioned large internal resistance voltage drop scenario 1 and large internal resistance voltage drop scenario 2, there are other large internal resistance voltage drop scenarios. For example, in a low-temperature environment, the internal resistance of the battery is large. The reason is that low temperature will reduce the conductivity of the materials inside the battery, thereby increasing the internal impedance of the battery. The high impedance will cause an increase in the internal resistance voltage drop. The scenarios where the internal resistance voltage drop is large should not limit the embodiments of the present application.
[0058] It should be noted that the process of upgrading the firmware and then restarting the firmware is short and can be completed during the power-on or restart process of the electronic device.
[0059] It should also be noted that the initial depth of discharge is usually not updated. The scenarios for update include, in addition to the aforementioned firmware upgrade scenarios, another scenario: when the time that the electronic device is in a static state is greater than or equal to a preset time a, the initial depth of discharge will be calibrated and updated.
[0060] Among them, the static state is the state where the current of the battery is less than or equal to a current threshold before the electronic device enters scenarios such as power-on or restart. Among them, the current threshold is close to 0 and can be several milliamperes or more than ten milliamperes, etc.
[0061] It should be noted here that the foregoing describes that the initial depth of discharge can reflect the power that has been consumed by the battery before the fuel gauge starts to be used. It also describes that the start of use includes the time when the fuel gauge first measures parameter A after power-on or restart. It can be seen here that the start of use also includes the time when the fuel gauge first measures parameter A when the static state is greater than or equal to the preset time a.
[0062] It should also be noted that calibrating and updating the initial state of charge (SOC) is also a way to update the initial SOC. In this scenario, when the fuel gauge determines the real-time remaining power using the calibrated and updated initial SOC, the aforementioned "Coulomb integral power / battery chemical capacity" will also be cleared to 0 and start accumulating from 0 again.
[0063] In some possible cases, after the electronic device updates the initial SOC during the firmware upgrade and restart process, it is also necessary to determine whether the time when the electronic device is in a stationary state is greater than or equal to a preset time a to determine whether it is necessary to calibrate the updated initial SOC for more accurate measurement of the real-time SOC. The description of this process can refer to the following Figure 4 steps S11 - S14 shown in
[0064] S11. After the fuel gauge firmware is upgraded, when restarting the upgraded firmware, initialize the algorithm in the firmware. The algorithm initialization includes updating the initial SOC of the battery based on the OCV look-up table method.
[0065] Among them, updating the initial SOC of the battery based on the OCV look-up table method includes the methods involved in the aforementioned formula (1) and formula (2): after obtaining the actual voltage of the battery by subtracting the internal resistance voltage drop from the open-circuit voltage of the battery, then perform a look-up table (voltage - power correspondence table) based on the actual voltage to determine the initial SOC.
[0066] Among them, the OCV look-up table method can be referred to as the open-circuit voltage method.
[0067] S12. Determine whether the time when the battery is in a stationary state is greater than or equal to the preset time a.
[0068] The preset time a can be 30 minutes or 40 minutes, and can also be other values, such as 35 minutes. The embodiments of the present application do not limit this.
[0069] When the time when the battery is in a stationary state is greater than or equal to the preset time a, the electronic device executes the following step S13 to calibrate the updated initial SOC in step S11.
[0070] When the time when the battery is in a stationary state is less than the preset time a, the electronic device executes the following S14 to estimate the real-time remaining power of the battery using the updated initial SOC in step S11.
[0071] S13. Calibrate the initial SOC.
[0072] The ways to calibrate the initial SOC include but are not limited to the following calibration method 1 and calibration method 2.
[0073] Calibration method 1: Based on the difference between the open-circuit voltage of the battery at rest and the nominal voltage, the initial depth of discharge of the battery can be estimated. For example, if the open-circuit voltage of the battery is M1 volts and the nominal voltage is M2 volts, the initial depth of discharge of the battery can be estimated as (M2 - M1) / M2. Among them, the nominal voltage is the ideal operating voltage specified by the battery manufacturer for the battery. It is the theoretical reference value of the voltage required by the electronic device based on the design and specification requirements of the battery manufacturer. Among them, the open-circuit voltage at rest is the open-circuit voltage when the resting time of the battery is greater than or equal to the preset time a. This open-circuit voltage at rest is obtained by the electronic device measuring the open-circuit voltage when the resting time of the battery is greater than or equal to the preset time a.
[0074] Calibration method 2: Use the open-circuit voltage at rest in combination with the current consumption model to calculate the initial depth of discharge, and take the calculated initial depth of discharge as the calibrated initial depth of discharge.
[0075] It should be noted here that the open-circuit voltage involved in step S13 is the open-circuit voltage measured in real time when calibrating the initial depth of discharge.
[0076] S14. Estimate the real-time remaining power of the battery using the initial depth of discharge.
[0077] In the case where step S13 is executed, the initial depth of discharge in step S14 is the calibrated initial depth of discharge in step S13.
[0078] In the case where step S13 is not executed, the initial depth of discharge in step S14 is the updated initial depth of discharge in step S11.
[0079] In step S14, the process of estimating the real-time remaining power of the battery using the initial depth of discharge can refer to the aforementioned formula (3) and formula (4), which will not be elaborated here.
[0080] It should be noted that the reasons for calibrating the initial depth of discharge in step S13 include: when the static state time of the battery is greater than or equal to the preset time a, the parameters for calculating the initial depth of discharge, such as the open-circuit voltage of the measured battery (static open-circuit voltage), are relatively accurate (close to or equal to the parameters measured when the battery is not connected to a load). Therefore, using parameters such as the static open-circuit voltage to calibrate the initial depth of discharge can obtain an accurate initial depth of discharge. Moreover, there is an error in the cumulative consumed electric quantity calculated by "Coulomb integral electric quantity / battery chemical capacity" in the foregoing formula (4). Therefore, the initial depth of discharge is calibrated and updated, and "Coulomb integral electric quantity / battery chemical capacity" is cleared when calibrating and updating the initial depth of discharge. Subsequently, using the calibrated initial depth of discharge and accumulating "Coulomb integral electric quantity / battery chemical capacity" starting from 0 can calculate the real-time depth of discharge more accurately. The error caused by the cumulative consumed electric quantity calculated by "Coulomb integral electric quantity / battery chemical capacity" can be corrected.
[0081] To solve the problem in the foregoing solution that when updating the initial depth of discharge in scenarios such as power-on or restart, the measured initial depth of discharge is too large, resulting in a too small real-time remaining battery capacity, and further causing a large change in the battery capacity value before and after power-on or restart. Another method for calculating the battery capacity is proposed. In this method, when the electronic device is in scenarios such as power-on or restart, it is determined to upgrade the firmware at time 1. Before notifying the fuel gauge to upgrade the firmware, the electronic device can record the real-time depth of discharge corresponding to time 1. Then, after the firmware upgrade is completed, when updating the initial depth of discharge in the upgraded firmware during the restart of the fuel gauge, the real-time depth of discharge corresponding to time 1 is used as the updated initial depth of discharge.
[0082] In the case where the real-time depth of discharge corresponding to time 1 is recorded in the fuel gauge memory. The data in the fuel gauge memory will be cleared when the fuel gauge restarts. Therefore, before notifying the fuel gauge to upgrade the firmware, it is necessary to copy the real-time depth of discharge corresponding to time 1 from the fuel gauge memory to a memory a outside the fuel gauge. The data in this memory a will not be cleared when the fuel gauge restarts. Based on this, the electronic device can use the real-time depth of discharge corresponding to time 1 as the updated initial depth of discharge, including: when restarting the fuel gauge, writing the real-time discharge corresponding to time 1 back to the fuel gauge, and then the fuel gauge uses the real-time depth of discharge corresponding to time 1 as the updated initial depth of discharge.
[0083] The reason for using the real-time depth of discharge corresponding to time 1 as the updated initial depth of discharge is as follows: Time 1 is equal to or close to the time of firmware upgrade. Since the power consumption of the battery in scenarios such as power-on or restart is small (usually so small that it does not cause a change in the power value). Therefore, the power consumption in scenarios such as power-on or restart can be ignored. After updating the initial depth of discharge, the "Coulomb integral power / battery chemical capacity" in formula (4) will be cleared. Then, when the upgraded firmware calculates the real-time remaining power at time 2 using formula (4), the corresponding initial depth of discharge equal to the real-time depth of discharge at time 1 can also obtain the real-time remaining power at time 2.
[0084] It should be noted that time 2 is a time after calculating the real-time remaining power using formula (4) after the firmware restarts. The electronic device can obtain the real-time remaining power at time 2 by subtracting the power consumed from time 3 to time 2 from the updated initial depth of discharge. Here, time 3 is the time when the fuel gauge first measures the real-time remaining power after the firmware upgrade is completed. Time 3 is earlier than time 2. Among them, the power consumed from time 3 to time 2 is equal to the cumulative value of "Coulomb integral power / battery chemical capacity" from time 3 to time 2.
[0085] In some possible cases, after the fuel gauge restarts, it is also necessary to determine whether the time when the battery of the electronic device is in a static state before entering scenarios such as power-on or restart is greater than or equal to the preset time a.
[0086] If the time when the battery is in a static state is less than the preset time a. At this time, obtaining the real-time remaining power at time 2 by subtracting the power consumed from time 3 to time 2 from the updated initial depth of discharge includes: subtracting the power consumed from time 3 to time 2 from the updated initial depth of discharge, and the real-time remaining power at time 2 can be obtained.
[0087] If the time when the battery is in a static state is greater than or equal to the preset time a, then it is also necessary to calibrate and update the updated initial depth of discharge. Obtain the calibrated initial depth of discharge. At this time, obtaining the real-time remaining power at time 2 by subtracting the power consumed from time 3 to time 2 from the updated initial depth of discharge includes: First, calibrate and update the updated initial depth of discharge to obtain the calibrated initial depth of discharge. Then, subtract the power consumed from time 3 to time 2 from the calibrated initial depth of discharge, and the real-time remaining power at time 2 can be obtained.
[0088] Among them, the initial depth of discharge is calibrated using the static open-circuit voltage of the battery. The description of this process can refer to the aforementioned S13 and will not be elaborated here.
[0089] It should be noted that the reasons for calibrating the initial depth of discharge here include, in addition to the reasons in the aforementioned step S13, the following: The shutdown state is also a static state. In the scenario where the device is powered on again after the shutdown time is greater than or equal to the preset time a, power is usually lost during the shutdown state. When the shutdown time is relatively long, the lost power cannot be ignored. Therefore, the real-time depth of discharge corresponding to time 1 can no longer be used as the initial depth of discharge, as it will ignore the power consumed during the shutdown time and needs to be calibrated.
[0090] In this way, the upgraded firmware can have an accurate initial depth of discharge, so that the initial depth of discharge can still accurately calculate the real-time remaining power after being updated or calibrated. Generally speaking, when using this power calculation method, during the firmware upgrade process when the electronic device is powered on or restarted. The restart or shutdown time is relatively short, and the power values displayed by the electronic device before and after powering on again are equal or differ by 1%. As Figure 5 Figure (1) shows an exemplary user interface in the electronic device before powering on. At this time, the battery level identifier 111 can be displayed in the status bar, and at this time, the battery level identifier 111 indicates that the battery power value is 23%. As Figure 5 As shown in Figure (2), when the shutdown time is relatively short and the device is powered on again after shutdown, the battery level identifier 111 still indicates that the battery power value is 23%. The battery power value does not change when the device is powered on again after a short shutdown.
[0091] Next, based on Figure 6 This document will describe in detail how to update the initial depth of discharge during the firmware upgrade and restart process using the power calculation method, and related content on estimating the real-time depth of discharge of the battery based on the upgraded firmware. This process can refer to the following description of steps S101 - S110.
[0092] S101. The electronic device determines to upgrade the fuel gauge firmware at time 1. Before notifying the fuel gauge to perform the firmware upgrade, copy the real-time depth of discharge corresponding to time 1 from the memory 1 of the fuel gauge to the memory a outside the fuel gauge; at this time 1, the electronic device is in the process of powering on or restarting.
[0093] This memory 1 can be the internal memory of the fuel gauge. When the fuel gauge restarts, the data in this memory 1 will be cleared.
[0094] This memory a can be a memory that can be used during the power-on process. For example, it can be the internal memory of the processor. It can also be the flash of the electronic device, etc. This application embodiment does not make any limitations in this regard. The data in this memory a will not be cleared when the fuel gauge restarts.
[0095] The electronic device determines to upgrade the fuel gauge firmware at time 1, including: the electronic device receives the new firmware sent by the cloud server, compares the version of the new firmware with the version of the old firmware in the fuel gauge, and when it is determined that the versions are different, it can be set to upgrade the fuel gauge firmware at time 1.
[0096] S102. The electronic device notifies the fuel gauge to perform a firmware upgrade.
[0097] S103. After the firmware upgrade is completed, the electronic device starts to restart the fuel gauge after the firmware upgrade.
[0098] Restarting the fuel gauge is to initialize the upgraded firmware (new firmware) so that the new firmware can be used. Among them, initializing the new firmware includes initializing the battery charge estimation algorithm in the new firmware. Initializing the battery charge estimation algorithm includes: updating the initial discharge depth in the new firmware. The battery charge estimation algorithm may include the aforementioned formulas (1)-(4).
[0099] The upgraded firmware can also be referred to as the post-upgrade firmware.
[0100] S104. Whether it is a restart for upgrade reset.
[0101] If it is not a restart for upgrade reset, for example, it is an abnormal restart caused by a fuel gauge system crash, then at this time the internal resistance voltage drop will not be too large, and the following step S105a can be executed to update the initial discharge depth in the new firmware based on the OCV look-up table method.
[0102] If it is a restart for upgrade reset, at this time the internal resistance voltage drop is too large due to power-on or restart, then the following step S105b is executed to write the real-time discharge depth corresponding to time 1 back to the fuel gauge to update the initial discharge depth in the new firmware based on the initial discharge depth corresponding to time 1.
[0103] S105a. Initialize the algorithm in the upgraded firmware. Performing algorithm initialization includes updating the initial discharge depth based on the OCV look-up table method.
[0104] Among them, updating the initial discharge depth by the OCV look-up table method is to use the methods involved in the aforementioned formulas (1) and (2), including: after obtaining the actual voltage of the battery by subtracting the internal resistance voltage drop from the open-circuit voltage of the battery, then perform a look-up table (voltage-electricity correspondence table) based on the actual voltage to determine the updated initial discharge depth.
[0105] S105b. The fuel gauge waits for the electronic device to write the real-time discharge depth corresponding to time 1 back to the fuel gauge.
[0106] After the fuel gauge starts to restart and before the restart ends, it waits for the electronic device to write the real-time discharge depth corresponding to time 1 back to the fuel gauge.
[0107] S106. The fuel gauge determines whether it has received the real-time depth of discharge corresponding to time 1.
[0108] If it has not received the real-time depth of discharge corresponding to time 1, then perform the following step S107a to further determine whether the waiting time has reached the preset time 1.
[0109] If it has received the real-time depth of discharge corresponding to time 1, then perform the following step S107b to update the initial depth of discharge using the real-time depth of discharge corresponding to time 1.
[0110] Here, it should be noted that receiving the real-time depth of discharge corresponding to time 1 is by default received when the waiting time is less than the preset time 1.
[0111] S107a. Whether the waiting time has reached the preset time 1.
[0112] The preset time 1 can be 3s, and can also be other values, such as 2s or 2.5s, etc. The embodiments of the present application do not limit the preset time 1, but the preset time 1 should be less than the time required for the electronic device to power on or restart.
[0113] When the waiting time has not reached the preset time 1, continue to execute step S105 to wait for the electronic device to write the real-time depth of discharge corresponding to time 1 back to the fuel gauge.
[0114] When the waiting time has reached the preset time 1, then execute step S105a to update the initial depth of discharge based on the OCV look-up table method.
[0115] Here, it should be noted that setting the waiting preset time 1 is to update the initial depth of discharge even when the transmission of the real-time depth of discharge corresponding to time 1 to the fuel gauge fails during the startup process.
[0116] S107b. Initialize the algorithm in the upgraded firmware. The algorithm initialization includes updating the initial depth of discharge using the real-time depth of discharge corresponding to time 1.
[0117] In some possible cases, the real-time depth of discharge corresponding to time 1 can be used as the updated initial depth of discharge.
[0118] In other possible cases, in combination with the aging condition of the battery, the real-time depth of discharge corresponding to time 1 can be appropriately multiplied by a coefficient as the updated initial depth of discharge. This coefficient is greater than or equal to 1. This coefficient is related to the aging degree of the battery. The greater the aging degree, the greater this coefficient.
[0119] S108. The fuel gauge determines whether the time when the battery is in the static state is greater than or equal to the preset time a.
[0120] For the relevant description of the static state, reference can be made to the foregoing description of the static state, which will not be elaborated here.
[0121] When the time for which the battery is in the static state is greater than or equal to the preset time a, the electronic device performs the following step S109 to calibrate the updated initial depth of discharge.
[0122] When the time for which the battery is in the static state is less than the preset time a, the electronic device performs the following S110 to estimate the real-time remaining power of the battery using the updated initial depth of discharge.
[0123] S109. The electronic device calibrates the updated initial depth of discharge.
[0124] The process of calibrating the updated initial depth of discharge in step S109 to obtain the calibrated initial depth of discharge can be referred to the foregoing description of step S13, which will not be elaborated here.
[0125] S110. The electronic device estimates the real-time remaining power of the battery using the initial depth of discharge.
[0126] It should be noted here that in the case where step S109 is not executed, the initial depth of discharge involved in step S110 is the updated initial depth of discharge in step S107b or step S105a. In the case where step S109 is executed, the initial depth of discharge involved in step S110 is the calibrated initial depth of discharge in step S109.
[0127] The process of estimating the real-time remaining power of the battery using the initial depth of discharge here can be referred to the relevant description of determining the initial depth of discharge at time 2, which will not be elaborated here.
[0128] In the foregoing content, the instructions corresponding to relevant operations such as firmware upgrade, copying the real-time depth of discharge corresponding to time 1, and restarting the fuel gauge after upgrade in the electronic device are written into the processor of the electronic device. The instructions corresponding to relevant operations such as updating the initial depth of discharge, calculating parameters such as "Coulomb integral power / battery chemical capacity", and calculating the real-time depth of discharge in combination with the updated initial discharge parameters are written into the fuel gauge of the electronic device.
[0129] Next, based on Figure 7 Describe in detail the interaction process between the processor and the fuel gauge in the process of updating the initial depth of discharge during firmware upgrade and restarting to estimate the real-time depth of discharge based on the upgraded firmware. This interaction process can be referred to the following description of steps S201 - S215.
[0130] S201. The processor controls the electronic device to enter the restart state or the power-on state.
[0131] In response to a power-on operation, the processor starts the electronic device when the electronic device is in a powered-off state.
[0132] Alternatively, in response to an operation of restarting the electronic device, the processor restarts the electronic device when the electronic device is in a powered-on state.
[0133] During the power-on process or the restart process, the processor interacts with the fuel gauge to execute the following steps S202 to S214 to implement firmware upgrade, fuel gauge restart, and operations such as calculating the real-time depth of discharge based on the new firmware. This interaction process can refer to the following description of steps S202 - S214.
[0134] S202. The processor determines to upgrade the fuel gauge firmware at time 1.
[0135] The processor determines to upgrade the fuel gauge firmware at time 1, including: the processor receives the new firmware sent by the cloud server, compares the version of the new firmware with the version of the old firmware in the fuel gauge, and when it determines that the versions are different. The processor can set to upgrade the fuel gauge firmware at time 1.
[0136] S203. The processor sends an instruction to the fuel gauge to back up the real-time depth of discharge, and the fuel gauge sends the real-time depth of discharge corresponding to time 1 to the processor.
[0137] After receiving the instruction to send the backup real-time depth of discharge, the fuel gauge obtains the real-time depth of discharge corresponding to time 1 from memory 1 and sends the real-time depth of discharge corresponding to time 1 to the processor.
[0138] S204. The processor records the real-time depth of discharge corresponding to time 1.
[0139] The processor can record the real-time depth of discharge corresponding to time 1 in the memory of the processor.
[0140] S205. The processor sends a firmware upgrade instruction to the fuel gauge.
[0141] After sending the firmware upgrade instruction, or after starting to time after sending the firmware upgrade instruction, when the timing reaches the preset time 2, the processor can also execute the following step S208 to query whether the upgrade of the fuel gauge is completed.
[0142] Among them, the preset time 2 is greater than 0 but less than the time required for firmware upgrade. For example, it can be 0.1s, 0.05s, etc., and the embodiments of the present application do not limit this.
[0143] S206. After completing the firmware upgrade, the fuel gauge starts to restart the fuel gauge after the firmware upgrade.
[0144] S207. The fuel gauge determines that it is a restart for upgrade reset.
[0145] It should be mainly noted that here it is described in terms of upgrade reset and restart. For the relevant content related to non-upgrade reset and restart, reference can be made to the previous descriptions of step S104 and step S105a, which will not be elaborated here.
[0146] S208. The processor queries the fuel gauge to check if the upgrade is completed, and the fuel gauge notifies the processor that the upgrade is completed.
[0147] After the processor determines that the upgrade is completed, it sends the real-time depth of discharge corresponding to time 1 to the fuel gauge.
[0148] If the processor does not query that the upgrade is completed, it can query again.
[0149] S209. The fuel gauge waits for the processor to write back the real-time depth of discharge corresponding to time 1 to the fuel gauge.
[0150] S210. The fuel gauge determines whether it has received the real-time depth of discharge corresponding to time 1.
[0151] When it determines that it has received the real-time depth of discharge corresponding to time 1, the fuel gauge executes the following step S212 to update the initial depth of discharge in the upgraded firmware using the real-time depth of discharge corresponding to time 1.
[0152] When it determines that it has not received the real-time depth of discharge corresponding to time 1, the fuel gauge executes the following S213 to update the initial depth of discharge in the upgraded firmware based on the OCV look-up table method.
[0153] S211. The fuel gauge determines whether the waiting time has reached the preset time 1.
[0154] For the relevant description of the preset time 1, reference can be made to the previous relevant content, which will not be elaborated here.
[0155] When it determines that the waiting time has not reached the preset time 1, the fuel gauge returns to execute step S210 to continue waiting for the real-time depth of discharge corresponding to time 1 sent by the processor.
[0156] When it determines that the waiting time has reached the preset time 1, the fuel gauge executes the following S213 to update the initial depth of discharge in the upgraded firmware based on the OCV look-up table method.
[0157] S212. The fuel gauge updates the initial depth of discharge using the real-time depth of discharge corresponding to time 1.
[0158] For the content involved in step S212, reference can be made to the previous description of step S107b, which will not be elaborated here.
[0159] S213. The fuel gauge updates the initial depth of discharge in the upgraded firmware based on the OCV look-up table method.
[0160] Among them, the OCV look-up table method updates the initial state of charge (SOC), which is the method involved in the aforementioned formulas (1) and (2), including: after obtaining the actual voltage of the battery by subtracting the voltage drop across the internal resistance from the open-circuit voltage of the battery, a look-up table (voltage-SOC correspondence table) is performed based on the actual voltage to determine the updated initial SOC.
[0161] S214. The fuel gauge estimates the real-time remaining capacity of the battery based on the initial SOC.
[0162] After the restart is completed, the fuel gauge estimates the real-time remaining capacity of the battery based on the initial SOC.
[0163] It should be noted here that when it is determined not to perform calibration, the initial SOC involved in step S214 is the updated initial SOC in step S213 or step S212.
[0164] When it is determined to perform calibration, the initial SOC involved in this step S214 is the calibrated initial SOC.
[0165] The real-time remaining capacity determined in step S14 can be the real-time remaining capacity at time 2 involved above. The relevant process can refer to the description of determining the real-time remaining capacity at time 2 above, and will not be elaborated here.
[0166] After obtaining the updated initial SOC, before performing the following step S215, the fuel gauge will also determine whether to perform calibration. This process includes: the fuel gauge determines whether the time when the battery is in a static state is greater than or equal to a preset time a. When the time when the battery is in a static state is greater than or equal to the preset time a, the updated initial SOC is calibrated. The calibration process can refer to the description of step S108 above, and will not be elaborated here. When the time when the battery is in a static state is less than the preset time a, the updated initial SOC is not calibrated.
[0167] S215. The processor displays the battery capacity value on the interface based on the real-time remaining capacity.
[0168] After the power-on or restart is completed, the electronic device can be used normally. At this time, the processor can display the capacity value in the electronic device based on the real-time remaining capacity. The greater the real-time remaining capacity, the greater this capacity value.
[0169] It should be noted that Figure 7 in, the execution order of step S208 can be after step S205. There is no sequence relationship with step S206 and step S207.
[0170] It should also be noted that upgrading the firmware of the fuel gauge and restarting the fuel gauge include but are not limited to the aforementioned Figure 7In the scenario of powering on or restarting the electronic device involved. For the sake of convenience of description, Figure 7 In this example, the electronic device upgrades the firmware of the fuel gauge and restarts the fuel gauge when powering on or restarting.
[0171] The following introduces an exemplary fuel gauge.
[0172] As Figure 8 shown, the fuel gauge may include a processing unit, a metering unit, an external storage unit, and a communication unit.
[0173] Among them, the processing unit is the core component of the fuel gauge, usually composed of a microcontroller or a dedicated chip. The processing unit is responsible for controlling the operation of the fuel gauge and executing the battery power estimation algorithm to measure the battery power (including the real-time remaining power, etc.). The processing unit also includes a memory, which can be used to store the data required for measuring the battery power. This memory is a volatile memory, and the data in it will be cleared when the fuel gauge is powered off or restarted.
[0174] The metering unit may include firmware, which is a software for measuring the battery power. The aforementioned battery power estimation algorithm is included in the firmware.
[0175] The external storage unit may include an electrically erasable programmable read-only memory (EEPROM). The aforementioned voltage-power correspondence table can be stored in this EEPROM. This EEPROM is a non-volatile memory and can keep the data from being cleared when the fuel gauge is powered off or restarted.
[0176] The communication unit is responsible for data interaction and communication with other modules (external modules) outside the fuel gauge. It can support different communication interfaces, such as UART, I2C, SPI, wireless communication, etc. The communication unit can be used to transmit the measurement data of the fuel gauge to an external module (such as the processor of the electronic device), or receive control commands and configuration information from the external module. For example, the aforementioned instructions such as the instruction to back up the real-time depth of discharge sent by the processor and the firmware upgrade instruction are all interacted through the communication unit.
[0177] The following introduces the exemplary electronic device provided by the embodiments of the present application.
[0178] Figure 9 is a schematic structural diagram of the electronic device provided by the embodiments of the present application.
[0179] The following takes the electronic device as an example to specifically illustrate the embodiments. It should be understood that the electronic device may have more Figure 9More or fewer components shown in [figure] can combine two or more components, or can have different component configurations. Figure 9 The various components shown in [figure] can be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application specific integrated circuits.
[0180] The electronic device may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone interface 170D, a sensor module 180, a key 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0181] It can be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or have different component arrangements. The illustrated components can be implemented in hardware, software, or a combination of software and hardware.
[0182] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices, or may be integrated in one or more processors.
[0183] Among them, the controller can be the nerve center and command center of the electronic device. The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of fetching and executing instructions.
[0184] A memory can also be set in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store the instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to use the instruction or data again, it can directly call it from the said memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0185] In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0186] It can be understood that the interface connection relationship between the modules illustrated in the embodiments of the present application is only for illustrative purposes and does not constitute a structural limitation on the electronic device. In other embodiments of the present application, the electronic device may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0187] The charging management module 140 is used to receive charging input from a charger. Among them, the charger can be a wireless charger or a wired charger.
[0188] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives the inputs from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193, the wireless communication module 160, etc.
[0189] The wireless communication function of the electronic device can be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modulation and demodulation processor, and the baseband processor, etc.
[0190] The antenna 1 and the antenna 2 are used to transmit and receive electromagnetic wave signals.
[0191] In some embodiments, the antenna 1 of the electronic device is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device can communicate with the network and other devices through wireless communication technologies. The wireless communication technologies may include the global system for mobile communications (GSM), the general packet radio service (GPRS), etc.
[0192] The display screen 194 is used to display images, videos, etc.
[0193] The camera 193 is used to capture static images or videos.
[0194] The internal memory 121 may include one or more random access memories (RAM) and one or more non-volatile memories (NVM).
[0195] The random access memory may include a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDR SDRAM, for example, the fifth generation of DDR SDRAM is generally called DDR5 SDRAM), etc.;
[0196] Non-volatile memory may include disk storage devices and flash memory.
[0197] Flash memory can be classified into NOR FLASH, NAND FLASH, 3D NAND FLASH, etc. according to the operating principle, and can be classified into single-level cell (SLC), multi-level cell, etc. according to the number of potential levels of storage cells.
[0198] Random access memory can be directly read and written by the processor 110, and can be used to store the operating system or executable programs of other running programs (such as machine instructions), and can also be used to store data of users and application programs, etc.
[0199] Non-volatile memory can also store executable programs and data of users and application programs, etc., and can be pre-loaded into random access memory for the processor 110 to directly read and write.
[0200] The external memory interface 120 can be used to connect to an external non-volatile memory to expand the storage capacity of the electronic device. The external non-volatile memory communicates with the processor 110 through the external memory interface 120 to implement the data storage function. For example, files such as music and videos are saved in the external non-volatile memory.
[0201] The electronic device can implement audio functions through the audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor, etc. For example, music playback, recording, etc.
[0202] The keys 190 include a power-on key, volume keys, etc. The keys 190 can be mechanical keys or touch keys. The electronic device can receive key inputs and generate key signal inputs related to the user settings and function control of the electronic device.
[0203] In the embodiments of the present application, the processor 110 can call computer instructions stored in the internal memory 121 to enable the terminal to execute the power consumption calculation method in the embodiments of the present application.
[0204] The present application also provides a chip system, and the chip system includes at least one processor for implementing the functions involved in the method executed by the electronic device in any one of the above embodiments.
[0205] In a possible design, the chip system further includes a memory, and the memory is used to store program instructions and data, and the memory is located inside or outside the processor.
[0206] The chip system can be composed of chips, or can include chips and other discrete devices.
[0207] Optionally, there can be one or more processors in the chip system. The processor can be implemented by hardware or by software. When implemented by hardware, the processor can be a logic circuit, an integrated circuit, etc. When implemented by software, the processor can be a general-purpose processor that implements functions by reading software code stored in a memory.
[0208] Optionally, there can also be one or more memories in the chip system. The memory can be integrated with the processor or can be separately arranged from the processor, which is not limited in the embodiments of the present application.
[0209] Exemplarily, the memory can be a non-transitory processor, such as a read-only memory (ROM). It can be integrated with the processor on the same chip or can be separately arranged on different chips. The embodiments of the present application do not specifically limit the type of the memory and the arrangement manner of the memory and the processor.
[0210] Exemplarily, the chip system can be a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on chip (SoC), a central processing unit (CPU), a network processor (NP), a digital signal processing circuit (DSP), a micro controller unit (MCU), a programmable logic device (PLD), or other integrated chips.
[0211] The present application also provides a computer program product, which includes: a computer program (which can also be referred to as code or instruction). When the computer program is run, it causes a computer to execute the method performed by the electronic device in any one of the above embodiments.
[0212] The present application also provides a computer-readable storage medium, which stores a computer program (which can also be referred to as code or instruction). When the computer program is run, it causes a computer to execute the method performed by the electronic device in any one of the above embodiments.
[0213] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the various embodiments of the present application.
[0214] In the above embodiments, depending on the context, the term "when..." can be interpreted to mean "if...", or "after...", or "in response to determining...", or "in response to detecting...". Similarly, depending on the context, the phrase "when determining..." or "if detecting (the stated condition or event)" can be interpreted to mean "if determining...", or "in response to determining...", or "when detecting (the stated condition or event)", or "in response to detecting (the stated condition or event)".
[0215] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. As used in the specification and claims of the present application, the singular forms "a", "an", "the", "above", "said", "this" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used in the present application refers to and includes any or all possible combinations of one or more of the listed items.
[0216] The terms "first" and "second" are only used for descriptive purposes, and cannot be construed as implying or suggesting relative importance or implicitly indicating the quantity of the indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more of such features. In the description of the embodiments of the present application, unless otherwise specified, the meaning of "a plurality" is two or more.
[0217] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (such as coaxial cable, optical fiber, digital subscriber line) or wirelessly (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid-state drive), etc.
[0218] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware with a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above method embodiments. The foregoing storage medium includes: various media that can store program codes such as ROM or random access memory RAM, magnetic disks, or optical discs.
Claims
1. A method for calculating electric quantity, characterized in that, The method includes: The electronic device determines to upgrade the first firmware of the fuel gauge to the second firmware at a first time; Before notifying the fuel gauge to upgrade the first firmware, the electronic device copies the real-time depth of discharge corresponding to the first time from the first memory of the fuel gauge to a second memory outside the fuel gauge; the data in the first memory will be cleared when the fuel gauge restarts; After upgrading the first firmware to the second firmware, the electronic device controls the fuel gauge to restart, and the restart includes: when writing the real-time depth of discharge back to the fuel gauge, the electronic device updates the initial depth of discharge in the second firmware using the real-time depth of discharge; The electronic device determines the battery power of the electronic device at a second time through the updated initial depth of discharge; the second time is later than the first time.
2. The method according to claim 1, wherein The restart further includes: when not writing the real-time depth of discharge back to the fuel gauge, the electronic device updates the initial depth of discharge using the battery open-circuit voltage and the battery internal resistance voltage drop.
3. The method according to claim 2, characterized in that, The electronic device determines the battery power of the electronic device at a second time through the updated initial depth of discharge, specifically including: When the time that the electronic device is in a static state is less than a first preset time, the electronic device subtracts the power consumed from the third time to the second time from the updated initial depth of discharge as the battery power at the second time; the third time is the time when the fuel gauge first measures the battery power after completing the upgrade; the third time is later than the first time but earlier than the second time.
4. The method according to claim 2, wherein The electronic device determines the battery power of the electronic device at a second time through the updated initial depth of discharge, specifically including: When the time that the electronic device is in a static state is greater than or equal to the first preset time, the electronic device calibrates the updated initial depth of discharge using the static open-circuit voltage; the static open-circuit voltage is the open-circuit voltage measured when the time in the static state is greater than or equal to the first preset time; The electronic device determines the battery power at the second time based on the calibrated initial depth of discharge.
5. The method according to any one of claims 2-4, characterized in that, The first memory is the memory in the fuel gauge; the second memory is the memory in the processor of the electronic device.
6. The method according to claim 5, characterized in that, Before updating the initial depth of discharge in the second firmware using the real-time depth of discharge after controlling the fuel gauge to restart, the method further includes: After the restart, the fuel gauge starts to wait for the processor to send the real-time depth of discharge; Before the fuel gauge waits for a second preset time, if the fuel gauge determines that it has received the real-time depth of discharge, it writes the real-time depth of discharge back to the first memory of the fuel gauge.
7. The method according to claim 5, wherein Before updating the initial depth of discharge using the battery open-circuit voltage and the battery internal resistance voltage drop after controlling the fuel gauge to restart, the method further includes: After the restart, the fuel gauge starts to wait for the processor to send the real-time depth of discharge; When the fuel gauge waits until the second preset time and determines that it has not received the real-time depth of discharge.
8. The method according to any one of claims 1-7, characterized in that, The method further includes: Before the electronic device determines to upgrade the first firmware of the fuel gauge to the second firmware at a first time, in response to a power-on operation, the electronic device starts the electronic device in a shutdown state; After the second time, the electronic device completes the startup.
9. The method according to any one of claims 1-7, characterized in that, The method further includes: Before the electronic device determines to upgrade the first firmware of the fuel gauge to the second firmware at a first time, in response to an operation of restarting the electronic device, the electronic device restarts the electronic device in a powered-on state; After the second time, the electronic device completes the restart.
10. The method according to claim 8 or 9, characterized in that, The method further includes: After the second time, the electronic device displays a power value in the electronic device based on the battery power at the second time; the greater the battery power at the second time, the greater the power value.
11. An electronic device, characterized in that, Including: One or more processors, a memory, and a fuel gauge; the memory is coupled to the one or more processors, the memory is configured to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to cause the electronic device to execute the method according to any one of claims 1-10.
12. A computer-readable storage medium, comprising computer instructions, characterized in that, When the computer instructions run on the electronic device, the electronic device is caused to execute the method according to any one of claims 1-10.
13. A chip system, the chip system being applied to an electronic device, characterized in that, The chip system includes one or more processors, and the processors are configured to call computer instructions to cause the electronic device to execute the method according to any one of claims 1-10.