CN112782596A - Battery electric quantity calculation method, electronic device and storage medium - Google Patents

Battery electric quantity calculation method, electronic device and storage medium Download PDF

Info

Publication number
CN112782596A
CN112782596A CN202011416816.4A CN202011416816A CN112782596A CN 112782596 A CN112782596 A CN 112782596A CN 202011416816 A CN202011416816 A CN 202011416816A CN 112782596 A CN112782596 A CN 112782596A
Authority
CN
China
Prior art keywords
voltage value
value
battery
smooth
values
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011416816.4A
Other languages
Chinese (zh)
Inventor
贺彩文
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Xinguodu Tech Co Ltd
Original Assignee
Shenzhen Xinguodu Tech Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Xinguodu Tech Co Ltd filed Critical Shenzhen Xinguodu Tech Co Ltd
Priority to CN202011416816.4A priority Critical patent/CN112782596A/en
Publication of CN112782596A publication Critical patent/CN112782596A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G01MEASURING; TESTING
    • G01RMEASURING ELECTRIC VARIABLES; MEASURING MAGNETIC VARIABLES
    • G01R31/00Arrangements for testing electric properties; Arrangements for locating electric faults; Arrangements for electrical testing characterised by what is being tested not provided for elsewhere
    • G01R31/36Arrangements for testing, measuring or monitoring the electrical condition of accumulators or electric batteries, e.g. capacity or state of charge [SoC]
    • G01R31/385Arrangements for measuring battery or accumulator variables
    • G01R31/387Determining ampere-hour charge capacity or SoC
    • G01R31/388Determining ampere-hour charge capacity or SoC involving voltage measurements

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Secondary Cells (AREA)
  • Charge And Discharge Circuits For Batteries Or The Like (AREA)

Abstract

The invention discloses a battery electric quantity calculation method, electronic equipment and a storage medium, wherein the battery electric quantity calculation method comprises the following steps: continuously acquiring a plurality of ADC values, and acquiring depolarization voltage values according to the plurality of ADC values; obtaining an effective smooth voltage value according to a plurality of continuous depolarization voltage values; and determining the battery capacity according to the smooth voltage value. According to the invention, the depolarization voltage value is obtained after the ADC value acquired by the ADC, then the effective smooth voltage value is obtained after a plurality of continuous depolarization voltage values are obtained, and finally the battery electric quantity is determined according to the smooth voltage value, so that the accurate and stable smooth voltage value is obtained through the plurality of continuous depolarization voltage values after the ADC is used for sampling, and the accurate battery electric quantity is calculated.

Description

