Background
Fig. 1 is an electrical schematic diagram of a conventional electricity meter. Referring to fig. 1, the fuel gauge includes a battery BAT, a switch SW, a resistor Rsense, an amplifier 11, analog-to-digital converters (ADCs) 12 and 13, an
accumulator 14, and a
time base circuit 15. The acquisition of the current is calculated by detecting the voltage on the resistor Rsense. The resistance Rsense is a measuring resistance, and is a current detection resistance of the order of m Ω. Resistor RL is the system load. The battery BAT discharges the system load RL by turning on the switch SW. When the system is working normally, the current loop includes battery BAT, switch SW, and resistor Rsense and RL. Assuming that the loop current is I
0The instantaneous voltage drop across the resistor Rsense is vs (t) I
0(t) × Rsense, the
electricity meter 10 continuously detects the voltage difference Vs across the resistor Rsense, converts it into a digital quantity Current through the amplifier 11 and the ADC13, and then accumulates, and the unit of the Accumulated Current is Vh (volt-hour). Accumulating the quantized Vs is equivalent to integrating them
The discharge capacity can therefore be expressed as:
as can be seen from the above equation, the deviation of the resistance Rsense causes the deviation of the power calculation.
Fig. 2 is a welded structure of the resistor in the electricity meter shown in fig. 1. As shown in fig. 2, when a resistor Rsense having a resistance of several tens of milliohms is actually used, a welding resistance Rsolder is introduced during welding. The value of Rsolder sometimes reaches the milliohm level and therefore the weld resistance greatly increases the measurement error. Therefore, the conventional electricity meter has a problem that the current detection result has large deviation. In addition, the resistor itself may have manufacturing variations, which may also cause variations in the current measurement results.
Disclosure of Invention
The invention aims to solve the technical problem of providing a current acquisition calibration circuit in an electricity meter, which can be used for adjusting the error of a measuring resistor, thereby improving the current acquisition precision of the electricity meter.
In order to solve the technical problem, the invention provides a current acquisition calibration circuit in an electricity meter, which comprises the electricity meter, a measuring resistor, a voltage sampler, an electricity accumulator and a current acquisition calibration circuit, wherein the input end of the voltage sampler is connected to two ends of the measuring resistor, the output end of the voltage sampler is connected with the electricity accumulator, the current acquisition calibration circuit comprises a battery, a first switch, a second switch, a calibration enabling circuit, a current source and a controller, the battery is connected with the measuring resistor in series and is connected with a load in parallel through the first switch, and the first switch is controlled by a first state signal to be switched on and off; the second switch, the current source, the battery and the measuring resistor are connected in parallel; the calibration enabling circuit generates a second state signal and outputs the second state signal to the second switch, and the second switch is controlled by the second state signal to be opened and closed; when the second switch is closed, the current source, the battery and the measuring resistor form a loop, and the controller calculates the calibration resistance value of the measuring resistor according to the current value of the current source and the sampling value of the voltage sampler; when the first switch is closed, the battery, the measuring resistor and the load form a loop, and the controller adopts the calibration resistance value to calculate the electric quantity.
In an embodiment of the invention, the first status signal is a power-on status signal of a device in which the fuel gauge is located.
In an embodiment of the invention, the calibration enabling circuit generates the second status signal according to a power-off status signal of a device in which the fuel gauge is located.
In an embodiment of the invention, the calibration enabling circuit generates the second state signal according to a shutdown state signal of a device where the fuel gauge is located, and one of an on-bit signal and a power supply stabilization signal of the battery.
In an embodiment of the invention, the calibration enable circuit further detects a calibration flag and generates the second state signal when the calibration flag is set.
In an embodiment of the invention, the current collection calibration circuit further includes a register for storing the calibration resistance value of the measuring resistor, and the register is connected to the controller.
The invention also provides a current acquisition and calibration circuit of the electricity meter, which comprises a battery, a measuring resistor and a voltage sampler, wherein the battery is connected with the measuring resistor in series, and the input end of the voltage sampler is connected with the two ends of the measuring resistor; the calibration enabling circuit generates a second state signal and outputs the second state signal to the second switch, and the second switch is controlled by the second state signal to be opened and closed; when the second switch is closed, the current source, the battery and the measuring resistor form a loop, and the controller calculates the calibration resistance value of the measuring resistor according to the current value of the current source and the sampling value of the voltage sampler.
In an embodiment of the invention, the calibration enabling circuit generates the second status signal according to a power-off status signal of a device in which the fuel gauge is located.
In an embodiment of the invention, the calibration enabling circuit generates the second state signal according to a shutdown state signal of a device where the fuel gauge is located, and one of an on-bit signal and a power supply stabilization signal of the battery.
In an embodiment of the invention, the calibration enable circuit further detects a calibration flag and generates the second state signal when the calibration flag is not set.
In an embodiment of the invention, the current collection calibration circuit further includes a register for storing the calibration resistance value of the measuring resistor, and the register is connected to the controller.
The invention also provides a current acquisition and calibration method of the electricity meter, the electricity meter comprises a measuring resistor, a voltage sampler, an electricity accumulator and a current acquisition and calibration circuit, the input end of the voltage sampler is connected with the two ends of the measuring resistor, the output end of the voltage sampler is connected with the electricity accumulator, the first switch is controlled by a first state signal to be switched on and off, the current acquisition and calibration circuit comprises a battery, a first switch, a second switch and a current source, the battery is connected with the measuring resistor in series and is connected with a load in parallel through the first switch, and the second switch, the current source, the battery and the measuring resistor are connected in parallel; wherein the first switch is controlled to open and close by a first status signal and the second switch is controlled to open and close by a second status signal, the method comprising the steps of: providing the second state signal to close the second switch, wherein the current source, the battery and the measuring resistor form a loop; calculating a calibration resistance value of the measuring resistor according to the current value of the current source and the sampling value of the voltage sampler; and providing the first state signal to close the first switch, forming a loop by the battery, the measuring resistor and the load, and calculating the electric quantity by the controller by adopting the calibration resistance value.
In an embodiment of the invention, the first status signal is a power-on status signal of the fuel gauge.
In an embodiment of the invention, the second status signal is provided according to a power-off status signal of a device where the electricity meter is located.
In an embodiment of the invention, the second status signal is provided according to a shutdown status signal of a device where the electricity meter is located, and one of an on-bit signal and a power stabilization signal of the battery.
In an embodiment of the present invention, the method includes: after the calibration resistance value is obtained, a calibration flag is set, wherein the calibration flag is detected, and the second state signal is generated when the calibration flag is not set.
In an embodiment of the invention, when the calibration flag is not set, if the boot vector of the device where the fuel gauge is located is received, the second status signal is still provided, and the boot process is suspended.
According to the electricity meter and the current calibration circuit thereof, errors of the mounting and the resistor are eliminated by calibrating the actual value of the precision resistor after mounting, the calibration value is written into the register of the battery voltage domain, and the value is called to calculate the electricity quantity during normal operation, so that the calculation precision of the electricity meter is optimized. The current calibration method of the embodiment of the invention respectively ensures the time of calibration and the time of electric quantity calculation when the computer is started up through strict flow design, and ensures the accuracy of calibration and the accuracy of current calculation.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in detail below.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention, but the present invention may be practiced in other ways than those specifically described herein, and thus the present invention is not limited to the specific embodiments disclosed below.
As used in this application and the appended claims, the terms "a," "an," "the," and/or "the" are not intended to be inclusive in the singular, but rather are intended to be inclusive in the plural unless the context clearly dictates otherwise. In general, the terms "comprises" and "comprising" merely indicate that steps and elements are included which are explicitly identified, that the steps and elements do not form an exclusive list, and that a method or apparatus may include other steps or elements.
The embodiment of the invention describes a current acquisition calibration circuit and a calibration method in an electricity meter, which are used for correcting errors of a measured resistor, particularly errors introduced by the resistor during mounting and errors of the resistor. The electricity meter of the present invention can be used for measuring the capacity of a battery, and thus can be widely applied to various portable electronic devices.
Fig. 3 is an electrical schematic diagram of an electricity meter according to an embodiment of the present invention. Referring to fig. 3, the fuel gauge 30 of the present embodiment includes a measuring resistor Rsense, an amplifier 31, analog-to-digital converters (ADCs) 32 and 33, an accumulator 34, a time base circuit 35, a current source 36, and a calibration enable circuit 40. The amplifier 31 and the ADC 33 form a voltage sampler, the input end of the amplifier 31 is connected to two ends of the measuring resistor Rsense, and the output end is connected to the input end of the ADC 33. The output of the ADC 33 is connected to an accumulator 34. Accumulator 34 and time reference circuit 35 form a charge accumulator.
The current collection calibration circuit 40 includes a battery BAT, a first switch SW1, a second switch SW2, a calibration enable circuit 41, a current source 42, and a controller 43. The battery BAT is connected in series with the measuring resistor Rsense and in parallel with the load RL through a first switch SW 1. The second switch SW2, the current source 42, the battery BAT and the measuring resistor Rsense are connected in parallel. The measurement resistance Rsense is nominally the resistance Rsense, however, due to the introduction of the weld resistance value Rsolder, the actual resistance Rsns is the sum of Rsense and Rsolder. In addition, the actual resistance value Rsns is the sum of Rsense 'and Rsolder, taking into account the difference between the actual value Rsense' and the nominal value of the measurement resistance Rsense. Current source 42 has a current Ical. To ensure the accuracy of the calibration, Ical needs to be stable with low error. For example, Ical has an error of + -1%.
The electricity meter of the present embodiment has two states of electricity amount calculation and resistance calibration. To this end, a first state signal and a second state signal are provided for controlling the first switch SW1 and the second switch SW2, respectively, corresponding to the two states. The power amount calculation is usually performed after the device in which the fuel gauge is located is turned on, so that the on-state signal of the device in which the fuel gauge is located is selected as the first state signal to be supplied to the first switch SW 1. The first switch SW1 is controlled by the power-on state signal to open and close, i.e. when the power-on state signal indicates that the apparatus is powered on, the first switch SW1 is closed, otherwise the first switch SW1 is open. When the device where the fuel gauge is located is turned off, the calibration accuracy can be further ensured, so that the off-state signal of the device where the fuel gauge is located is selected as the second state signal and provided to the second switch SW 2. The calibration enable circuit 41 generates a second status signal according to the power-off status and outputs the second status signal to the second switch SW 2. The second switch SW2 is controlled by the second status signal to open and close, i.e. when the off status signal indicates that the apparatus is off, the second switch SW2 is closed, otherwise the second switch SW2 is open.
When the second switch SW2 is closed, the current source 42, the battery BAT and the measuring resistor Rsense form a loop. The voltage sampler formed by the amplifier 31 and the ADC 33 will collect the voltage Vcal across the measurement resistor Rsense. The actual measured resistance value Rsns — Vcal/Ical can now be calculated in the controller 43. This resistance value can be used as a calibration resistance value.
When the first switch SW1 is closed, the battery BAT, the measurement resistor Rsense, and the load RL form a loop. The controller 43 can now perform the power calculation using the calibrated resistance value, and the power calculation process is already in the prior art and is not expanded here.
Preferably, a register 44 is provided for holding the calibration resistance value. The register 44 is connected to the controller 43 so that the controller 43 can access the register 44. Thus, when the electricity meter is in the electricity amount calculation state, the value REGcal thereof can be called from the register 44 to perform the calculation of the electricity amount.
Fig. 4 is an electrical schematic diagram of an electricity meter according to another embodiment of the present invention. Referring to fig. 4, the fuel gauge 30 of the present embodiment includes a measuring resistor Rsense, an amplifier 31, analog-to-digital converters (ADCs) 32 and 33, an accumulator 34, a time base circuit 35, a current source 36, and a calibration enable circuit 40. The amplifier 31 and the ADC 33 form a voltage sampler, the input end of the amplifier 31 is connected to two ends of the measuring resistor Rsense, and the output end is connected to the input end of the ADC 33. The output of the ADC 33 is connected to an accumulator 34. Accumulator 34 and time reference circuit 35 form a charge accumulator.
The current collection calibration circuit 40 includes a battery BAT, a first switch SW1, a second switch SW2, a calibration enable circuit 41, a current source 42, and a controller 43. The battery BAT is connected in series with the measuring resistor Rsense and in parallel with the load RL through a first switch SW 1. The second switch SW2, the current source 42, the battery BAT and the measuring resistor Rsense are connected in parallel. The measurement resistance Rsense is nominally the resistance Rsense, however, due to the introduction of the weld resistance value Rsolder, the actual resistance Rsns is the sum of Rsense and Rsolder. In addition, the actual resistance value Rsns is the sum of Rsense 'and Rsolder, taking into account the difference between the actual value Rsense' and the nominal value of the measurement resistance Rsense. Current source 42 has a current Ical. To ensure the accuracy of the calibration, Ical needs to be stable with low error. For example, Ical has an error of + -1%.
The electricity meter of the present embodiment has two states of electricity amount calculation and resistance calibration. To this end, a first state signal and a second state signal are provided for controlling the first switch SW1 and the second switch SW2, respectively, corresponding to the two states. The power amount calculation is usually performed after the device in which the fuel gauge is located is turned on, so that the on-state signal of the device in which the fuel gauge is located is selected as the first state signal to be supplied to the first switch SW 1. The first switch SW1 is controlled by the power-on state signal to open and close, i.e. when the power-on state signal indicates that the apparatus is powered on, the first switch SW1 is closed, otherwise the first switch SW1 is open. When the device where the fuel gauge is located is turned off, the calibration accuracy can be further ensured, so that the off-state signal of the device where the fuel gauge is located is selected as the second state signal and provided to the second switch SW 2. The present embodiment is different from the previous embodiment in that the calibration enable circuit 41 generates the second status signal according to the battery on-bit signal and the shutdown status signal. The calibration enable circuit 41 may be implemented as an and gate at this time. That is, the calibration is performed only when the battery is in place and the device in which the fuel gauge is located is in a power-off state.
In another variation, the battery presence signal may be replaced by a power supply stabilization signal, that is, calibration is performed only when the power supply is stable and the device in which the electricity meter is located is in a power-off state.
Fig. 5 is an electrical schematic diagram of an electricity meter according to yet another embodiment of the present invention. Referring to fig. 5, the fuel gauge 30 of the present embodiment includes a measuring resistor Rsense, an amplifier 31, analog-to-digital converters (ADCs) 32 and 33, an accumulator 34, a time base circuit 35, a current source 36, and a calibration enable circuit 40. The amplifier 31 and the ADC 33 form a voltage sampler, the input end of the amplifier 31 is connected to two ends of the measuring resistor Rsense, and the output end is connected to the input end of the ADC 33. The output of the ADC 33 is connected to an accumulator 34. Accumulator 34 and time reference circuit 35 form a charge accumulator.
The current collection calibration circuit 40 includes a battery BAT, a first switch SW1, a second switch SW2, a calibration enable circuit 41, a current source 42, and a controller 43. The battery BAT is connected in series with the measuring resistor Rsense and in parallel with the load RL through a first switch SW 1. The second switch SW2, the current source 42, the battery BAT and the measuring resistor Rsense are connected in parallel. The measurement resistance Rsense is nominally the resistance Rsense, however, due to the introduction of the weld resistance value Rsolder, the actual resistance Rsns is the sum of Rsense and Rsolder. In addition, the actual resistance value Rsns is the sum of Rsense 'and Rsolder, taking into account the difference between the actual value Rsense' and the nominal value of the measurement resistance Rsense. Current source 42 has a current Ical. To ensure the accuracy of the calibration, Ical needs to be stable with low error. For example, Ical has an error of + -1%. The value of the current Ical may be set to 100mA or several hundred mA, as needed.
The electricity meter of the present embodiment has two states of electricity amount calculation and resistance calibration. To this end, a first state signal and a second state signal are provided for controlling the first switch SW1 and the second switch SW2, respectively, corresponding to the two states. The power amount calculation is usually performed after the device in which the fuel gauge is located is turned on, so that the on-state signal of the device in which the fuel gauge is located is selected as the first state signal to be supplied to the first switch SW 1. The first switch SW1 is controlled by the power-on state signal to open and close, i.e. when the power-on state signal indicates that the apparatus is powered on, the first switch SW1 is closed, otherwise the first switch SW1 is open. When the device where the fuel gauge is located is turned off, the calibration accuracy can be further ensured, so that the off-state signal of the device where the fuel gauge is located is selected as the second state signal and provided to the second switch SW 2. The difference between this embodiment and the previous embodiment is that the current collection calibration circuit 40 further includes a register 45, which stores a calibration flag bit. After the controller 43 obtains the calibration resistance value, the calibration flag is set (e.g., set 1). The calibration enable circuit 41 detects the calibration flag bit, and generates the second status signal according to the battery on-bit signal and the power-off status signal when the calibration flag bit is not set. The calibration enable circuit 41 may now be implemented as an and gate with 3 signal inputs. That is, only when calibration is not performed, the battery is in place, and the device in which the fuel gauge is located is in a power-off state, calibration is performed.
In another variation, the battery presence signal may be replaced by a power supply stabilization signal, that is, calibration is performed only when the power supply is stable and the device in which the electricity meter is located is in a power-off state.
Fig. 6 is a flowchart of a current collection calibration method according to an embodiment of the invention. Referring to fig. 6, in the current collection calibration method of the present embodiment, when the power management chip is in the power-on reset state, the following steps are performed:
in step 61, detecting whether the equipment where the electricity meter is located is in a power-off state, if so, entering step 62, otherwise, continuing to wait;
in step 62, judging whether a starting vector exists, if so, entering step 66, otherwise, entering step 63; the starting vector is an event which can cause the equipment where the electricity meter is located to start, such as pressing a starting key, starting charging and the like;
in step 63, a resistance value calibration is performed; the specific calibration process can refer to the foregoing embodiments, and is not expanded herein;
at step 64, the calibration resistance value is written into a register;
in step 65, judging whether a starting-up vector exists again, if so, entering step 66, otherwise, continuing to wait;
in step 66, the power is turned on, and the electricity meter performs electricity quantity calculation;
in step 67, the value of the register is called for calculation when the electric quantity calculation is performed;
at step 68, the charge calculation is performed in a loop.
Fig. 7 is a flow chart of a current collection calibration method according to another embodiment of the invention. Referring to fig. 7, in the current collection calibration method of the present embodiment, when the power management chip is in the power-on reset state, the following steps are performed:
in step 71, detecting whether the equipment where the electricity meter is located is in a power-off state, if so, entering step 62, otherwise, continuing to wait;
in step 72, determining whether the calibration flag is 1, if so, entering step 73, otherwise, entering step 74;
in step 73, judging whether a starting vector exists, if so, entering step 77, otherwise, continuing to wait; the starting vector is an event which can cause the equipment where the electricity meter is located to start, such as pressing a starting key, starting charging and the like;
at step 74, a resistance value calibration is performed; the specific calibration process can refer to the foregoing embodiments, and is not expanded herein;
at step 75, the calibration resistance value is written into the register and the calibration flag bit is set;
at step 76, it is determined again whether a boot vector exists, if so, step 66 is entered, otherwise, the wait continues;
in step 77, the power is turned on, and the electricity meter performs electricity quantity calculation;
in step 78, the register value is called for calculation when the power calculation is performed;
in step 79, the power calculation is performed cyclically.
Fig. 8 is a flowchart of a current collection calibration method according to another embodiment of the present invention. Referring to fig. 8, in the current collection calibration method of the present embodiment, when the power management chip is in the power-on reset state, the following steps are performed:
in step 81, judging whether the battery is in place, if so, entering step 83, otherwise, entering step 82;
in step 82, judging whether the power supply is stable, if so, entering step 83, otherwise, returning to step 81;
in step 83, detecting whether the device where the electricity meter is located is in a power-off state, if so, entering step 84, otherwise, continuing to wait;
in step 84, determining whether the calibration flag is 1, if so, indicating that calibration has been performed, entering step 85, otherwise, entering step 86;
in step 85, judging whether a starting vector exists, if so, entering step 89, otherwise, continuing to wait; the starting vector is an event which can cause the equipment where the electricity meter is located to start, such as pressing a starting key, starting charging and the like;
at step 86, a resistance value calibration is performed; the specific calibration process can refer to the foregoing embodiments, and is not expanded herein;
at step 87, writing the calibration resistance value to the register and setting the calibration flag bit;
in step 88, it is determined again whether a boot vector exists, if yes, step 66 is entered, otherwise, the process continues to wait;
in step 89, starting up, the electricity meter performs electricity quantity calculation;
in step 90, the value of the register is called for calculation when the electric quantity calculation is performed;
in step 91, power calculation is performed in a loop.
In addition, when the power is turned on and each power supply is turned on, the calibration value is influenced by the increase of the load current. The calibration is performed in a shutdown condition. In order to avoid the calibration accuracy being affected by the power-on during the calibration of the resistance value, the embodiment shown in fig. 7 can be further optimized as the embodiment shown in fig. 9. Referring to fig. 9, in the current collection calibration method of the present embodiment, when the power management chip is in the power-on reset state, the following steps are performed:
in step 1001, detecting whether the device where the electricity meter is located is in a power-off state, if so, entering step 62, otherwise, continuing to wait;
in step 1002, judging whether the calibration flag bit is 1, if so, indicating that the calibration is performed, entering step 1003, otherwise, entering step 1004;
in step 1003, judging whether a starting-up vector exists, if so, entering step 1011, otherwise, continuing to wait; the starting vector is an event which can cause the equipment where the electricity meter is located to start, such as pressing a starting key, starting charging and the like;
in step 1004, judging whether a starting vector exists, if so, entering step 1008, otherwise, entering step 1005;
in step 1005, performing a resistance value calibration; the specific calibration process can refer to the foregoing embodiments, and is not expanded herein;
at step 1006, writing the calibration resistance value into a register and setting a calibration flag bit;
in step 1007, it is determined again whether a boot vector exists, if yes, step 66 is entered, otherwise, the waiting is continued;
at step 1008, a resistance value calibration is performed;
in step 1009, a boot process is performed;
at step 1010, writing a calibration resistance value to a register and setting a calibration flag bit;
in step 1011, the electricity meter is started up to calculate the electricity quantity;
in step 1012, the value of the register is called for calculation when the electric quantity calculation is performed;
in step 1013, the power calculation is performed cyclically.
That is, when the boot vector is determined to exist in step 1004, the boot process is not performed immediately, but is delayed for a predetermined time (e.g., 100ms), the resistance calibration is performed in step 1008 within the predetermined time, and then the boot process is performed in step 1009.
According to the electricity meter and the current calibration circuit thereof, errors of the mounting and the resistor are eliminated by calibrating the actual value of the precision resistor after mounting, the calibration value is written into the register of the battery voltage domain, and the value is called to calculate the electric quantity during normal operation, so that the calculation accuracy of the electricity meter is optimized. The current calibration method of the embodiment of the invention respectively ensures the time of calibration and the time of electric quantity calculation when the computer is started up through strict flow design, and ensures the accuracy of calibration and the accuracy of current calculation.
Although the present invention has been described with reference to the present specific embodiments, it will be appreciated by those skilled in the art that the above embodiments are merely illustrative of the present invention, and various equivalent changes and substitutions may be made without departing from the spirit of the invention, and therefore, it is intended that all changes and modifications to the above embodiments within the spirit and scope of the present invention be covered by the appended claims.