Clock Battery Monitor Circuit - Page 1
Forum section: electronics / projects

author: bitogre
author_rank: Contributor
timestamp: July 18, 2020, 07:49:06 pm
content: I am working on a personal project using a Teensy 4.1 to monitor/log info in my RV. When the RV is in use, the Teensy will be on, powered by the RV's 12V lead acid battery. But I remove the lead acid battery when in storage, so, to keep the Real-Time Clock set, I will have a smaller battery (lithium coin cell or 2 AA batteries to power the RTC). I want to use a spare ADC input on the Teensy to monitor the RTC battery and let me know when it is low so I can change it before it dies. Problem is, it looks like the Teensy ADC input will put too much load on the battery when it has no power (other than for the RTC) which will kill my RTC battery in a month or so if I connect it directly. Will the following circuit help prevent the extra load on the RTC battery when the Teensy has no power (effectively pulling the ADC Input and Enable Logic pins to Ground)?If so, any recommendations on the FET? This is a one off project so through hole components are preferred. I have no experience with FETs so not sure if I got this right. The key thing I am looking for is as low as possible Drain to Source current (micro-amps or less) when Enable Logic is pulled low and turns on restively (can have a resistance as high a 1K ohm) or known fixed voltage drop when Enable Logic is pulled high. I am not worried about the current draw when enabled as I can minimize how long it is enabled to when I am checking the voltage (a couple milliseconds every hour/day or so).I am also open to other suggestions for other circuits that would work using through hole components.

author: madires
author_rank: Super Contributor
timestamp: July 18, 2020, 08:23:01 pm
content: A JFET would be the wrong transistor for that purpose (because of the depletion mode). Better use a low-leakage small signal p-channel MOSFET or a PNP BJT.

author: bitogre
author_rank: Contributor
timestamp: July 18, 2020, 08:47:59 pm
content: Quote from: madires on July 18, 2020, 08:23:01 pmThe problem I see with using a PNP BJT is that the Teensy 4.1 uses 3.3V logic so the Enable logic high voltage may only be a couple tenths of a volts higher than the battery voltage I am trying to measure. I am having problems figuring out how to amplify that signal enough to provide enough Base to Emitter voltage to get an accurate voltage reading.As for using a MOSFET, as I said, I do not know much about FETs (of all types) so that seems reasonable. Would it be more or less a drop in replacement to the JFET in my circuit diagram? Or would the circuit need changes to support the MOSFET?

author: madires
author_rank: Super Contributor
timestamp: July 18, 2020, 09:03:13 pm
content: The PNP or p-ch MOSFET would have a pull-up resistor to prevent them from conducting and the MCU would pull the base/gate down for switching on. But that switching will draw some power from the battery. Another idea would be to use a CMOS switch. Basically you're looking for a low power switch with a low leakage current.

author: bitogre
author_rank: Contributor
timestamp: July 18, 2020, 09:10:24 pm
content: Quote from: madires on July 18, 2020, 09:03:13 pmI do not think an active low solution will work. The problem I see with that is that the MCU, when powered off, effectively is a 1.5K pull down to ground. What is to keep it from turning on in that case? I was looking for an active high solution so that a low on Enable is off (so the turned off MCU and intentional off are the same).

author: madires
author_rank: Super Contributor
timestamp: July 18, 2020, 09:16:04 pm
content: Simply add an NPN BJT or n-channel MOSFET for turning the high side switch transistor on.

author: bitogre
author_rank: Contributor
timestamp: July 18, 2020, 09:29:24 pm
content: Quote from: madires on July 18, 2020, 09:16:04 pmSo, something like this? I think I have BJTs that would work for this on hand.

author: madires
author_rank: Super Contributor
timestamp: July 18, 2020, 09:42:53 pm
content: Yep! And don't forget to add the PNP's voltage drop to the measured voltage.

author: Ian.M
author_rank: Super Contributor
timestamp: July 18, 2020, 10:10:52 pm
content: Looks like a mess. The original circuit would work as long as the JFET's pinch-off voltage was less than the lowest battery voltage of interest, but great care would have to be taken *NOT* to forward bias the gate-channel junction by taking the gate above the battery voltage.As there's a 12V supply available, it would make more sense to use a N-MOSFET as the ADC isolator, source to the ADC, and use the main battery voltage (after the usual automotive transient filtering and protection circuits) to pull its gate well above Teensy Vcc when you want it on and down to 0V when you want it off. A BSS170 would do well enough, with another one for the Teensy to pull its gate down if you want to be able to turn it off when the main 12V supply is present.

author: james_s
author_rank: Super Contributor
timestamp: July 18, 2020, 10:11:00 pm
content: What's the input impedance of the ADC? I'd have thought it would be very high, but maybe they've got some external circuitry on there?

author: bitogre
author_rank: Contributor
timestamp: July 18, 2020, 10:37:51 pm
content: Quote from: Ian.M on July 18, 2020, 10:10:52 pmI cannot be sure that the gate voltage would not exceed battery voltage without adding additional circuitry. So, to ensure that, it would likely be just as complex as the BJT solution.The 12V supply is only available when making measurements. But it is not available when I need the ADC Input isolated. In fact, the reason the Teensy is off is because that 12V had been removed.