Battery electric quantity calculation method, electronic device and storage medium
Technical Field
The present invention relates to the field of battery power technologies, and in particular, to a battery power calculation method, an electronic device, and a storage medium.
Background
At present, two methods are commonly used in a battery power calculation method. The first is to adopt a professional high-performance electricity meter chip to automatically and accurately count the battery electricity quantity, and the second is to adopt a mode of collecting the battery voltage by an ADC (analog to digital converter), and then to carry out rough calculation according to the battery voltage adopted by the ADC to obtain the current battery electricity quantity.
For the first method, the electric quantity of the battery is calculated by adopting an electricity meter chip, the electricity meter chip samples the current, the voltage and the temperature of the battery in real time, and meanwhile, an independent hardware accumulator is adopted for calculating the electric quantity, and then the electric quantity of the battery is estimated based on sampled related data. However, the electricity meter chip is expensive and cannot be widely applied to low-cost products in the market. The second method for acquiring the battery power by adopting the ADC is mainly to estimate the battery power through the voltage converted by the ADC, but the voltage read by the ADC is unstable due to the problems of ADC reference voltage jitter, hardware resistance consistency, environmental electromagnetic interference and the like.
Disclosure of Invention
The present invention is directed to solving at least one of the problems of the prior art. Therefore, the invention provides a battery electric quantity calculation method which can improve the stability of battery electric quantity calculation and obtain a stable battery voltage value.
The invention further provides the electronic equipment.
The invention also provides a computer readable storage medium.
In a first aspect, an embodiment of the present invention provides a battery level calculation method, including:
continuously acquiring a plurality of ADC values, and acquiring depolarization voltage values according to the plurality of ADC values;
obtaining an effective smooth voltage value according to a plurality of continuous depolarization voltage values;
and determining the battery capacity according to the smooth voltage value.
The battery electric quantity calculation method provided by the embodiment of the invention at least has the following beneficial effects: the method comprises the steps of obtaining depolarization voltage values after ADC values collected by the ADC, obtaining effective smooth voltage values after a plurality of continuous depolarization voltage values, and finally determining the battery electric quantity according to the smooth voltage values, so that accurate and stable smooth voltage values are obtained through the plurality of continuous depolarization voltage values after ADC sampling, and then the accurate battery electric quantity is calculated.
According to still further embodiments of the battery charge amount calculation method of the present invention, the determining the battery charge amount according to the smoothed voltage value includes:
acquiring the charging state of a battery;
determining a charge compensation voltage value according to the charging state and the smooth voltage value;
and determining the battery electric quantity according to the charging compensation voltage value and a preset battery electric quantity database.
According to still further embodiments of the present invention, the determining a charge compensation voltage value according to the state of charge and the smoothed voltage value includes:
if the charging state is the external power, determining a charging voltage difference compensation value according to the smooth voltage value, and determining the charging compensation voltage value according to the difference value of the smooth voltage value and the charging voltage difference compensation value;
and if the charging state is no external power, the smooth voltage value is the charging compensation voltage value.
According to still further embodiments of the battery charge amount calculation method of the present invention, the determining the battery charge amount according to the smoothed voltage value includes:
determining a correction voltage value according to the smooth voltage value and the discharge compensation value;
and determining the battery capacity according to the corrected voltage value.
According to still further embodiments of the present invention, the determining a correction voltage value according to the smoothed voltage value and the discharge compensation value includes:
if the smooth voltage value is smaller than the correction voltage value with the latest generation time in the existing correction voltage values, determining a discharge compensation value according to the smooth voltage value, and obtaining the correction voltage value according to the discharge compensation value and the smooth voltage value;
and if the smooth voltage value is larger than or equal to the correction voltage value with the latest generation time in the existing correction voltage values, the correction voltage value is the smooth voltage value.
According to another embodiment of the present invention, the method for calculating battery power, wherein the continuously obtaining a plurality of ADC values and obtaining a depolarization voltage value according to the plurality of ADC values includes:
obtaining a plurality of said ADC values;
sorting the plurality of ADC values and removing the largest and smallest ADC values;
and calculating the average value of the plurality of removed ADC values to obtain a depolarization voltage value.
According to another embodiment of the present invention, the method for calculating battery power, wherein obtaining an effective smoothed voltage value according to a plurality of successive depolarization voltage values includes:
and carrying out average calculation on a plurality of continuous depolarization voltage values to obtain the smooth voltage value.
According to another embodiment of the present invention, the method for calculating battery power, wherein the obtaining of the effective smoothed voltage value according to a plurality of successive depolarization voltage values further includes:
and if the difference value between the smooth voltage value and the depolarization voltage value with the latest generation time in the continuous depolarization voltage values is within a preset difference value range, the smooth voltage value is an effective smooth voltage value.
In a second aspect, an embodiment of the present invention provides an electronic device including: a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor when executing the program implementing:
the battery power calculation method according to the first aspect.
In a third aspect, an embodiment of the present invention provides a computer-readable storage medium storing computer-executable instructions for causing a computer to perform the battery level calculation method according to the first aspect.
Additional features and advantages of the application will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the application. The objectives and other advantages of the application may be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Drawings
FIG. 1 is a flow chart illustrating a method for calculating battery power according to an embodiment of the present invention;
FIG. 2 is a flow chart illustrating a method for calculating battery power according to another embodiment of the present invention;
FIG. 3 is a flow chart illustrating a method for calculating battery power according to another embodiment of the present invention;
FIG. 4 is a flow chart illustrating a method for calculating battery power according to another embodiment of the present invention;
FIG. 5 is a flow chart illustrating a method for calculating battery power according to another embodiment of the present invention;
FIG. 6 is a flow chart illustrating a method for calculating battery power according to another embodiment of the present invention;
FIG. 7 is a flow chart illustrating a method for calculating battery power according to another embodiment of the present invention;
FIG. 8 is a flow chart illustrating a method for calculating battery power according to another embodiment of the present invention;
fig. 9 is a block diagram of an embodiment of an electronic device according to the invention.
Detailed Description
The concept and technical effects of the present invention will be clearly and completely described below in conjunction with the embodiments to fully understand the objects, features and effects of the present invention. It is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all embodiments, and those skilled in the art can obtain other embodiments without inventive effort based on the embodiments of the present invention, and all embodiments are within the protection scope of the present invention.
In the description of the present invention, if an orientation description is referred to, for example, the orientations or positional relationships indicated by "upper", "lower", "front", "rear", "left", "right", etc. are based on the orientations or positional relationships shown in the drawings, only for convenience of describing the present invention and simplifying the description, but not for indicating or implying that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and thus should not be construed as limiting the present invention. If a feature is referred to as being "disposed," "secured," "connected," or "mounted" to another feature, it can be directly disposed, secured, or connected to the other feature or indirectly disposed, secured, connected, or mounted to the other feature.
In the description of the embodiments of the present invention, if "a number" is referred to, it means one or more, if "a plurality" is referred to, it means two or more, if "greater than", "less than" or "more than" is referred to, it is understood that the number is not included, and if "greater than", "lower" or "inner" is referred to, it is understood that the number is included. If reference is made to "first" or "second", this should be understood to distinguish between features and not to indicate or imply relative importance or to implicitly indicate the number of indicated features or to implicitly indicate the precedence of the indicated features.
In battery electric quantity management, two common methods are mainly used, one is to adopt a professional high-performance electric quantity meter chip to automatically and accurately count the battery electric quantity. And the other method is to adopt a mode of collecting the battery voltage by the ADC and roughly calculate the electric quantity according to the battery voltage value.
For the POS, since the POS market is competitive, the price of the POS is continuously going low to seize the market, and therefore the hardware devices of the POS need to be continuously optimized. To ensure that product costs are minimized, only the ADC can be used to read the voltage value. After the ADC collects the voltage value, the MCU converts the collected voltage value, but the voltage value read by the ADC is unstable due to the reference voltage jitter of the ADC, the consistency of hardware resistance, environmental electromagnetic interference and the like, so that the accuracy of battery electric quantity calculation is reduced.
Based on this, the application discloses a battery capacity calculation method, an electronic device and a storage medium, which can process the voltage value acquired by the ADC to obtain an accurate voltage value, thereby improving the accuracy of battery capacity calculation.
Referring to fig. 1, in a first aspect, an embodiment of the present invention discloses a battery power calculation method, including:
s100, continuously acquiring a plurality of ADC values, and acquiring depolarization voltage values according to the plurality of ADC values;
s200, obtaining an effective smooth voltage value according to a plurality of continuous depolarization voltage values;
and S300, determining the battery capacity according to the smooth voltage value.
Wherein, steps S100 to S300 are executed according to a preset execution time interval to update the battery power in real time. The continuous acquisition of the plurality of ADC values may be continuously acquiring the plurality of ADC values within a preset time, or continuously acquiring the ADC values according to preset acquisition times of the ADC values. If a plurality of ADC values are continuously obtained according to the preset time, assuming that the preset time is 1 second and the time required for obtaining each ADC value is 0.1 second, 10 ADC values are continuously obtained within 1 second. If the ADC values are obtained according to the preset obtaining times, assuming that the preset obtaining times are 10 times, 10 ADC values are continuously obtained. The depolarization voltage values are obtained according to the plurality of ADC values, effective smooth voltage values are determined according to the plurality of continuously obtained depolarization voltage values, and the battery electric quantity is determined according to the smooth voltage values, so that the influences of ADC reference voltage value jitter, hardware resistance consistency, environmental electromagnetic interference and the like can be reduced by determining the depolarization voltage values through the plurality of continuously obtained voltage values, more accurate smooth voltage values can be obtained, and the calculated battery electric quantity is more accurate.
Obtaining an effective smooth voltage value according to a plurality of continuous depolarization voltage values, calculating to obtain an effective smooth voltage, judging the effective smooth voltage, wherein the smooth voltage meeting the judgment condition is an effective smooth voltage, and if the judgment condition is not met, the smooth voltage is an invalid smooth voltage. Referring to fig. 2, in some embodiments, step S100 includes:
s110, acquiring a plurality of ADC values;
s120, sequencing the ADC values, and removing the largest ADC value and the smallest ADC value;
and S130, calculating the average value of the plurality of removed ADC values to obtain a depolarization voltage value.
The plurality of ADC values are obtained according to preset reading times, the plurality of ADC values are obtained according to the preset reading times, then the plurality of ADC values are sequenced, and particularly the plurality of ADC values are sequenced by a Hill sequencing method. After the ADC values are sequenced, the largest and smallest ADC values can be found out through a Hill sequencing method, then the largest and smallest ADC values are removed, and the rest multiple ADC values are subjected to average calculation to obtain a depolarization voltage value. Because ADC reference voltage jitter, hardware resistance uniformity, environmental electromagnetic interference and the like cause that the ADC reading value is unstable, the minimum and maximum ADC values are taken out to be removed after a plurality of ADC values are obtained, then the average value is calculated to obtain more accurate and stable depolarization voltage values, and further the calculated battery electric quantity is more accurate.
For example, the preset number of readings is 16 seconds, the ADC values are continuously read 16 times to obtain 16 ADC values, then the 16 ADC values are sorted according to the hill sorting method, then the largest and smallest ADC values among the 16 ADC values are removed, and then the remaining 14 ADC values are averaged, that is, the sum of the 14 ADC values is divided by 14 to obtain the depolarization voltage value. By removing the maximum and minimum ADC values, ADC values that have a greater impact on the overall voltage average digital value are filtered out, so that the calculated depolarization voltage value is more accurate.
If the ADC values obtained in 16 consecutive times are 3.5V, 4.0V, 3.6V, 4.2V, 3.7V, 3.8V, 4.0V, 4.1V, 3.9V, 4.5V, 3.7V, 3.9V, 4.2V, 4.1V, 4.0V, 4.3V, then the minimum value of 3.5V and the maximum value of 4.5V out of the 16 ADC values are removed, the remaining 4.0V, 3.6V, 4.2V, 3.7V, 3.8V, 4.0V, 4.1V, 3.9V, 3.7V, 3.9V, 4.2V, 4.1V, 4.0V, 4.3V are added to obtain 55.5, and 55.5 is divided by 14 to approximately equal to 3.96V, thus 3.96V is taken as the voltage value. Referring to fig. 3, in some embodiments, step S200 includes:
and S210, calculating the average value of a plurality of continuous depolarization voltage values to obtain a smooth voltage value.
After the depolarization voltage value is obtained through calculation, the average value of the depolarization voltage values is further calculated to obtain a smooth voltage value, and the instability caused by direct reading of the ADC value is further eliminated, so that the calculation of the battery capacity is more accurate.
And determining the number of specific storage depolarization voltage values through the preset storage times. Therefore, a plurality of depolarization voltage values are obtained and stored according to the preset storage times, and the depolarization voltage values stored for many times are averaged to obtain a smooth voltage value. And the preset storage times can be set according to the requirements of users.
For example, in the present embodiment, the preset number of times of reading is 16, and 16 ADC values are continuously read for 1 second and then the 16 ADC values are subjected to average value calculation and conversion to obtain the depolarization voltage value. In the embodiment, the storage times are preset to be 4 times, that is, 1 depolarization voltage value is obtained by calculation after 16 ADC values are continuously obtained in 1 second, then 4 depolarization voltage values obtained by calculation for the previous 4 times in the current time are obtained, and if the current preset time is T, the depolarization voltage values at T, T-1, T-2, and T-3 moments are obtained. And calculating the average value of the 4 depolarization voltage values to obtain a smooth voltage value. In conclusion, a more accurate smooth voltage value is calculated to obtain more accurate battery electric quantity.
Assume that at 12: a depolarization voltage value of 3.96V was calculated at 00 hours, and 11: 59. 11: 58. 11: 57 calculate the depolarization voltage values to be 3.92V, 3.95V, 4V, so 12: the smooth voltage value at the time 00 is (3.96+3.92+3.95+4)/4 ≈ 3.96, so that the smooth voltage value obtained by averaging the depolarization voltage value calculated at the current time and the depolarization voltage values at the previous three times is more accurate.
Referring to fig. 3, in some embodiments, step S200 further comprises:
and S220, if the difference value between the smooth voltage value and the depolarization voltage value with the latest generation time in the continuous depolarization voltage values is within a preset difference value range, the smooth voltage value is an effective smooth voltage value.
After the smooth voltage value is obtained, it is necessary to determine whether the smooth voltage value calculated at the current time is stable, and then a difference value calculation is performed with the depolarization voltage value with the latest generation time among the plurality of continuous depolarization voltage values. And then calculating whether the difference value between the depolarization voltage value and the smooth voltage value with the latest generation time is within a preset difference value range, if the difference value between the depolarization voltage value and the smooth voltage value is within the preset difference value range, the difference value between the depolarization voltage values is proved to be unobvious, the acquired depolarization voltage value is relatively stable, and the smooth voltage value obtained by current calculation is stable, so that the battery electric quantity is more accurately obtained. If the difference value between the smooth voltage value and the depolarization voltage value with the latest generation time in the continuous depolarization voltage values is not within the preset difference value range, it is proved that the smooth voltage value calculated at the current moment is unstable, and the difference value between the depolarization voltage values is obvious, so that the smooth voltage value calculated at the current moment needs to be discarded, the smooth voltage value is calculated again according to the depolarization voltage values, the obtained smooth voltage value is accurate and stable, and the calculated battery electric quantity is more accurate.
In this embodiment, the predetermined difference range is from-20 mV to 20mV, and if the difference between the depolarization voltage value and the smoothing voltage value at the latest generation time is within-20 mV to 20mV, the data is considered to be stable. And if the difference value between the depolarization voltage value with the latest generation time and the smooth voltage value is not between-20 mV and 20mV, the smooth voltage value is considered to be not advisable, and the smooth voltage value needs to be discarded. Whether the difference value between the depolarization voltage value and the smooth voltage value with the latest generation time is within a preset difference value range is judged, and then the unstable smooth voltage value is filtered out to obtain an accurate smooth voltage value, so that the battery electric quantity obtained through calculation is more accurate.
Referring to fig. 4, in some embodiments, step S300 includes:
s310, acquiring the charging state of the battery;
s320, determining a charging compensation voltage value according to the charging state and the smooth voltage value;
and S330, determining the battery electric quantity according to the charging compensation voltage value and a preset battery electric quantity database.
The battery is generally powered by the USB, the USB is powered by 5V voltage, 4.2V is output under the condition of no load after the charging IC passes through, and the battery voltage is generally between 2.5V and 4.2V, so the voltage difference between the output voltage of the charging IC and the actual voltage of the battery influences, and the lower the voltage of the battery, the larger the error of the read ADC voltage value. Therefore, the charging state of the battery is obtained, the charging compensation voltage value is determined according to the charging state of the battery and the smooth voltage value, and finally the battery capacity is determined according to the charging compensation voltage value, so that the smooth voltage value is further optimized to obtain the charging compensation voltage value, and the battery capacity can be accurately calculated in the charging process. The charging state acquisition is realized by monitoring a charging indication pin of the charging IC, if the charging indication pin is at a high level, the battery is in a charging stop state, if the charging indication pin is at a low level, the battery is in a charging state, and the charging state is determined by monitoring the level of the charging indication pin, so that the charging state acquisition is simple and easy.
Referring to fig. 5, in some embodiments, step S320 includes:
s321, if the charging state is the external power, determining a charging voltage difference compensation value according to the smooth voltage value, and determining a charging compensation voltage value according to the difference value of the smooth voltage value and the charging voltage difference compensation value;
and S322, if the charging state is no external power, the smooth voltage value is the charging compensation voltage value.
If the charging state is external power, the charging state is influenced by the potential difference between the output voltage of the charging IC and the actual voltage of the battery, and the acquired ADC value has an error, so that a charging voltage difference compensation value needs to be determined according to the smooth voltage value, and then a charging compensation voltage value is determined according to the difference between the smooth voltage value and the charging voltage difference compensation value, so that more accurate battery electric quantity is calculated according to the charging compensation voltage value. If the charging state is no external power, the acquired ADC value is proved not to be influenced by the potential difference existing between the output voltage of the charging IC and the actual voltage of the battery, and therefore the electric quantity of the battery can be accurately calculated by taking the smooth voltage value as the charging compensation voltage value.
Specifically, the charging voltage difference compensation value is obtained according to the smoothed voltage value, and the charging voltage difference compensation value is obtained by substituting the smoothed voltage value into formula (1), where formula (1) is:
Vx=Vd-((Vcmp-2500)/25) (1)
where Vx is the charging differential voltage compensation value, Vcmp is the smoothing voltage value, and Vd is a constant, where the actual condition of the battery is determined in a constant configuration. For example, if the smoothing voltage value is 4200mV and the constant is 90, the charging voltage difference compensation value Vd becomes 90- ((4200) -2500)/25) 22mV, and the current charging voltage difference compensation value is 22 mV. Since the value of the smoothed voltage value changes according to the change of the depolarization voltage value, and the value of the smoothed voltage value changes when the depolarization voltage value changes, the charge voltage difference compensation value also changes from moment to moment.
The charging voltage difference compensation value is calculated through the formula (1), the charging state of the battery is obtained specifically by obtaining the charging state of the charging IC, and if the charging state is external power, that is, the battery is being charged, there is an error in directly obtaining the battery power according to the smooth voltage value, so that the influence of the external power on the battery power needs to be considered. Because the ADC value acquired by the ADC is directly passed by the battery in the charging process, an error exists, and therefore the optimized smooth voltage value is obtained according to the difference value of the smooth voltage value and the charging voltage difference compensation value, and the charging compensation voltage value is obtained. The calculation formula of the charge compensation voltage value is as follows:
Vadj=Vcmp-Vx (2)
in the formula, Vadj is a charging compensation voltage value, Vcmp is a smoothing voltage value, and Vx is a charging differential voltage compensation value.
If the charging state is external power, an accurate charging compensation voltage value is calculated through the difference value of the smooth voltage value and the charging voltage difference compensation value, and therefore the electric quantity of the battery is calculated more accurately. If the charging state is no external power, the battery is not charged externally, and the smooth voltage value is used as the charging compensation voltage value. Therefore, the current voltage value is re-determined by detecting whether there is an influence of external power to obtain the charge compensation voltage value, and thus the calculated charge compensation voltage value is stable and accurate.
If the smooth voltage value calculated in the current time is 4.2V, then a charging indication pin of the charging IC is monitored, if the charging indication pin is at a high level, the charging state is no external power, and the charging compensation voltage value is 4.2V. If the charging indication pin is monitored to be at a low level, which indicates that the charging state is external power, the charging voltage difference compensation value is calculated according to the formula (1) to be 22mV, the difference value between the smooth voltage value of the charging compensation voltage value and the charging voltage difference compensation value is 4.178V, and the charging compensation voltage value at the current time is 4.178V. And judging whether the smooth voltage value calculated at the current time has an error or not through the charging state, and calculating to obtain a correct voltage value in the charging state according to the charging voltage difference compensation value and the smooth voltage value, so that the voltage value calculation at the current time of the voltage is more accurate.
Referring to fig. 6, in some embodiments, step S300 includes:
s330, determining a correction voltage value according to the smooth voltage value and the charging compensation value;
and S340, determining the battery capacity according to the corrected voltage value.
When starting a function with large power consumption, the application device may cause a large current change, and the battery has an internal resistance, that is, the output voltage Vout ═ Vbat- (I x Rbat), that is, the voltage across the battery when obtaining the ADC value may have a large jump, so that the obtained ADC value may have an error. Based on the above, the correction voltage value is determined through the smooth voltage value and the charging compensation voltage value to judge whether the calculation of the battery electric quantity is influenced, and the battery electric quantity is more accurately calculated according to the correction voltage value.
Referring to fig. 7, in some embodiments, step S330 includes:
s331, if the smooth voltage value is smaller than the correction voltage value with the latest generation time in the existing correction voltage values, determining a discharge compensation value according to the smooth voltage value, and determining a correction voltage value according to the discharge compensation value and the smooth voltage value;
and S332, if the smooth voltage value is larger than or equal to the correction voltage value with the latest generation time in the existing correction voltage values, the correction voltage value is the smooth voltage value.
The existing correction voltage value is initially defaulted to 0, and is updated to the last obtained correction voltage value through the large-current discharge virtualization treatment. Therefore, the smooth voltage value is received each time and is compared with the corrected voltage value with the latest generation time to judge whether the battery has the phenomenon of large-current discharge, and then the accurate corrected voltage value is calculated.
If the smooth voltage value is smaller than the correction voltage value with the latest generation time in the existing correction voltage values, the function with large power consumption of the application equipment is used, so the voltage drop speed is high, and the error exists when the battery electric quantity is directly calculated by the smooth voltage value. Therefore, the discharge compensation value is determined according to the smooth voltage value, and the correction voltage value is determined according to the discharge compensation value and the smooth voltage value, so that the voltage value of the battery at the current moment is more accurate, and the calculated battery electric quantity is more accurate.
Referring to fig. 8, in some embodiments, step S330 further includes:
s331', if the charging compensation voltage value is smaller than the correction voltage value with the latest generation time in the existing correction voltage values, determining a discharging compensation value according to the smooth voltage value, and obtaining the correction voltage value according to the discharging compensation value and the charging compensation voltage value;
s332', if the charging compensation voltage value is larger than or equal to the correction voltage value with the latest generation time in the existing correction voltage values, the correction voltage value is the charging compensation voltage value.
When the battery is charged and the charging compensation voltage value is smaller than the correction voltage value with the latest generation time in the existing correction voltage values, the application equipment simultaneously uses the function with high power consumption, so the voltage drop speed is high, and the error exists when the battery electric quantity is directly calculated by the charging compensation voltage value. Therefore, the discharge compensation value is determined according to the smooth voltage value, and the correction voltage value is determined according to the discharge compensation value and the charge compensation voltage value, so that the voltage value of the battery at the current moment is more accurate, and the calculated battery electric quantity is more accurate.
Specifically, if the smoothed voltage value is greater than 4.1V, the discharge compensation value is 3 mV; if the smooth voltage value is in the range of 3.66V-4.1V, the discharge compensation value is 2 mV; if the smooth voltage value is in the range of 3.52V-3.66V, the discharge step value is 1 mV; if the smooth voltage value is less than 3.52V, the discharge compensation value is 3 mV. If the charging compensation voltage value is compared with the correction voltage value with the latest generation time in the existing correction voltage values, and if the charging compensation voltage value is smaller than the correction voltage value with the latest generation time in the existing correction voltage values, the condition that the battery has large-current discharging is proved, the correction voltage value is determined according to the difference value of the charging compensation voltage value and the discharging compensation value, and the correction voltage value is also the voltage value of the battery under the condition that the large-current discharging exists. In conclusion, the voltage value of the battery is more accurately obtained through calculation, the battery electric quantity is determined through correcting the voltage value, and the obtained battery electric quantity is more accurate.
And if the charging compensation voltage value is larger than or equal to the correction voltage value with the latest generation time in the existing correction voltage values, and the battery is not considered to have the large-current discharging phenomenon, the correction voltage value is the charging compensation voltage value. The charging compensation voltage value is compared with the correction voltage value with the latest generation time in the existing correction voltage values to judge whether the battery has a large-current discharging phenomenon, and if not, the charging compensation voltage value is used as the final voltage value, so that the voltage value of the battery is accurately calculated.
For example: if the charging compensation voltage value is 4.178V and the corrected voltage value with the latest generation time is 4.2, the corrected voltage value is smaller than the corrected voltage value with the latest generation time, and the battery is considered to have the large-current discharging phenomenon. Then, when 4.178V is greater than 4.1V, the discharge compensation value is 3mV, and the correction voltage value is the difference between the charge compensation voltage value and the discharge compensation value, and the correction voltage value is calculated to be 4.175. The correction voltage value is determined according to the difference value of the charging compensation voltage value and the discharging compensation value when the battery is detected to have large-current discharging, so that the accurate value of the voltage value of the battery at the current time is improved.
In some embodiments, the battery level calculation method further includes:
and S400, determining the electric quantity percentage of the battery according to the battery voltage.
If the battery is not influenced by the potential difference between the output voltage value of the charging IC and the actual voltage of the battery and the large-current discharging phenomenon does not exist, calculating the electric quantity of the battery according to the smooth voltage value, and finally determining the electric quantity percentage according to the electric quantity of the battery. If the battery is influenced by the potential difference between the output voltage value of the charging IC and the actual voltage of the battery and the large-current discharging phenomenon does not exist, calculating the electric quantity of the battery according to the charging compensation voltage value, and calculating the electric quantity percentage of the battery according to the electric quantity of the battery. If the battery is influenced by the potential difference between the output voltage value of the charging IC and the actual voltage of the battery and a large-current discharging phenomenon exists, the electric quantity of the battery is calculated according to the calculated correction voltage value, and then the electric quantity percentage of the battery is calculated according to the electric quantity of the battery, so that the calculated electric quantity percentage is stable and accurate.
The method for calculating the battery charge level according to the embodiment of the present invention is described in detail in one specific embodiment with reference to fig. 1 to 8. It is to be understood that the following description is only exemplary, and not a specific limitation of the invention.
16 ADC values acquired by the ADCs are acquired for 16 times continuously, then the 16 ADC values are subjected to Hill sorting to sort the 16 ADC values, then the largest and smallest ADC values are removed to obtain 14 ADC values, and then the rest 14 ADC values are subjected to average value calculation to obtain a depolarization voltage value. The smooth voltage value is obtained by performing an average value calculation with the depolarization voltage values acquired the last 4 times, and then the difference between the depolarization voltage value acquired the last time and the smooth voltage value among the depolarization voltage values acquired the 4 times is calculated. If the difference value is within the preset difference value range, the calculated smooth voltage value is proved to be stable, and the battery electric quantity is determined according to the smooth voltage value. If the difference value between the depolarization voltage value and the smooth voltage value acquired last time is not within the preset difference value range, the calculated smooth voltage value is proved to be unstable, and the smooth voltage value is rejected so as to recalculate the smooth voltage value until the difference value between the depolarization voltage value and the smooth voltage value acquired last time is within the preset difference value range, and the battery electric quantity is determined according to the smooth voltage value. If the charging state is external electricity, the difference value between the smooth voltage value and the charging voltage difference compensation value is used as the charging compensation voltage value, and if the charging state is no external electricity, the smooth voltage value is used as the charging compensation voltage value. The charging compensation voltage value is determined by judging whether the external power exists or not, so that the condition that the battery electric quantity is directly calculated according to the smooth voltage value under the condition that the external power exists is prevented, and the calculated battery electric quantity is inaccurate. By re-determining the charge compensation voltage value according to the charging state, the calculated battery power is more accurate. And determining the correction voltage value according to the difference between the discharge compensation value and the charge compensation voltage value when the charge compensation voltage value is smaller than the correction voltage value with the latest generation time in the existing correction voltage values. And if the charging compensation voltage value is larger than or equal to the correction voltage value with the latest generation time in the existing correction voltage values, the charging compensation voltage value is the correction voltage value. And finally, determining the electric quantity of the battery according to the corrected voltage value, and determining the current electric quantity percentage according to the electric quantity of the battery.
In a second aspect, referring to fig. 9, an embodiment of the present invention further discloses an electronic device, including: a memory 200, a processor 100 and a computer program stored on the memory 200 and executable on the processor 100, the processor 100 when executing the program implementing: such as the card-transfer slice switching method of the first aspect.
The electronic device may be a mobile terminal device or a non-mobile terminal device. The mobile terminal equipment can be a mobile phone, a tablet computer, a notebook computer, a palm computer, vehicle-mounted terminal equipment, wearable equipment, a super mobile personal computer, a netbook, a personal digital assistant, CPE, UFI (wireless hotspot equipment) and the like; the non-mobile terminal equipment can be a personal computer, a television, a teller machine or a self-service machine and the like; the embodiments of the present invention are not particularly limited.
The memory 200 may be an external memory or an internal memory, and the external memory is an external memory card, such as a MicroSD card. The external memory card communicates with the processor through the external memory interface to realize the data storage function. For example, files such as music, video, etc. are saved in an external memory card. The internal memory may be used to store computer-executable program code, which includes instructions.
Processor 100 may include one or more processing units, such as: the processor 100 may include an Application Processor (AP), a modem processor, a Graphics Processing Unit (GPU), an Image Signal Processor (ISP), a controller, a video codec, a Digital Signal Processor (DSP), a baseband processor, and/or a neural-Network Processing Unit (NPU), etc. The different processing units may be separate devices or may be integrated into one or more processors.
In a third aspect, an embodiment of the present invention further discloses a computer-readable storage medium, where computer-executable instructions are stored, and the computer-executable instructions are configured to enable a computer to execute the method for calculating battery power according to the first aspect.
The computer-executable instructions are used for causing a computer to execute the battery level calculation method according to the first aspect, so that the battery level calculation method is easy to implement.
The above-described embodiments of the apparatus are merely illustrative, wherein the units illustrated as separate components may or may not be physically separate, i.e. may be located in one place, or may also be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
One of ordinary skill in the art will appreciate that all or some of the steps, systems, and methods disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on computer readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media). The term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data, as is well known to those of ordinary skill in the art. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, Digital Versatile Disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can accessed by a computer. In addition, communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media as known to those skilled in the art.
The embodiments of the present invention have been described in detail with reference to the accompanying drawings, but the present invention is not limited to the above embodiments, and various changes can be made within the knowledge of those skilled in the art without departing from the gist of the present invention. Furthermore, the embodiments of the present invention and the features of the embodiments may be combined with each other without conflict.

