EEVblog Electronics Community Forum

Electronics => Projects, Designs, and Technical Stuff => Topic started by: Northy on May 25, 2021, 04:59:05 pm

Title: Measuring RTC battery?
Post by: Northy on May 25, 2021, 04:59:05 pm
I'm trying to figure out the best way to measure the battery on a RTC in something I'm designing.

I have:
BQ32002 RTC running from a CR2032 backup battery when the power is off.
BQ32002 running from 3V3 when the power is on.
A spare input on a TLA2024 ADC, running from 3V3.

I'm just looking for a quick and dirty voltage measurement to warn that the battery is about dead, nothing too accurate. I know this might take years if it's never actually powered down.

I've used the FET switching circuits with potential dividers for measuring power rails higher than VCC, but in this case I'm measuring lower than VCC, so I don't need a potential divider.
How can I measure the battery voltage (obviously only when running on external power) of the RTC battery without significantly affecting its life?

Thanks,

G


Title: Re: Measuring RTC battery?
Post by: Zero999 on May 25, 2021, 07:14:42 pm
You can measure it directly with the ADC input, which will have a very high input impedance. The problem is, when the power is disconnected, it will discharge through the ESD protection diodes. A Switch is required to isolate it, when the power is disconnected. If there's plenty of power available, whist the device is powered, the simplest way to do this is with a small relay.
Title: Re: Measuring RTC battery?
Post by: Peabody on May 25, 2021, 10:59:35 pm
A relay, or a P-channel mosfet with its gate driven by an NPN transistor.  Given how long these coin cells last, and what it's going to take to implement, this has to be of borderline usefulness at best.  But it certainly can be done.
Title: Re: Measuring RTC battery?
Post by: Someone on May 25, 2021, 11:07:21 pm
A relay, or a P-channel mosfet with its gate driven by an NPN transistor.  Given how long these coin cells last, and what it's going to take to implement, this has to be of borderline usefulness at best.  But it certainly can be done.
Yes, most often the "flat battery" warning is an after the fact alert that is triggered by illogical/corrupt data coming from the battery backup data source. Try and guess how many users will actually react to a "almost flat battery" warning?
Title: Re: Measuring RTC battery?
Post by: NiHaoMike on May 26, 2021, 12:14:18 am
A relay, or a P-channel mosfet with its gate driven by an NPN transistor.  Given how long these coin cells last, and what it's going to take to implement, this has to be of borderline usefulness at best.  But it certainly can be done.

If there's a higher voltage available (e.g 5V or even a simple discrete charge pump), a N channel MOSFET would be a more straightforward solution.
Title: Re: Measuring RTC battery?
Post by: Peabody on May 26, 2021, 03:23:10 am
Even if his processor is running at 3.3V, an N-channel might work.  A new CR2032 would be a little over 3V, but you really only need  a good measurement when it's down to maybe 2.7V.  So a logic level mosfet might do it.  There's no current, so it would only have to turn on a little bit.  But you might need a high-value pull-down resistor on the source to get it to turn on.  You would just need a mosfet with a really low gate threshold voltage.
Title: Re: Measuring RTC battery?
Post by: Zero999 on May 26, 2021, 07:55:17 am
A relay, or a P-channel mosfet with its gate driven by an NPN transistor.  Given how long these coin cells last, and what it's going to take to implement, this has to be of borderline usefulness at best.  But it certainly can be done.
How do you stop the voltage on the battery from turning on the MOSFET?
Title: Re: Measuring RTC battery?
Post by: Peabody on May 26, 2021, 02:34:28 pm
A relay, or a P-channel mosfet with its gate driven by an NPN transistor.  Given how long these coin cells last, and what it's going to take to implement, this has to be of borderline usefulness at best.  But it certainly can be done.
How do you stop the voltage on the battery from turning on the MOSFET?

For the P-channel, I was thinking of the circuit below.  The mosfet will stay off unless the NPN turns on and grounds its gate.
Title: Re: Measuring RTC battery?
Post by: Northy on May 26, 2021, 03:32:44 pm
A relay, or a P-channel mosfet with its gate driven by an NPN transistor.  Given how long these coin cells last, and what it's going to take to implement, this has to be of borderline usefulness at best.  But it certainly can be done.
How do you stop the voltage on the battery from turning on the MOSFET?

For the P-channel, I was thinking of the circuit below.  The mosfet will stay off unless the NPN turns on and grounds its gate.

Thanks all, I've gone with this approach put used an N Fet instead of a transistor, is there any reason to not use the N Fet?
Should I "load" the coin cell while measuring it? Would that give a better measurement?

Thanks,