author: bitogre
author_rank: Contributor
timestamp: July 18, 2020, 10:44:21 pm
content: Quote from: james_s on July 18, 2020, 10:11:00 pmAccording to Page 60 and 61 ofhttps://www.pjrc.com/teensy/IMXRT1060CEC_rev0_1.pdf,the input impedance should between 5k ohms and 30k ohms but I am pretty sure that is while power is applied to the Teensy 4.1. When I measured is with my multi-meter while not powered, it was about 1500 ohms. According tohttps://www.pjrc.com/teensy/schematic.html,there should be no additional circuity on the pin I was measuring relative to ground.

author: Peabody
author_rank: Super Contributor
timestamp: July 18, 2020, 11:24:39 pm
content: There probably is a way to make this work, but I wonder if your time might be better spent on some other part of your project. If you disconnect the RTC module from your circuit when your RV goes into storage, the coin cell will keep it going for a year, or even a lot longer. Not to mention larger batteries, or even two coin cells in parallel. And even in the worst case, it's not the end of the world if you have to reset the RTC at some point. I just got a DS3231 RTC, and the datasheet says when it's battery powered and inactive except for timekeeping, it draws 1µA. You're looking at months and months.

author: bitogre
author_rank: Contributor
timestamp: July 19, 2020, 12:36:01 am
content: Quote from: Peabody on July 18, 2020, 11:24:39 pmI was hoping it would be a bit easier than it is currently looking like it might be. I am currently not planning on using a DS3231 RTC as the Teensy 4.1 does have a built in RTC (not as many features and draws more current at 250uA but less work to use). Also, was not planning on putting this some place where it is easy to access for replacing the battery but I am starting to rethink that plan. I do have WIFI D1 mini - Data logger shield which does have a DS1307 that I could use for this project for the RTC.

author: Ian.M
author_rank: Super Contributor
timestamp: July 19, 2020, 01:02:07 am
content: As long as nothing else is holding the nom. 12V rail up, and the MOSFET doesn't get overheated in storage, this will do:Leakage current should be under 1uA. It will go up a bit at seriously elevated temperatures, so don't store your RV in a tin shed in Death Valley! A 2N7000 should also work.

author: bitogre
author_rank: Contributor
timestamp: July 19, 2020, 04:16:23 pm
content: I thought of another possibly simpler option: op amp as buffer. An op amp in a non-inverting unity gain should provide a high impedance (even when it does not have power) yet provide low impedance output to drive the ADC. Does this sound reasonable?

author: Ian.M
author_rank: Super Contributor
timestamp: July 19, 2020, 04:40:21 pm
content: An OPAMP's input impedance when unpowered depends on its exact topology and input protection network and is rarely specified.

author: Peabody
author_rank: Super Contributor
timestamp: July 19, 2020, 04:52:26 pm
content: I don't know about the opamp, but can I back up and ask how you plan to power up the Teensy periodically to check the battery voltage? Is the coin cell going to power that process, or are you going to temporarily manually connect the 12V supply?In a way, using the built-in RTC seems to complicate things somewhat. I assume the RTC shares a common ground with the rest of the processor. If it didn't until it's time to measure, I don't think the ADC input would be a current sink at all.Is there a tutorial on the Teensy RTC? I didn't find much on Youtube.

author: Peabody
author_rank: Super Contributor
timestamp: July 19, 2020, 05:45:32 pm
content: I found this in one of the Teensy datasheets:"20.5 Reset and Initialization of SNVSSNVS is implemented in two sections (HP and LP) that both must be initialized by software following POR. If the SNVS_LP is powered by an uninterrupted power source that is separate from main SoC power, then SNVS can operate in either of two modes, depending upon whether the main SoC power is on or off. During main SoC power-down SNVS_HP is powered-down, but SNVS_LP is powered from the backup power supply and iselectrically isolatedfrom the rest of the chip. In this mode SNVS_LP keeps its registers' values and monitors the SNVS_LP tamper detection inputs, but the LP registers cannot be read or written. During main SoC power-up the isolation of SNVS_LP is disabled and both SNVS_HP and SNVS_LP are powered from the main SoC power."I don't know what "electrically isolated" means here, but have you actually tested whether the ADC input sinks current from the coin battery when the main power is down?