Claims (10)

1. The battery power calculation method is characterized by comprising the following steps:
continuously acquiring a plurality of ADC values, and acquiring depolarization voltage values according to the plurality of ADC values;
obtaining an effective smooth voltage value according to a plurality of continuous depolarization voltage values;
and determining the battery capacity according to the smooth voltage value.
2. The battery level calculation method of claim 1, wherein the determining the battery level according to the smoothed voltage value comprises:
acquiring the charging state of a battery;
determining a charge compensation voltage value according to the charging state and the smooth voltage value;
and determining the battery electric quantity according to the charging compensation voltage value and a preset battery electric quantity database.
3. The battery level calculation method of claim 2, wherein determining a charge compensation voltage value based on the state of charge and the smoothed voltage value comprises:
if the charging state is the external power, determining a charging voltage difference compensation value according to the smooth voltage value, and determining the charging compensation voltage value according to the difference value of the smooth voltage value and the charging voltage difference compensation value;
and if the charging state is no external power, the smooth voltage value is the charging compensation voltage value.
4. The battery level calculation method of claim 1, wherein the determining the battery level according to the smoothed voltage value comprises:
determining a correction voltage value according to the smooth voltage value and the discharge compensation value;
and determining the battery capacity according to the corrected voltage value.
5. The battery power level calculation method of claim 4, wherein determining a correction voltage value according to the smoothed voltage value and the discharge compensation value comprises:
if the smooth voltage value is smaller than the correction voltage value with the latest generation time in the existing correction voltage values, determining a discharge compensation value according to the smooth voltage value, and obtaining the correction voltage value according to the discharge compensation value and the smooth voltage value;
and if the smooth voltage value is larger than or equal to the correction voltage value with the latest generation time in the existing correction voltage values, the correction voltage value is the smooth voltage value.
6. The method of claim 1, wherein the continuously obtaining a plurality of ADC values and obtaining a depolarization voltage value according to the plurality of ADC values comprises:
obtaining a plurality of said ADC values;
sorting the plurality of ADC values and removing the largest and smallest ADC values;
and calculating the average value of the plurality of removed ADC values to obtain a depolarization voltage value.
7. The method according to claim 1, wherein the obtaining an effective smoothed voltage value according to a plurality of successive depolarization voltage values comprises:
and carrying out average calculation on a plurality of continuous depolarization voltage values to obtain the smooth voltage value.
8. The method of calculating battery power according to claim 7, wherein the obtaining an effective smoothed voltage value from a plurality of successive depolarization voltage values further comprises:
and if the difference value between the smooth voltage value and the depolarization voltage value with the latest generation time in the continuous depolarization voltage values is within a preset difference value range, the smooth voltage value is an effective smooth voltage value.
9. An electronic device, comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor when executing the program implementing:
the battery charge level calculation method according to any one of claims 1 to 8.
10. A computer-readable storage medium storing computer-executable instructions for causing a computer to perform the battery level calculation method according to any one of claims 1 to 8.
CN202011416816.4A 2020-12-07 2020-12-07 Battery electric quantity calculation method, electronic device and storage medium Pending CN112782596A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011416816.4A CN112782596A (en) 2020-12-07 2020-12-07 Battery electric quantity calculation method, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011416816.4A CN112782596A (en) 2020-12-07 2020-12-07 Battery electric quantity calculation method, electronic device and storage medium