G
Title: Re: Measuring RTC battery?
Post by: Peabody on May 26, 2021, 05:36:53 pm
I think an N-channel mosfet should work fine.  You may need a 1Meg pulldown on its gate to keep it from ever floating.  And a 1Meg pulldown on the analog read pin would provide a standard "load" for measuring the battery, although I don't think that's necessary.

But remember that every time you measure the voltage, you use up some coin cell power - through the gate resistor and through the load resistor.  So if you measure often, you will materially shorten the coin cell life.  Once a month should be often enough.
Title: Re: Measuring RTC battery?
Post by: ledtester on May 26, 2021, 05:52:33 pm
Would it be possible to drive the gate directly from the Arduino GPIO pin?

Are there any issues if the GPIO pin is HI-Z?
Title: Re: Measuring RTC battery?
Post by: Peabody on May 26, 2021, 06:14:25 pm
Would it be possible to drive the gate directly from the Arduino GPIO pin?

Are there any issues if the GPIO pin is HI-Z?

No, that doesn't work.  As Zero999 said in the first reply, when you power down the Arduino, the internal protection diode going from the GPIO pin to Vcc would become a diode to ground because Vcc will quickly decay to ground.  That would drop the gate voltage to about 0.65V, which would turn on the mosfet.  That would also sink current from the coin battery through the gate pullup resistor.  So you would be wasting a lot of coin cell power when the Arduino is powered down.  Kinda the worst of all possible worlds.

I would need to think about it, but it might be possible to connect the coin cell B+ directly to the analog input pin, but only connect the RTC's ground to the Arduino ground when the Arduino is powered up.  Then a single N-channel mosfet might be enough, and that could be automatic so that it comes up with the Arcuino's Vcc.  Not sure about all that though.  There is the issue of the I2C lines and whether they might provide a path for the return current back to the B- terminal.  You might need to experiment to find that out.

Edit:  I don't think the ground switch works.  I wssn't able to come up with anything that made sense.

Title: Re: Measuring RTC battery?
Post by: NiHaoMike on May 26, 2021, 10:36:16 pm
What about a pair of small MOSFETs with one acting as a source follower and the other compensating for the Vgs? You could even find one that's a pair in one package to get better matching. Or maybe an opamp with inputs that remain high impedance even when unpowered.
Title: Re: Measuring RTC battery?
Post by: Zero999 on May 27, 2021, 06:59:49 pm
A relay, or a P-channel mosfet with its gate driven by an NPN transistor.  Given how long these coin cells last, and what it's going to take to implement, this has to be of borderline usefulness at best.  But it certainly can be done.
How do you stop the voltage on the battery from turning on the MOSFET?

For the P-channel, I was thinking of the circuit below.  The mosfet will stay off unless the NPN turns on and grounds its gate.

Thanks all, I've gone with this approach put used an N Fet instead of a transistor, is there any reason to not use the N Fet?
Should I "load" the coin cell while measuring it? Would that give a better measurement?

Thanks,

G
A MOSFET is a type of transistor.

Why do you prefer to use a MOSFET? There are no advantages I can think of and it'll work out more expensive. MOSFETs also tend to leak more, than BJTs, but at 3V, it won't be a problem.
https://ww1.microchip.com/downloads/en/DeviceDoc/TP2104-P-Channel-Enhancement-Mode-Vertical-DMOS-FET-Data-Sheet-20005958A.pdf (https://ww1.microchip.com/downloads/en/DeviceDoc/TP2104-P-Channel-Enhancement-Mode-Vertical-DMOS-FET-Data-Sheet-20005958A.pdf)
https://www.mouser.com/datasheet/2/302/nxp_bc556_557-1188849.pdf (https://www.mouser.com/datasheet/2/302/nxp_bc556_557-1188849.pdf)

I'd go with BJTs, given the choice. As it's only 3V, the P-MOSFET can be swapped for a BJT, which can be run in reverse, to give a very low saturation voltage. A tiny current is required to charge the ADC sample and hold capacitor, so the low hFE isn't an issue.
(https://www.eevblog.com/forum/projects/measuring-rtc-battery/?action=dlattach;attach=1222704;image)
Title: Re: Measuring RTC battery?
Post by: Peabody on May 27, 2021, 11:01:47 pm
Zero999, can you explain why your PNP is backwards?
Title: Re: Measuring RTC battery?
Post by: Zero999 on May 28, 2021, 01:24:08 pm
Zero999, can you explain why your PNP is backwards?
Lower saturation voltage.
Title: Re: Measuring RTC battery?
Post by: Peabody on May 29, 2021, 03:42:18 am
Thanks.  I didn't know that.