Author Topic: Clock Battery Monitor Circuit  (Read 7274 times)

0 Members and 1 Guest are viewing this topic.

Offline bitogreTopic starter

  • Contributor
  • Posts: 19
  • Country: us
Clock Battery Monitor Circuit
« on: July 18, 2020, 07:49:06 pm »
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.
« Last Edit: July 18, 2020, 08:01:04 pm by bitogre »
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 8276
  • Country: de
  • A qualified hobbyist ;)
Re: Clock Battery Monitor Circuit
« Reply #1 on: July 18, 2020, 08:23:01 pm »
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.
 
The following users thanked this post: bitogre

Offline bitogreTopic starter

  • Contributor
  • Posts: 19
  • Country: us
Re: Clock Battery Monitor Circuit
« Reply #2 on: July 18, 2020, 08:47:59 pm »
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.

The 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?
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 8276
  • Country: de
  • A qualified hobbyist ;)
Re: Clock Battery Monitor Circuit
« Reply #3 on: July 18, 2020, 09:03:13 pm »
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.
 

Offline bitogreTopic starter

  • Contributor
  • Posts: 19
  • Country: us
Re: Clock Battery Monitor Circuit
« Reply #4 on: July 18, 2020, 09:10:24 pm »
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.

I 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).
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 8276
  • Country: de
  • A qualified hobbyist ;)
Re: Clock Battery Monitor Circuit
« Reply #5 on: July 18, 2020, 09:16:04 pm »
Simply add an NPN BJT or n-channel MOSFET for turning the high side switch transistor on.
 
The following users thanked this post: bitogre

Offline bitogreTopic starter

  • Contributor
  • Posts: 19
  • Country: us
Re: Clock Battery Monitor Circuit
« Reply #6 on: July 18, 2020, 09:29:24 pm »
Simply add an NPN BJT or n-channel MOSFET for turning the high side switch transistor on.

So, something like this?  I think I have BJTs that would work for this on hand.

 

Offline madires

  • Super Contributor
  • ***
  • Posts: 8276
  • Country: de
  • A qualified hobbyist ;)
Re: Clock Battery Monitor Circuit
« Reply #7 on: July 18, 2020, 09:42:53 pm »
Yep! And don't forget to add the PNP's voltage drop to the measured voltage.
 
The following users thanked this post: bitogre

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13218
Re: Clock Battery Monitor Circuit
« Reply #8 on: July 18, 2020, 10:10:52 pm »
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.

 
The following users thanked this post: bitogre

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Clock Battery Monitor Circuit
« Reply #9 on: July 18, 2020, 10:11:00 pm »
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?
 

Offline bitogreTopic starter

  • Contributor
  • Posts: 19
  • Country: us
Re: Clock Battery Monitor Circuit
« Reply #10 on: July 18, 2020, 10:37:51 pm »
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.

I 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.
« Last Edit: July 18, 2020, 10:45:59 pm by bitogre »
 

Offline bitogreTopic starter

  • Contributor
  • Posts: 19
  • Country: us
Re: Clock Battery Monitor Circuit
« Reply #11 on: July 18, 2020, 10:44:21 pm »
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?

According to Page 60 and 61 of https://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 to https://www.pjrc.com/teensy/schematic.html, there should be no additional circuity on the pin I was measuring relative to ground.
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2248
  • Country: us
Re: Clock Battery Monitor Circuit
« Reply #12 on: July 18, 2020, 11:24:39 pm »
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.
 
 

Offline bitogreTopic starter

  • Contributor
  • Posts: 19
  • Country: us
Re: Clock Battery Monitor Circuit
« Reply #13 on: July 19, 2020, 12:36:01 am »
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.

I 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.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13218
Re: Clock Battery Monitor Circuit
« Reply #14 on: July 19, 2020, 01:02:07 am »
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.
 
The following users thanked this post: bitogre

Offline bitogreTopic starter

  • Contributor
  • Posts: 19
  • Country: us
Re: Clock Battery Monitor Circuit
« Reply #15 on: July 19, 2020, 04:16:23 pm »
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?
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13218
Re: Clock Battery Monitor Circuit
« Reply #16 on: July 19, 2020, 04:40:21 pm »
An OPAMP's input impedance when unpowered depends on its exact topology and input protection network and is rarely specified.
 
The following users thanked this post: bitogre

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2248
  • Country: us
Re: Clock Battery Monitor Circuit
« Reply #17 on: July 19, 2020, 04:52:26 pm »
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.
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2248
  • Country: us
Re: Clock Battery Monitor Circuit
« Reply #18 on: July 19, 2020, 05:45:32 pm »
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 is electrically isolated from 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?
 

Offline bitogreTopic starter

  • Contributor
  • Posts: 19
  • Country: us
Re: Clock Battery Monitor Circuit
« Reply #19 on: July 19, 2020, 05:48:01 pm »
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.

I 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 but https://www.pjrc.com/teensy/td_libs_Time.html#teensy3 has the basics (though it does not seem to have been updated for Teensy 4.x).
 

Offline bitogreTopic starter

  • Contributor
  • Posts: 19
  • Country: us
Re: Clock Battery Monitor Circuit
« Reply #20 on: July 19, 2020, 05:54:32 pm »
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 is electrically isolated from 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?

I 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.
 

Offline bitogreTopic starter

  • Contributor
  • Posts: 19
  • Country: us
Re: Clock Battery Monitor Circuit
« Reply #21 on: July 19, 2020, 05:59:38 pm »
An OPAMP's input impedance when unpowered depends on its exact topology and input protection network and is rarely specified.

Good 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.
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2248
  • Country: us
Re: Clock Battery Monitor Circuit
« Reply #22 on: July 19, 2020, 06:09:17 pm »

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.

Well, 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.

 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2248
  • Country: us
Re: Clock Battery Monitor Circuit
« Reply #23 on: July 19, 2020, 06:21:25 pm »

I 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.

But 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.

 

Offline bitogreTopic starter

  • Contributor
  • Posts: 19
  • Country: us
Re: Clock Battery Monitor Circuit
« Reply #24 on: July 19, 2020, 06:33:26 pm »
But 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.

I 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:
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf