CN103792490B - The method measured and calculate system battery electricity - Google Patents
The method measured and calculate system battery electricity Download PDFInfo
- Publication number
- CN103792490B CN103792490B CN201310594575.6A CN201310594575A CN103792490B CN 103792490 B CN103792490 B CN 103792490B CN 201310594575 A CN201310594575 A CN 201310594575A CN 103792490 B CN103792490 B CN 103792490B
- Authority
- CN
- China
- Prior art keywords
- electricity
- battery
- voltage
- current
- processes
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Landscapes
- Charge And Discharge Circuits For Batteries Or The Like (AREA)
- Secondary Cells (AREA)
- Tests Of Electric Status Of Batteries (AREA)
Abstract
The invention discloses a kind of method measured and calculate battery electric quantity, comprise the following steps: step one, utilize ADC to measure cell voltage method and obtain the reference voltage of battery, it is preferred that by continuous 10 AD conversion and average and obtain reference voltage;Step 2, according to the state of the main current consuming apparatus of system, calculates the compensation voltage of each described main current consuming apparatus;Step 3, calculates the summation compensating voltage of described reference voltage and all described main current consuming apparatus, as the voltage after compensating;Step 4, obtains the corresponding electricity measuring electric quantity as battery according to the voltage after described compensation by voltage electricity relation table;Step 5, updates, with the measuring electric quantity of described battery, the display electricity that battery is current.Use the present invention, can only use ADC voltage measurement battery electric quantity method on the premise of can not obtaining current information, and by the improvement in the method and algorithm so that accuracy of measurement significantly rises, and battery charging and discharging curve is closer to truth.
Description
Technical field
The present invention relates to a kind of computer automation measuring method, particularly relate to a kind of measurement and calculating electricity
The method of pond electricity.
Background technology
In panel computer, mobile phone etc. use the equipment of battery, it is typically necessary display present battery
Electricity.Occasion exigent for certainty of measurement, the special chip such as coulometer to be used.Storehouse
Logical sequence meter, by measuring the voltage of battery, charge/discharge current, can accurately calculate battery storage and consumption
Energy, thus draw current battery charge.
In order to cost-effective, for the consumption electronic product that required precision is not the highest, the most not
This kind of special coulant meter chip can be used, but use the method only measuring cell voltage by ADC
Measure and calculate battery electric quantity.The principle of the method is, battery is under different electricity, and it exports
Voltage is different.Electricity is the most, and voltage is the highest, and on the contrary, electricity is the fewest, and voltage is the lowest.
But practical situation is, cell voltage list is correlated with electricity, is also correlated with charge/discharge current.And measure
Battery current is again that relatively difficult, the most general consumption electronic product does not possess battery current measurement
Function.So not increasing any algorithm, it is only to calculate battery electric quantity simply by voltage, effect
It is excessively poor, has time error even can reach 50% more than.
For the problems referred to above, the voltage that some design just adds under different scene on this basis is mended
Repay function.By to the voltage measurement under different scenes, recording voltage compensation value, then recording
Compensate according to different patterns after virtual voltage.Owing to voltage pulsation is relatively big, voltage compensation is the most very
Difficulty is made accurately, the computing such as therefore typically also can simply average result of calculation, makes knot
Fruit seems more steady.
To sum up, the major defect of prior art includes:
If 1 uses special coulometer chip, the most relatively costly, take around increase by 0.5~1 U.S. dollar;
2, not using coulometer chip, battery curve is unsmooth, electricity display error big, fluctuation is big,
Such as before and after restarting systems, battery electric quantity deviation is very big, charging time electricity rapid increase, pull out and fill
Electrical equipment electricity rapid decrease etc..
Summary of the invention
Present invention mainly solves under no current measures the restriction of function, only use voltage system to survey online
The problem that amount battery electric quantity deviation is big and the fluctuation of battery charging and discharging curve is big.
For achieving the above object, the invention discloses a kind of method measured and calculate system battery electricity,
Specifically include following steps:
Step one, utilizes ADC to measure cell voltage method and obtains the reference voltage U of battery;
Step 2, according to the state of the main current consuming apparatus of system, depends on each described main current consuming apparatus
The compensation voltage of each described main current consuming apparatus is calculated according to below equation;
When battery is in discharge condition: UCompensate voltage=UCompensate side-play amount+F(U)*VCurrency/VMaximum,
When battery is in charged state: UCompensate voltage=UCompensate side-play amount-F(U)*VCurrency/VMaximum;
Wherein, VCurrencyIt is the value of current main current consuming apparatus correspondence attribute, VMaximumIt it is described corresponding genus
Property accessible maximum, F (U) is the function with described reference voltage as parameter, represents according to current
The maximum that described reference voltage calculates when main current consuming apparatus operates in described corresponding attribute maximum is mended
Repay voltage;UCompensate side-play amountFor compensating side-play amount, the state phase that its size current consuming apparatus main with system is current
Close;
Step 3, calculate described reference voltage and all described main current consuming apparatus compensates the total of voltage
With, as the voltage after compensating;
Step 4, obtains corresponding electricity according to the voltage after described compensation by voltage-capacity relation table
Measuring electric quantity as battery;
Step 5, updates, with the measuring electric quantity of described battery, the display electricity that battery is current.
Described main current consuming apparatus at least includes LCD backlight, CPU and GPU;For LCD backlight,
Described corresponding attribute is LCD backlight brightness, and for CPU, described corresponding attribute is that CPU runs frequency
Rate value, for GPU, described corresponding attribute is GPU running frequency value.
The present invention is different from some schemes not using current measurement equally only in accordance with several specific application
Scene carrys out setting compensation value, but calculates for selected main current consuming apparatus, it is possible to obtain relatively
For voltage compensation value accurately.
In order to solve further, the display electricity error of described battery is big, battery curve is unsmooth, fluctuation
The problem such as big, between described step 4 and step 5, it is also possible to include the electricity of the measurement to described battery
Amount is carried out in anti-bounce-back process, slope restriction process, simulation discharge and recharge process, electricity Filtering Processing
One or more, and/or include processing independent of the preservation electricity of step one to step 5.Wherein said
Each item that anti-bounce-back process, slope restriction process, simulate in discharge and recharge process, electricity Filtering Processing
When processing, all using the output electricity of the next item up process as currently processed input electricity, and ought
The input electricity that the output electricity of pre-treatment processes as the next item down, the process being connected with described step 4
Input electricity be through described step 4 process after measuring electric quantity, the process being connected with described step 5
Output electricity as the measuring electric quantity in described step 5.
Described anti-bounce-back processes and specifically includes: it is right to be carried out by display electricity current with battery for input electricity
Ratio, when battery is in discharge condition, if the display electricity that described input electricity is current more than described battery
Amount, then use the current display electricity of described battery as output electricity;When battery is in charged state
Time, if the display electricity that described input electricity is current less than described battery, then use described battery current
Display electricity is as described output electricity;Other situations use described input electricity as output electricity.
Described slope restriction processes and specifically includes: carried out by display electricity current with battery for input electricity
Contrast, if described input electricity ninThe display electricity n current more than described batterym, then electricity is exported
For nout=(int) ((nin-nm)/N+1)+nm;If described input electricity ninLess than described display
Electricity nm, then output electricity is nout=(int) ((nin-nm)/N-1)+nm;If described input electricity
Amount ninEqual to described display electricity nm, output electricity is: nout=nin;Wherein nin noutAnd nmFor with hundred
Dividing the numerical value before percentage sign when making display, N is one and adjusts in real time according to current working current size
Coefficient.
Existing technology is used is the mode of fixed slope, and i.e. no matter charging and discharging currents is how many,
All use fixing slope.The present invention then can according to the dynamic the tuned slope of current charging and discharging currents, from
And closer to truth.
Described simulation discharge and recharge processes and specifically includes: when system detects that the current display electricity of battery exists
Do not change in a period of time, if system is in charged state, then calculates and simulate in the charge state
The required duration t of chargingc, at tcIn the range of duration, by described input electricity ninAdd according to time per unit
The speed change of 1 is as output electricity;If system is in discharge condition, then calculate mould in the discharged condition
Intend the required duration t of electric discharged, at tdIn the range of duration, by described input electricity ninAccording to time per unit
The speed change subtracting 1 is as output electricity, wherein said ninDuring for representing with hundred-mark system before percentage sign
Numerical value.
Described electricity Filtering Processing specifically includes: the value of input electricity is joined filtering queue end,
By a data deletion the earliest in queue, then all values in filtering queue is averaged as defeated
Go out electricity.
Present invention uses queue-type Filtering Processing rather than common average value filtering mode, use
This mode not only can numerically produce filter effect, the most also can produce filter effect.
Described preservation electricity processes and includes step: detecting that the current display electricity of battery changes,
Or exceed Preset Time, or during user's modification time, described display electricity and time letter will be preserved
Breath is to file system, with the survey calculation of electricity during participation system boot next time.During system boot next time,
Then and the most calculated from file system, last information about power and temporal information are first loaded,
Electricity and time contrast, if electricity is more or less the same, and the time changes not less than the value specified, then recognize
Information about power for being loaded into from file system is effective, and follow-up calculating is carried out the most on this basis,
If electricity deviation is relatively big, the most direct current calculated charge value of use, ignore and store before
Information about power.
The embodiment of the present invention is to be solved be technical problem is that on the premise of can not obtaining current information,
For only using ADC voltage measurement battery electric quantity method, and by the improvement in the method and algorithm,
Making accuracy of measurement significantly increase, battery charging and discharging curve is closer to truth, thus significantly
Promote user's experience.
Implement the embodiment of the present invention, have the advantages that
1, contrast uses special coulometer chip or increases the scheme of current measurement, and the present invention increases hardly
Adding extra cost, the ADC directly using chip to carry can complete battery electric quantity measurement function;
2, contrasting the scheme that similar no current is measured, mending because present invention uses the most accurate voltage
Compensation method and algorithm, so the result that the present invention records is the most accurate;
3, the scheme that similar no current is measured is contrasted, owing to present invention uses preferable algorithm and intelligence
Can parameter adjustment function, such as dynamically slope limitation function, simulation discharge and recharge processing procedure, queue
Formula Filtering Processing etc. so that the battery charging and discharging curve that the present invention obtains is closer to truth;
4, contrast similar measurement scheme, have benefited from electricity preservation of the present invention and process and start pre-loaded function,
The present invention starts shooting or restarts at once after shut down, and electricity will not suddenly change.
Accompanying drawing explanation
Fig. 1 is the flow chart of one embodiment of the present of invention.
Fig. 2 is that the embodiment of the present invention calculates the flow chart compensating voltage.
Fig. 3 be the embodiment of the present invention table look-up acquisition measuring electric quantity flow chart.
Fig. 4 is the flow chart of an alternative embodiment of the invention.
Fig. 5 is the embodiment of the present invention anti-bounce-back process chart.
Fig. 6 is that embodiment of the present invention slope limits process chart.
Fig. 7 is that the embodiment of the present invention simulates discharge and recharge process chart.
Fig. 8 is embodiment of the present invention electricity Filtering Processing flow chart.
Fig. 9 is that the embodiment of the present invention preserves electricity process chart.
Figure 10 is embodiment of the present invention start preload process flow chart.
Detailed description of the invention
For making the object, technical solutions and advantages of the present invention clearer, below in conjunction with accompanying drawing to this
Invention is described in further detail.
As it is shown in figure 1, be the flow chart of one embodiment of the invention, specifically include step:
S11, utilizes ADC to measure cell voltage method and obtains the reference voltage of battery, it is preferred that pass through
Continuous 10 AD conversion are also averaged and are obtained reference voltage;
S12, according to the state of the main current consuming apparatus of system, calculates the benefit of each described main current consuming apparatus
Repay voltage;
S13, calculates the summation compensating voltage of described reference voltage and all described main current consuming apparatus,
As the voltage after compensating;
S14, obtains corresponding electricity conduct according to the voltage after described compensation by voltage-capacity relation table
The measuring electric quantity of battery;
S15, updates, with the measuring electric quantity of described battery, the display electricity that battery is current.
Wherein, in described step S12, main current consuming apparatus is according to different different the setting of Systematic selection
Standby.Such as in panel computer, LCD backlight and CPU, GPU are main current consuming apparatus, power consumption
Do not fix.Therefore by measuring different LCD backlight brightness, cpu frequency, GPU frequency in difference
Voltage deviation value under cell voltage, then by curve matching, obtains the data of some key points,
Then voltage can be calculated further according to actual LCD backlight brightness, cpu frequency, GPU frequency
Offset, such that it is able to accurately calculate battery electric quantity.
Assume current by ADC measurement to cell voltage be U, then can by the voltage after compensation
It is expressed as Uc=U+Ublc+Ucpuc+Ugpuc.Wherein UcFor the voltage after compensating, UblcFor LCD backlight
Compensate voltage, UcpucVoltage, U is compensated for CPUgpucVoltage is compensated for GPU.
LCD backlight compensates voltage Ublc=Ubl_offset+Fbl(U)*Vbl/Vblmax, wherein Ubl_offsetFor compensating
Side-play amount, the most relevant to actual system, the battery that used etc., need actual measurement to determine;FblIt is one
Individual function, it can calculate the offset of high-high brightness, this function and reality according to current voltage value
LCD backlight, the battery used etc. are the most relevant, need actual measurement to determine;VblIt it is current LCD backlight
Brightness value, VblmaxIt it is backlight maximum.
CPU compensates voltage Ucpuc=Ucpu_offset+Fcpu(U)*Vcpu/Vcpumax, wherein Ucpu_offsetFor mending
Repay side-play amount, the most relevant to actual system, the battery that used etc., need actual measurement to determine;Fcpu
Being a function, it can calculate offset during maximum cpu frequency, this letter according to current voltage value
Number and actual CPU, the battery used etc. are the most relevant, need actual measurement decision;VcpuIt is current CPU
Running frequency value, VcpumaxIt it is the frequency maxima of CPU operation.
GPU compensates voltage Ugpuc=Ugpu_offset+Fgpu(U)*Vgpu/Vgpumax, wherein Ugpu_offsetFor mending
Repay side-play amount, the most relevant to actual system, the battery that used etc., need actual measurement to determine;Fgpu
Being a function, it can calculate offset during maximum GPU frequency, this letter according to current voltage value
Number and actual GPU, the battery used etc. are the most relevant, need actual measurement decision;VgpuIt is current GPU
Running frequency value, VgpumaxIt it is the frequency maxima of GPU operation.
When charging, it is also desirable to calculate charging according to LCD backlight, cpu frequency, GPU frequency etc.
The offset of voltage.Because in systems, the total current that charger provides is fixing, when system is transported
When the electric current of needs is big during row, can automatically reduce charging current.And different charging currents, even if
In the case of battery capacity is identical, cell voltage is the most different, it is therefore desirable to does voltage for charging and mends
Repay.Computing formula when charging voltage compensation calculation formula and electric discharge is the most essentially the same, different
Place is, when backlight/CPU/GPU electric current increases, compensates voltage and reduces, the parameter therefore used
Different.The computing formula used during charging is in form: Ublc=Ubl_offset-Fbl(U)*Vbl/Vblmax;
Ucpuc=Ucpu_offset-Fcpu(U)*Vcpu/Vcpumax;Ugpuc=Ugpu_offset-Fgpu(U)*Vgpu/Vgpumax。
Furthermore, it is contemplated that USB port is when connecting computer and charger, it is possible to the maximum current got
Being different, this directly influences whether the measurement of battery electric quantity during charging.Therefore increase in the design
Add the function of feeder ear detection, when different feeder ears being detected, different compensation can have been used to join
Number.As preferably detecting according to being, when connecting computer, computer can carry out data communication with equipment,
And when connecting charger, do not have data communication.
For convenience of understanding, by Fig. 2, voltage compensation handling process will be described below.
Assume that the voltage recorded by ADC measurement voltage method is U;
S131, it may be judged whether have external power source to input, if it has, then enter step S132, otherwise,
Enter step S134;
S132, it is judged that whether the external power source of connection is computer, if it is, enter step S133, no
Then, step 135 is entered;
S133, calculates LCD backlight under computer model and compensates voltage Ublc, CPU compensate voltage Ucpuc、
GPU compensates voltage Ugpuc;
S134, calculates LCD backlight under discharge mode and compensates voltage Ublc, CPU compensate voltage Ucpuc、
GPU compensates voltage Ugpuc;
S135, calculates LCD backlight under charge mode and compensates voltage Ublc, CPU compensate voltage Ucpuc、
GPU compensates voltage Ugpuc;
S136, according to formula Uc=U+Ublc+Ucpuc+UgpucCalculate the voltage after compensating.
Fig. 3 show in step S14 to table look-up and obtains the idiographic flow of battery electric quantity, specifically includes step:
S141, it is judged that whether battery is in charged state, if being in charged state, then enters step
Rapid S142, otherwise enters step S143;
S142, obtains the measuring electric quantity of present battery, and enters step S144 by looking into charging voltage table;
S143, obtains the measuring electric quantity of present battery, and enters step S144 by looking into discharge voltage table;
S144, returns the measuring electric quantity of present battery.
Although the display electricity that embodiment obtains as shown in Figure 1, by intending main current consuming apparatus
Close voltage compensation curve, it is thus achieved that battery electric quantity more accurately, but if on the basis of this embodiment
On add anti-bounce-back process, slope restriction process, simulation discharge and recharge process, electricity Filtering Processing with
And preserve electricity process in one or more, it will obtain closer to the truth and meet people
The result of psychology.
As shown in Figure 4, for the flow chart of another embodiment of the present invention.
S1, obtains battery measurement electricity: identical with the step S11 to S14 of first embodiment, according to
The reference voltage utilizing ADC measurement cell voltage method to obtain is carried out by the state of the main current consuming apparatus of system
Voltage compensation, and the measuring electric quantity of battery is determined according to the voltage after compensating.
S2, anti-bounce-back processes: assume that currently displaying electricity is nmIf put it has been acknowledged that battery is in
Electricity condition, such as, be not connected with charger bright screen and run, then for being calculated more than nmResult should
This to abandon, and otherwise battery not in charging but understand to the experience of the no good cake of user in rising by battery electric quantity,
The most directly use value n of currently displaying electricitymThe result processed as this step;Equally, if it is confirmed that
Battery is in charged state, and calculated electricity is less than nm, the most also to abandon, prevent battery from filling
The situation that during electricity, battery electric quantity declines on the contrary occurs, and the most also uses value n of currently displaying electricitymMake
The result processed for this step;For other situations, use the measuring electric quantity obtained through S1 step as this
The result that step processes.
S3, slope restriction processes: the most directly uses the result through step S2, and is based on current
Display electricity, is further adjusted the electricity after step S2 processes.Currently fill according to system
Discharge condition and the state of main current consuming apparatus, calculate electric quantity change rate N, utilize this to become
Rate limits the amplitude of electric quantity change, pins down the rapid fluctuations of battery electric quantity in time.It is assumed that
The result that described step S2 processes is denoted as nin, currently displaying electricity is denoted as nm.Work as ninCompare nm
Time big, according to formula ((int) (nin-nm)/N+1)+nmDescribed step S2 result is adjusted further;
Work as ninCompare nmHour, according to formula ((int) (nin-nm)/N-1)+nmDescribed step S2 result is entered
One successive step;Work as ninEqual to nmTime, do not adjust;Wherein ninAnd nmFor showing with hundred-mark system
Time percentage sign before numerical value.
S4, simulation discharge and recharge processes: if system detects that the described display electricity long period becomes
Dynamic, and in the case of the charging and discharging state of the clearest and the most definite battery, make described after step S3 processes
Electricity is within the time determined according to system current state, with less than change during normal discharge and recharge
Amplitude changes.Owing to the charge/discharge rates of simulation is slower than actual charge/discharge rates, therefore a period of time
After, calculated electricity can be gradually close to the electricity of display, and finally the two is equal.Such place
When reason makes user feel charging, battery electric quantity rises than relatively evenly, and during electric discharge, battery electric quantity ratio is more uniform
Ground declines.
S5, electricity Filtering Processing: the electricity obtained after above step adjusts is joined and puts down
Sliding filtering queue, and by a data deletion the earliest in queue, then average and be calculated
Whole battery electric quantity.And be used for updating described display electricity by result.
S6, preserves electricity and processes: detecting that the current display electricity of battery changes, or away from
Preserved from last time and exceed Preset Time, or during user's modification time, presently described display electricity will be preserved
The value of amount and temporal information are to file system, with the survey calculation of electricity during participation system boot next time.
Wherein said anti-bounce-back processes the concrete steps of S2 as shown in Figure 5:
Before performing described anti-bounce-back process S2, the result first loading acquisition battery measurement process is made
The input electricity processed for anti-bounce-back;Described anti-bounce-back processes and specifically includes step:
S21, it is judged that whether battery is in charged state.If battery is in charged state, then enter
Step S22, otherwise enters step S23;
S22, it is judged that whether input electricity is less than display electricity, if it does, enter step S24,
Otherwise, step S25 is entered;
S23, it is judged that whether input electricity is more than display electricity, if it does, enter step S24,
Otherwise, step S25 is entered;
S24, is assigned to the value of currently displaying electricity export electricity;
S25, is assigned to export electricity by the value of input electricity.
After using above process, although the accuracy that battery electric quantity is measured can be effectively improved, but imitate
Fruit or not ideal enough.Main cause is that system complexity is the highest, it is impossible to the most accurately will be all
Module ruuning situation is converted into voltage compensation value, and its characteristic of different batteries is the most different, then adds
Upper ADC measurement error etc., the result fluctuating margin finally obtained is the biggest.In view of battery electricity
Amount can not be undergone mutation, and therefore the result after said method processes is entered by the embodiment of the present invention again
Line slope restriction process and electricity Filtering Processing, pin down the rapid fluctuations of battery electric quantity in time.
Described slope restriction process concrete steps as shown in Figure 6:
Before performing described slope restriction and processing step, the output electricity of first load step S2 is as tiltedly
The input electricity n that rate restriction processesin;Described slope restriction processes and includes step:
S31, it is judged that input electricity ninWhether more than display electricity nm, if it is, enter step S32,
Otherwise, step S34 is entered;
S32, according to LCD backlight brightness Vbl, CPU running frequency Vcpu, the running frequency of GPU
VgpuAnd whether connect computer slope calculations coefficient N;
S33, exports electricity noutFor nout=((int)(nin-nm)/N+1)+nm;
S34, it is judged that input electricity ninWhether less than display electricity nm, if it is, enter step S35,
Otherwise, step S37 is entered;
S35, according to LCD backlight brightness Vbl, CPU running frequency Vcpu, the running frequency of GPU
VgpuAnd whether connect computer slope calculations coefficient N;
S36, exports electricity noutFor nout=((int)(nin-nm)/N-1)+nm;
S37, is assigned to export electricity by the value of input electricity.
Preferably, in step s 32, the calculation of N is as follows:
Charged state: N=10+ (30*Vbl/Vblmax)+(10*Vcpu/Vcpumax)+(10*Vgpu/Vgpumax),
Discharge condition: N=60-(30* (Vbl)/Vblmax)-(10*Vcpu/Vcpumax)-(10*Vgpu/Vgpumax),
The wherein value of numeral, will be adjusted according to actual battery, backlight, CPU, GPU.
After using such algorithm, the maximum rate of change of battery electric quantity is limited, thus reaches good
Smooth effect.
Electric discharge a period of time and battery do not discharge after be inserted into charger or charging a period of time and
The most suddenly it is transferred to low after just disconnecting charger or long-time heavy-duty service during battery underfill
Load operation etc., these time electricity only be most difficult to calculate by voltage, the most all can occur partially
The situation that difference is bigger.Owing to adding anti-bounce-back measure, when situation about generally occurring within is exactly to grow very much one section
The battery electric quantity of interior display is held at same level, and actually battery is in charge or discharge
's.For this situation, the present embodiment uses simulation discharge and recharge to process, according to slower than normal discharge and recharge
Speed carry out simulated battery charge and discharge process.Owing to the charge/discharge rates of simulation is bound to fill than actual
The velocity of discharge is slow, and therefore after a period of time, calculated charge value can be gradually to the charge value of display
Close, final display electricity is by equal with the charge value calculated.It is concrete that described simulation discharge and recharge processes
Step is as shown in Figure 7:
Before performing described simulation discharge and recharge and processing step, first load the result conduct that anti-bounce-back processes
The input electricity n of simulation discharge and rechargein;Described simulation discharge and recharge processes and includes step:
S41, it is judged that whether display electricity changes, if it is, enter step S42, otherwise,
Enter step S43;
S42, resets timer Ts, and enter step S411;
S43, it is judged that whether battery is in charged state, if it is, enter step S44, otherwise, enters
Enter step S45;
S44, calculates under conditions present, and charging should produce the time t of changec, and enter step S46;
S45, it is judged that whether battery is in discharge condition, if it is, enter step S47, otherwise, enters
Enter step S411;
S46, it is judged that TsWhether more than tc, if it is, enter step S48, otherwise enter step S411;
S47, calculates under conditions present, and electric discharge should produce the time t of changed, and enter step S49;
S48, calculates output electricity nout=nin+ 1, reset timer Ts, and enter S412;
S49, it is judged that TsWhether more than td, if it is, enter step S410, otherwise enter step
S411;
S410, calculates output electricity nout=nin-1, reset timer Ts, and enter step S412;
S411, is assigned to export electricity by the value of input electricity;
S412, returns output electricity.
After such process, when user can feel charging, battery electric quantity rises than relatively evenly, puts
During electricity, battery electric quantity declines than relatively evenly, without there is being in for a long time the situation of same level,
Thus improve Consumer's Experience well.
The concrete steps of described electricity Filtering Processing as shown in Figure 8, are performing described electricity Filtering Processing
Before step, the result first described simulation discharge and recharge processed is as the input of described electricity Filtering Processing
Electricity, described electricity Filtering Processing specifically includes step:
S51, removes value the earliest in filtering queue;
S52, joins queue end by the value of input electricity;
S53, averages to all values in filtering queue and is assigned to export electricity.
By such process so that the fluctuation in positive and negative scope is canceled each other out, thus reaches very
Good smooth effect.
After shut down, the software calculating electricity just cannot be properly functioning, and therefore common practice is just for system
It is to recalculate battery electric quantity during start every time.Due to some above-mentioned reasons, finally calculate
Electricity may be with the electricity deviation more than 10% before shutdown, and this understands the body the worst to client
Test.In order to solve this problem, native system is designed with slotting charger automatic turn-on function, and adds institute
State preservation electricity to process.As it is shown in figure 9, described preservation electricity process concretely comprise the following steps:
S61, it is judged that whether display electricity changes, if it is, enter step S64, otherwise enters
Enter step S63;
S62, it is judged that whether user revises system time, if it is, enter step S64;
S63, it is judged that distance last saved has reached tsaveDuration, if it has,
Then enter step S64, otherwise, enter step S66, wherein tsaveIt it is a value set in advance;
S64, preserves current electric quantity information and temporal information to file system;
S65, empties the timer T for recording distance last savednc;
S66, preservation completes.
The reference of electricity is calculated as next time when the meaning that described preservation electricity processes is to start shooting.Next time
During start, such as, when user manually starts shooting or inserts charger charging start, first load from file system
Last electricity and temporal information, then contrast with current calculated battery electric quantity and time.As
Really battery electric quantity is more or less the same, and the time changes not less than the value specified, then it is assumed that from file system
The battery level information being loaded into is effective, and follow-up calculating is all carried out on this basis.Thus may be used
To ensure that user is in the case of restarting or the unused time is not to grow very much, it is ensured that battery electric quantity shows
Concordance.If battery electric quantity deviation is relatively big, such as user changes battery, or time deviation is very
For a long time or temporal regression, such as after changing battery or long-time shutdown, battery miss out a lot,
At this moment when user the most less remembers to shut down for the last time, how many battery electric quantities is, then the most directly
Use current calculated charge value, and neglect the information about power stored before.If in start
Shi Buneng gets the information about power of last storage, then can only directly use calculated battery electricity
Amount.When this situation generally only occurs in plant produced, normally use thus without affecting user.
The concrete steps of described start prestrain as shown in Figure 10, including step:
S71, obtains the measuring electric quantity of battery according to the step of S1;
S72, carries out electricity Filtering Processing by the measuring electric quantity that S71 step obtains according to the step of S5;
S73, it is judged that filtering queue is the fullest, if it is, enter step S74, otherwise, returns step
Rapid S71;
S74, loads information about power and temporal information from file system;
S75, it is judged that the information about power loaded from file system is the most effective, if effectively, enters step
Rapid S76, does not deals with;
S76, sets the currently displaying electricity charge value as preservation, and uses the charge value of preservation to fill filter
Ripple queue;
S77, opening initialization completes.
Except above-mentioned process, the design also uses average voltage, filter the bigger value of variance,
The conventional design such as look-up table conversion battery electric quantity, describe in detail the most in the document.It is appreciated that this
Invention is to apply in the system that no current is measured, but the processing method that the present invention is to battery electric quantity, aobvious
So can be used on system or the coulomb chip of belt current measurement.
Although it should be noted that above-described embodiment employs at described anti-bounce-back in one embodiment
Reason, slope restriction process, simulate discharge and recharge process, electricity Filtering Processing and preserve electricity process,
But these six process need not necessarily the most all use, and can the most only select it
In one or more with optimum results.The most described anti-bounce-back process, slope restriction process, simulation
Discharge and recharge process, the processing sequence of electricity Filtering Processing are not inevitable as shown in above-described embodiment, can
Corresponding suitably adjustment is made with the needs according to user.
The above is the preferred embodiment of the present invention, it is noted that general for the art
For logical technical staff, under the premise without departing from the principles of the invention, it is also possible to make some improvement and
Retouching, these improvements and modifications are also considered as protection scope of the present invention.
Claims (9)
1. the method measured and calculate system battery electricity, it is characterised in that include following step
Rapid:
Step one, utilizes ADC to measure cell voltage method and obtains the reference voltage U of battery;
Step 2, according to the state of the main current consuming apparatus of system, depends on each described main current consuming apparatus
The compensation voltage of each described main current consuming apparatus is calculated according to below equation;
When battery is in discharge condition: UCompensate voltage=UCompensate side-play amount+F(U)*VCurrency/VMaximum,
When battery is in charged state: UCompensate voltage=UCompensate side-play amount-F(U)*VCurrency/VMaximum;
Wherein, VCurrencyIt is the value of current main current consuming apparatus correspondence attribute, VMaximumIt it is described correspondence
The accessible maximum of attribute, F (U) is the function with described reference voltage as parameter, represents according to working as
Before described reference voltage calculate maximum when main current consuming apparatus operates in described corresponding attribute maximum
Compensate voltage;UCompensate side-play amountFor compensating side-play amount, the shape that its size current consuming apparatus main with system is current
State is correlated with;
Step 3, calculate described reference voltage and all described main current consuming apparatus compensates the total of voltage
With, as the voltage after compensating;
Step 4, obtains corresponding electricity according to the voltage after described compensation by voltage-capacity relation table
Measuring electric quantity as battery;
Step 5, updates, with the measuring electric quantity of described battery, the display electricity that battery is current.
Method the most according to claim 1, it is characterised in that described main current consuming apparatus is at least
Including LCD backlight, CPU and GPU;For LCD backlight, described corresponding attribute is the LCD back of the body
Brightness, for CPU, described corresponding attribute is CPU running frequency value, for GPU, described right
Answering attribute is GPU running frequency value.
Method the most according to claim 1, it is characterised in that in described step 4 and step 5
Between, still further comprise the measuring electric quantity to described battery and carry out at anti-bounce-back process, slope restriction
One or more in reason, simulation discharge and recharge process, electricity Filtering Processing, and/or includes independent of step
The preservation electricity of rapid one to five processes;Wherein said anti-bounce-back process, slope restriction process, simulation is filled
Each item in discharge process, electricity Filtering Processing is when processing, and the output all processed by the next item up is electric
Measure as currently processed input electricity, and currently processed is exported what electricity processed as the next item down
Input electricity, the input electricity that the next item down being connected with described step 4 processes is through described step everywhere
Measuring electric quantity after reason, the output electricity that the next item up being connected with described step 5 processes is as described step
Measuring electric quantity in rapid five.
Method the most according to claim 3, it is characterised in that described anti-bounce-back processes concrete bag
Include: the display electricity inputting electricity current with battery anti-bounce-back processed contrasts, at battery
When discharge condition, if the input electricity that described anti-bounce-back processes is more than the display electricity that described battery is current
Amount, then the output electricity that the display electricity using described battery current processes as anti-bounce-back;At battery
When charged state, if the input electricity that described anti-bounce-back processes is less than the display electricity that described battery is current
Amount, then the output electricity that the display electricity using described battery current processes as described anti-bounce-back;Other
The output electricity that the input electricity that situation uses described anti-bounce-back to process processes as anti-bounce-back.
Method the most according to claim 3, it is characterised in that described slope restriction processes concrete bag
Include: the display electricity inputting electricity current with battery slope restriction processed contrasts, if institute
State the input electricity n that slope restriction processesinThe display electricity n current more than described batterym, then slope limit
The fixed output electricity n processedoutFor: nout=(int) ((nin-nm)/N+1)+nm;If it is described defeated
Enter electricity ninLess than described display electricity nm, then output electricity noutFor: nout=(int) ((nin-nm)
/N-1)+nm;If described input electricity ninEqual to described display electricity nm, export electricity noutFor:
nout=nin;Wherein nin noutAnd nmNumerical value before percentage sign during for showing with hundred-mark system, according to N
The coefficient that current working current size adjusts in real time.
Method the most according to claim 3, it is characterised in that described simulation discharge and recharge processes concrete
Including: when system detects that the current display electricity of battery did not changed within a period of time, if
System is in charged state, then calculate duration t needed for analog charge in the charge statec, at tcDuration model
In enclosing, the input electricity n that described simulation discharge and recharge is processedinThe speed adding 1 according to time per unit becomes
It is turned to simulate the output electricity that discharge and recharge processes;If system is in discharge condition, then calculate in electric discharge
The required duration t of state Imitating electric discharged, at tdIn the range of duration, by described input electricity ninAccording to often
The output electricity that the speed change that unit interval subtracts 1 processes as simulation discharge and recharge, wherein said ninFor
Numerical value before percentage sign when representing with hundred-mark system.
Method the most according to claim 3, it is characterised in that described electricity Filtering Processing is specifically wrapped
Include: by electricity Filtering Processing input electricity value join filtering queue end, by queue the earliest
A data deletion, then to filtering queue in all values average as electricity Filtering Processing
Output electricity.
Method the most according to claim 3, it is characterised in that described preservation electricity processes and includes step
Rapid: to detect that the current display electricity of battery changes, or distance last saved exceedes
Preset Time, or during user's modification time, described display electricity and temporal information will be preserved to literary composition
Part system, with the survey calculation of electricity during participation system boot next time.
Method the most according to claim 8, it is characterised in that described preservation electricity processes and also includes
Step: when system boot next time, the last electricity letter preserved before first loading shutdown from file system
Breath and temporal information, and measuring electric quantity when calculating start, the electricity being then loaded into described in contrast with
The measuring electric quantity of described calculating, if the two electricity is more or less the same, and time change is not less than specifying
Value, then it is assumed that the described information about power being loaded into from file system is effective, display initial after start
Electricity will calculate according to the information about power of described loading, if electricity deviation is relatively big, the most directly makes
With described calculated measuring electric quantity, ignore the information about power stored before.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310594575.6A CN103792490B (en) | 2013-11-22 | 2013-11-22 | The method measured and calculate system battery electricity |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310594575.6A CN103792490B (en) | 2013-11-22 | 2013-11-22 | The method measured and calculate system battery electricity |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103792490A CN103792490A (en) | 2014-05-14 |
CN103792490B true CN103792490B (en) | 2016-08-17 |
Family
ID=50668352
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201310594575.6A Active CN103792490B (en) | 2013-11-22 | 2013-11-22 | The method measured and calculate system battery electricity |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103792490B (en) |
Families Citing this family (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103969595A (en) * | 2014-05-23 | 2014-08-06 | 开曼群岛威睿电通股份有限公司 | Electric quantity detecting device and method |
CN105491208A (en) * | 2014-09-16 | 2016-04-13 | 中兴通讯股份有限公司 | Method for storing electric quantity information of mobile terminal, and mobile terminal |
CN105759211A (en) * | 2014-12-19 | 2016-07-13 | 宇龙计算机通信科技(深圳)有限公司 | Battery residual electricity quantity value display method and system |
CN105866688A (en) | 2015-12-30 | 2016-08-17 | 乐视移动智能信息技术(北京)有限公司 | Method of measuring mobile communication terminal equipment cell capacity and system thereof |
CN107643493A (en) * | 2017-09-15 | 2018-01-30 | 深圳市道通智能航空技术有限公司 | A kind of battery electric quantity predictor method and device, unmanned plane |
CN112130082A (en) * | 2019-06-05 | 2020-12-25 | 海能达通信股份有限公司 | Method and equipment for calculating battery electric quantity and device with storage function |
CN110231048B (en) * | 2019-06-26 | 2023-06-16 | 腾讯科技(深圳)有限公司 | Location information display method, device, terminal and storage medium |
CN111556556B (en) * | 2020-05-09 | 2023-03-14 | 上海锐伟电子科技有限公司 | Control method for displaying battery capacity of mobile terminal |
CN115089912A (en) * | 2022-06-21 | 2022-09-23 | 南京苏瑞科技实业有限公司 | Fire-fighting equipment power monitoring system |
CN115728641B (en) * | 2022-11-14 | 2023-09-01 | 珠海英集芯半导体有限公司 | OCV electric quantity calculation method with self-learning and self-calibration functions |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5352968A (en) * | 1992-05-28 | 1994-10-04 | Apple Computer, Inc. | Battery charge state determination |
CN1641372A (en) * | 2004-01-02 | 2005-07-20 | 明基电通股份有限公司 | Mobile electronic device cell volume compensating device and method |
CN101806867A (en) * | 2010-03-12 | 2010-08-18 | 中兴通讯股份有限公司 | Method and device for measuring electric quantity of mobile phone battery |
CN103176132A (en) * | 2011-12-22 | 2013-06-26 | 联芯科技有限公司 | Estimation method and terminal device of electricity quantity of battery |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP4767558B2 (en) * | 2005-03-07 | 2011-09-07 | 日立ビークルエナジー株式会社 | Power supply state detection device, power supply device, and initial characteristic extraction device used for power supply device |
JP4649682B2 (en) * | 2008-09-02 | 2011-03-16 | 株式会社豊田中央研究所 | Secondary battery state estimation device |
-
2013
- 2013-11-22 CN CN201310594575.6A patent/CN103792490B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5352968A (en) * | 1992-05-28 | 1994-10-04 | Apple Computer, Inc. | Battery charge state determination |
CN1641372A (en) * | 2004-01-02 | 2005-07-20 | 明基电通股份有限公司 | Mobile electronic device cell volume compensating device and method |
CN101806867A (en) * | 2010-03-12 | 2010-08-18 | 中兴通讯股份有限公司 | Method and device for measuring electric quantity of mobile phone battery |
CN103176132A (en) * | 2011-12-22 | 2013-06-26 | 联芯科技有限公司 | Estimation method and terminal device of electricity quantity of battery |
Also Published As
Publication number | Publication date |
---|---|
CN103792490A (en) | 2014-05-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103792490B (en) | The method measured and calculate system battery electricity | |
CN103792489B (en) | Improved method for measuring and calculating system battery electricity quantity | |
CN104280686B (en) | Storage battery residual electric quantity detection method | |
EP1662269A1 (en) | Battery remaining power calculating method, battery remaining power calculating device, and battery remaining power calculating program | |
CN108539300A (en) | The electric quantity balancing method and system of battery pack | |
CN106646256A (en) | Battery capacity calculating method | |
CN103956530B (en) | A kind of lithium ion battery control method for quickly charging | |
CN103091639A (en) | Battery service life detecting method and detecting device | |
CN106249168B (en) | A kind of battery curve modification method and device | |
CN106574948B (en) | A kind of electricity estimation method and terminal | |
CN105006871B (en) | A kind of method and device for being used to simulate actual battery charging process | |
CN107817374A (en) | A kind of method and device for the operating current and dump energy for detecting electric terminal | |
CN106772091A (en) | The update method of battery capacity value, device and terminal | |
CN109462260A (en) | A kind of charging method, charging equipment and electronic equipment | |
CN109975708A (en) | A kind of automatic on-line modification method of battery SOC | |
CN115932605A (en) | Method and device for correcting residual electric quantity of energy storage battery and battery management system | |
CN108051756A (en) | Evaluation method, system and the storage medium of accumulator SOC | |
CN102914744A (en) | Mobile terminal, battery power display system of mobile terminal, and method for acquiring battery power | |
CN107918101A (en) | State of charge indicating means and instruction system | |
CN204287445U (en) | For the cell degradation detector of battery cell | |
CN206558637U (en) | A kind of lithium ion battery self discharge screening plant | |
CN106451646B (en) | Quickly wearing mobile power supply equipment device | |
CN107546433A (en) | Battery information processing method and processing device | |
CN104092253A (en) | Method for dynamically regulating intelligent mobile terminal electric quantity display and intelligent mobile terminal | |
CN106131342A (en) | A kind of method and system controlling mobile terminal shutdown |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant |