Method and device for calculating battery impedance value, terminal equipment and storage medium
By discretely transforming the voltage and current values of the terminal equipment battery and calculating the battery impedance value, the problem of insufficient reliability of EIS analysis results in the existing technology is solved, and accurate analysis of the aging degree and health status of the battery is achieved.
Patent Information
- Application Number
- CN202310892601.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-19
- Publication Date
- 2025-01-21
AI Technical Summary
In the prior art, the electrochemical impedance spectrum EIS analysis has not been designed for the specific products of the terminal equipment, which makes the reliability of the analysis results still need to be discussed.
By obtaining multiple voltage values and multiple current values of the battery, a voltage sequence and a current sequence are formed. When the step response conditions are met, these values are discretely transformed to calculate the battery impedance value.
It achieves accurate calculation of battery impedance value, can accurately analyze the aging degree and health status of the battery, and improves the reliability and universality of the analysis.
Smart Images

Figure CN119335424A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of charging, and in particular to a method, device, terminal equipment and storage medium for calculating a battery impedance value. Background Art
[0002] With the development of fast charging technology, the fast charging power has increased from 20W to 100W or even 150W. However, high-current fast charging can cause battery "damage" under certain conditions, such as battery lithium deposition. Therefore, how to monitor the battery-related status has become an important issue in the field of fast charging.
[0003] In the relevant technical solutions, a method of battery electrochemical impedance spectroscopy (EIS) is proposed. However, the existing electrochemical impedance spectroscopy (EIS) is not designed for specific terminal devices (such as mobile phones). The existing EIS analysis is based on laboratory simulation data and is not engineered for actual product battery data, so the reliability of the analysis results is questionable. Summary of the invention
[0004] The embodiments of the present application provide a method, apparatus, terminal device and storage medium for calculating the impedance value of a battery, which can be used to accurately obtain the impedance value of the battery according to multiple voltage values and multiple current values of the battery, so that the aging degree of the battery can be accurately analyzed according to the battery impedance value to determine the health status of the battery.
[0005] In a first aspect, the present application provides a method for calculating a battery impedance value, the method being applied to a terminal device, the terminal device comprising a battery, the method comprising: obtaining a plurality of voltage values and a plurality of current values of the battery, the plurality of voltage values constituting a voltage sequence and the plurality of current values constituting a current sequence; performing a discrete transformation on the voltage values in the voltage sequence and the current values in the current sequence to obtain discrete transformation values respectively corresponding to the voltage sequence and the current sequence, when at least one of the voltage sequence and the current sequence satisfies a step response condition; and calculating the battery impedance value according to the discrete transformation values respectively corresponding to the voltage sequence and the current sequence.
[0006] A second aspect of the present application provides a device for calculating a battery impedance value, the device being applied to a terminal device, the terminal device including a battery, and the device including:
[0007] An acquisition module, used for acquiring a plurality of voltage values and a plurality of current values of the battery, wherein the plurality of voltage values constitute a voltage sequence and the plurality of current values constitute a current sequence;
[0008] A discrete transformation module, configured to perform discrete transformation on a voltage value in the voltage sequence and a current value in the current sequence when at least one of the voltage sequence and the current sequence satisfies a step response condition, so as to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively;
[0009] The calculation module is used to calculate the battery impedance value according to the discrete transformation values corresponding to the voltage sequence and the current sequence respectively.
[0010] A third aspect of the present application provides a terminal device, which may include:
[0011] A memory storing executable program code;
[0012] a processor coupled to the memory;
[0013] The processor is used to execute the method described in the first aspect of the present application.
[0014] Another aspect of an embodiment of the present application provides a computer-readable storage medium, comprising instructions, which, when executed on a processor, enables the processor to execute the method described in the first aspect of the present application.
[0015] Yet another aspect of an embodiment of the present application discloses a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the method described in the first aspect of the present application.
[0016] Another aspect of an embodiment of the present application discloses an application publishing platform, which is used to publish a computer program product. When the computer program product runs on a computer, the computer executes the method described in the first aspect of the present application.
[0017] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0018] In an embodiment of the present application, multiple voltage values and multiple current values of the battery are obtained, the multiple voltage values constitute a voltage sequence and the multiple current values constitute a current sequence; when at least one of the voltage sequence and the current sequence meets the step response condition, the voltage value in the voltage sequence and the current value in the current sequence are discretely transformed to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively; the battery impedance value is calculated according to the discrete transformation values corresponding to the voltage sequence and the current sequence respectively. It is used to accurately obtain the battery impedance value according to the multiple voltage values and multiple current values of the battery, so that the aging degree of the battery can be accurately analyzed according to the battery impedance value, and the health state of the battery can be determined. Compared with the EIS analysis based on laboratory simulation data in the prior art, the present application specifically analyzes the multiple voltage values and multiple current values of the battery in each terminal device, which is more universal and reliable. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments and the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application, and other drawings can be obtained based on these drawings.
[0020] Figure 1 A schematic diagram of an embodiment of a method for calculating a battery impedance value in an embodiment of the present application;
[0021] Figure 2 A schematic diagram showing a step change in battery voltage caused by a step change in battery current;
[0022] Figure 3 A schematic diagram of an embodiment of a device for calculating a battery impedance value in an embodiment of the present application;
[0023] Figure 4 This is a schematic diagram of an embodiment of a terminal device in an embodiment of the present application;
[0024] Figure 5 This is another schematic diagram of a terminal device in an embodiment of the present application. DETAILED DESCRIPTION
[0025] The embodiments of the present application provide a method, apparatus, terminal device and storage medium for calculating the impedance value of a battery, which can be used to accurately obtain the impedance value of the battery according to multiple voltage values and multiple current values of the battery, so as to accurately analyze the aging degree of the battery and determine the health status of the battery.
[0026] In order to make the technical personnel in the technical field better understand the scheme of the present application, the technical scheme in the embodiment of the present application will be described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, not all of the embodiments. Based on the embodiments in the present application, they should all fall within the scope of protection of the present application.
[0027] The following is a brief description of some terms involved in this application, as follows:
[0028] SOC (State of Charge) refers to the state of charge of the battery, that is, the charging state, and is a key technology of the battery management system. The state of charge is the ratio of the remaining capacity of the battery after a period of use or long-term storage to its fully charged capacity, usually expressed as a percentage. Its value range is 0 to 1. When SOC = 0, it means that the battery is fully discharged, and when SOC = 1, it means that the battery is fully charged.
[0029] SOH (State of Health) is used to describe the health status of the battery and reflects the current rated capacity of the battery, which is the ratio of the current rated capacity to the initial rated capacity. The SOH of the battery can also be expressed as the aging state of the battery, which can be divided into calendar aging and cycle aging according to the different electrochemical reaction mechanisms in the aging process.
[0030] HIDL is an interface description language (IDL) used to specify the interface between HAL and its users. It allows specified types and function calls to be collected into interfaces and packages. More broadly speaking, HIDL is a system that allows independently compiled code libraries to communicate with each other. HIDL is actually used for inter-process communication (IPC). Inter-process communication can be called Binderized. For libraries that must be connected to processes, passthrough mode can also be used (but not supported in Java). HIDL organizes specified data structures and method signatures into interfaces, which are collected into packages for use.
[0031] Standard I / O (Input / Output), some commonly used function interfaces (Application Programming Interface, API) may include but are not limited to: fopen (open a file), fgetc (read a character from a file), fgets (read a string of characters from a file), fread (read multiple elements from a file stream), fwrite (write a file to a stream file), putc (write a character to a file), puts (write a string to a file)...
[0032] Common string processing functions include:
[0033] (1) strcpy function: defines two character arrays, s1 and s2, with the format of strcpy(s1, s2). It copies the characters in s2 to the s1 array. Note that s2 will end when it encounters \0, and \0 will be copied into s1.
[0034] (2) strncpy function: defines two character arrays, the format is: strncpy(s1, s2, n); its function is to copy the first n characters in s2 to s1. If the copy process is less than n, the copy ends when \0 is encountered.
[0035] (3) strcat function: defines two character arrays, the format is: strcat(s1, s2); its function is to connect the characters in the s2 character array to the s1 character array, and the function of concatenating strings is the same. It ends when encountering \0.
[0036] (4) strncat function: defines two character arrays, the format is: strncat(s1,s2,n); its function is to connect n characters in the s2 character array to the s1 character array, and the function of concatenating strings is the same. It ends when encountering \0.
[0037] (5) strcmp function: defines two character arrays, the format is: strcmp(s1, s2); it is a comparison function. When comparing two characters, if \0 is encountered, the comparison ends.
[0038] (6) strncmp function: defines two character arrays, the format is: strcmp(s1, s2, n); it is a comparison function. When comparing two characters, if \0 is encountered, the comparison ends.
[0039] (7) sprintf function: defines a character array as c1, the format is: sprintf(c1,"format","data"); its function is to package the data according to the format and store it in the array c1. It should be noted that the return value of the "sprintf function" is the effective length of the package.
[0040] (8) sscanf function: defines a character array as c1, the format is: sscanf(c1,"format",data); its function is to format the content of c1 and output it to data.
[0041] (9) strchr function: defines a character array s1, the format is: strchr(s1,ch); its function is to search for the position where the character ch appears in the character array s1. If successful, it returns the address of the position where the character appears. If not found, it returns a null value (NULL).
[0042] (10) strstr function: defines two character arrays s1 and s2, the format is: strstr(s1, s2); its function is to find the position where the s2 string appears in the s1 character array and return the address of this position.
[0043] (11) strtok function: defines two character arrays, s1 and s2, with the format: strtok(s1,"target of cutting"); its function is to cut @ in s1 and return the string before the cut.
[0044] (12) atoi, atof, atol, atoll and other functions:
[0045] First, define two character arrays a1 and a2; the functions are:
[0046] atoi function: can convert string into integer type data;
[0047] atof function: can convert a string into float type data;
[0048] atol function: can convert a string into long type data;
[0049] atoll function: can convert a string into long long type data.
[0050] With the development of fast charging technology, the fast charging power has increased from 20W to 100W or even 150W. However, high-current fast charging can cause battery "damage" under certain conditions, such as battery lithium deposition. Therefore, how to monitor the battery-related status has become an important issue in the field of fast charging.
[0051] In the related technical scheme, a battery electrochemical impedance spectroscopy (EIS) method is proposed, which can use a small-amplitude sinusoidal potential (or current) as a perturbation electrical signal to make the electrode system produce an approximately linear response, and measure the ratio of the alternating potential and current signal of the electrode system in a wide frequency range (this ratio is the impedance of the system) to study the electrode system.
[0052] However, the existing electrochemical impedance spectroscopy (EIS) is not designed for specific terminal devices (such as mobile phones), and there are no commercial EIS products in the mobile phone field. Existing EIS analysis is based on laboratory simulation data, and there is no engineering design based on the battery data of actual products, so the reliability of the analysis results is questionable.
[0053] In the embodiment of the present application, the terminal device can be a mobile phone, a tablet computer, a computer with wireless transceiver function, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal device in industrial control, a wireless terminal device in self driving, a wireless terminal device in remote medical, a wireless terminal device in a smart grid, a wireless terminal device in transportation safety, a wireless terminal device in a smart city, or a wireless terminal device in a smart home, etc.
[0054] As an example but not limitation, in the embodiments of the present application, the terminal device may also be a wearable device. Wearable devices may also be referred to as wearable smart devices, which are a general term for wearable devices that are intelligently designed and developed using wearable technology for daily wear, such as glasses, gloves, watches, clothing, and shoes. A wearable device is a portable device that is worn directly on the body or integrated into the user's clothes or accessories. Wearable devices are not only hardware devices, but also powerful functions achieved through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include full-featured, large-sized, and fully or partially independent of smartphones, such as smart watches or smart glasses, as well as devices that only focus on a certain type of application function and need to be used in conjunction with other devices such as smartphones, such as various types of smart bracelets and smart jewelry for vital sign monitoring.
[0055] In an embodiment of the present application, the analog-to-digital converter (ADC) sampling value (including the battery voltage value (voltage, which can be abbreviated as volt) and current value (current, which can be abbreviated as curr)) can be updated regularly → determine whether the step response conditions are met → whether noise compensation is required → calculate the discrete transformation values corresponding to the voltage sequence and current sequence respectively → calculate the battery impedance value. Therefore, the degree of battery aging can be accurately analyzed according to the battery impedance value to determine the health status of the battery. Compared with the EIS analysis based on laboratory simulation data in the prior art, the present application conducts specific analysis on multiple voltage values and multiple current values of the battery in each terminal device, which is more universal and reliable.
[0056] The above steps can be considered as the steps executed by the EIS calculation thread (eis_cal_thread). Before creating the EIS calculation thread, the battery configuration file (which may include sampling frequency, number of calculation frequencies, and at least one calculation frequency) can also be parsed, the total number of sampling points can be calculated, memory space can be allocated, etc.
[0057] The technical solution of the present application is further described below by way of embodiments. Figure 1 FIG. 1 is a schematic diagram of an embodiment of a method for calculating a battery impedance value in an embodiment of the present application. The method is applied to a terminal device, and the terminal device includes a battery. The method embodiment may include:
[0058] 101. Acquire multiple voltage values and multiple current values of a battery, wherein the multiple voltage values constitute a voltage sequence and the multiple current values constitute a current sequence.
[0059] It can be understood that the number of voltage values contained in the voltage sequence corresponds to the total number of sampling points, and the number of current values contained in the current sequence also corresponds to the total number of sampling points. The voltage values in the voltage sequence and the current values in the current sequence can be considered to be one-to-one corresponding, that is, they can be called voltage-current pairs. Therefore, the voltage sequence and the current sequence can also be considered as an overall voltage-current pair sequence.
[0060] In an optional implementation, the total number of sampling points may be preset or calculated based on the sampling frequency and the minimum calculation frequency in the EIS configuration file.
[0061] In an optional implementation, the voltage values in the voltage sequence are increasing, and at the same time, the current values in the current sequence are also increasing, that is, arranged from small to large.
[0062] In another optional implementation, the voltage values in the voltage sequence are decreasing, and at the same time, the current values in the current sequence are also decreasing, that is, arranged from large to small.
[0063] In an optional implementation, the voltage value and the current value of the battery may be sampled according to the total number of sampling points, and then sorted to obtain a voltage sequence and a current sequence.
[0064] In another optional implementation, voltage values and current values that meet the total number of sampling points may be acquired from the multiple voltage values and current values that have been sampled and sorted, to obtain a voltage sequence and a current sequence.
[0065] 102. When at least one of the voltage sequence and the current sequence satisfies a step response condition, discrete transformation is performed on the voltage value in the voltage sequence and the current value in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence, respectively.
[0066] It should be noted that, because the voltage values in the voltage sequence and the current values in the current sequence are one-to-one corresponding, and the current step change causes the voltage step change, therefore, when judging whether the voltage sequence and the current sequence meet the step response condition, if it is judged that the voltage value in the voltage sequence meets the step response condition, it can be considered that the current value in the current sequence also meets the step response condition, and a discrete transformation is performed on the voltage value in the voltage sequence and the current value in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively; if it is judged that the current value in the current sequence meets the step response condition, it can be considered that the voltage value in the voltage sequence meets the step response condition. The voltage values also meet the step response condition, and discrete transformation is performed on the voltage values in the voltage sequence and the current values in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively; in order to ensure the accuracy of the judgment result, it is also possible to judge whether the voltage values in the voltage sequence and the current values in the current sequence meet the step response condition. If the voltage values in the voltage sequence meet the step response condition, and the current values in the current sequence meet the step response condition, discrete transformation is performed on the voltage values in the voltage sequence and the current values in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively.
[0067] In an optional implementation, the discrete transformation may include a discrete Fourier transform (DFT) transformation.
[0068] 103. Calculate the battery impedance value according to the discrete transformation values corresponding to the voltage sequence and the current sequence respectively.
[0069] In an optional implementation, the discrete transform value includes a discrete transform complex value; the discrete transform complex value may include at least one of a discrete transform imaginary part value and a discrete transform real part value.
[0070] In an optional implementation, the battery impedance value includes at least one of a real impedance value of the battery and an imaginary impedance value of the battery.
[0071] For example, Figure 2 The figure shows a schematic diagram of a battery voltage step change caused by a battery current step change. Figure 2 As shown in the figure, the boxed ones are the voltage and current components needed for EIS analysis. The EIS process is Z = DFT (battery_voltage) / DFT (battery_current), where Z is the complex impedance value at different calculation frequencies. DFT (Discrete Fourier Transform) is discrete Fourier transform. The function of DFT is to transform the signal from the time domain to the frequency domain, and both the time domain and the frequency domain are discrete. It can be found out which sinusoidal waves a signal is composed of, and the result is the amplitude and phase of the sinusoidal wave.
[0072] The specific calculation formula of DFT transformation is as follows:
[0073]
[0074]
[0075] Among them, the sine wave superposition X(k) represents the DFT transformation value, while x(n) represents the sampled data (voltage value and current value), and N is the total number of sampling points.
[0076] 104. Determine the degree of battery aging based on the battery impedance value.
[0077] The battery impedance value is positively correlated with the battery aging degree. That is, the larger the battery impedance value, the more serious the battery aging degree. It should be noted that step 104 is an optional step.
[0078] In an embodiment of the present application, multiple voltage values and multiple current values of the battery are obtained, the multiple voltage values constitute a voltage sequence and the multiple current values constitute a current sequence; when at least one of the voltage sequence and the current sequence meets the step response condition, the voltage value in the voltage sequence and the current value in the current sequence are discretely transformed to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively; the battery impedance value is calculated according to the discrete transformation values corresponding to the voltage sequence and the current sequence respectively. It is used to accurately obtain the battery impedance value according to the multiple voltage values and multiple current values of the battery, so that the aging degree of the battery can be accurately analyzed according to the battery impedance value, and the health state of the battery can be determined. Compared with the EIS analysis based on laboratory simulation data in the prior art, the present application specifically analyzes the multiple voltage values and multiple current values of the battery in each terminal device, which is more universal and reliable.
[0079] Before step 101, the method may further include: parsing the EIS configuration file of the battery to obtain the sampling frequency, the number of calculation frequencies, and at least one calculation frequency.
[0080] 1. Regarding parsing the EIS configuration file of the battery, the sampling frequency, the number of calculation frequencies, and the relevant content of at least one calculation frequency are obtained. The following is a detailed description:
[0081] (1) When using hidl to initialize the EIS part, the battery's EIS configuration file (battery_eis.txt) will be parsed first. For example, the fopen api can be used to open the EIS configuration file (battery_eis.txt). If fopen fails, it indicates that the terminal device does not support the EIS electrochemical impedance spectroscopy analysis function (the system is not configured with the EIS configuration file), and the operation ends. If fopen succeeds, it indicates that the mobile phone supports the EIS electrochemical impedance spectroscopy analysis function, and the subsequent steps are performed.
[0082] Exemplarily, the fgets function can be used to obtain each line of the EIS configuration file (battery_eis.txt) from the beginning to the end. If it can be obtained, it means that it is not the last line, and the line needs to be parsed, and the buffer (buffer, buf for short) = fgets (the line); otherwise, subsequent steps such as determining the minimum calculation frequency are performed.
[0083] (2) Exemplarily, the format of the EIS configuration file is as follows:
[0084] sampling_fmhz:1000;
[0085] cal_fmhz_num:2;
[0086] cal_fmhz:25,50;
[0087] Among them, sampling_fmhz is the sampling frequency of the raw data of the analog-to-digital converter (ADC), the unit is megahertz (MHz), cal_fmhz_num is the number of calculated frequencies; and cal_fmhz is the actual calculated frequency, the number of calculated frequencies can be one or more.
[0088] In an optional implementation, the configuration parameters of the EIS configuration file (sampling frequency, number of calculation frequencies and at least one calculation frequency) can be dynamically updated, and the sampling frequency, number of calculation frequencies and at least one calculation frequency can be updated subsequently without modifying the code.
[0089] (3) Use the fgets function to read a line of the configuration file into the string array buf. You can use strstrapi to determine whether the string array buf contains a substring of "cal_fmhz_num:", "cal_fmhz:", or "sampling_fmhz:".
[0090] When the string array buf contains the substring "cal_fmhz_num:", it indicates that the line is used to configure cal_fmhz_num to calculate the number of frequencies. You can use buf_temp = strstr(buf, ":") to find the memory location of the character ":". If buf_temp is not empty (if it is not found, buf_temp is empty), then move the pointer of buf_temp to the right by one character (that is, buf_temp+1), and you can find the memory location of the character to the right of ":". For example, the position of the character "2" in the configuration file example above, and then use the atoi function to convert the character "2" into the integer type (int) number 2, that is, cal_fmhz_num = atoi(buf_temp+1) = 2. If it is not contained, use another string to try whether it is contained and proceed to the next step.
[0091] When the string array buf contains the substring "cal_fmhz:", it indicates that the line is for configuring the calculation frequency cal_fmhz. Since there may be multiple calculation frequencies, it is necessary to know how many calculation frequencies there are before allocating memory to each calculation frequency. Therefore, it is necessary to parse the line first to get the number of calculation frequencies. You can use buf_temp = strstr(buf, ":") to find the memory location of the character ":". If buf_temp is not empty (if it is not found, buf_temp is empty), and *buf_temp! = '\0' (the last character of any string must be '\0'), then move the pointer of buf_temp to the right by one character (i.e., buf_temp+1), and then judge *buf_temp! = '\0'. If it is not equal, the calculation frequency count is increased by 1 (count+1), and the pointer of buf_temp is moved to the right by one character (i.e., buf_temp+1). The configuration of the calculation frequency is separated by ',', so use buf_temp = strstr(buf, ",") to find the memory location of ','. If it is not found (buf_temp is empty), it means that it is the last digital string, and the specific calculation frequency is parsed; if it is found (buf_temp is not empty), execute buf_temp+1 to move one character to the right, and then re-judge *buf_temp! = '\0', so that the current configuration number count of the calculation frequency can be known.
[0092] When the string array buf contains the substring "sampling_fmhz:", it indicates that the line is to configure the sampling frequency. You can use buf_temp = strstr(buf, ":") to find the memory location of the character ":". If buf_temp is not empty (if it is not found, buf_temp is empty), and *buf_temp! = '\0', then sampling_fmhz = atoi(buf_temp+1) to determine whether sampling_fmhz is equal to 0, or whether sampling_fmhz is greater than the first frequency threshold (for example, whether sampling_fmhz is greater than 1000Hz). If sampling_fmhz = 0, or sampling_mhz> the first frequency threshold, then the operation of the entire EIS module ends, otherwise, the next line is parsed.
[0093] It should be noted that there is no limitation on the timing of determining whether the string array buf contains the substrings “cal_fmhz_num:”, “cal_fmhz:” and “sampling_fmhz:”.
[0094] (4) It can be known from (3) the number of configured frequencies for calculation (count). If count is not equal to cal_fmhz_num, it indicates that the number of frequencies for calculation is incorrect, and the operation of the entire EIS module will be directly terminated. Otherwise (i.e., count is equal to cal_fmhz_num), allocate memory for cal_fmhz according to the number of cal_fmhz_num, and initialize index = 0; then re-parse this line in the same operation manner as parsing the number of frequencies for calculation. Use buf_temp = strstr(buf, ":") to find the memory location of the character ":". If buf_temp is not empty (if not found, buf_temp will be empty), and at the same time *buf_temp!='\0' (the last character of any string must be '\0'), then move the pointer of buf_temp one character to the right (i.e., buf_temp + 1); if *buf_temp!='\0', and index < cal_fmhz_num, then convert it to the calculation frequency of the index-th one through cal_fmhz[index] = atoi(buf_temp), and then determine whether the calculation frequency cal_fmhz of the index-th one is within the legal range; if it is not within the legal range (for example, cal_fmhz[index] = 0, or cal_fmhz[index] > 1hz, or cal_fmhz[index] > sampling_fmhz), then terminate the operation; if it is within the legal range, then index + 1. You can use buf_temp = strstr(buf, ",") to find the memory location of ','. If buf_temp is not empty (if not found, buf_temp will be empty and parse the next line), then execute buf_temp + 1 to move one character to the right, and then re-judge whether *buf_temp!='\0' and whether index is less than cal_fmhz_num.
[0095] 2. In an alternative implementation, the total number of sampling points can be calculated based on the minimum calculation frequency and the sampling frequency among the at least one calculated frequency obtained by parsing.
[0096] In an alternative implementation, the total number of sampling points is equal to the product of the sampling frequency and the minimum calculation frequency.
[0097] In an alternative implementation, when determining the minimum calculation frequency, it is necessary to judge whether each calculation frequency among the at least one calculation frequency is within the legal range. When each calculation frequency is within the legal range, determine the minimum calculation frequency among the at least one calculation frequency.
[0098] (1) Calculate the total number of sampling points
[0099] Exemplarily, from at least one calculation frequency cal_fmhz parsed from the configuration file, the minimum calculation frequency (min_fmhz) is obtained by front-to-back comparison; then the total number of ADC sampling points (sampling_node_n) of the EIS is calculated, as shown below:
[0100] sampling_node_n=sampling_fmhz / min_fmhz.
[0101] For example, if the sampling frequency (sampling_fmhz) is 1000 MHz and the minimum calculation frequency (min_fmhz) is 25 MHz, then the total number of sampling points sampling_node_n = 1000 / 25 = 40 sampling points.
[0102] It should be noted that if sampling_node_n=0 indicates that the total number of sampling points is calculated incorrectly, then the operation of the entire EIS module is terminated; if sampling_node_n≠0, the remainder of the total number of sampling points modulo 2 (i.e., sampling_node_n%2) is taken. If the remainder is not 0, it indicates that there is an odd number of sampling points. This is convenient for subsequent processing, and the total number of sampling points, sampling_node_n+1, needs to be processed before proceeding to the next step to allocate memory space to the sampled voltage and current. If the remainder is 0, proceed directly to the next step to allocate memory space to the sampled voltage and current.
[0103] (2) Allocate memory space
[0104] In an optional implementation, memory space may be allocated for sampled voltage-current pairs according to the total number of sampling points.
[0105] It is understandable that the EIS algorithm needs to calculate the DFT transformed complex values of the continuously sampled voltage and current values, so a certain amount of memory space is required to save the sampled voltage and current pairs, where the structure of each voltage and current pair is as follows:
[0106] Struct{
[0107] Double volt;
[0108] Double curr;
[0109] }sampling_volt_curr;
[0110] Among them, Double represents a decimal, sampling_volt_curr is the sampling voltage-current pair, and then apply for a memory space of the size of the sampling_volt_curr structure multiplied by the total number of sampling points sampling_node_n, and assign its first memory address to the voltage-current pair (volt_curr). Calculating EIS can determine the step current, and determining the step current requires determining whether the current values sampled in the first half and the current values sampled in the second half meet the step response conditions, and there may be a small part of the current values of noise points that need to be eliminated, so it is necessary to sort the current values sampled in the first and second halves and record the position of the current value in the original sampled voltage-current pair (volt_curr) sequence before sorting, so its structure is as follows:
[0111] Struct{
[0112] Double curr;
[0113] Double index;
[0114] }sort_curr;
[0115] Among them, sort_curr is the current sequence, curr is the sorted current value, and index is its position in the volt_curr sequence when it is not sorted.
[0116] Then, sort the current values sampled in the first half to obtain the first half current sequence (sort_f), and allocate memory space to sort_f. The size of the memory space is the size of the sort_curr structure multiplied by sampling_node_n / 2.
[0117] Sort the current values sampled in the second half to obtain the second half current sequence (sort_a), and allocate memory space to sort_a. The size of the memory space is the size of the sort_curr structure multiplied by sampling_node_n / 2.
[0118] In an optional implementation, the calculation of EIS can also determine the step voltage. To determine the step voltage, it is necessary to determine whether the voltage values sampled in the first half and the voltage values sampled in the second half meet the step response conditions. In addition, there may be a small number of noise voltage values that need to be eliminated. Therefore, it is necessary to sort the voltage values sampled in the first and second halves and record the position of the voltage value in the original sampled voltage-current pair (volt_curr) sequence before sorting. Therefore, its structure is as follows:
[0119] Struct{
[0120] Double volt;
[0121] Double index;
[0122] }sort_volt;
[0123] Among them, sort_volt is the voltage sequence, volt is the sorted voltage value, and index is its position in the volt_curr sequence when it is not sorted.
[0124] Then, sort the voltage values sampled in the first half and allocate memory space. The size of the memory space is the size of the sort_curr structure multiplied by sampling_node_n / 2.
[0125] Sort the voltage values sampled in the second half and allocate memory space. The size of the memory space is the size of the sort_curr structure multiplied by sampling_node_n / 2.
[0126] Performing the DFT transform will result in a complex value, so its structure is defined as follows:
[0127] Struct{
[0128] Double real;
[0129] Double image;
[0130] }dft_complex;
[0131] Among them, dft_complex is the DFT transformation complex value. Memory space is allocated to the DFT transformation complex value of the sampled voltage. The size of the memory space is the size of the dft_complex structure multiplied by sampling_node_n, and the first address of the memory is assigned to the voltage transformation complex value sequence (complex_volt); memory space is allocated to the DFT transformation complex value of the sampled current. The size of the memory space is the size of the dft_complex structure multiplied by sampling_node_n, and the first address of the memory is assigned to the current transformation complex value sequence (complex_curr). There will be several EIS real impedance values at the calculation frequency when there are several calculation frequencies configured. Therefore, the structure of the final calculation result of EIS is as follows:
[0132] Struct{
[0133] Double real_r;
[0134] unsigned int k;
[0135] }dft_result;
[0136] Among them, dft_result is the real impedance value of EIS at the calculation frequency. A memory space with a size equal to the size of the dft_result structure multiplied by cal_fmhz_num is allocated to it, and its first address is assigned to result.
[0137] In an optional implementation, the final calculation result of the EIS may further include an imaginary impedance value. Similarly, memory space may also be allocated to the imaginary impedance value of the EIS at the calculation frequency.
[0138] It should be noted that the types of the sampling voltage-current pair (samping_volt_curr) structure, the current sequence (sort_curr) structure, the voltage sequence (sort_volt) structure, the DFT transformation complex value (dft_complex) structure and the dft_result real impedance value structure are fixed, so the corresponding structure sizes can be considered to be known.
[0139] (3) Calculate the frequency component corresponding to the target calculation frequency
[0140] In an optional implementation, a frequency component corresponding to a target calculation frequency may be calculated, and at least one calculation frequency includes the target calculation frequency.
[0141] In an optional implementation, calculating the frequency component corresponding to the target calculation frequency may include: calculating the frequency component corresponding to the target calculation frequency based on the target calculation frequency, the total number of sampling points and the sampling frequency, wherein the frequency component corresponding to the target calculation frequency is the target calculation frequency multiplied by the ratio of the total number of sampling points to the sampling frequency.
[0142] In an optional implementation, calculating the battery impedance value according to the discrete transformation values corresponding to the voltage sequence and the current sequence respectively may include: calculating the battery impedance value at the target calculation frequency according to the discrete transformation values corresponding to the voltage sequence and the current sequence respectively, and the frequency components corresponding to the target calculation frequency.
[0143] It is understandable that the k value corresponding to the calculated frequency needs to be initialized. The k value corresponds to the kth frequency component, and its calculation formula is as follows:
[0144] cal_fmhz[i]=sampling_fmhz*k / sampling_node_n;
[0145] Among them, cal_fmhz[i] represents the value of the i-th calculation frequency, sampling_fmhz represents the sampling frequency, and sampling_node_n represents the total number of sampling points.
[0146] Therefore, when i < cal_fmhz_nums, result[i].k = cal_fmhz[i] * sampling_node_n / sampling_fmhz; then i is incremented by 1.
[0147] When i ≥ cal_fmhz_nums, the flag of the EIS calculation thread is initialized. Exemplarily, since EIS requires a step current and it is a stable step current, the current condition for the EIS calculation thread to run is the screen-off state + the charging state. Because the system power consumption is stable in the screen-off state and a step current can only be obtained in the charging state, the states of screen on / off need to be recorded. The screen status (screen_status) = the default screen state (SCREEN_DEFAULT), the charging status (line_status) = the default charging state (CHG_DEFAULT), and the flag for the initial EIS calculation thread to run (thread_run) is set to false. Since some common variable resources need to be protected, a lock used by EIS is set to regulate access to the common resources.
[0148] The following elaborates on step 101 of obtaining multiple voltages and multiple currents of the battery, where multiple voltage values form a voltage sequence and multiple current values form a current sequence, as follows:
[0149] In an alternative implementation, the steps of obtaining multiple voltage values and multiple current values of the battery are performed when the terminal device is in the screen-off state and the charging state.
[0150] (1) Conditions for the EIS calculation thread (eis_cal_thread) to run
[0151] The eis_cal_thread first locks (eis_lock), and then checks the flag of thread_run. It can continue to run only when the flag of thread_run is true. This flag of thread_run is set to true in the screen-off state + the charging state, and set to false in other cases. If the flag of thread_run is false at this time, it indicates that the EIS calculation thread should not be run. At this time, the lock is released (eis_lock), and then the EIS calculation thread enters the waiting queue and waits until it is awakened.
[0152] When the thread_run flag = true, the battery voltage value volt and the battery current value current will be updated first and filled into the sampling voltage and current pair (sampling_volt_curr) structure, and then the front and back halves of the sampling voltage and current pair will be sorted and recorded into the sort_f sequence and sort_a sequence respectively.
[0153] (2) When the status of the LCD module and the charging module changes, the EIS module will be notified
[0154] If the screen is not in the off state (screen is on), screen_status = SCREEN_RESUME (indicating screen is on);
[0155] If the screen is off, screen_status = SCREEN_SUSPEND (indicating screen off);
[0156] If it is in charging state, line_status = CHG_ONLINE (indicating charging);
[0157] If it is in the non-charging state, line_status=CHG_OFFLINE (indicating non-charging).
[0158] Regardless of the status of the LCD module and the charging module, after determining the specific status, the EIS calculation thread is locked, that is, the lock (eis_lock) operation is performed.
[0159] If screen_status = SCREEN_SUSPEND and line_status = CHG_OFFLINE (i.e., screen off state + charging state), the thread_run flag will be judged at this time. If the thread_run flag is equal to false, it means that the EIS calculation thread needs to be awakened and restarted, and the thread_run flag will be reset to true, and the values of the sampled voltage-current pair (volt_curr) sequence will be cleared, the values of the complex_volt sequence of the voltage DFT transformation will be cleared, the values of the complex_curr sequence of the current value DFT transformation will be cleared, the values of the current sequences of the front and rear segments (sort_f and sort_a) will be cleared, and then the number of sampling points (sort_f_nodes) in the first half will be cleared, the number of sampling points (sort_a_nodes) in the second half will be cleared, the number of actual sampling points (sampling_actual_nodes) will be cleared, and then the lock (eis_lock) operation will be performed.
[0160] If it is in the non-screen-off state + non-charging state, screen-off state + non-charging state, or non-screen-off state + charging state, directly set the flag of thread_run to false, and then perform the unlock (eis_lock) operation.
[0161] (3) The number of voltage values included in the voltage sequence corresponds to the total number of sampling points, and the number of current values included in the current sequence corresponds to the total number of sampling points
[0162] Exemplarily, the EIS calculation thread running on hidl will read the battery voltage value (volt) and battery current value (curr) sampled by the ADC from the kernel, and then judge the relationship between the actual total number of sampling points (sampling_actual_nodes) and the configured total number of sampling points (sampling_node_n) at this time.
[0163] If sampling_actual_nodes < sampling_node_n, it means that the sampling is not enough yet. At this time, update the record of the original voltage-current pair sequence volt_curr[sampling_actual_node].volt = volt, while volt_curr[sampling_actual_node].curr = current, and the current value curr_f to be inserted into the first half of the sort_f sequence is curr_f = current; the current value curr_a to be inserted into the second half of the sort_a sequence is curr_a = current; the actual total number of sampling points sampling_actual_nodes is increased by 1.
[0164] If sampling_actual_nodes ≥ sampling_node_n, although the sampling is enough, it is still necessary to update the record of the original voltage-current pair sequence volt_curr[sampling_actual_node].volt = volt, while volt_curr[sampling_actual_node].curr = current, and the current value curr_f inserted into the sort_f sequence is curr_f = volt_curr[sampling_actual_node / 2].curr. Optionally, the current value curr_a inserted into the sort_a sequence is curr_a = current. The sorting process is detailed below.
[0165] If at this time the number of recorded sampling points sort_f_nodes of the first half of the sort_f sequence < sampling_node_n / 2. That is, the memory area of the soft_f sequence has not been filled yet. Then, a new sampled current value should be filled into the sort_f sequence, and record the total number of sampling points of the sort_f sequence with pre_index = sort_f_nodes. If the value of sort_f_nodes is equal to 0, it indicates that the sort_f sequence is empty and has never been updated. Therefore, directly set the curr of the 0th (i.e., soft_f_nodesth) of sort_f to curr_f. The position of this current value in the voltage-current pair (volt_curr) sequence is 0, and then sort_f_nodes is equal to 1.
[0166] That is, all settings are as follows:
[0167] sort_f[sort_f_nodes].curr = curr_f;
[0168] sort_f[sort_f_nodes].index = 0;
[0169] sort_f_nodes = 1.
[0170] If sort_f_nodes is not equal to 0, it indicates that there is already data in the sort_f sequence at this time. However, it is necessary to determine whether sort_f_nodes is less than sampling_node_n / 2. If srot_f_nodes < sampling_node_n / 2, it is necessary to directly add it and perform sorting. First, find the insertion position in the sort_f sequence. That is, when pre_index > 0 and sort_f[pre_index].curr > curr_f, the curr in the sort_f sequence is arranged in ascending order. The elements in the sort_f sequence with curr greater than curr_f need to be moved backward by one, that is, sort_f[pre_index + 1] = sort_f[pre_index]; then the search position is moved forward, that is, pre_index--; and so on until the first position not greater than cuff_f is found. Then make room for pre_index + 1, and curr_f needs to be filled. At the same time, the index of the sort_f sequence increases following sort_f_nodes, that is:
[0171] sort_f[pre_index + 1].curr = curr_f;
[0172] sort_f[pre_index+1].index=sort_f_nodes;
[0173] sort_f_nodes+1.
[0174] At this point, the soft_f sequence completes a data update.
[0175] When soft_nodes = sampling_node_n / 2, it indicates that the sort_f sequence is full. To add a new sampling current value, one of the data in the sort_f sequence needs to be removed and then added. You can set a temporary variable i = sort_f_nodes-1. Then, if sort_f[i].index = 0 (because the sort_f sequence is full, then what needs to be removed is a sampling point of volt_cur recorded at the beginning of the sort_f sequence, and the element with index = 0 in the sort_f sequence corresponding to this sampling point), it indicates that the point to be removed is found, and the position of the point to be removed in the sort_f sequence is recorded record_index = i; and the position curr is set to curr_f, and the index is set to the end of sort_f_nodes-1, and then i-- is executed, that is, the operation record_index = i; sort_f[i].curr = curr_f; sort_f[i].index = sort_f_node-1; i--. If sort_f[i].index! =0, you need to reduce all sort[i].index by 1 (because a new element is inserted, so the original index needs to be reduced by 1).
[0176] When i decreases to less than 0, pre_index = record_index will be set; because an element is inserted, and an element is inserted into an ordered sequence, it is necessary to determine whether to sort to the left or to the right starting from the pre_index position. If pre_index = 0, it means that the first element of the sort_f sequence is inserted, so it needs to be sorted to the right; if sort_f[pre_index].curr>sort_f[pre_index-1].curr, it means that the current value at the insertion position is greater than curr in the previous sort_f sequence, so it also needs to be re-sorted. That is, pre_index = 0, or sort_f[pre_index].curr>sort_f[pre_index-1].curr, it is necessary to sort to the right starting from the pre_index position.
[0177] The specific sorting rule is as follows: when pre_index < (sort_f_nodes - 1), and at the same time sort_f[pre_index + 1].curr < sort_f[pre_index].curr, then swap the values of sort_f[pre_index + 1] and sort_f[pre_index], and set pre_index + 1.
[0178] When pre_index = 0, or when neither sort_f[pre_index].curr > sort_f[pre_index - 1].curr is satisfied, it is necessary to sort from the position of pre_index to the left.
[0179] When pre_index > 0, and at the same time sort_f[pre_index].curr > sort_f[pre_index - 1].curr, then swap the values of sort_f[pre_index] and sort_f[pre_index - 1], and set pre_index - 1.
[0180] Regarding the case where sort_f_nodes = sampling_node_n / 2, at this time the sort_f sequence is full and the sort_a sequence is empty. Then the newly added data needs to be filled into the sort_a sequence and the same sorting process is performed, which is the same as the sort_f sequence processing. It will not be elaborated here, except that sort_f is changed to sort_a and sort_f_nodes is changed to sort_a_nodes.
[0181] When sampling_actual_nodes = sampling_node_n, both the sort_f sequence and the sort_a sequence need to be updated. The newly sampled curr is updated into the sort_a sequence, and the updated value of the sort_f sequence uses the intermediate value in the voltage - current pair (volt_curr), that is, volt_curr[sampling_actual_nodes / 2].curr.
[0182] The following elaborates on step 102. When at least one of the voltage sequence and the current sequence satisfies the step - response condition, a discrete transformation is performed on the voltage values in the voltage sequence and the current values in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively.
[0183] 1. For the current values in the current sequence satisfying the step - response condition
[0184] In an optional implementation, the current sequence includes a first sequence and a second sequence, wherein the first sequence is a first half sequence of the current sequence, and the second sequence is a second half sequence of the current sequence.
[0185] When at least one of the voltage sequence and the current sequence satisfies a step response condition, performing discrete transformation on the voltage value in the voltage sequence and the current value in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively may include: when it is determined that the current value in the current sequence satisfies the step response condition based on the center point current value of the first sequence and the center point current value of the second sequence, performing discrete transformation on the voltage value in the voltage sequence and the current value in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively.
[0186] In an optional implementation, the number of current values included in the current sequence corresponds to the total number of sampling points; when it is determined that the current value in the current sequence satisfies the step response condition according to the center point current value of the first sequence and the center point current value of the second sequence, discrete transformation is performed on the voltage value in the voltage sequence and the current value in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively, which may include: if the following conditions are met, it is determined that the current value of the current sequence satisfies the step response condition, and discrete transformation is performed on the voltage value in the voltage sequence and the current value in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively;
[0187] Condition 1: The difference between the center point current value of the second sequence and the center point current value of the first sequence is greater than or equal to the first current threshold;
[0188] Condition 2: The difference between the current value of the center point of the first sequence and the current value of the first target point of the first sequence is less than the second current threshold; wherein the current value of the first target point is the current value of the position corresponding to the number of noise points in the first sequence, and the number of noise points is calculated based on the total number of sampling points;
[0189] Condition 3: The difference between the current value of the second target point in the first sequence and the current value of the center point in the first sequence is less than the second current threshold; wherein the current value of the second target point is the current value of the position corresponding to the number of currents included in the first sequence minus the number of noise points minus 1;
[0190] Condition 4: The difference between the current value of the center point of the second sequence and the current value of the third target point of the second sequence is less than the second current threshold; wherein the current value of the third target point is the current value of the position corresponding to the number of noise points in the second sequence;
[0191] And, condition 5: the difference between the current value of the fourth target point of the second sequence and the current value of the center point of the second sequence is less than the second current threshold; wherein the current value of the fourth target point is the current value of the position corresponding to the number of currents included in the second sequence minus the number of noise points minus 1;
[0192] Wherein, when the current value in the current sequence increases, the first current threshold is greater than or equal to the second current threshold, and when the current value in the current sequence decreases, the first current threshold is less than or equal to the second current threshold.
[0193] 2. The voltage in the voltage sequence meets the step response condition
[0194] In an optional implementation, the voltage sequence includes a third sequence and a fourth sequence, wherein the third sequence is a first half sequence of the voltage sequence, and the fourth sequence is a second half sequence of the voltage sequence.
[0195] When at least one of the voltage sequence and the current sequence satisfies a step response condition, performing discrete transformation on the voltage value in the voltage sequence and the current value in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively may include: when it is determined that the voltage value in the voltage sequence satisfies the step response condition based on the center point voltage value of the third sequence and the center point voltage value of the fourth sequence, performing discrete transformation on the voltage value in the voltage sequence and the current value in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively.
[0196] In an optional implementation, the number of voltage values included in the voltage sequence corresponds to the total number of sampling points; when it is determined that the voltage values in the voltage sequence meet the step response condition according to the center point voltage value of the third sequence and the center point voltage value of the fourth sequence, discrete transformation is performed on the voltage values in the voltage sequence and the current values in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively, which may include: if the following conditions are met, it is determined that the voltage values of the voltage sequence meet the step response condition, and discrete transformation is performed on the voltage values in the voltage sequence and the current values in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively;
[0197] Condition 1: The difference between the center point voltage value of the fourth sequence and the center point voltage value of the third sequence is greater than or equal to the first voltage threshold;
[0198] Condition 2: The difference between the voltage value of the center point of the third sequence and the voltage value of the first target point of the third sequence is less than the second voltage threshold; wherein the voltage value of the first target point is the voltage value of the position corresponding to the number of noise points in the third sequence, and the number of noise points is calculated based on the total number of sampling points;
[0199] Condition 3: The difference between the voltage value of the second target point of the third sequence and the voltage value of the center point of the third sequence is less than the second voltage threshold; wherein the voltage value of the second target point is the voltage value of the position corresponding to the number of voltages included in the third sequence minus the number of noise points minus 1;
[0200] Condition 4: the difference between the voltage value of the center point of the fourth sequence and the voltage value of the third target point of the fourth sequence is less than the second voltage threshold; wherein the voltage value of the third target point is the voltage value of the position corresponding to the number of noise points in the fourth sequence;
[0201] And, condition 5: the difference between the voltage value of the fourth target point of the fourth sequence and the voltage value of the center point of the fourth sequence is less than the second voltage threshold; wherein the voltage value of the fourth target point is the voltage value of the position corresponding to the number of voltages included in the fourth sequence minus the number of noise points minus 1;
[0202] Wherein, when the voltage value in the voltage sequence increases, the first voltage threshold is greater than or equal to the second voltage threshold, and when the voltage value in the current sequence decreases, the first voltage threshold is less than or equal to the second voltage threshold.
[0203] Exemplarily, the voltage and current values in the sort_f sequence and the sort_a sequence are judged whether they meet the step response conditions. If the step response conditions are met, it can also be judged whether noise compensation is needed. Then, a DFT transform is performed on volt in the sampling voltage and current pair (sampling_volt_curr), and a DFT transform is performed on curr in sampling_volt_curr. Finally, the battery impedance value is calculated using the DFT transformed complex value of volt and the DFT transformed complex value of curr.
[0204] When the step response condition is not met or the DFT-related transformation calculation is completed, the lock (eis_lock) action is executed. Then the time can be delayed, for example, 1 second. The thread 1 second cycle loop runs when the thread_run flag = true is met.
[0205] It can be understood that the current threshold (bal_step_ma) is a threshold for judging whether the current value is stable and balanced. For example, assuming that the current threshold is 100 milliamperes (mA), if the difference between the current values in a current sequence is within 100mA, the current interval in the current sequence is determined to be balanced, and the default value may be 100mA; if the difference between the current values in a current sequence exceeds 100mA, the current interval in the current sequence is determined to be unbalanced.
[0206] Optionally, the number of left and right noise nodes (sidelobe_nodes) of a sorted sequence is calculated as follows:
[0207] sidelobe_nodes=sampling_node_n / Y, where Y is a constant and can be an empirical value.
[0208] Assume that Y is 20 and the total number of sampling points (sampling_node_n) is 40, then the number of noise points sidelobe_nodes = 40 / 20 = 2. f_center_point is equal to half of sort_f_nodes, which is the center point of the sort_f sequence; f_left_points = side_f_nodes, f_left_points belongs to the starting point of the first noise-removed point in the sequence sort_f; f_right_points = sort_f_nodes-sidelobe_nodes-1, f_right_points belongs to the starting point of the last noise-removed point in the sequence sort_f. Similarly, the same preprocessing is performed on the variables related to the sort_a sequence.
[0209] Determine the size of the actual number of sampling points (sampling_actual_node) and the required total number of sampling points (sampling_node_n). If they are less than the actual number of sampling points, it means that the total number of sampling points is insufficient and no DFT transformation is required. If f_center_point-sidelobe_nodes<a specific threshold (for example, 5), or a_center_point-sidelobe_nodes<a specific threshold (for example, 5), it means that the noise point position of the sort_f sequence or the sort_a sequence is too close to the center point position and no DFT transformation is performed.
[0210] If sort[f_center_point].curr - 300 > sort[a_center_point].curr, that is, the center point curr of the sort_f sequence is more than 300 mA greater than the center point curr of the sort_a sequence, it proves that there is a relatively large current value drop before and after, and then further judgment is required. The test needs to judge the magnitude relationship between the current value at the noise point position and the current value at the center point. If the current value at the center point of the sort_f sequence is less than 100 mA compared to the current value at the f_left_points position on the left, and the current value at the f_right_points position on the right of the sort_f sequence is less than 100 mA compared to the current value at the center point, and the current value at the center point of the sort_a sequence is less than 100 mA compared to the current value at the a_left_points position on the left, and the current value at the a_right_point position on the right of the sort_a sequence is less than 100 mA compared to the current value at the center point (where sort_f and sort_a are both ordered increasing sequences, and the value on the left is smaller than the value on the right), that is:
[0211] sort[f_center_point].curr - sort[f_left_point].curr < bal_step_ma, and at the same time
[0212] sort[f_right_point].curr - sort[f_center_point].curr < bal_step_ma, and at the same time
[0213] sort[a_center_point].curr - sort[a_left_point].curr < bal_step_ma, and at the same time
[0214] sort[a_right_point].curr - sort[a_center_point].curr < bal_step_ma.
[0215] If satisfied, DFT transformation needs to be performed. If not satisfied, it indicates that the current value is unstable and fluctuates greatly at this time, and it is not suitable for DFT transformation. However, the actual situation is not perfect, and there are always a few points with large fluctuations. Therefore, compensation processing for noise points is required. To enter the function for judging whether noise points need compensation, the compensate_volt_curr function is uniformly used. This function has 4 parameters:
[0216] sidelobe_nodes: the number of noise points (such as 2);
[0217] start_index: the starting position of the noise point judgment sequence (for example, 0 or f_right_point+1=17+1=18, for example, 0 or a_right_point+1=17+1=18);
[0218] compare_curr: compare the noise point current value with the current threshold to determine whether it is a noise point (center point current value sort_f[f_center_point].curr or sort_a[a_center_point].curr);
[0219] handle_point: the sequence position where the noise point does not need to be actually processed (for sort_f, the noise point on the left needs to be processed, and for sort_a, the noise point on the right needs to be processed);
[0220] sort_part: A sequence flag indicating which part is being processed (equal to sort_f_flag or sort_a_flag).
[0221] The noise processing enters the compensate_volt_curr function. First, it determines whether the current sort_part belongs to sort_f_flag or sort_a_flag. If sort_part is equal to sort_f_flag, the sort pointer is set to point to the sort_f memory area, and the sort_nodes variable is equal to sort_f_nodes; if sort_part is equal to sort_a_flag, the sort pointer is set to point to the sort_a memory area, and the sort_nodes variable is equal to sort_a_nodes; then it is determined whether the start_index of the noise point is equal to 0. If it is equal to 0, it means that the noise point on the left side of the sort sequence is judged. At this time, the replacement element is eplace=sort[sidelobe_nodes]. For example, start_index=0, sidelobe_nodes=2, then replace=sort[2]. The noise point judgment position is sort[0] and sort[1]. If sort[0] or sort[1] does not meet the requirements, the current value of sort[2] is used for compensation and replacement. There needs to be an index structure with two elements, one is the source_index of curr in the sort sequence in the volt_curr sequence, and the sort_index sequence in this sort sequence, as shown below:
[0222] Structure {
[0223] Source_index;
[0224] Sort_index;
[0225] }eis_index;
[0226] Allocate memory space of the structure type with the size of eis_index multiplied by sidelobe_nodes for tmp_record and clear it. Set i = start_index, and initially set the number of detected noise points (len) to 0. Poll and judge each noise point. If i < (start_index + sidelobe_nodes), and if Fabs(sort[i].curr - compare_cur) < 100mA, that is, the difference between the current value of this noise point and the comparison current is within 100mA, it means it is not a noise point. If not satisfied, this noise point needs to be recorded.
[0227] tmp_record[len].source_index = sort[i].index;
[0228] tmp_record[len].sort_index = i;
[0229] Increment the number of recorded points by 1, i.e., len++, and after all judgments are completed, i will be reset to 0 again; then judge and compensate each element in tmp_record. When i < len, if
[0230] (sort_part = sort_f_flag and tmp_record[i].source_index > handle_point), or, (sort_part = sort_a_flag and tmp_record[i].source_index < handle_point), that is, the points within sidelobe_nodes before and after the center point of volt_curr in the original sequence are not processed. They belong to the step current drop part points and are not processed for noise. If not satisfied, noise processing is required. Judge whether sort_part belongs to sort_a_flag. If it does, then temp_record[i].cource_index and replace_curr.index need to be offset by sort_a_nodes;
[0231] Remove the noise data in the volt_curr sequence and update the sort sequence:
[0232] volt_curr[tmp_record[i].source_index].curr=volt_curr[index].curr;
[0233] volt_curr[tmp_record[i].source_index].volt=volt_curr[index].volt;
[0234] sort[tmp_record[i].sort_index].curr=volt_curr[index].curr;
[0235] Since the sort data is updated by one, the sort sequence needs to be re-sorted; then i++ is executed to process each element in tmp_record until i=len.
[0236] sort_f and sort_a process the noise points respectively, so the compensate_volt_curr function needs to be called four times:
[0237] compensate_volt_curr(sidelobe_nodes,0,sort_f[f_center_point].curr,f_right_point,sort_f_flag);
[0238] compensate_volt_curr(sidelobe_nodes,f_right_point+1,sort_f[f_center_point].curr,f_right_point,sort_f_flag);
[0239] compensate_volt_curr(sidelobe_nodes,0,sort_a[a_center_point].curr,a_left_point,sort_a_flag);
[0240] compensate_volt_curr(sidelobe_nodes,a_right_point+1,sort_f[f_center_point].curr,a_left_point,sort_a_flag).
[0241] 3. Perform discrete transformation on the voltage values in the voltage sequence and the current values in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively.
[0242] Exemplarily, calculate the memory area to store the complex values of the volt DFT transform, that is, clear the memory area with the starting address complex_volt; it is also necessary to calculate the memory area to store the complex values of the curr DFT transform, that is, clear the memory area with the starting address complex_curr. Then set the initial value of k to 0, and then determine whether k is less than sampling_node_n. If k < sampling_node_n, then initialize the variable n = 0; then determine whether n is less than sampling_node_n. When n < sampling_node_n, perform the DFT transform at k to obtain the complex transform value, that is
[0243] complex_volt[k].real += volt_curr[n].volt * cos((2 * π * k * n) / sampling_node_n);
[0244] complex_volt[k].image += volt_curr[n].volt * sin((2 * π * k * n) / sampling_node_n) * (-1);
[0245] complex_curr[k].real += volt_curr[n].curr * cos((2 * π * k * n) / sampling_node_n);
[0246] complex_curr[k].image += volt_curr[n].curr * sin((2 * π * k * n) / sampling_node_n) * (-1).
[0247] Calculate the real and imaginary parts of volt at k respectively, and then let n + 1 and continue to loop the above process until n = sampling_node_n. At this time, it is necessary to calculate the impedance at other k values, so set k = k + 1, and continue to determine whether k is less than sampling_node_n, then repeat the above calculation process until k = sampling_node_n. At this time, the DFT transform of volt at all k values is okay, and a sequence of voltage transform complex values (complex_volt) is obtained. Then perform the DFT transform of the current in the same way to obtain a sequence of current transform complex values (complex_curr).
[0248] The following expands and explains the calculation of the battery impedance value according to the discrete transform values corresponding to the voltage sequence and the current sequence in step 103, as follows:
[0249] The impedance value of k corresponding to each calculated frequency can be obtained using complex_volt and complex_curr. Set the initial variable i = 0, and then determine whether i is less than the number of calculated frequency cal_fmhz_nums. When i ≥ cal_fmhz_nums, the operation ends; when i < cal_fmhz_nums, the impedance value at the corresponding k is calculated using this formula.
[0250] result[i].real_r = ((*(complex_volt + result[i].k)).real *
[0251] (*(complex_curr + result[i].k)).real +
[0252] (*(complex_volt + result[i].k)).image *
[0253] (*(complex_curr + result[i].k)).image) /
[0254] (EIS_SQUARE((*(complex_curr + result[i].k)).real) +
[0255] EIS_SQUARE((*(complex_curr + result[i].k)).image));
[0256] result[i].image_r = ((*(complex_volt + result[i].k)).image *
[0257] (*(complex_curr + result[i].k)).real -
[0258] (*(complex_volt + result[i].k)).real *
[0259] (*(complex_curr + result[i].k)).image) /
[0260] (EIS_SQUARE((*(complex_curr + result[i].k)).real) +
[0261] EIS_SQUARE((*(complex_curr + result[i].k)).image));
[0262] i++, then determine whether i is less than the calculated frequency number cal_fmhz_nums, and proceed to the subsequent steps.
[0263] Among them, (*(complex_curr+result[i].k) refers to the element of the complex_curr sequence offset by result[i].k; (*(complex_volt+result[i].k) refers to the element of the complex_volt sequence offset by result[i].k; EIS_SQUARE is to find the square of a certain value. It can be understood that the real part of (a+bj) / (c+dj) is (ac+bd) / (c*c+d*d). So far, the impedance value at each calculation frequency can be obtained.
[0264] It should be noted that the embodiment of the present application can update the data of the power meter once every 1s, and the EIS calculation thread polls the sampled data once every 1s, which is applicable to sampling frequencies of 1 Hz (Hz) and lower, and is also applicable to higher sampling frequencies.
[0265] It is understandable that the technical solution of this application implements EIS impedance spectrum analysis on the terminal device platform. Dynamically configurable parameters, judgment of step response conditions, noise compensation, EIS calculation threads and other contents can be integrated to accurately calculate the battery impedance value, which can be used to predict the degree of battery aging and thus determine the health status of the battery. This provides a basis for subsequent prediction of battery aging, prevention of battery lithium deposition and other related functions. Moreover, the technical solution of this application is highly scalable because the configuration file can be modified.
[0266] like Figure 3 FIG. 1 is a schematic diagram of an embodiment of a device for calculating a battery impedance value in an embodiment of the present application. The device is applied to a terminal device, and the terminal device includes a battery. The device may include:
[0267] An acquisition module 301 is used to acquire multiple voltage values and multiple current values of a battery, where the multiple voltage values constitute a voltage sequence and the multiple current values constitute a current sequence;
[0268] A discrete transformation module 302 is used to perform discrete transformation on the voltage value in the voltage sequence and the current value in the current sequence when at least one of the voltage sequence and the current sequence meets the step response condition, so as to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively;
[0269] The calculation module 303 is used to calculate the battery impedance value according to the discrete transformation values corresponding to the voltage sequence and the current sequence respectively.
[0270] Optionally, the current sequence includes a first sequence and a second sequence, wherein the first sequence is the first half sequence of the current sequence, and the second sequence is the second half sequence of the current sequence; the discrete transformation module 302 is specifically used to perform discrete transformation on the voltage value in the voltage sequence and the current value in the current sequence when it is determined that the current value in the current sequence meets the step response condition based on the center point current value of the first sequence and the center point current value of the second sequence, so as to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively; and / or,
[0271] The voltage sequence includes a third sequence and a fourth sequence, wherein the third sequence is the first half sequence of the voltage sequence and the fourth sequence is the second half sequence of the voltage sequence; the discrete transformation module 302 is specifically used to perform discrete transformation on the voltage values in the voltage sequence and the current values in the current sequence when it is determined that the voltage values in the voltage sequence meet the step response conditions based on the center point voltage values of the third sequence and the center point voltage values of the fourth sequence, so as to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively.
[0272] Optionally, the number of current values included in the current sequence corresponds to the total number of sampling points; a discrete transformation module 302 is specifically used to determine that the current value of the current sequence satisfies the step response condition if the following conditions are met, and to perform discrete transformation on the voltage values in the voltage sequence and the current values in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively;
[0273] The difference between the central point current value of the second sequence and the central point current value of the first sequence is greater than or equal to the first current threshold;
[0274] The difference between the current value of the center point of the first sequence and the current value of the first target point of the first sequence is less than the second current threshold; wherein the current value of the first target point is the current value of the position corresponding to the number of noise points in the first sequence, and the number of noise points is calculated based on the total number of sampling points;
[0275] The difference between the current value of the second target point of the first sequence and the current value of the center point of the first sequence is less than the second current threshold; wherein the current value of the second target point is the current value of the position corresponding to the number of currents included in the first sequence minus the number of noise points minus 1;
[0276] The difference between the current value at the center point of the second sequence and the current value at the third target point of the second sequence is less than the second current threshold; wherein the current value at the third target point is the current value at the position corresponding to the number of noise points in the second sequence;
[0277] And, the difference between the current value of the fourth target point of the second sequence and the current value of the center point of the second sequence is less than the second current threshold; wherein the current value of the fourth target point is the current value of the position corresponding to the number of currents included in the second sequence minus the number of noise points minus 1;
[0278] Wherein, when the current value in the current sequence increases, the first current threshold is greater than or equal to the second current threshold, and when the current value in the current sequence decreases, the first current threshold is less than or equal to the second current threshold.
[0279] Optionally, the number of voltage values included in the voltage sequence corresponds to the total number of sampling points; a discrete transformation module 302 is specifically used to determine that the voltage value of the voltage sequence satisfies the step response condition if the following conditions are met, and to perform discrete transformation on the voltage value in the voltage sequence and the current value in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively;
[0280] A difference between a center point voltage value of the fourth sequence and a center point voltage value of the third sequence is greater than or equal to a first voltage threshold;
[0281] The difference between the center point voltage value of the third sequence and the first target point voltage value of the third sequence is less than the second voltage threshold; wherein the first target point voltage value is the voltage value of the position corresponding to the number of noise points in the third sequence, and the number of noise points is calculated based on the total number of sampling points;
[0282] The difference between the voltage value of the second target point of the third sequence and the voltage value of the center point of the third sequence is less than the second voltage threshold; wherein the voltage value of the second target point is the voltage value of the position corresponding to the number of voltages included in the third sequence minus the number of noise points minus 1;
[0283] The difference between the center point voltage value of the fourth sequence and the third target point voltage value of the fourth sequence is less than the second voltage threshold; wherein the third target point voltage value is the voltage value of the position corresponding to the number of noise points in the fourth sequence;
[0284] And, the difference between the voltage value of the fourth target point of the fourth sequence and the voltage value of the center point of the fourth sequence is less than the second voltage threshold; wherein the voltage value of the fourth target point is the voltage value of the position corresponding to the number of voltages included in the fourth sequence minus the number of noise points minus 1;
[0285] Wherein, when the voltage value in the voltage sequence increases, the first voltage threshold is greater than or equal to the second voltage threshold, and when the voltage value in the current sequence decreases, the first voltage threshold is less than or equal to the second voltage threshold.
[0286] Optionally, the discrete transformation module 302 is specifically used to determine whether to perform noise compensation on the voltage values in the voltage sequence and the current values in the current sequence when at least one of the voltage sequence and the current sequence meets the step response condition; when noise compensation is performed on the voltage values in the voltage sequence and the current values in the current sequence, perform discrete transformation on the voltage values in the voltage sequence and the current values in the current sequence after noise compensation to obtain discrete transformation values corresponding to the voltage sequence and the current sequence, respectively.
[0287] Optionally, the discrete transformation module 302 is specifically used to determine to compensate for the fifth target point current value when the difference between the center point current value of the first sequence and the fifth target point current value of the first sequence is greater than or equal to a second current threshold, wherein the fifth target point current value is the current value before the first target point position in the first sequence; to determine to compensate for the sixth target point current value when the difference between the sixth target point current value of the second sequence and the center point current value of the second sequence is greater than or equal to the second current threshold, wherein the sixth target point current value is the current value after the fourth target point position in the second sequence; and to perform discrete transformation on the voltage values in the voltage sequence and the current values in the current sequence after noise compensation to obtain discrete transformation values corresponding to the voltage sequence and the current sequence, respectively.
[0288] Optionally, the discrete transformation module 302 is specifically used to determine to compensate for the fifth target point voltage value when the difference between the center point voltage value of the third sequence and the fifth target point voltage value of the third sequence is greater than or equal to a second voltage threshold, wherein the fifth target point voltage value is the voltage value before the first target point position in the third sequence; to determine to compensate for the sixth target point voltage value when the difference between the sixth target point voltage value of the fourth sequence and the center point voltage value of the fourth sequence is greater than or equal to the second voltage threshold, wherein the sixth target point voltage value is the voltage value after the fourth target point position in the fourth sequence; and to perform discrete transformation on the voltage values in the voltage sequence and the current values in the current sequence after noise compensation to obtain discrete transformation values corresponding to the voltage sequence and the current sequence, respectively.
[0289] Optionally, the device may include: a parsing module, configured to parse a configuration file of the battery EIS to obtain a sampling frequency, a number of calculation frequencies, and at least one calculation frequency;
[0290] The calculation module 303 is further configured to calculate the total number of sampling points according to the minimum calculation frequency of at least one calculation frequency and the sampling frequency.
[0291] Optionally, the total number of sampling points is equal to the product of the sampling frequency and the minimum calculation frequency.
[0292] Optionally, the acquisition module 301 is specifically used to execute the steps of acquiring multiple voltage values and multiple current values of the battery when the terminal device is in a screen-off state and a charging state.
[0293] Optionally, the calculation module 303 is also used to calculate the frequency components corresponding to the target calculation frequency, and at least one calculation frequency includes the target calculation frequency; it is specifically used to calculate the battery impedance value at the target calculation frequency based on the discrete transformation values corresponding to the voltage sequence and the current sequence, respectively, and the frequency components corresponding to the target calculation frequency.
[0294] Optionally, the calculation module 303 is specifically used to calculate the frequency component corresponding to the target calculation frequency according to the target calculation frequency, the total number of sampling points and the sampling frequency, wherein the frequency component corresponding to the target calculation frequency is the target calculation frequency multiplied by the ratio of the total number of sampling points to the sampling frequency.
[0295] Optionally, the device may further include: a determination module, configured to determine the battery aging degree according to the battery impedance value, wherein the battery impedance value is positively correlated with the battery aging degree.
[0296] like Figure 4 As shown, it is a schematic diagram of an embodiment of a terminal device in an embodiment of the present application, and the terminal device includes a battery and Figure 3 The device for calculating the battery impedance value is shown.
[0297] like Figure 5 FIG. 1 is a schematic diagram of another embodiment of a terminal device in an embodiment of the present application. It may include:
[0298] Combine the following Figure 5 The following is a detailed introduction to the various components of the mobile phone in the terminal device:
[0299] The RF circuit 510 can be used for receiving and sending signals during information transmission or calls. In particular, after receiving the downlink information of the base station, it is sent to the processor 580 for processing; in addition, the designed uplink data is sent to the base station. Generally, the RF circuit 510 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (Low Noise Amplifier, LNA), a duplexer, etc. In addition, the RF circuit 510 can also communicate with the network and other devices through wireless communication. The above wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile communication (Global System of Mobile communication, GSM), General Packet Radio Service (General Packet Radio Service, GPRS), Code Division Multiple Access (Code Division Multiple Access, CDMA), Wideband Code Division Multiple Access (Wideband Code Division Multiple Access, WCDMA), Long Term Evolution (Long Term Evolution, LTE), email, Short Messaging Service (SMS), etc.
[0300] The memory 520 can be used to store software programs and modules. The processor 580 executes various functional applications and data processing of the mobile phone by running the software programs and modules stored in the memory 520. The memory 520 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 520 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0301] The input unit 530 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the mobile phone. Specifically, the input unit 530 may include a touch panel 531 and other input devices 532. The touch panel 531, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 531 or near the touch panel 531 using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch panel 531 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it to the processor 580, and can receive and execute commands sent by the processor 580. In addition, the touch panel 531 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 531, the input unit 530 may also include other input devices 532. Specifically, other input devices 532 may include but are not limited to one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, etc.
[0302] The display unit 540 can be used to display information input by the user or information provided to the user and various menus of the mobile phone. The display unit 540 may include a display panel 541. Optionally, the display panel 541 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. Further, the touch panel 531 may cover the display panel 541. When the touch panel 531 detects a touch operation on or near it, it is transmitted to the processor 580 to determine the type of touch event. Subsequently, the processor 580 provides a corresponding visual output on the display panel 541 according to the type of touch event. Although in Figure 5 In the embodiment, the touch panel 531 and the display panel 541 are used as two independent components to realize the input and output functions of the mobile phone, but in some embodiments, the touch panel 531 and the display panel 541 can be integrated to realize the input and output functions of the mobile phone.
[0303] The mobile phone may also include at least one sensor 550, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 541 according to the brightness of the ambient light, and the proximity sensor may turn off the display panel 541 and / or the backlight when the mobile phone is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors that can be configured in the mobile phone, such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., they will not be repeated here.
[0304] The audio circuit 560, the speaker 561, and the microphone 562 can provide an audio interface between the user and the mobile phone. The audio circuit 560 can transmit the received audio data to the speaker 561 after converting the received audio data into an electrical signal, which is converted into a sound signal for output; on the other hand, the microphone 562 converts the collected sound signal into an electrical signal, which is received by the audio circuit 560 and converted into audio data, and then the audio data is output to the processor 580 for processing, and then sent to another mobile phone through the RF circuit 510, or the audio data is output to the memory 520 for further processing.
[0305] Wi-Fi is a short-range wireless transmission technology. The mobile phone can help users send and receive emails, browse web pages and access streaming media through the Wi-Fi module 570, which provides users with wireless broadband Internet access. Figure 5A Wi-Fi module 570 is shown, but it is understandable that it is not an essential component of the mobile phone and can be omitted as needed without changing the essence of the invention.
[0306] The processor 580 is the control center of the mobile phone. It uses various interfaces and lines to connect various parts of the entire mobile phone. By running or executing software programs and / or modules stored in the memory 520, and calling data stored in the memory 520, it executes various functions of the mobile phone and processes data, thereby monitoring the mobile phone as a whole. Optionally, the processor 580 may include one or more processing units; preferably, the processor 580 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 580.
[0307] The mobile phone also includes a power source 590 (such as a battery) for supplying power to various components. Preferably, the power source can be logically connected to the processor 580 through a power management system, so that the power management system can manage charging, discharging, power consumption and other functions.
[0308] Although not shown, the mobile phone may also include a camera, a Bluetooth module, etc., which will not be described in detail here.
[0309] In an embodiment of the present application, the processor 580 is used to obtain multiple voltage values and multiple current values of the battery, the multiple voltage values constitute a voltage sequence and the multiple current values constitute a current sequence; when at least one of the voltage sequence and the current sequence meets the step response condition, a discrete transformation is performed on the voltage value in the voltage sequence and the current value in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively; the battery impedance value is calculated according to the discrete transformation values corresponding to the voltage sequence and the current sequence respectively.
[0310] Optionally, the current sequence includes a first sequence and a second sequence, wherein the first sequence is a first half sequence of the current sequence, and the second sequence is a second half sequence of the current sequence; the processor 580 is specifically configured to, when it is determined that the current value in the current sequence satisfies a step response condition based on the center point current value of the first sequence and the center point current value of the second sequence, perform discrete transformation on the voltage value in the voltage sequence and the current value in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively; and / or,
[0311] The voltage sequence includes a third sequence and a fourth sequence, wherein the third sequence is the first half sequence of the voltage sequence and the fourth sequence is the second half sequence of the voltage sequence; the processor 580 is specifically used to perform discrete transformation on the voltage values in the voltage sequence and the current values in the current sequence when it is determined that the voltage values in the voltage sequence meet the step response conditions based on the center point voltage value of the third sequence and the center point voltage value of the fourth sequence, so as to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively.
[0312] Optionally, the number of current values included in the current sequence corresponds to the total number of sampling points; the processor 580 is specifically configured to determine that the current value of the current sequence satisfies the step response condition if the following conditions are met, and to perform discrete transformation on the voltage values in the voltage sequence and the current values in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively;
[0313] The difference between the central point current value of the second sequence and the central point current value of the first sequence is greater than or equal to the first current threshold;
[0314] The difference between the current value of the center point of the first sequence and the current value of the first target point of the first sequence is less than the second current threshold; wherein the current value of the first target point is the current value of the position corresponding to the number of noise points in the first sequence, and the number of noise points is calculated based on the total number of sampling points;
[0315] The difference between the current value of the second target point of the first sequence and the current value of the center point of the first sequence is less than the second current threshold; wherein the current value of the second target point is the current value of the position corresponding to the number of currents included in the first sequence minus the number of noise points minus 1;
[0316] The difference between the current value at the center point of the second sequence and the current value at the third target point of the second sequence is less than the second current threshold; wherein the current value at the third target point is the current value at the position corresponding to the number of noise points in the second sequence;
[0317] And, the difference between the current value of the fourth target point of the second sequence and the current value of the center point of the second sequence is less than the second current threshold; wherein the current value of the fourth target point is the current value of the position corresponding to the number of currents included in the second sequence minus the number of noise points minus 1;
[0318] Wherein, when the current value in the current sequence increases, the first current threshold is greater than or equal to the second current threshold, and when the current value in the current sequence decreases, the first current threshold is less than or equal to the second current threshold.
[0319] Optionally, the number of voltage values included in the voltage sequence corresponds to the total number of sampling points; the processor 580 is specifically configured to determine that the voltage value of the voltage sequence satisfies the step response condition if the following conditions are met, and to perform discrete transformation on the voltage value in the voltage sequence and the current value in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively;
[0320] A difference between a center point voltage value of the fourth sequence and a center point voltage value of the third sequence is greater than or equal to a first voltage threshold;
[0321] The difference between the center point voltage value of the third sequence and the first target point voltage value of the third sequence is less than the second voltage threshold; wherein the first target point voltage value is the voltage value of the position corresponding to the number of noise points in the third sequence, and the number of noise points is calculated based on the total number of sampling points;
[0322] The difference between the voltage value of the second target point of the third sequence and the voltage value of the center point of the third sequence is less than the second voltage threshold; wherein the voltage value of the second target point is the voltage value of the position corresponding to the number of voltages included in the third sequence minus the number of noise points minus 1;
[0323] The difference between the center point voltage value of the fourth sequence and the third target point voltage value of the fourth sequence is less than the second voltage threshold; wherein the third target point voltage value is the voltage value of the position corresponding to the number of noise points in the fourth sequence;
[0324] And, the difference between the voltage value of the fourth target point of the fourth sequence and the voltage value of the center point of the fourth sequence is less than the second voltage threshold; wherein the voltage value of the fourth target point is the voltage value of the position corresponding to the number of voltages included in the fourth sequence minus the number of noise points minus 1;
[0325] Wherein, when the voltage value in the voltage sequence increases, the first voltage threshold is greater than or equal to the second voltage threshold, and when the voltage value in the current sequence decreases, the first voltage threshold is less than or equal to the second voltage threshold.
[0326] Optionally, the processor 580 is specifically used to determine whether to perform noise compensation on the voltage values in the voltage sequence and the current values in the current sequence when at least one of the voltage sequence and the current sequence meets the step response condition; when noise compensation is performed on the voltage values in the voltage sequence and the current values in the current sequence, perform discrete transformation on the voltage values in the voltage sequence and the current values in the current sequence after noise compensation to obtain discrete transformation values corresponding to the voltage sequence and the current sequence, respectively.
[0327] Optionally, the processor 580 is specifically used to determine to compensate for the fifth target point current value when the difference between the center point current value of the first sequence and the fifth target point current value of the first sequence is greater than or equal to a second current threshold, wherein the fifth target point current value is the current value before the first target point position in the first sequence; determine to compensate for the sixth target point current value when the difference between the sixth target point current value of the second sequence and the center point current value of the second sequence is greater than or equal to the second current threshold, wherein the sixth target point current value is the current value after the fourth target point position in the second sequence; and perform discrete transformation on the voltage values in the voltage sequence and the current values in the current sequence after noise compensation to obtain discrete transformation values corresponding to the voltage sequence and the current sequence, respectively.
[0328] Optionally, the processor 580 is specifically used to determine to compensate for the fifth target point voltage value when the difference between the center point voltage value of the third sequence and the fifth target point voltage value of the third sequence is greater than or equal to a second voltage threshold, wherein the fifth target point voltage value is the voltage value before the first target point position in the third sequence; determine to compensate for the sixth target point voltage value when the difference between the sixth target point voltage value of the fourth sequence and the center point voltage value of the fourth sequence is greater than or equal to the second voltage threshold, wherein the sixth target point voltage value is the voltage value after the fourth target point position in the fourth sequence; and perform discrete transformation on the voltage values in the voltage sequence and the current values in the current sequence after noise compensation to obtain discrete transformation values corresponding to the voltage sequence and the current sequence, respectively.
[0329] Optionally, the processor 580 is used to parse the configuration file of the battery EIS to obtain the sampling frequency, the number of calculation frequencies, and at least one calculation frequency; and calculate the total number of sampling points based on the minimum calculation frequency and the sampling frequency among the at least one calculation frequency.
[0330] Optionally, the total number of sampling points is equal to the product of the sampling frequency and the minimum calculation frequency.
[0331] Optionally, the processor 580 is specifically configured to execute the step of acquiring a voltage sequence and a current sequence of the battery according to a total number of sampling points when the terminal device is in a screen-off state and a charging state.
[0332] Optionally, the processor 580 is also used to calculate the frequency components corresponding to the target calculation frequency, and at least one calculation frequency includes the target calculation frequency; specifically, it is used to calculate the battery impedance value at the target calculation frequency according to the discrete transformation values corresponding to the voltage sequence and the current sequence, respectively, and the frequency components corresponding to the target calculation frequency.
[0333] Optionally, the processor 580 is specifically used to calculate the frequency component corresponding to the target calculation frequency based on the target calculation frequency, the total number of sampling points and the sampling frequency, wherein the frequency component corresponding to the target calculation frequency is the target calculation frequency multiplied by the ratio of the total number of sampling points to the sampling frequency.
[0334] Optionally, the processor 580 is used to determine the battery aging degree according to the battery impedance value, and the battery impedance value is positively correlated with the battery aging degree.
[0335] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (Digital Subscriber Line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a server, data center, etc. that contains one or more available media integrated. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD), or a semiconductor medium (eg, a solid state disk (SSD)).
[0336] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0337] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0338] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0339] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0340] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk.
[0341] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for calculating a battery impedance value, characterized in that: The method is applied to a terminal device, the terminal device includes a battery, and the method includes: Acquire a plurality of voltage values and a plurality of current values of the battery, wherein the plurality of voltage values constitute a voltage sequence and the plurality of current values constitute a current sequence; When at least one of the voltage sequence and the current sequence satisfies a step response condition, performing discrete transformation on a voltage value in the voltage sequence and a current value in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively; The battery impedance value is calculated according to the discrete transformation values corresponding to the voltage sequence and the current sequence respectively.
2. The method according to claim 1, characterized in that The current sequence includes a first sequence and a second sequence, wherein the first sequence is the first half sequence of the current sequence, and the second sequence is the second half sequence of the current sequence; the voltage sequence includes a third sequence and a fourth sequence, wherein the third sequence is the first half sequence of the voltage sequence, and the fourth sequence is the second half sequence of the voltage sequence; When at least one of the voltage sequence and the current sequence satisfies a step response condition, performing discrete transformation on the voltage value in the voltage sequence and the current value in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively includes: When it is determined that the current value in the current sequence satisfies a step response condition according to the center point current value of the first sequence and the center point current value of the second sequence, performing discrete transformation on the voltage value in the voltage sequence and the current value in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively; and / or, When it is determined that the voltage values in the voltage sequence meet the step response condition based on the center point voltage value of the third sequence and the center point voltage value of the fourth sequence, discrete transformation is performed on the voltage values in the voltage sequence and the current values in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively.
3. The method according to claim 2, characterized in that The number of current values included in the current sequence corresponds to the total number of sampling points; The method of performing discrete transformation on the voltage values in the voltage sequence and the current values in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively, when it is determined that the current values in the current sequence meet the step response condition according to the center point current value of the first sequence and the center point current value of the second sequence, comprises: If the following conditions are met, it is determined that the current value of the current sequence meets the step response condition, and discrete transformation is performed on the voltage values in the voltage sequence and the current values in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively; A difference between a central point current value of the second sequence and a central point current value of the first sequence is greater than or equal to a first current threshold; The difference between the current value at the center point of the first sequence and the current value at the first target point of the first sequence is less than the second current threshold; wherein the current value at the first target point is the current value at the position corresponding to the number of noise points in the first sequence, and the number of noise points is calculated based on the total number of sampling points; The difference between the current value of the second target point of the first sequence and the current value of the center point of the first sequence is less than the second current threshold; wherein the current value of the second target point is the current value of the position corresponding to the number of currents included in the first sequence minus the number of noise points minus 1; The difference between the current value at the center point of the second sequence and the current value at the third target point of the second sequence is less than the second current threshold; wherein the current value at the third target point is the current value at the position corresponding to the number of noise points in the second sequence; And, the difference between the current value of the fourth target point of the second sequence and the current value of the center point of the second sequence is less than the second current threshold; wherein the current value of the fourth target point is the current value of the position corresponding to the number of currents included in the second sequence minus the number of noise points minus 1; Wherein, when the current value in the current sequence increases, the first current threshold is greater than or equal to the second current threshold, and when the current value in the current sequence decreases, the first current threshold is less than or equal to the second current threshold.
4. The method according to claim 3, characterized in that The number of voltage values included in the voltage sequence corresponds to the total number of sampling points; The method of performing discrete transformation on the voltage values in the voltage sequence and the current values in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively, when it is determined that the voltage values in the voltage sequence meet the step response condition according to the center point voltage values of the third sequence and the center point voltage values of the fourth sequence, comprises: If the following conditions are met, it is determined that the voltage value of the voltage sequence meets the step response condition, and discrete transformation is performed on the voltage value in the voltage sequence and the current value in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively; The difference between the center point voltage value of the fourth sequence and the center point voltage value of the third sequence is greater than or equal to the first voltage threshold; The difference between the center point voltage value of the third sequence and the first target point voltage value of the third sequence is less than the second voltage threshold; wherein the first target point voltage value is the voltage value of the position corresponding to the number of noise points in the third sequence, and the number of noise points is calculated according to the total number of sampling points; The difference between the voltage value of the second target point of the third sequence and the voltage value of the center point of the third sequence is less than the second voltage threshold; wherein the voltage value of the second target point is the voltage value of the position corresponding to the number of voltages included in the third sequence minus the number of noise points minus 1; The difference between the center point voltage value of the fourth sequence and the third target point voltage value of the fourth sequence is less than the second voltage threshold; wherein the third target point voltage value is the voltage value of the position corresponding to the number of noise points in the fourth sequence; and a difference between a fourth target point voltage value of the fourth sequence and a center point voltage value of the fourth sequence is less than the second voltage threshold; wherein the fourth target point voltage value is a voltage value at a position corresponding to the number of voltages included in the fourth sequence minus the number of noise points minus 1; Wherein, when the voltage value in the voltage sequence increases, the first voltage threshold is greater than or equal to the second voltage threshold, and when the voltage value in the current sequence decreases, the first voltage threshold is less than or equal to the second voltage threshold.
5. The method according to any one of claims 2 to 4, characterized in that: When at least one of the voltage sequence and the current sequence satisfies a step response condition, performing discrete transformation on the voltage value in the voltage sequence and the current value in the current sequence to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively includes: When at least one of the voltage sequence and the current sequence meets a step response condition, determining whether to perform noise compensation on the voltage value in the voltage sequence and the current value in the current sequence; When noise compensation is performed on the voltage values in the voltage sequence and the current values in the current sequence, discrete transformation is performed on the voltage values in the voltage sequence and the current values in the current sequence after noise compensation to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively.
6. The method according to claim 5, characterized in that In the case of performing noise compensation on the voltage values in the voltage sequence and the current values in the current sequence, performing discrete transformation on the voltage values in the voltage sequence and the current values in the current sequence after noise compensation to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively, including: When the difference between the central point current value of the first sequence and the fifth target point current value of the first sequence is greater than or equal to a second current threshold, determining to compensate the fifth target point current value, wherein the fifth target point current value is a current value before the first target point position in the first sequence; When the difference between the current value of the sixth target point of the second sequence and the current value of the center point of the second sequence is greater than or equal to the second current threshold, determining to compensate the current value of the sixth target point, wherein the current value of the sixth target point is the current value after the position of the fourth target point in the second sequence; Discrete transformation is performed on the voltage values in the voltage sequence and the current values in the current sequence after noise compensation to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively.
7. The method according to claim 5, characterized in that In the case of performing noise compensation on the voltage values in the voltage sequence and the current values in the current sequence, performing discrete transformation on the voltage values in the voltage sequence and the current values in the current sequence after noise compensation to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively, including: When the difference between the center point voltage value of the third sequence and the fifth target point voltage value of the third sequence is greater than or equal to the second voltage threshold, determining to compensate the fifth target point voltage value, wherein the fifth target point voltage value is a voltage value before the first target point position in the third sequence; When the difference between the sixth target point voltage value of the fourth sequence and the center point voltage value of the fourth sequence is greater than or equal to the second voltage threshold, determining to compensate the sixth target point voltage value, wherein the sixth target point voltage value is a voltage value after the fourth target point position in the fourth sequence; Discrete transformation is performed on the voltage values in the voltage sequence and the current values in the current sequence after noise compensation to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively.
8. The method according to any one of claims 1 to 4, characterized in that Before acquiring the voltage sequence and current sequence of the battery, the method further includes: Parsing the configuration file of the battery EIS to obtain a sampling frequency, a number of calculation frequencies, and at least one calculation frequency; The total number of sampling points is calculated according to the minimum calculation frequency of the at least one calculation frequency and the sampling frequency.
9. The method according to claim 8, characterized in that The total number of sampling points is equal to the product of the sampling frequency and the minimum calculation frequency.
10. The method according to claim 8, characterized in that When the terminal device is in a screen-off state and a charging state, the step of obtaining multiple voltage values and multiple current values of the battery is performed.
11. The method according to claim 8, characterized in that The method further comprises: Calculating a frequency component corresponding to a target calculation frequency, wherein the at least one calculation frequency includes the target calculation frequency; The calculating the battery impedance value according to the discrete transformation values respectively corresponding to the voltage sequence and the current sequence includes: The battery impedance value at the target calculation frequency is calculated according to the discrete transformation values corresponding to the voltage sequence and the current sequence, respectively, and the frequency component corresponding to the target calculation frequency.
12. The method according to claim 11, characterized in that The calculation target calculation frequency component corresponding to the frequency includes: A frequency component corresponding to the target calculation frequency is calculated according to the target calculation frequency, the total number of sampling points and the sampling frequency, wherein the frequency component corresponding to the target calculation frequency is the target calculation frequency multiplied by the ratio of the total number of sampling points to the sampling frequency.
13. The method according to any one of claims 1 to 4, characterized in that The method further comprises: The battery aging degree is determined according to the battery impedance value, and the battery impedance value is positively correlated with the battery aging degree.
14. A device for calculating battery impedance, characterized in that: The device is applied to a terminal device, the terminal device includes a battery, and the device includes: An acquisition module, used for acquiring a plurality of voltage values and a plurality of current values of the battery, wherein the plurality of voltage values constitute a voltage sequence and the plurality of current values constitute a current sequence; A discrete transformation module, configured to perform discrete transformation on a voltage value in the voltage sequence and a current value in the current sequence when at least one of the voltage sequence and the current sequence satisfies a step response condition, so as to obtain discrete transformation values corresponding to the voltage sequence and the current sequence respectively; The calculation module is used to calculate the battery impedance value according to the discrete transformation values corresponding to the voltage sequence and the current sequence respectively.
15. A terminal device, characterized in that: include: A memory storing executable program code; a processor coupled to the memory; The processor is used to execute the method according to any one of claims 1 to 13.
16. A computer-readable storage medium comprising instructions, which, when executed on a processor, causes the processor to perform the method according to any one of claims 1 to 13.
Citation Information
Cited By
Battery ohmic internal resistance determination method and system and storage medium
CN120742148A