Battery electric quantity detection method, electronic equipment and storage medium
By adopting a sliding window-based battery power detection method in low-power video surveillance equipment, the existing battery management methods are solved, and efficient and accurate battery power detection is achieved, which is suitable for the application of low-power video surveillance equipment.
Patent Information
- Application Number
- CN202510479805.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-17
- Publication Date
- 2025-06-06
- Estimated Expiration
- 2045-04-17
AI Technical Summary
Existing battery management methods show high cost and low stability in low power video surveillance equipment, and rely on external battery meter or inaccurate ADC module sampling, affecting the effectiveness of battery management.
The battery power detection method based on the sliding window is adopted, and the original battery voltage value is read through the ADC module, the actual voltage value is calculated, and the charging status and the power supply status of the SOC main control chip are corrected and compensated. The sliding window is updated to calculate the average voltage value and determine the remaining battery power.
This method does not require an external battery meter, which reduces production costs, improves the stability and accuracy of battery power detection, and is suitable for applications of low-power video surveillance equipment.
Smart Images

Figure CN120103186A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of battery technology, and in particular to a battery power detection method based on a sliding window, an electronic device and a computer-readable storage medium. Background Art
[0002] In the low-power video surveillance industry, the performance requirements of battery management systems are increasing. With the widespread application of low-power video surveillance equipment, existing battery management methods have shown obvious shortcomings in terms of stability, accuracy and cost control.
[0003] First, most low-power video surveillance devices rely on a fuel gauge to read the battery voltage and communicate with a microcontroller (MCU) through an I2C interface. The MCU converts the voltage value read through a voltage and power percentage mapping table to calculate the power percentage and send it to the monitoring device to achieve battery power management. However, adding peripheral circuits such as a fuel gauge will significantly increase the production cost of the product and take up valuable hardware space.
[0004] Secondly, if the battery voltage is not read using a fuel gauge, and the battery voltage is sampled only by the ADC module built into the MCU, the battery voltage is easily affected by factors such as load changes and temperature fluctuations, resulting in inaccurate instantaneous voltage sampling values. This inaccuracy will directly affect the effectiveness of the battery management function, and further affect the performance and reliability of the entire low-power video surveillance system.
[0005] Therefore, there is an urgent need to develop more efficient, stable and cost-controlled battery management solutions to meet the stringent requirements of the low-power video surveillance industry for battery management. Summary of the invention
[0006] In view of this, the present invention proposes a battery power detection method based on a sliding window, an electronic device and a computer-readable storage medium, aiming to overcome the shortcomings of existing battery management methods such as high cost and low stability.
[0007] In order to solve the above problems, the present invention adopts the following technical solutions: In a first aspect, the present invention proposes a battery power detection method based on a sliding window, which is applied to an embedded device, wherein the embedded device includes an ADC module, a SOC main control chip, an MCU micro control chip and a battery, and the battery power detection method includes: The ADC module reads the original voltage value of the battery, and calculates the actual voltage value according to the original voltage value and a preset conversion formula; Determine whether the battery is in a charging state according to the actual voltage value, obtain a corrected voltage value according to the determination result, and obtain a compensation value according to the corrected voltage value and the power supply state of the SOC main control chip; Adding the actual voltage value and the compensation value to calculate a compensation voltage value; The sliding window is updated using the compensation voltage value, and an average voltage value of the effective voltage values in the updated sliding window is calculated so as to determine the remaining power of the battery according to the average voltage value; wherein a preset number of voltage values arranged in chronological order are stored in the sliding window.
[0008] Further, the reading of the original voltage value of the battery by the ADC module and calculating the actual voltage value according to the original voltage value and a preset conversion formula include: Turning on the ADC module, reading the original voltage value of the battery through the ADC module, and turning off the ADC module; Substitute the original voltage value into the preset conversion formula to calculate the actual voltage value, and update the current actual voltage value to the calculated actual voltage value; wherein the preset conversion formula is: actual voltage value = (original voltage value × standard operating voltage value of the ADC module) / resolution of the ADC module.
[0009] Further, judging whether the battery is in a charging state according to the actual voltage value, and obtaining a corrected voltage value according to the judgment result, includes: If the actual voltage value is greater than or equal to a preset charger connection threshold, it is determined that the battery is in a charging state; if the actual voltage value is less than the preset charger connection threshold, it is determined that the battery is in an uncharged state; When the battery is in a charging state, disconnecting from the charger and waiting for a preset first time period to re-obtain the actual voltage value, re-establishing the connection with the charger and adding the re-obtained actual voltage value and the preset corrected voltage drop value to calculate a corrected voltage value; When the battery is in an uncharged state, the actual voltage value is obtained and recorded as a corrected voltage value.
[0010] Further, obtaining the compensation value according to the corrected voltage value and the power supply state of the SOC main control chip includes: When it is confirmed that the SOC main control chip is in a powered-on working state, a static compensation value and a dynamic compensation value are obtained, and the static compensation value and the dynamic compensation value are added to calculate a compensation value; wherein the static compensation value=the average voltage value of all valid voltage values in the current sliding window-the corrected voltage value-the dynamic compensation value, and the dynamic compensation value is obtained when the SOC main control chip performs a self-test; When it is confirmed that the SOC main control chip is in a non-working state, the compensation value is set to 0.
[0011] Further, the using the compensation voltage value to update the sliding window and calculating the average voltage value of the effective voltage values in the updated sliding window includes: Inserting the compensation voltage value into the head of the sliding window, discarding the voltage value at the tail of the sliding window, and moving other voltage values in the sliding window backward in sequence to complete the updating of the sliding window; The number of valid voltage values in the updated sliding window is counted, and the average voltage value of all valid voltage values in the updated sliding window is calculated; wherein the average voltage value=the sum of all valid voltage values in the updated sliding window / the number.
[0012] Further, determining the remaining power of the battery according to the average voltage value includes: Compare the average voltage value with a preset voltage capacity table; wherein the preset voltage capacity table includes a voltage value, a power percentage, and a one-to-one correspondence between the voltage value and the power percentage, the power percentage includes 100%, 20%, and 0%, the voltage value corresponding to a power percentage of 100% is recorded as the highest threshold, the voltage value corresponding to a power percentage of 20% is recorded as the middle threshold, and the voltage value corresponding to a power percentage of 0% is recorded as the lowest threshold, and the remaining power of the battery is expressed in the form of power percentage; If the average voltage value is greater than the maximum threshold, the power percentage is 100%; If the average voltage value is less than or equal to the highest threshold value and greater than the middle threshold value, the average voltage value is substituted into a preset linear difference formula to calculate the power percentage corresponding to the average voltage value; wherein the preset linear difference formula is: power percentage = high power percentage − [(high voltage value − average voltage value) / interval voltage value step length] × interval power percentage step length; If the average voltage value is less than or equal to the middle threshold value and greater than or equal to the minimum threshold value, query the power percentage corresponding to the average voltage value in the preset voltage capacity table; If the average voltage value is less than the minimum threshold, the power percentage is 0%.
[0013] Furthermore, before reading the original voltage value of the battery through the ADC module, the method further includes: The MCU microcontroller chip is started, and after entering the sleep state for a preset second time period, a preset number of voltage value samples are taken to obtain the remaining power of the battery; Using the obtained remaining power to update the current remaining power of the battery, and determining whether the remaining power is greater than a preset safety power; If yes, the sliding window is updated using the voltage value corresponding to the remaining power obtained to complete the initialization of the sliding window; If not, the MCU microcontroller chip sleeps for a preset third time period at intervals of a preset period until the remaining power of the battery is greater than the preset safety power.
[0014] Furthermore, the battery power detection method further includes: Determine the working mode of the MCU microcontroller chip; When the MCU microcontroller chip is in a normal working mode, the mode of the SOC main control chip is determined; if the SOC main control chip is in a low power consumption mode, the remaining power of the battery is detected at a preset fourth time interval after the SOC main control chip is powered off; if the SOC main control chip is in a normal power mode, the remaining power of the battery is detected at a preset fourth time interval; When the MCU microcontroller chip is in the factory test mode, the remaining power of the battery is detected at every preset fifth time interval; wherein the preset fifth time interval is less than the preset fourth time interval; When the MCU microcontroller chip is in the system upgrade mode, it is determined whether the remaining power of the battery is greater than a preset power threshold; if so, the system upgrade is performed, otherwise the system upgrade is not started.
[0015] In a second aspect, the present invention further provides an electronic device, wherein the electronic device is an embedded device, and the embedded device comprises: a memory for storing program instructions; and The processor is used to execute the program instructions to implement the steps of the battery power detection method based on the sliding window as described above.
[0016] In a third aspect, the present invention further proposes a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, the steps of the battery power detection method based on a sliding window as described above are implemented.
[0017] Compared with the prior art, the beneficial effects of the present invention are: a battery power detection method based on a sliding window, an electronic device and a computer-readable storage medium, which are applied to an embedded device, wherein the embedded device includes an ADC module, a SOC main control chip, an MCU microcontroller chip and a battery, and the battery power detection method includes: reading the original voltage value of the battery through the ADC module, and calculating the actual voltage value according to the original voltage value and a preset conversion formula; judging whether the battery is in a charging state according to the actual voltage value, and obtaining a corrected voltage value according to the judgment result, and obtaining a compensation value according to the corrected voltage value and the power supply state of the SOC main control chip; adding the actual voltage value and the compensation value to calculate the compensation voltage value; using the compensation voltage value to update the sliding window, and calculating the average voltage value of the effective voltage values in the updated sliding window, so as to determine the remaining power of the battery according to the average voltage value; wherein a preset number of voltage values arranged in chronological order are stored in the sliding window. It can be seen that the battery power detection method, electronic device and computer-readable storage medium based on the sliding window make full use of the ADC module inside the embedded device to sample the battery voltage, without the need for an additional external power meter or other peripheral circuits, thereby significantly reducing the production cost of the product. At the same time, by judging the charging state of the battery and obtaining the corrected voltage value, the influence of the battery on the voltage sampling value when it is in the charging state is effectively eliminated. Combined with the power supply state of the SOC main control chip to calculate the compensation value, the voltage reading deviation caused by the SOC main control chip in the working state can be effectively compensated. In addition, in order to further improve the stability of battery voltage detection, the battery power detection method also adopts a sliding window technology, allowing the battery voltage to be sampled multiple times and the average voltage value to be calculated, thereby effectively smoothing the fluctuation of the instantaneous voltage sampling value and reducing the error caused by load changes and temperature fluctuations. By combining voltage correction, compensation mechanism and sliding window technology, the stability and accuracy of the battery remaining power detection can be ensured, which is very suitable for low-power video surveillance equipment. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings: Figure 1 It is a flowchart of a first embodiment of a battery power detection method based on a sliding window of the present invention; Figure 2 It is a flow chart of a second embodiment of a battery power detection method based on a sliding window of the present invention; Figure 3It is a flowchart diagram of a third embodiment of a battery power detection method based on a sliding window of the present invention; Figure 4 It is a flowchart diagram of a fourth embodiment of a battery power detection method based on a sliding window of the present invention; Figure 5 It is a flowchart diagram of a fifth embodiment of a battery power detection method based on a sliding window of the present invention; Figure 6 It is a schematic diagram of the structure of an electronic device in a hardware operating environment involved in an embodiment of the present invention. DETAILED DESCRIPTION
[0019] The scheme in the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is only a part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0020] It should be noted that if the embodiments of the present invention involve directional indications (such as up, down, left, right, front, back, etc.), the directional indications are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.
[0021] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present invention, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0022] It should be noted that embedded devices are widely used in various fields, among which video surveillance equipment is a typical application scenario. The SOC main control chip (System on Chip) integrates a complete and complex system and supports a variety of complex task processing. This article specifically refers to the video main control chip for security surveillance cameras. The MCU microcontroller unit (Microcontroller Unit) is a microcomputer chip that integrates a processor, memory, and I / O interface, which is specially used for embedded device control. The steps of the battery power detection method mentioned in this article are mainly performed by the MCU. The ADC module (Analog-to-Digital Converter) is used to convert analog signals (such as voltage, temperature, and light intensity) into digital signals for processing by digital systems (such as MCU / SOC). In this article, the ADC module is mainly used to identify the battery charge status and read the supply voltage. I2C (Inter-Integrated Circuit) is a synchronous, half-duplex serial communication protocol mainly used for communication between short-distance devices.
[0023] See also Figure 1 As shown, it is a flow chart of the first embodiment of the battery power detection method based on sliding window of the present invention.
[0024] In this embodiment, the battery power detection method based on the sliding window is applied to an embedded device, wherein the embedded device includes an ADC module, a SOC main control chip, an MCU micro control chip, and a battery. The battery power detection method includes: Step S100: reading the original voltage value of the battery through the ADC module, and calculating the actual voltage value according to the original voltage value and a preset conversion formula.
[0025] Specifically, the preset conversion formula is determined based on the operating characteristics and parameters of the ADC module, which determine the accuracy and range of the conversion of analog signals into digital signals. Since different ADC modules may have different operating characteristics and parameters, the conversion of the read raw voltage value through the preset conversion formula can adapt to the characteristics of various ADC modules, thereby converting the sampled raw voltage value into a more accurate actual voltage value to ensure the accuracy of the detection result.
[0026] Step S200: judging whether the battery is in a charging state according to the actual voltage value, obtaining a corrected voltage value according to the judgment result, and obtaining a compensation value according to the corrected voltage value and the power supply state of the SOC main control chip.
[0027] Specifically, when the battery is in a charging state, the internal chemical reaction will cause the voltage to rise, which may cause the detection result to be biased high, thus affecting the judgment of the actual state of the battery. Therefore, by judging whether the battery is charging and taking different countermeasures based on the judgment result, the actual state of the battery power can be more accurately reflected. At the same time, the different power supply states of the SOC main control chip (such as power-on state or standby state) will also affect the power consumption and voltage requirements of its internal circuits. Under different power supply states, the voltage of the SOC main control chip may change, which will directly affect the sampling size of the ADC module, and then affect the accuracy of the battery voltage. By judging the power supply state of the SOC main control chip, the corresponding compensation measures can be flexibly applied to offset the battery voltage detection error caused by the difference in power supply state.
[0028] Step S300: Add the actual voltage value and the compensation value to calculate a compensation voltage value.
[0029] Specifically, by adding the actual voltage value to the compensation value, a compensation voltage value that is closer to the actual state of the battery can be obtained. This process ensures that the detection result of the battery voltage is more reliable under different detection environments.
[0030] Step S400: using the compensation voltage value to update the sliding window, and calculating an average voltage value of the effective voltage values in the updated sliding window, so as to determine the remaining power of the battery according to the average voltage value.
[0031] The sliding window stores a preset number of voltage values arranged in chronological order.
[0032] Specifically, a sliding window is a data processing technology used to store multiple amounts of data, which can effectively smooth the data and reduce the impact of instantaneous fluctuations on the results. The sliding window of this embodiment is used to store a preset number of voltage values arranged in chronological order, and can dynamically respond to voltage changes. As the battery state changes, new voltage values are introduced into the sliding window, and old voltage values are removed, thereby maintaining sensitivity to the current state of the battery. When updating the sliding window, the use of a compensated voltage value can ensure that the stored voltage value is closer to the actual state of the battery. This is because the compensated voltage value has taken into account possible detection errors and external influences, thereby improving the reliability of the data. By calculating the average voltage value of the effective voltage values in the sliding window, a more stable and reliable voltage reference can be obtained to more accurately reflect the actual state of the battery, and then used to estimate the actual remaining power of the battery.
[0033] Compared with the prior art, the battery power detection method based on the sliding window of the embodiment of the present invention makes full use of the ADC module inside the embedded device to sample the battery voltage, without the need for an additional external power meter or other peripheral circuits, thereby significantly reducing the production cost of the product. At the same time, by judging the charging state of the battery and obtaining the corrected voltage value, the influence of the battery on the voltage sampling value when it is in the charging state is effectively eliminated. Combined with the power supply state of the SOC main control chip to calculate the compensation value, the voltage reading deviation caused by the SOC main control chip in the working state can be effectively compensated. In addition, in order to further improve the stability of battery voltage detection, the battery power detection method also adopts a sliding window technology, allowing the battery voltage to be sampled multiple times and the average voltage value to be calculated, thereby effectively smoothing the fluctuation of the instantaneous voltage sampling value and reducing the error caused by load changes and temperature fluctuations. By combining the voltage correction, compensation mechanism and sliding window technology, the stability and accuracy of the battery remaining power detection can be ensured, which is very suitable for low-power video surveillance equipment.
[0034] See also Figure 2 As shown, it is a flow chart of the second embodiment of the battery power detection method based on sliding window of the present invention.
[0035] This embodiment, based on the first embodiment of the battery power detection method based on the sliding window, respectively describes in detail the steps of obtaining the actual voltage value, the corrected voltage value and the compensation value.
[0036] In this embodiment, step S100 and step S200 include: Step S101: turning on the ADC module, reading the original voltage value of the battery through the ADC module, and turning off the ADC module.
[0037] Specifically, step S101 is: enable the ADC module and perform corresponding configuration, including setting the ADC channel and frequency division coefficient; start the software to trigger the ADC conversion, and obtain the original voltage value of the battery read by the ADC module through the query mode to complete the data sampling. In order to save power, the ADC module is turned off after the data sampling is completed.
[0038] It should be noted that in order to save power, the ADC module is turned off by default. Therefore, when performing ADC sampling, it needs to be explicitly enabled. After use, the ADC module will also be turned off in time to reduce energy consumption. In addition, the setting of the frequency division coefficient needs to find a balance between sampling speed and accuracy. Too large a frequency division coefficient may reduce the system's noise immunity.
[0039] Step S102: Substituting the original voltage value into a preset conversion formula to calculate an actual voltage value, and updating the current actual voltage value to the calculated actual voltage value.
[0040] Among them, the preset conversion formula is: actual voltage value = (original voltage value × standard operating voltage value of ADC module) / resolution of ADC module.
[0041] Specifically, in this embodiment, the standard operating voltage value of the ADC module is 3300mV, and the resolution of the ADC module is 4096. When the calculated actual voltage value exceeds 2500mV, it is considered that the battery is connected to the charger and the battery is in a charging state. At this time, the charging state can be recorded for subsequent reading of the battery power to correct and compensate the actual voltage value.
[0042] Step S201: if the actual voltage value is greater than or equal to a preset charger connection threshold, it is determined that the battery is in a charging state; if the actual voltage value is less than the preset charger connection threshold, it is determined that the battery is in an uncharged state.
[0043] Specifically, in this embodiment, the preset charger connection threshold is 2500mV. If the actual voltage value is greater than or equal to 2500mV, it is determined that the battery is in a charging state, and the charging state is returned to 1 (1 means charging, 0 means not charging); if the actual voltage value is less than 2500mV, it is determined that the battery is in an uncharged state, and the charging state is returned to 0.
[0044] Step S202a: When the battery is in a charging state, disconnect the charger and wait for a preset first time period to regain the actual voltage value, re-establish the connection with the charger and add the regained actual voltage value and the preset corrected voltage drop value to calculate a corrected voltage value.
[0045] Specifically, when the battery is in a charging state, the charging power supply is turned off and the voltage is waited for to stabilize, which usually takes about 10 seconds (i.e., the first time length is preset to be 10 seconds). Then, the actual voltage value is obtained through the ADC module and corrected. Finally, the charging power supply is turned on again, and the corrected voltage value is returned.
[0046] Step S202b: when the battery is in an uncharged state, the actual voltage value is obtained and recorded as a corrected voltage value.
[0047] Specifically, when the battery is in an uncharged state, there is no interference from the charging current and the battery voltage is relatively stable. Therefore, the more accurate actual voltage value obtained through the ADC module can be directly used as the corrected voltage value.
[0048] It should be noted that the core goal of this correction process is to eliminate the interference of the charging circuit on the actual voltage value of the battery to ensure that the accurate actual voltage value can still be obtained in the charging state. This process includes two correction steps.
[0049] First, regarding the charging interference problem, when the battery is in the charging state, the current and voltage fluctuations in the circuit may cause the battery voltage value to be artificially high. If the voltage value is sampled directly, the battery power may be misjudged. In order to solve this problem, the charging power supply is temporarily turned off, and sampling is performed after the voltage stabilizes to obtain the true battery voltage value.
[0050] Secondly, regarding the voltage drop problem, the moment of turning off the charging power may cause a small voltage drop (such as 10mV). If the voltage value is sampled directly, the battery power may be misjudged. In order to solve this problem, a fixed value correction mechanism is adopted, that is, a preset correction voltage drop value of 10mV is used for correction. This preset correction voltage drop value needs to be calibrated according to the battery type and hardware to ensure its accuracy, but an error of ±5mV may be introduced during the calibration process.
[0051] It should be noted that there is no particular order between step S202a and step S202b, and either one may be performed.
[0052] Step S203a: when it is confirmed that the SOC main control chip is in a powered-on working state, a static compensation value and a dynamic compensation value are obtained, and the static compensation value and the dynamic compensation value are added together to calculate a compensation value.
[0053] The static compensation value=the average voltage value of all valid voltage values in the current sliding window-the corrected voltage value-the dynamic compensation value, and the dynamic compensation value is obtained when the SOC main control chip performs self-test.
[0054] Specifically, when the SOC main control chip is in a power supply state (i.e., in a power-on working state), the MCU micro-control chip calculates the static compensation value and dynamic compensation value of the battery voltage. The static compensation value is mainly used to eliminate inherent hardware deviations, such as errors in voltage divider resistors. Since the voltage of the SOC main control chip is relatively stable when it is first powered on, the static compensation value is only generated when the battery power is detected for the first time, and remains unchanged in subsequent use until the SOC main control chip is powered on again. This design can reduce the complexity of calculations and improve the response speed of the system. The dynamic compensation value is provided to the MCU micro-control chip after the SOC main control chip self-checks the voltage, and is mainly used to eliminate the battery voltage ADC detection error that may occur during the operation of the SOC main control chip. This dynamic compensation is real-time and can adapt to changes in battery status. The compensation mechanism can effectively improve the accuracy of battery voltage detection by combining static compensation and dynamic compensation.
[0055] Step S203b: when it is confirmed that the SOC main control chip is in a non-working state, the compensation value is set to 0.
[0056] Specifically, when the SOC main control chip is in an unpowered state (i.e., not working), the power supply circuit of the SOC main control chip does not affect the battery voltage detection, and the MCU micro-control chip will clear the previous compensation value to avoid the influence of errors. This process ensures that when the SOC main control chip is in an unpowered state, the MCU micro-control chip will not use an outdated compensation value.
[0057] It should be noted that there is no particular order between step S203a and step S203b, and either one may be performed.
[0058] In general, different processing methods are adopted for the SOC main control chip when it is powered and when it is not powered, ensuring that reliable battery voltage information can be obtained under various working conditions, thereby providing an accurate power estimation basis for the battery management system.
[0059] The battery power detection method based on sliding window of this embodiment relies on the ADC module inside the embedded device to sample the battery voltage without the need for peripheral circuits such as external power meters. This means that no additional hardware components are required in product design, which significantly reduces the production cost of the product and saves valuable hardware space. This integrated design makes the device more compact and suitable for application scenarios of low-power video surveillance equipment. By judging the charging state of the battery and obtaining the corrected voltage value, the accuracy of voltage detection is further improved. The compensation value is calculated according to the power supply state of the SOC main control chip, and it is added to the actual voltage value, which can effectively compensate for the voltage detection error caused by load changes or other factors. This dynamic correction mechanism ensures the effectiveness of battery power management, thereby improving the performance and reliability of the entire battery power management system.
[0060] See also Figure 3 As shown, it is a flow chart of the third embodiment of the battery power detection method based on sliding window of the present invention.
[0061] Compared with other embodiments of the battery power detection method based on a sliding window, this embodiment describes in detail the steps of obtaining the average voltage value and the remaining power of the battery.
[0062] In this embodiment, step S400 includes: Step S401: inserting the compensation voltage value into the head of the sliding window, discarding the voltage value at the tail of the sliding window, and moving other voltage values in the sliding window backward in sequence to complete the updating of the sliding window.
[0063] Specifically, the sliding window adopts a dynamic window filling mechanism, and the valid data gradually increases during initialization, thereby avoiding mutation errors caused by insufficient data in the initial stage. In addition, the mechanism has good fault tolerance and can ignore invalid data (such as the initial value of the voltage value of 0), thereby improving the robustness of the system. By setting the sliding window size of 20 samples (that is, the preset number is 20), the sliding window can effectively suppress high-frequency noise (such as load mutation) while retaining low-frequency trends (such as slow decrease in power). Experimental data show that when the sliding window size is 20, the standard deviation of voltage fluctuation is reduced by about 40%. At the same time, the sliding window has a low computational overhead and a time complexity of O(n), which is very suitable for low-computing MCU microcontroller chips (such as 8-bit MCUs). In addition, the array size of the sliding window is fixed (the default is 20 uint16_t, occupying 40 bytes), ensuring the controllability of resource consumption. It can be seen that the design of the sliding window has shown significant advantages in dynamic filling, noise resistance and low computational overhead.
[0064] Step S402: Count the number of valid voltage values in the updated sliding window, and calculate the average voltage value of all valid voltage values in the updated sliding window.
[0065] The average voltage value=the sum of all valid voltage values in the updated sliding window / the number.
[0066] Specifically, the sliding window statistical method is used to smooth the continuously sampled voltage values, thereby effectively suppressing the impact of instantaneous noise on battery power detection and realizing the core function of battery voltage filtering. This statistical method mainly includes two aspects: on the one hand, by averaging historical data, reducing fluctuations and reducing the noise that may appear in a single sampling (such as load mutations and temperature drift); on the other hand, the sliding window data is updated in real time to dynamically correct the voltage value and adapt to the long-term voltage change trend. This design ensures the accuracy and stability of battery power detection.
[0067] It should be noted that by using the sliding window technology, the battery voltage can be sampled multiple times and the average value can be calculated, which effectively smooths the fluctuation of the instantaneous sampling value and reduces the error caused by factors such as load changes and temperature fluctuations. The voltage values stored in the sliding window are arranged in chronological order, which can better reflect the changing trend of the battery voltage, thereby improving the stability and accuracy of voltage detection. At the same time, the real-time update mechanism of the sliding window enables the battery power detection to respond quickly to the battery voltage changes, ensuring that the detection of the remaining battery power is more timely and accurate. This real-time feedback capability is crucial for the long-term stable operation of low-power video surveillance equipment.
[0068] Step S403: Compare the average voltage value with a preset voltage capacity table.
[0069] Among them, the preset voltage capacity table includes voltage value, power percentage and a one-to-one correspondence between voltage value and power percentage, the power percentage includes 100%, 20% and 0%, the voltage value corresponding to the power percentage of 100% is recorded as the highest threshold, the voltage value corresponding to the power percentage of 20% is recorded as the middle threshold, and the voltage value corresponding to the power percentage of 0% is recorded as the lowest threshold, and the remaining power of the battery is expressed in the form of power percentage.
[0070] Specifically, a preset voltage capacity table of the battery is formulated according to the battery discharge curve. The following is an example of the table: Table 1 Preset voltage capacity table
[0071] From Table 1, we can see that: in the interval between 100% and 20% of the power percentage, the power percentage step is equal, both are 20%. In the interval between 20% and 10% of the power percentage, the power percentage step is 10%. In the interval between 10% and 0%, the power percentage step is equal, both are 2%.
[0072] Step S404a: If the average voltage value is greater than the maximum threshold, the power percentage is 100%.
[0073] Specifically, if the average voltage value is higher than the highest threshold value (4130mV) in the preset voltage capacity table, the battery percentage corresponding to the current remaining power of the battery is 100%.
[0074] Step S404b: If the average voltage value is less than or equal to the highest threshold value and greater than the middle threshold value, the average voltage value is substituted into a preset linear difference formula to calculate the percentage of electricity corresponding to the average voltage value.
[0075] Among them, the preset linear difference formula is: power percentage = high power percentage − [(high voltage value − average voltage value) / interval voltage value step] × interval power percentage step.
[0076] Specifically, if the average voltage value is in the range of 4130mV~3784mV (excluding 3784mV), the preset linear difference formula needs to be used to calculate the power percentage. The following example illustrates the specific calculation process: Assuming the average voltage value is 3900mV, it can be determined that this average voltage value is between 80% (4020mV) and 60% (3962mV). Then, High power percentage = 80%; High voltage value = 4020mV; Low power percentage = 60%; low voltage value = 3962mV; Interval voltage value step size = high voltage value - low voltage value = 4020mV-3962mV = 58mV; The interval power percentage step length = high power percentage - low power percentage = 80% - 60% = 20%; Substitute the above values into the preset linear interpolation formula: Battery percentage = 80% − [(4020mV − 3900mV) / 58mV] × 20% ≈ 38.6%.
[0077] Then, substituting the average voltage value of 3900 mV into the preset linear difference formula, the power percentage is calculated to be 38.6%.
[0078] Step S404c: If the average voltage value is less than or equal to the middle threshold value and greater than or equal to the minimum threshold value, query the power percentage corresponding to the average voltage value in the preset voltage capacity table.
[0079] Specifically, if the average voltage value is in the range of 3784mV ~ 3050mV, the corresponding power percentage in the preset voltage capacity table is directly returned to effectively avoid interpolation errors. Because within this voltage range, the relationship between the power percentage and the voltage value is relatively stable and linear. By directly looking up the table, the power percentage corresponding to the average voltage value can be obtained to ensure the accuracy of the test results and avoid errors introduced by interpolation calculations.
[0080] Step S404d: If the average voltage value is less than the minimum threshold, the power percentage is 0%.
[0081] Specifically, if the average voltage value is lower than the lowest threshold value (3050mV) in the preset voltage capacity table, the battery percentage corresponding to the current remaining power of the battery is 0%.
[0082] It should be noted that there is no particular order among step S404a, step S404b, step S404c and step S404d, and any one of them may be implemented.
[0083] The battery power detection method based on sliding window of this embodiment can accurately map the battery voltage value to the power percentage. This mapping method mainly relies on the preset voltage capacity table formulated based on the battery discharge curve for accurate mapping, and the user can intuitively understand the remaining battery power. At the same time, the method supports battery discharge curves of different battery models to ensure applicability in a variety of application scenarios. In addition, the method also has a boundary protection function, which can effectively handle voltage over-limit scenarios (such as overvoltage and undervoltage) to ensure that the output value is always within a reasonable range. This method of mapping the power percentage not only improves the accuracy of battery power estimation, but also enhances the safety and reliability of the system, providing users with a better user experience.
[0084] See also Figure 4 As shown, it is a flow chart of the fourth embodiment of the battery power detection method based on sliding window of the present invention.
[0085] Compared with other embodiments of the battery power detection method based on a sliding window, this embodiment adds a sliding window initialization step.
[0086] In this embodiment, before step S100, the method further includes: Step S501: starting the MCU microcontroller chip, and sampling the voltage value a preset number of times after entering the sleep state for a preset second time period to obtain the remaining power of the battery.
[0087] Specifically, the specific process of sliding window initialization is: first, start the MCU micro-control chip and initialize the MCU port, including functions such as ADC module and charging control. Next, configure the software timer (SWT) to realize the sleep wake-up function. Subsequently, enter the sleep state for 50 milliseconds (that is, the preset second time length is 50 milliseconds) to wait for the system of the MCU micro-control chip to stabilize. Finally, update the battery capacity information, and perform three initial voltage value samplings (that is, the preset number of times is 3 times) to avoid the influence of instantaneous errors. Through these operations, the accuracy and stability of the sliding window initialization can be ensured.
[0088] Step S502: using the obtained remaining power to update the current remaining power of the battery, and determining whether the remaining power is greater than a preset safety power.
[0089] Specifically, the sliding window initialization is performed when the MCU microcontroller starts the system, aiming to ensure that the battery has sufficient power to support the normal operation of the embedded device. When the remaining power is less than 10% (that is, the preset safety power is 10%), the system will enter the sleep waiting state to avoid abnormal startup or data errors caused by insufficient power.
[0090] Step S503a: If yes, the voltage value corresponding to the remaining power obtained is used to update the sliding window to complete the initialization of the sliding window.
[0091] Specifically, if the remaining power is greater than 10%, it means that the battery power is normal, and the system will fill the historical data of the sliding window to complete the sliding window initialization.
[0092] Step S503b: If not, the MCU microcontroller chip sleeps for a preset third time period at preset intervals until the remaining power of the battery is greater than the preset safety power.
[0093] Specifically, if the remaining power is less than or equal to 10%, it means that the battery power is low. The system will sleep for 3 minutes at each preset interval (that is, the preset third time length is 3 minutes), and will update the battery capacity information again after the battery power is restored (only a single sampling is required at this time).
[0094] It should be noted that there is no particular order between step S503a and step S503b, and either one may be performed.
[0095] The battery power detection method based on sliding window in this embodiment, the core logic of sliding window initialization includes: first, hardware initialization, configuration of key modules such as ADC module and charging control pin; second, multiple sampling to verify battery voltage, eliminating the influence of instantaneous fluctuations; if the battery power is insufficient, the system will periodically sleep and retry until the battery power is restored or the timeout condition is reached; finally, fill the historical voltage data to complete the sliding window initialization, providing a stable benchmark for subsequent battery power detection. This series of steps ensures that the system of MCU microcontroller chip can not only achieve fast response and efficient operation when the power is sufficient, but also maintain reliability and stability when the power is low.
[0096] See also Figure 5 As shown, it is a flow chart of the fifth embodiment of the battery power detection method based on sliding window of the present invention.
[0097] Compared with other embodiments of the battery power detection method based on a sliding window, this embodiment adds a multi-mode power management step.
[0098] In this embodiment, the battery power detection method further includes: Step S601: Determine the working mode of the MCU microcontroller chip.
[0099] Specifically, the working modes of the MCU microcontroller chip include a normal working mode, a factory test mode and a system upgrade mode.
[0100] Step S602a: When the MCU microcontroller chip is in a normal working mode, the mode of the SOC main control chip is determined; if the SOC main control chip is in a low power consumption mode, the remaining power of the battery is detected at a preset fourth time interval after the SOC main control chip is powered off; if the SOC main control chip is in a normal power mode, the remaining power of the battery is detected at a preset fourth time interval.
[0101] Specifically, the size of the preset fourth time length can be set by the SOC main control chip. In this embodiment, the preset fourth time length is set to 3 minutes.
[0102] Step S602b: When the MCU microcontroller chip is in the factory test mode, the remaining power of the battery is detected at every preset fifth time interval.
[0103] Among them, the preset fifth duration is shorter than the preset fourth duration.
[0104] Specifically, the preset fifth time length can be set to 3 seconds, so that the battery power detection is performed every 3 seconds. On the premise of ignoring factors such as power consumption, it is ensured that the latest battery power and charging status can be obtained during the factory measurement test process.
[0105] Step S602c: When the MCU microcontroller chip is in the system upgrade mode, it is determined whether the remaining power of the battery is greater than a preset power threshold; if so, the system upgrade is performed, otherwise the system upgrade is not started.
[0106] Specifically, during the system upgrade process, the software needs to be closed and the program needs to be re-burned. To prevent sudden power outages, it is necessary to confirm that the battery power is above 20% (i.e., the preset power threshold is 20%) before the system upgrade operation can be performed. In other words, after the MCU microcontroller chip is in the system upgrade mode, it is necessary to confirm that the remaining battery power is greater than the preset power threshold before the system upgrade operation can be started.
[0107] It should be noted that there is no particular order among step S602a, step S602b and step S602c, and any one of them can be implemented.
[0108] The battery power detection method based on sliding window of this embodiment adopts a multi-mode power management mechanism, and dynamically adjusts the detection frequency, peripheral control strategy and power consumption optimization to adapt to the needs of different scenarios. In terms of dynamic power consumption optimization, the system detects the battery power on demand in normal working mode, and performs high-frequency sampling in factory test mode. The system upgrade mode completely shuts down the peripherals, thereby reducing the overall power consumption by 20% to 30%. In addition, the battery power detection method also has an abnormal recovery mechanism, which automatically resets the heartbeat timeout of the SOC main control chip, combined with the watchdog and software timer (SWT) interrupts, to ensure that the system deadlock recovery time does not exceed 10 seconds. In terms of flexible configuration, users can also dynamically set the detection time interval and compensation parameters through UART instructions to adapt to different types of batteries. And the battery power detection method uses a modular design, so that the hardware has good compatibility and is easy to port to different MCU platforms.
[0109] It should be noted that the existing battery management methods have multiple defects. First, there is a voltage fluctuation error. The battery voltage is easily affected by factors such as load changes and temperature fluctuations, resulting in inaccurate instantaneous sampling values. Secondly, due to the interference of the charging state, the accuracy of the power calculation will be significantly affected during the charging process. In addition, the adaptability of the existing system is poor, and there is a lack of dynamically adjusted detection strategies under different working modes (such as low power consumption and normal power mode). Moreover, additional costs will be required. Peripheral circuits such as fuel meters not only increase the production cost of the product, but also cause unstable detection results and occupy hardware circuit space.
[0110] Therefore, the battery power detection method based on sliding window proposed in this embodiment mainly needs to solve the following problems: 1. How to remove the external circuit of the power meter and use the ADC circuit of the microcontroller to complete the battery power detection to save production costs; 2. How to reduce the interference of voltage fluctuations on power calculation through dynamic smoothing algorithm; 3. How to eliminate the influence of charging status on voltage sampling; 4. How to dynamically adjust the power detection strategy according to different working modes to reduce power consumption.
[0111] In order to solve the above problem, this embodiment proposes a battery power detection method based on a sliding window, and the specific steps are as follows: 1. Use a fixed-length sliding window to store historical voltage data, and use the calculated valid data as the actual battery voltage; 2. If charging is in progress, turn off the charging power and then delay reading the voltage value to eliminate interference in the charging circuit; 3. If charging is in progress, voltage drop correction needs to be performed on the collected value during charging; 4. Compensate the voltage value according to the operating status (power on / off) of the SOC main control chip and the compensation parameters; 5. Adopt a multi-mode detection strategy and select the most suitable power detection frequency for different modes to take into account both real-time performance and power consumption optimization.
[0112] By executing the above steps, the battery power detection method can achieve the following technical effects: 1. High-precision power calculation: The sliding window averaging algorithm significantly reduces the error caused by voltage fluctuations and improves the stability of power detection (the measured fluctuation is reduced by about 30%).
[0113] 2. Enhanced anti-interference capability: The dynamic compensation mechanism eliminates the interference of charging status on voltage sampling, and the error is controlled within ±3% in the charging scenario. The sliding window + dynamic compensation dual mechanism takes into account long-term smoothing and instantaneous correction.
[0114] 3. Dynamic power consumption optimization: The multi-mode detection strategy reduces the sampling frequency in low-power mode (such as extending it from 3 minutes to 30 minutes), reducing overall power consumption by 15% to 20%. The multi-mode strategy dynamically balances real-time performance and power consumption to meet the needs of IoT terminals.
[0115] 4. Flexible adaptability: No need to connect to the power meter, saving production costs and developer input costs. You only need to configure parameters (window size, detection time interval) to support different battery types and application scenarios. And the parameters (window size, detection time interval) are configurable to be compatible with different battery types and application scenarios.
[0116] In summary, the battery power detection method based on sliding windows in this embodiment effectively solves the problems of production cost, hardware space, sampling accuracy, etc. through integrated design, dynamic correction compensation mechanism and real-time update strategy, and provides an efficient, stable and cost-controllable battery management solution for the low-power video surveillance industry.
[0117] The following is an embodiment of the electronic device provided by the present invention. The embodiment of the electronic device and the embodiment of the battery power detection method based on the sliding window belong to the same concept, and the details not described in detail in the embodiment of the electronic device can refer to the embodiment of the battery power detection method based on the sliding window.
[0118] See also Figure 6 As shown, it is a schematic diagram of the structure of an electronic device in a hardware operating environment involved in an embodiment of the present invention.
[0119] In this embodiment, an electronic device is provided, wherein the electronic device is an embedded device, and the embedded device includes: Memory 1005, used to store program instructions; and The processor 1001 is used to execute the program instructions to implement the steps of the battery power detection method based on the sliding window as described above.
[0120] The electronic device of the embodiment of the present invention can be a computing device such as a desktop computer, a notebook, a palm computer, and a server. Figure 6 As shown, the electronic device may include: a processor 1001 (such as a CPU), a network interface 1004, a user interface 1003, a memory 1005 and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit, such as a keyboard (Keyboard), and the user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0121] Those skilled in the art will understand that Figure 6 The electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0122] like Figure 6 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module and a computer program.
[0123] exist Figure 6 In the electronic device shown, the network interface 1004 is mainly used to connect to the background server and communicate data with the background server; the user interface 1003 is mainly used to connect to the client (user end) and communicate data with the client; and the processor 1001 can be used to call the computer program stored in the memory 1005. When the computer program is called and executed by the processor 1001, the steps of the above-mentioned battery power detection method based on the sliding window are implemented.
[0124] The following is an embodiment of the computer-readable storage medium provided by the present invention. The embodiment of the computer-readable storage medium and the above-mentioned embodiment of the battery power detection method based on the sliding window and the electronic device belong to the same concept, and the details not described in detail in the embodiment of the computer-readable storage medium can refer to the above-mentioned embodiment of the battery power detection method based on the sliding window and the electronic device.
[0125] In this embodiment, a computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, the steps of the battery power detection method based on a sliding window as described above are implemented.
[0126] Since the electronic device and computer-readable storage medium of the present invention can both implement the steps of the above-mentioned battery power detection method based on a sliding window, they at least have all the beneficial effects brought by the technical solution of the above-mentioned step embodiment of the battery power detection method based on a sliding window, which will not be described one by one here.
[0127] The above description is only a partial or preferred embodiment of the present invention. Neither the text nor the drawings can limit the scope of protection of the present invention. All equivalent structural changes made by using the contents of the present invention specification and drawings under the overall concept of the present invention, or direct / indirect application in other related technical fields are included in the scope of protection of the present invention.
[0128] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0129] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0130] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0131] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0132] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A battery power detection method based on a sliding window is applied to an embedded device, wherein the embedded device includes an ADC module, a SOC main control chip, an MCU micro control chip and a battery, and is characterized in that: The battery power detection method comprises: The ADC module reads the original voltage value of the battery, and calculates the actual voltage value according to the original voltage value and a preset conversion formula; Determine whether the battery is in a charging state according to the actual voltage value, obtain a corrected voltage value according to the determination result, and obtain a compensation value according to the corrected voltage value and the power supply state of the SOC main control chip; Adding the actual voltage value and the compensation value to calculate a compensation voltage value; The sliding window is updated using the compensation voltage value, and an average voltage value of the effective voltage values in the updated sliding window is calculated so as to determine the remaining power of the battery according to the average voltage value; wherein a preset number of voltage values arranged in chronological order are stored in the sliding window.
2. The battery power detection method based on sliding window according to claim 1 is characterized in that: The method of reading the original voltage value of the battery through the ADC module and calculating the actual voltage value according to the original voltage value and a preset conversion formula includes: Turning on the ADC module, reading the original voltage value of the battery through the ADC module, and turning off the ADC module; Substitute the original voltage value into the preset conversion formula to calculate the actual voltage value, and update the current actual voltage value to the calculated actual voltage value; wherein the preset conversion formula is: actual voltage value = (original voltage value × standard operating voltage value of the ADC module) / resolution of the ADC module.
3. The battery power detection method based on sliding window according to claim 1 is characterized in that: The step of judging whether the battery is in a charging state according to the actual voltage value and obtaining a corrected voltage value according to the judging result includes: If the actual voltage value is greater than or equal to a preset charger connection threshold, it is determined that the battery is in a charging state; if the actual voltage value is less than the preset charger connection threshold, it is determined that the battery is in an uncharged state; When the battery is in a charging state, disconnecting from the charger and waiting for a preset first time period to re-obtain the actual voltage value, re-establishing the connection with the charger and adding the re-obtained actual voltage value and the preset corrected voltage drop value to calculate a corrected voltage value; When the battery is in an uncharged state, the actual voltage value is obtained and recorded as a corrected voltage value.
4. The battery power detection method based on sliding window according to claim 1 is characterized in that: The obtaining of the compensation value according to the corrected voltage value and the power supply state of the SOC main control chip includes: When it is confirmed that the SOC main control chip is in a powered-on working state, a static compensation value and a dynamic compensation value are obtained, and the static compensation value and the dynamic compensation value are added to calculate a compensation value; wherein the static compensation value=the average voltage value of all valid voltage values in the current sliding window-the corrected voltage value-the dynamic compensation value, and the dynamic compensation value is obtained when the SOC main control chip performs a self-test; When it is confirmed that the SOC main control chip is in a non-working state, the compensation value is set to 0.
5. The battery power detection method based on sliding window according to claim 1 is characterized in that: The method of updating the sliding window using the compensation voltage value and calculating an average voltage value of the effective voltage values in the updated sliding window includes: Inserting the compensation voltage value into the head of the sliding window, discarding the voltage value at the tail of the sliding window, and moving other voltage values in the sliding window backward in sequence to complete the updating of the sliding window; The number of valid voltage values in the updated sliding window is counted, and the average voltage value of all valid voltage values in the updated sliding window is calculated; wherein the average voltage value=the sum of all valid voltage values in the updated sliding window / the number.
6. The battery power detection method based on sliding window according to claim 1 is characterized in that: Determining the remaining power of the battery according to the average voltage value includes: Compare the average voltage value with a preset voltage capacity table; wherein the preset voltage capacity table includes a voltage value, a power percentage, and a one-to-one correspondence between the voltage value and the power percentage, the power percentage includes 100%, 20%, and 0%, the voltage value corresponding to a power percentage of 100% is recorded as the highest threshold, the voltage value corresponding to a power percentage of 20% is recorded as the middle threshold, and the voltage value corresponding to a power percentage of 0% is recorded as the lowest threshold, and the remaining power of the battery is expressed in the form of power percentage; If the average voltage value is greater than the maximum threshold, the power percentage is 100%; If the average voltage value is less than or equal to the highest threshold value and greater than the middle threshold value, the average voltage value is substituted into a preset linear difference formula to calculate the power percentage corresponding to the average voltage value; wherein the preset linear difference formula is: power percentage = high power percentage − [(high voltage value − average voltage value) / interval voltage value step length] × interval power percentage step length; If the average voltage value is less than or equal to the middle threshold value and greater than or equal to the minimum threshold value, query the power percentage corresponding to the average voltage value in the preset voltage capacity table; If the average voltage value is less than the minimum threshold, the power percentage is 0%.
7. The battery power detection method based on sliding window according to claim 1 is characterized in that: Before reading the original voltage value of the battery through the ADC module, the method further includes: The MCU microcontroller chip is started, and after entering the sleep state for a preset second time period, a preset number of voltage value samples are taken to obtain the remaining power of the battery; Using the obtained remaining power to update the current remaining power of the battery, and determining whether the remaining power is greater than a preset safety power; If yes, the sliding window is updated using the voltage value corresponding to the remaining power obtained to complete the initialization of the sliding window; If not, the MCU microcontroller chip sleeps for a preset third time period at intervals of a preset period until the remaining power of the battery is greater than the preset safety power.
8. The battery power detection method based on sliding window according to claim 1 is characterized in that: The battery power detection method also includes: Determine the working mode of the MCU microcontroller chip; When the MCU microcontroller chip is in a normal working mode, the mode of the SOC main control chip is determined; if the SOC main control chip is in a low power consumption mode, the remaining power of the battery is detected at a preset fourth time interval after the SOC main control chip is powered off; if the SOC main control chip is in a normal power mode, the remaining power of the battery is detected at a preset fourth time interval; When the MCU microcontroller chip is in the factory test mode, the remaining power of the battery is detected at every preset fifth time interval; wherein the preset fifth time interval is less than the preset fourth time interval; When the MCU microcontroller chip is in the system upgrade mode, it is determined whether the remaining power of the battery is greater than a preset power threshold; if so, the system upgrade is performed, otherwise the system upgrade is not started.
9. An electronic device, characterized in that: The electronic device is an embedded device, and the embedded device includes: a memory for storing program instructions; and A processor is used to execute the program instructions to implement the steps of the battery power detection method based on a sliding window as described in any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, the steps of the battery power detection method based on a sliding window as described in any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Method utilizing battery voltage to display electric quantity
CN102520364A
Method for measuring and calculating system battery electricity quantity
CN103792490A
Battery power calculation method, electronic equipment and storage medium
CN112782596A
Residual electric quantity detection method and device and medium
CN118011246A
Sliding window-based lithium battery SOC online prediction method, and related device
WO2024169315A1
Cited By
Intelligent battery data simulation transmission method and device, electronic equipment and storage medium
CN121585489A
Battery charging control method and device under low-power condition, electronic equipment and storage medium
CN122437217A
A battery charging control method and device under low power condition, electronic equipment and storage medium
CN122437217B