Publications (1)

Publication Number Publication Date
CN112782596A true CN112782596A (en) 2021-05-11

Family

ID=75750735

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011416816.4A Pending CN112782596A (en) 2020-12-07 2020-12-07 Battery electric quantity calculation method, electronic device and storage medium

Country Status (1)

Country Link
CN (1) CN112782596A (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101728588A (en) * 2008-10-10 2010-06-09 鸿富锦精密工业(深圳)有限公司 Wireless communication terminal and method for determining battery electric quantity thereof
CN103685706A (en) * 2012-09-21 2014-03-26 中兴通讯股份有限公司 Method for correcting electric quantity of mobile terminal and mobile terminal
US20170195067A1 (en) * 2015-12-30 2017-07-06 Le Holdings (Beijing) Co., Ltd. Method and electronic device for measuring battery capacity of mobile communication terminal equipment
CN107561548A (en) * 2017-04-24 2018-01-09 西安应用光学研究所 A kind of laser ranging data filtering method that system of taking aim at is seen for airborne photoelectric
CN108303651A (en) * 2017-12-19 2018-07-20 福建联迪商用设备有限公司 A kind of measurement method and terminal of battery capacity
CN109270467A (en) * 2017-07-18 2019-01-25 美的智慧家居科技有限公司 The battery electricity detection method and device of equipment
WO2020087373A1 (en) * 2018-10-31 2020-05-07 华为技术有限公司 Compensation method and apparatus for battery voltage, and terminal device
CN111142028A (en) * 2020-02-20 2020-05-12 广东天波信息技术股份有限公司 Method and device for measuring electric quantity of lithium battery
CN111399000A (en) * 2020-04-08 2020-07-10 广州通达汽车电气股份有限公司 GPS drift filtering method, state switching method of GPS terminal and switching equipment
CN111740464A (en) * 2020-07-03 2020-10-02 歌尔科技有限公司 Battery power compensation method, device, equipment and readable storage medium

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101728588A (en) * 2008-10-10 2010-06-09 鸿富锦精密工业(深圳)有限公司 Wireless communication terminal and method for determining battery electric quantity thereof
CN103685706A (en) * 2012-09-21 2014-03-26 中兴通讯股份有限公司 Method for correcting electric quantity of mobile terminal and mobile terminal
US20170195067A1 (en) * 2015-12-30 2017-07-06 Le Holdings (Beijing) Co., Ltd. Method and electronic device for measuring battery capacity of mobile communication terminal equipment
CN107561548A (en) * 2017-04-24 2018-01-09 西安应用光学研究所 A kind of laser ranging data filtering method that system of taking aim at is seen for airborne photoelectric
CN109270467A (en) * 2017-07-18 2019-01-25 美的智慧家居科技有限公司 The battery electricity detection method and device of equipment
CN108303651A (en) * 2017-12-19 2018-07-20 福建联迪商用设备有限公司 A kind of measurement method and terminal of battery capacity
WO2020087373A1 (en) * 2018-10-31 2020-05-07 华为技术有限公司 Compensation method and apparatus for battery voltage, and terminal device
CN111142028A (en) * 2020-02-20 2020-05-12 广东天波信息技术股份有限公司 Method and device for measuring electric quantity of lithium battery
CN111399000A (en) * 2020-04-08 2020-07-10 广州通达汽车电气股份有限公司 GPS drift filtering method, state switching method of GPS terminal and switching equipment
CN111740464A (en) * 2020-07-03 2020-10-02 歌尔科技有限公司 Battery power compensation method, device, equipment and readable storage medium

Similar Documents

Publication Publication Date Title
CN108646190B (en) Method, device and equipment for estimating residual charging time of battery
JP5541112B2 (en) Battery monitoring device and battery monitoring method
WO2019144646A1 (en) Battery power-level status estimation method, apparatus, and electronic device
WO2018196121A1 (en) Method and device for use in determining internal short circuit of battery
US10845417B2 (en) Battery state estimation device, battery control device, battery system, battery state estimation method
EP2851700B1 (en) Method and terminal for displaying capacity of battery
US20100072948A1 (en) Characteristic tracking method and circuit for a battery module
CN109466372B (en) Charging remaining time calculation method and device and storage medium
JP2002528850A (en) Battery pack having charge status indicator
EP2664938B1 (en) Open circuit voltage estimation device, condition estimation device, and method of estimating open circuit voltage
JP2014025738A (en) Residual capacity estimation device
CN110888065B (en) Battery pack state of charge correction method and device
CN110658466A (en) Method for calculating residual capacity of storage battery
US10578675B2 (en) Estimation method for battery capacity
US20170261561A1 (en) Device and method for computing residual capacity of cell, and recording medium
CN111142032A (en) Method, device and equipment for determining battery electric quantity and storage medium
JP2023101509A (en) Semiconductor device and method for detecting remaining amount of battery
CN112782596A (en) Battery electric quantity calculation method, electronic device and storage medium
KR20160011448A (en) Apparatus and method for calculating full charge capacity information of battery
CN116323288A (en) Method and device for determining display state of charge and battery management chip
CN114460475B (en) Battery OCV determining method and device and battery SOC estimating method
CN106772092B (en) Charging current setting system and method for obtaining battery voltage based on mobile terminal
JPS61209373A (en) Circuit for confirming residual power quantity in battery
JP7434757B2 (en) Charging control method, charging control device, charging device, and charging system
CN113352939A (en) Remaining power determination method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20210511

RJ01 Rejection of invention patent application after publication