Diode reverse current affecting ADC measurement?

Thread Starter

cmartinez

Joined Jan 17, 2007
8,255
I've been working on this circuit, posting about my progress on a different thread, but what I'm about to describe is so unusual (at least for me) that I thought it deserved its own thread.

1680740037911.png

The circuit in question is designed to allow connecting a bank of batteries (bank B) to a circuit and when that happens, a second bank of batteries (Bank A) is disengaged. An auxiliary circuit comprised of Q7 and Q8 is there to enable Battery bank A even when Bank B is connected.

I also need to be able to measure the voltages of both battery banks every once in a while so as to know when it's time to replace them. The late and extremely generous (and dearly missed) OBW0549 showed me how to accomplish this using two transistors and a voltage divider.

So to measure battery Bank B's voltage (when said bank is connected to the circuit), the gate of nFet Q3 is pulled high. This in effect pulls the gate of Q2 low and lets current flow through R3 and R4, which work as voltage dividers. This brings down the voltage to a workable level so that the MCU is able to read it at the node labeled ADC2.

The problem is that when battery Bank B is disconnected, the MCU is still sensing a voltage level at ADC2 (about 0.96V) and that's not supposed to happen. So I took my MM, and measured the voltage between ground and TEST POINT and lo and behold! ... my MM read 6.3V at said node even though battery Bank B was disconnected! ... the only explanation I can find is that somehow D4 is leaking reverse current that's flowing from battery Bank a through D2, and then back into Q2 and R3 and R4.

The values of R3 and R4 are 1k and 470 ohms, respectively. The diodes being used are PMEG4050EP,115

What gives? How can I get a reading of 0V at ADC2 when battery Bank B is disonnected?
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,255
Why do you need a ADC2 reading when Bank B is disconnected?
To actually know if said bank is present or not in the circuit. A reading of 0 should do that. A very low reading would tell me that said bank has practically been completely depleted.
 

nsaspook

Joined Aug 27, 2009
13,281
To actually know if said bank is present or not in the circuit. A reading of 0 should do that. A very low reading would tell me that said bank has practically been completely depleted.
I would think a reliable bank B condition test would require actual connection to the diode OR circuit but I'm not sure what your switch connection logic is.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,255
I would think a reliable bank B condition test would require actual connection to the diode OR circuit but I'm not sure what your switch connection logic is.
My switch connection logic is thoroughly described in this thread.

But here's a brief description of what it all comes down to:
  • I've built a device that is powered by an internal bank of batteries (Bank A), and I want to be able to connect an external bank of batteries (Bank B) which use will be prioritized over the internal one when it's connected. Imagine a non-rechargeable battery powered device that I'd like to keep running as long as possible without interruption and without having to open its enclosure to change its internal batteries often. What I did is I built an external battery pack (Bank B) that is easily replaced when depleted, and in the process of disconnecting it from the circuit and connecting a fresh pack of batteries, the internal battery Bank A takes over. This should allow the device to work continuously for up to 7 years (in my estimate) without actually having to open it to replace its internal batteries. The connector I'm using to plug in Bank B is represented by the contacts labeled S1 to S4 in the diagram.

I already built that circuit and it's working as expected, thankfully. But now I'm faced with the task of measuring the voltage levels of both battery banks so as to know when the time has come to replace either one of them. And as I've said, it seems that D4 is leaking reverse current and giving a false reading when battery bank B is disconnected. I recently made a test by short-circuiting the TEST POINT to ground after bank B is disconnected, and sure enough, I get a perfect reading of 0V as it should be. But If I remove said short, then I get a false reading of about 1V at ADC2.

I would very much like to avoid resourcing to a mechanical aid (such as microswitches or relays) to solve this problem, and use completely solid state electronics, if possible.
 

nsaspook

Joined Aug 27, 2009
13,281
Personally I would just quality the leakage voltage as a property of the disconnected circuit that tells you:
1. The disconnect is working.
2. The diode and associated measurement circuit is working instead of reading zero volts like a TP short or open diode would.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,255
Personally I would just quality the leakage voltage as a property of the disconnected circuit that tells you:
1. The disconnect is working.
2. The diode and associated measurement circuit is working instead of reading zero volts like a TP short or open diode would.
That's a possibility ... if I'm understanding your idea correctly, what you're saying is simply analyze how the measuring circuit behaves and compensate accordingly when reporting, right?
 

nsaspook

Joined Aug 27, 2009
13,281
That's a possibility ... if I'm understanding your idea correctly, what you're saying is simply analyze how the measuring circuit behaves and compensate accordingly when reporting, right?
Yes. A zero value is simply one counterfactual saying nothing measured. You can use a non-zero response as a conditional of correct operation like switching to a internal MCU vref to check for proper ADC operation.
 

crutschow

Joined Mar 14, 2008
34,452
I'd like a second opinion on this nuisance of mine ... would using pFets instead of diodes make a difference?
Don't see how PFETs can replace a diode in your application unless they are used in an ideal diode circuit.

As ST noted, check the reverse leakage value of your diodes.
 

MrAl

Joined Jun 17, 2014
11,487
Schottky diodes. Mainly because of their low forward voltage.

This is the first time I've heard their reverse leakage is relevant. Thanks for the heads up.
Hi,

Then let's make this the second time now :)

