# When to read Battery voltage and battery current during charging

I am using a micro-controller to drive a buck converter for Li-ion battery charging purpose(Micro-controller providing PWM to the buck converter). During charging the battery's current and voltage have to be constantly monitored in order to supervise charging. I have used external ADCs for monitoring the charging voltage and current.

To learn how to charge Li-Ion cells, i was going through a couple of documents. These documents tell, when to measure the battery voltage and charging current during charging. The problem is that i have read two different kind of methods in two different documents, and i am not sure which one is right and which one to follow.

1) This document by MicroChip says to measure both the voltage and current during the OFF time PWM duty cycle (when PWM is low)

This can be seen (Page. 6 "Voltage Sense" and Page. 7 "Current Sense").

2) However This document by NEC designs a battery charger, which measures the charging voltage during the OFF time PWM duty cycle and measure the charging current during the ON time PWM duty cycle.

This can be seen (page 23, 6.3 Battery Monitor, also figure 6-6: Battery Monitor) and (page 37 where the code is listed, inside the function "void do_adc_conversions (void){" it states "// measure battery current if charger output enabled... // ...otherwise measure battery voltage") .

So can anyone please tell me what is the right way to go ?

Thankyou!

• You can't measure the current when the PWM is off because then .. there is no current! – pjc50 Nov 10 '15 at 15:39
• There is no one single right method and all others bad methods, each inventor will claim his method is the best. Perhaps just measuring the battery voltage isn't a good information. To determine the voltage, a short discharge pulse & measure would do the trick. – Marko Buršič Nov 10 '15 at 15:47
• The datasheet has obviously a copypasta error because it is written by some intern – PlasmaHH Nov 10 '15 at 15:48
• @PlasmaHH as if an engineer wouldn't make copypasta (sic) errors... – Arsenal Nov 10 '15 at 16:22
• It's a common mistake in spaghetti code – Brian Drummond Nov 10 '15 at 17:23

Maybe you are getting confused as the PWM of the both systems are for different functions. The PWM of the Microchip document controls the buck converter transistor. There are 2 PWMs in the NEC document one controls the buck converter transistor, but the other controls a charge control transistor. The latter is used for the voltage and current measurement decision.

So in the case of the NEC document it is like pjc50 mentions, there is no current flow when the PWM is off (for the charge control transistor), so you cannot measure the current there. It has some advantages of measuring the voltage of the battery when no charging (or discharging) current is applied, as you are closer to the real open circuit voltage of the battery. Only closer because of the relaxation effect of batteries, which is on a seconds to minutes timescale, so much slower than your typical PWM signals.

Why exactly it would result in erroneous operation if you would measure the voltage and current during the on time of the PIC PWM is not really obvious to me. The only hint I could find was that the PWM gets disabled and adjusted after the measurements, which should be done when PWM is low (otherwise you will get strange PWM pulses).

As the PIC solution involves a buck converter but does not use the charge control transistors, there will always be a current flowing to the battery regardless of the state of the PWM, so you won't have a benefit of getting closer to the open circuit voltage.

Generally you want to get your measurements as close to the open circuit voltage as possible if you are doing voltage based state of charge indication. So ideally you want to measure the voltage if no current is going in or out of the battery and have waited for some minutes to let the battery settle (relaxation effect), waiting is usually omitted. The current would introduce an error because of the internal resistance, so the voltage you measure would be too high while charging and you'd estimate the state of charge as too high.

To be on the safe side, you'd still switch from constant current to constant voltage mode when the measured voltage reaches 4.2 V, primarily because you don't monitor the internal resistance of the battery at the same time to calculate the internal cell voltage. (And I think that approach to fast charging was recently patented for whatever reason)

The main reason for measuring Voltage while charging current is off is to eliminate errors caused by wiring and connector resistance. This is particularly important when charging Nicad or NiMH batteries, which require accurate measurement of voltage change for peak detection. Connector resistance may vary randomly due to insufficient contact pressure, oxidation, movement of the battery in its holder etc.

In addition the Microchip charger measures battery voltage relative to Ground, so the current sense resistor (which is between battery negative and Ground) would also cause an error. The NEC circuit uses a differential amplifier to measure voltage across the battery so it does not have this issue.

The Microchip charger may read current during PWM off time in order to reduce errors caused by ground loop currents. Battery current doesn't drop to zero instantly during PWM off time because there is a 470uF filter capacitor across the output of the buck converter. The source code for I_SENSE() says:-

      Notes: This function should be called after the PWM has
just been turned-off, since this is the point of
maximum current.


The description of current sensing on page 7 uses the phrase 'rest period of the charge cycle' when what it really means is 'OFF period of the PWM cycle' (the 'rest period' is usually a much longer time that allows the battery voltage to settle).

• In a buck converter the current doesn't drop to zero as the inductor is still driving the current, the capacitor smooths it further. Good catch on the source comment though. – Arsenal Nov 12 '15 at 8:24