author: bitogre
author_rank: Contributor
timestamp: July 19, 2020, 05:48:01 pm
content: Quote from: Peabody on July 19, 2020, 04:52:26 pmI will be powering the Teensy when I am using the RV (about every other month). So, I will only be checking the RTC battery about every other month when I am using the RV (probably when I am packing it for my trip). No, the coin cell is NOT going to power that process.Yes, the RTC shares a common ground. Even if I went to an external RTC like the DS1307 or DS3231, it would have a common ground between the battery and the data lines. So, I do not see how internal vs external RTC makes a difference on this problem.The info on how to use the Teensy 4.X RTC is the same as using the RTC on the Teensy 3.X (older Teensys didn't have an RTC). The documentation is minimal and the best is found in the code examples buthttps://www.pjrc.com/teensy/td_libs_Time.html#teensy3has the basics (though it does not seem to have been updated for Teensy 4.x).

author: bitogre
author_rank: Contributor
timestamp: July 19, 2020, 05:54:32 pm
content: Quote from: Peabody on July 19, 2020, 05:45:32 pmI also do not know what "electrically isolated" means in that paragraph. But, Yes, I put a multi-meter from ground to various ADC pins while the Teensy had no power (not even VBat for the RTC) and my multi-meter indicated about 1500 ohms from the ADC pin to ground. Maybe it is not linear (not a pure resistor) and could change with different voltages but I think that does clearly show the input would sink power from the battery.

author: bitogre
author_rank: Contributor
timestamp: July 19, 2020, 05:59:38 pm
content: Quote from: Ian.M on July 19, 2020, 04:40:21 pmGood point. Will have to test once I get an op amp to try for this purpose. Also, I could ensure a high impedance by adding a 100k ohm or maybe larger resistor between the op amp input and the battery. That would ensure at least that much input impedance even if op amp input impedance dropped to 0 when it looses power.

author: Peabody
author_rank: Super Contributor
timestamp: July 19, 2020, 06:09:17 pm
content: Quote from: bitogre on July 19, 2020, 05:48:01 pmWell, the difference is that you could just disconnect the separate RTC module when you go into storage, and connect it again when using the RV. This could be entire module or just the ADC connection or the ground connection. But you can do the same thing using the built-in RTC by just switching off the connection from B+ to the ADC pin. Of course I understand that a switch is not as elegant as making it work automatically.

author: Peabody
author_rank: Super Contributor
timestamp: July 19, 2020, 06:21:25 pm
content: Quote from: bitogre on July 19, 2020, 05:54:32 pmBut if VBat wasn't powered, that's still not quite the situation you would be in. The test I'd like to see is with the coin cell powering the RTC, but the main power off, so that this mysterious electrical isolation is in effect, how much current flows from the coin B+ to the ADC pin, with a 10K resistor in series just to be safe. My thought is that the coin battery may somehow be powering the isolation, such as by disconnecting its own ground from the rest of the chip. If it does that, you won't see any current flow through ADC. It's actually what "electrically isolated" should mean.

author: bitogre
author_rank: Contributor
timestamp: July 19, 2020, 06:33:26 pm
content: Quote from: Peabody on July 19, 2020, 06:21:25 pmI suspect what is going on and causing the load is that there is probably over-voltage protection diodes to clamp in the input voltage to Vdd + the diode voltage drop. So, with Vdd free floating, the moment you put a voltage source on the input, it tries to power the UMC with that input voltage. Dave did a video on this:

author: Peabody
author_rank: Super Contributor
timestamp: July 19, 2020, 06:44:38 pm
content: I understand, and that may be the case, but if "isolation" disconnects the battery ground from the main ground, you won't get any current flow even if the ADC pin was a direct short to its ground. For current to flow, there has to be a path back to the negative terminal of the coin battery from the system ground. If that's switched off, no current will flow. The standard DW01 lithium protection circuit does exactly that, so it's not impossible that they could have done the same for this chip.

author: bitogre
author_rank: Contributor
timestamp: July 19, 2020, 06:54:24 pm
content: Quote from: Peabody on July 19, 2020, 06:44:38 pmOk, so a standard DW01 lithium protection circuit is another option but only if using an external RTC. Interesting. Will have to investigate that further.

author: Peabody
author_rank: Super Contributor
timestamp: July 19, 2020, 10:27:42 pm
content: Quote from: bitogre on July 19, 2020, 06:54:24 pmI'm just saying that's something they could have done to make the internal RTC truly isolated. I just want you to do the test I described above to find out.For an external RTC module, it might be as simple as an N-channel mosfet switching the Teensy ground to the external module ground, with the gate controlled by a Teensy GPIO pin. But you would have the same issue as before, but in the opposite direction: when the main power is turned off, does that pin go to ground, or does the positive voltage applied to the ADC pin keep it from doing that? And of course there are the I2C lines between the module and the Teensy. I don't know what happens to them.

author: Peabody
author_rank: Super Contributor
timestamp: July 22, 2020, 01:13:59 am
content: Attached is a circuit that connects an external RTC module's ground to the Arduino ground only when the Arduino is powered up. I had hoped it could be done with one transistor, but I don't see way to do that. I breadboarded this, and I see no current flow out of the coin B+. However, when the Arduino is powered up, there is current flow through the base resistor of the PNP and the gate resistor of the mosfet. So it might be best to connect the emitter and base of the PNP to GPIO ports so they can be turned on only when you need to measure the voltage or communicate with the RTC.

author: bitogre
author_rank: Contributor
timestamp: August 09, 2020, 11:35:46 pm
content: Quote from: Ian.M on July 19, 2020, 04:40:21 pmI am thinking of using a LM741 Op Amp (https://www.ti.com/lit/ds/symlink/lm741.pdf). My testing of it seems to have a really high impedance with no power (which make sense given the specified functional diagram) and a reasonable Input Bias Current. I can give it 5V power to ensure I have enough head room on the output when powered.