Schottky diodes can have a significantly lower reverse leakage (or resistance) than a regular Si diode.
A regular Si diode can have 500 megohms while a Schottky like 1N5817 can have 20 kilohms. If that was up to 50 kilohms that would be a 10000 to 1 ratio. That's a huge difference. If the reverse leakage is flowing into a high impedance it could create a relatively high voltage. The solution is to either not use diodes or use Si diodes, or if you can decrease the impedance of the load without bothering anything else that would work too.

But why the complex switching arrangement. You can usually get away with a relatively high impedance voltage divider on the input to an ADC even though it may be recommended to be lower. That's because you can still get decent accuracy when super accuracy is not important. For example, if you use 12k to measure 12v you are drawing 1ma which may be significant in a battery application, but if you use 120k you are down to 100ua which is usually not significant, and if you use 1.2megohm you are down to just 10ua which is not going to mean jack. You combine that with a 0.1uf ceramic to allow the ADC acquire to see a low impedance while it takes a reading. The only difference then is the ADC input leakage which can skew the reading slightly with temperature. As the temperature changes the DC leakage current will change and thus change the reading, but it is not going to be a significant factor in every application, only those that are made to be an actual multimeter or something like that.

At the present time i use roughly 150k to measure a 12v battery 24 hours a day 7 days a week continuously and dont have any problems with the current drain.
See if you can simplify the circuitry and see how it goes. For your app i have no doubt it will work just fine.
There are calculations you can do to get an idea how the reading will change with temperature, but you see how insignificant it can be when you try it.
 

nsaspook

Joined Aug 27, 2009
13,281
Perfection may be the goal, but practical is always the reality.

You're always going to be measuring leakage (instead of actual battery potentials) currents at the battery disconnect test-point when B is disconnected. Is making that measurement as low as possible really a gain (tells you something unique and valuable) for circuit performance or is it a goal for perfection?
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,255
So I've gone through my circuit several times, and discovered that your clumsy friend here south of the border was not activating bank A (pulling up MEASURE at Q5's gate) when making the measurements. Once I did, things improved quite a bit.

Things improved again when I changed the Schottky diodes for silicon ones.

This is the reading I get when both battery banks are connected, with a 5V rail, and both R3/R4 and R6/R7 at 1k/470 ohms, respectively.

Measurement bank A: 194​
Measurement bank B: 194​


Which is pretty much within ball park to what I expected to get. So all was fine so far.


Things worked beautifully when I physically disconnected bank A, this is the reading I got:

Measurement bank A: 0​
Measurement bank B: 194​


But then everything went haywire when I reconnected bank A, and physically disconnected bank B:

Measurement bank A: 201​
Measurement bank B: 183​


It wouldn't have bothered me if the measurement of bank B had not been exactly zero. But a reading of 183 whilst the reading of bank A went UP?

What the fudge?
 

MrAl

Joined Jun 17, 2014
11,487
So I've gone through my circuit several times, and discovered that your clumsy friend here south of the border was not activating bank A (pulling up MEASURE at Q5's gate) when making the measurements. Once I did, things improved quite a bit.

Things improved again when I changed the Schottky diodes for silicon ones.

This is the reading I get when both battery banks are connected, with a 5V rail, and both R3/R4 and R6/R7 at 1k/470 ohms, respectively.

Measurement bank A: 194​
Measurement bank B: 194​


Which is pretty much within ball park to what I expected to get. So all was fine so far.


Things worked beautifully when I physically disconnected bank A, this is the reading I got:

Measurement bank A: 0​
Measurement bank B: 194​


But then everything went haywire when I reconnected bank A, and physically disconnected bank B:

Measurement bank A: 201​
Measurement bank B: 183​


It wouldn't have bothered me if the measurement of bank B had not been exactly zero. But a reading of 183 whilst the reading of bank A went UP?

What the fudge?
Hi,

I am not too worried about the A:201 for now but the B:183 is a big problem. To me that says that there is some leakage probably from something that is not turning off. Maybe try loading the measurement point and see if the B:183 goes down. If you load it with 10k and it goes down significantly then there is some device leakage or something like that.

I am just wondering now, how often do you have to take a measurement? I would think maybe only once or twice a day.
I am not really mocking out the design, but this thing looks way way way too complicated for what it has to do. Maybe i dont understand the complete intended operation though.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,255
Thanks, Al ... all help is always thoroughly welcome. At this point I'm going through every trace in the physical circuit vs the one in the diagram, and so far I've found no inconsistencies.

As for the frequency of measurements, it's best to make them about every 48 hours, since the circuit (which is battery powered) consumes a lot of power when taking samples. Anyway, maybe I'm being obstinate by refusing to use mechanical relays for this purpose ... I just hate them and simply prefer to use solid state electronics if I can get away with it. I hope it doesn't come to that in the end.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,255
Fixed it! ... it was a FREAKING SHORT between two traces that were hidden underneath a component ... what an annoying little nightmare this was! ... but now everything is working EXACTLY as it should, and not just within ball park figures ...

frustrated-jim-carrey.gif
 

MrAl

Joined Jun 17, 2014
11,487
Fixed it! ... it was a FREAKING SHORT between two traces that were hidden underneath a component ... what an annoying little nightmare this was! ... but now everything is working EXACTLY as it should, and not just within ball park figures ...

Wow ha ha, a short is the worse kind of leakage (ha ha).
Great, nice to hear you got it working.

I was going to lastly suggest using relays JUST to get it up and running normally, then replace with MOSFETs. Nice do know you don't have to do this now.

One thing you said i had to think about. Why does it consume a lot of power when making the measurements.
 
Top