Maker Pro
Maker Pro

dual power: battery or regulator

johnny_cash

Aug 13, 2013
39
Joined
Aug 13, 2013
Messages
39
Hello,

I have a uC low power. I'd like to power it on 2 ways:
- battery powered (3v)
- external power (3.3v)

I'm wondering how i can have a voltage selector input: if i have power on external, then it'll be powered through it, else it must work on battery. The goal is to save battery power when the external (which comes from a computer) is switched on.

I have heard about MAX690 IC, but i don't see how it works. I'm wondering if something easier is working (i think diod or 2, but i fear the voltage dropout if battery powered).

Thank you for your comments, ideas.

JC
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Place a schottky diode in series with the battery, then have the external power applied after this.

When the external power is applied, no power will flow from the battery, when it is removed the battery will again power it (without interruption)
 

johnny_cash

Aug 13, 2013
39
Joined
Aug 13, 2013
Messages
39
thank you Steve, as simple as this ? Going to learn how schottky is really working...
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
A Schottky diode is just like a regular diode* except that it has a low forward voltage drop. This means the least amount of power is wasted.

I've drawn you a circuit below. It shows what you have now, and what you need. Note that I've added an additional diode. This stops the battery from discharging into the external power supply if it is connected incorrectly or if it is a sort that power can feed back into.

attachment.php


The device will draw power from the supply with the highest voltage. If your power supply has a slightly higher voltage than the batteries, it will supply power when it is connected.

*Actually it has many differences, but this is the only important one in this case.
 

Attachments

  • Power.png
    Power.png
    9.9 KB · Views: 315

johnny_cash

Aug 13, 2013
39
Joined
Aug 13, 2013
Messages
39
Thank you Steve. Can you tell me if Schottky are "eating" current, and how much ?

Actually my MCU is running max 60uA, and this is why my battery can last a very long time.
If Schottky are using (well, the one on the battery side) more than a few uA, this is a no-go.

Thank you once again :)
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Diodes do not "eat" current, the same current that goes in, goes out. They do drop the voltage a bit though. A Schottky diode drops less than a normal diode, usually less than 0.5V at their full rating. At 50uA, the voltage drop will be much lower, probably more like 0.2V. Lowering the voltage to the uController will actually lower the current it uses, so the effect of adding the diode will make your battery last longer.

Bob
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
In addition to what Bob has said...

No device in series can "eat current" since everything in series passes the same current.

You probably were not (but you may have) been asking about leakage current. Can the plugpack leak current into the battery and vice versa. The answer to this is yes. The diodes are not perfect (and indeed schottky diodes are particularly bad at this)

Let's look at a diode you might choose: HERE. Now look at the datasheet. The link is on the page, but here it is anyway.

If you look at the datasheet, it says that you can leak up to 10mA, and that it has a forward voltage of 0.55V (And some might gasp and wonder if this is really any good at all)

But let's look at that in more detail. The worst case for leakage is if your battery or your power supply is connected backwards. In that case the reverse biased diode has about 6.5V across it. Now, many datasheets will have a graph that shows the reverse current and how it varies with voltage and temperature, but this one doesn't :-( (I'll come back to it)

There is, however, a graph showing forward voltage and how it varies with current. If you look at this, you'll find that for the 1N5818, this drops to about 0.1V at 300mA. 300mA is quite a few orders of magnitude higher than your actual current draw, so the voltage drop across the schottky is likely to be even lower! In any case, it will be far lower than the 0.55V that is specified, because that is only reached at the full current the diode is capable of.

OK, here is a better datasheet for a 1N5818. Yes, the same device from different manufacturers can behave slightly differently, but not enough to be a problem for you.) Figure 2 on page 3 shows that at 25C the diode will leak about 1uA if the reverse voltage is 10V (which is higher than we expect in the very worst case). Note that this could rise to 1mA at 150C -- I'm sure other things would have failed before then!

For the case when everything is connected correctly and the reverse voltage across the diode is under 1V, the reverse leakage is going to be around 0.3uA.

So even if your power pack was connected the wrong way, the battery drain would only increase by 1uA or so, and that is not a lot. The current flowing back into the battery to charge it (and I assume it's not rechargeable) is so low that it won't cause problems.

You may notice that I selected a 30V 1A diode, and that there are many diodes with higher and lower voltage ratings (this is the maximum reverse voltage and maximum forward current). Why did I pick that?

Well, I looked at all diodes with reverse voltages between 20V and 60V and forward currents between 500mA and 10A. This was the cheapest.

There are some tradeoffs, as the maximum reverse voltage and the maximum forward current increase, the forward voltage at any particular current increases. However, at the same time the reverse leakage also increases. SO, as a rule of thumb, I ensured the diodes were rated for a voltage at least twice what they were likely to be exposed to, and with a moderate current. I could have chosen a device that has a far lower forward current, but they're likely to be more expensive and mechanically (as well as electrically) less rugged. The last feature is possibly useful if you're experimenting :)
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
On a side note would this IC suitable ? http://www.farnell.com/datasheets/10810.pdf

This is an opto relais. As i understand on the DS, any U > forward, while open will select the other.

Am i right ? :)

Since this device requires between 900uA an 3000uA to operate, compared to your device's 60uA current draw, I would say no.

Also, a SSR is only ever a NO device. I can't think of a way to use this in your application without constant current draw from the batteries when the external power adapter is not present.
 

johnny_cash

Aug 13, 2013
39
Joined
Aug 13, 2013
Messages
39
Thank you for the explanations about the diodes, and everything else, it is far more clear for me.
 

johnny_cash

Aug 13, 2013
39
Joined
Aug 13, 2013
Messages
39
You grabbed the 900uA / 3000uA values on the LED operate current / LED turn off current, i see the lines now :) Thank you for showing me this.

Basically i'd have think such an ICs was common, but it was really harder to make it integrated with a circuit.

Last questions: i also though to use a IC relay in monostable + DPDT (with battery when relay not powered, else powerpack when relay on), would it have been a suitable solution or was it totally stupid ?

DS: http://www.farnell.com/datasheets/1717896.pdf
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Yeah, I suppose you could use a relay powered by the external adapter to switch between the battery and external power.

However, as the relay switches there would be a brief interruption of power to your circuit. Sure you can do things to get around this, but the solution is getting more and more complex.

Also the relay coil will dissipate 100mW, and that's about 600 times more than your circuit if you've quoted its current draw correctly. You would really want a good reason to use this method...
 

johnny_cash

Aug 13, 2013
39
Joined
Aug 13, 2013
Messages
39
Problem is i fear my externel power should be 0.3v less than battery (exactly 3.6v vs 3.3v)

I assume i could use 1N4001 (or any non-shottky valve) but related to diagram and low current, i'd not have plain 0.6v forward voltage. (what would be interesting to ensure V battery is lower than V external).

I suppose a resistor is a bad idea because it 'll permanently derivative a current from the battery, although ot can act as a voltage dropdown ?
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
What is your battery voltage (measure a fresh new cell)

What is the voltage from the adapter (measure it WHILE IT IS POWERING THE UNIT).

Then tell me what the minimum voltage your device will run at.

Remember that I've said that the voltage drop across those Schottky diodes will be around 0.1V, so forget 0.6V.

Also confirm that the current draw is 60uA.

If your power supply voltage is lower than your battery voltage then there is still something simple which can be done. We just need to know all the facts, not have you bring them up one at a time so we waste our time.

Another option is to get a power plug which incorporates a switch (which operates when the power is plugged in). Whilst this sounds nice, it will remove power to your device if power is lost to your external adapter, and possibly briefly whilst it is plugged in and/or removed.
 

johnny_cash

Aug 13, 2013
39
Joined
Aug 13, 2013
Messages
39
Excuse me, some things are moving, fastest than i would :)
Batt: 3.6v / 1200mAh
PSU: 3.3v very stable - the voltage 'll be bring after a voltage regulator
new MCU current draw: around 100uA in run mode (i'm doing a rough estimation, because i'd like to stay in sleep mode, which is ...10nA. 100uA is the worst case). This is a 1.8 to 3.6v powered MCU.

Sorry, but at first external PSU was aimed to be 5v, while battery cell was 3v - but i can't no longer rely on CR2032 for now.

I admit the problem is not simple, because i also need to think of self discharge of the battery. My goal is to last at least 6 months at those rates. So of course an opto which draw 9mA is a no-go.

The mechanical option is not possible for me, as both 'll be linked on the board.

The passive way is very interesting in fact, because relays sounds, as you mentionned, totally disproportionnate. I have tryed to search ICs performing such a function, but it sound delicate (MAX690 seems to have a BATT backup supply, but i definitively can't understand the way it works).

For now, my best option would certainly to stick to a lower voltage battery ie 3v, because my MCU is able to run in this voltage range, don't you think ?
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Batt: 3.6v / 1200mAh
This is a 1.8 to 3.6v powered MCU.

Is that a rechargeable lithium cell? If so, the voltage may go up as high as 4.2V when just charged.

I just want to make sure that the battery and the MCU are going to be happy together.

PSU: 3.3v very stable - the voltage 'll be bring after a voltage regulator
new MCU current draw: around 100uA in run mode (i'm doing a rough estimation, because i'd like to stay in sleep mode, which is ...10nA. 100uA is the worst case). This is a 1.8 to 3.6v powered MCU.

OK, lets say 100uA.

Will operate down to 1.8V (that's the entire circuit, not just the MCU)?

OK, let's do some back of the envelope calculations... If you have 1200mAh of capacity, what current draw on average is required for this to last 6 months?

6 months is 180 days, or 4320 hours. at 1e-4A, you require 0.432 Ah, so 1.2Ah is going to last almost three times as long as you desire. You may be limited by self-discharge if your device goes into a low power state for much of the time!

On the face of it, you're not scrambling for power, so there is at least some leeway.

One option is to use diodes like I suggested, but have the input power turn off the battery (as the battery has a higher voltage). Let me work on something...
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
OK, try this:

attachment.php


Let's start by assuming that the power pack hasn't been connected.

Resistor R1 pulls the gate of MOSFET Q1 to ground, turning it on. Diode D1 prevents any current from flowing through R1. There is no additional current draw from the battery and with Q1 turned on, the full battery voltage is available.

Now let's assume the power supply is connected, but is turned off. Nothing happens. There is still no voltage to turn the MOSFET Q1 off.

Now the power pack is turned on. The voltage at the gate of Q1 causes it to be rapidly turned off, effectively disconnecting the battery. Meanwhile, current from the power supply can flow through D1 to the circuit. If the battery voltage below the power pack voltage, some current will pass through the body diode of the mosfet. If this is an issue, place another schottky diode in series with the battery (reducing its effective voltage by 0.1V or so)

When the power pack is turned off or unplugged, the voltage at the gate returns to zero, effectively reconnecting the battery. Due to the gate charge, this may take a small amount of time, so capacitor C1 provides power to the circuit while the mosfet switches back on.

The potential risk with this circuit is that if the power from the plugpack falls very slowly, depending on the Vgs threshold of the MOSFET, it may not switch back on again until the voltage to the device has fallen too far. Conversely, a Vgs that is too high will turn off the battery before it runs completely flat.

A Vgs slightly above 1.8V would probably be optimal, but you might have to do some testing to see what happens if the power pack is turned off whilst plugged in to a unit with a quite flat battery. Does it successfully switch power back to the battery before the plugpack voltage falls below the voltage required to keep the MCU running.

If the MCU monitors the voltage at the gate of Q1 it can ascertain whether external power is available. With a slight modification, and if the MCU can detect brownout conditions, the MCU could force the gate low in order to try to resume battery power. Even more alternately, the MCU could completely control the switching between internal and external power. These things make the circuit quite simple, but also make the software more complex.
 

Attachments

  • power2.png
    power2.png
    13.6 KB · Views: 249

johnny_cash

Aug 13, 2013
39
Joined
Aug 13, 2013
Messages
39
Thank you for the schematic. I'll read quietly tomorrow, espcially to understand what you mean.

Is that a rechargeable lithium cell? If so, the voltage may go up as high as 4.2V when just charged.
No, i have some choice over the battery (in example 3.6v could be available in more than 1200mAh) but this 'll be a non rechargeable with advanced Lithium tech (ie, the one with less than 1% discharge per month).


OK, lets say 100uA.

Will operate down to 1.8V (that's the entire circuit, not just the MCU)?
In fact, my circuit is the MCU (pic with internal clock) - i'm 'software' guy. Bascially it will monitor 2 or 3 GPIOs, that would trigger an AD acquisition, and set 3 anothers GPIOs based on the AD result. GPIOs are linked to another part i don't have to care (= input logic, low current). Sure, i'll have to take care of the pulse time, bounces on my monitored GPIOs, but the function will run 'on demand', and wait most time (let's say it should work twice a month, for a few secs).

OK, let's do some back of the envelope calculations... If you have 1200mAh of capacity, what current draw on average is required for this to last 6 months?

6 months is 180 days, or 4320 hours. at 1e-4A, you require 0.432 Ah, so 1.2Ah is going to last almost three times as long as you desire. You may be limited by self-discharge if your device goes into a low power state for much of the time!

On the face of it, you're not scrambling for power, so there is at least some leeway.

One option is to use diodes like I suggested, but have the input power turn off the battery (as the battery has a higher voltage). Let me work on something...

Exactly. I used some Microchip tool for battery calculation, majored by some facts:
- internal clock speed
- enlarged acquire tension with FVR

With theses specs,i could mean the current to 100uA.
 

johnny_cash

Aug 13, 2013
39
Joined
Aug 13, 2013
Messages
39
Oh, i can't wait to study your explanation. Let my MUC monitor itself the power is finally something i have not even considered (let's stay i focused on an electronic solution).

What do you call a slow fallback ?

Actually i have ordered pieces to mockup a relay (with a calculated capacitor to absorbate the 5ms voltage switch) + flyback diode. Notice any 100mA on external power pack is not a problem, but your solutions are what i consider a real hardware design, and my own totally lacks of skills/elegance.

I'll test on LTSPICE you own design to really understand the drawbacks and see if i can meet them. Need to understand what a MOSFET is, vs classic NPN/PNP.

Low current ? High speed switch ?

Many thanks Steve for theses toughts and help.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Oh, i can't wait to study your explanation. Let my MUC monitor itself the power is finally something i have not even considered (let's stay i focused on an electronic solution).

What do you call a slow fallback ?

Well, I spoke kinda of 2.

The first is the time it takes to turn the mosfet on after the plugpack is removed. (This is pretty easily modelled as it is in the normally used portion of the device's operating range.

This is not instantaneous and is the time it takes to transfer the gate charge across the gate resistor. Roughly, this can be calculated as Q/I, where I is the current that passes through the resistor at the battery voltage.

Picking a mosfet almost at random, 1/2 of an SI4505, it has a gate charge of 20nC and the current is (say) 3/100,000 = 30uA. So the time is just under 1ms.

A 100uF capacitor at 100uA will drop about 1mV in 1ms, so the voltage drop is not significant (however the drop will be higher if the MCU is in a period of higher current draw.

The second deals with a slowly dropping voltage on the plugpack. Perhaps it has been unplugged and the voltage falls to zero over a period of 10 seconds. This is a little more problematic because we're dealing with aspects of a mosfet's behaviour that tend to be variable and where we typically don't operate them.

As the voltage on the gate of the mosfet falls, the mosfet turns on... slowly. Mosfets in this mode act like a constant current source. So as Vgs(th) is reached, current starts to flow, and this increases as the gate voltage decreases.

[ASIDE: I'm talking about the gate voltage decreasing because the gate is eventually grounded, but what is actually happening is that the difference in voltage between the source and gate is increasing]

S0 as the voltage at the gate falls, Vgs increases. The datasheet tells us that Vfs(th) for the P Channel mosfet is between -0.45 and 1.0 volts (I'm assuming they mean -1V). It also tells us that the threshold current for this P channel mosfet is 250uA -- which is way higher than our load! (This is telling me that this mosfet isn't actually a good one for this).

Let's assume that Vgs(th) is -0.8V. This means that the voltage at the gate only need drop to 0.8V below the battery voltage and already 250uA can flow. What we're really interested in is the voltage which allows 100uA to flow. And let's say that is -0.6V (I don't know). This means that as the power supply voltage drops to o.6V below the power supply, the battery can supply enough current for the MCU. But what iof it's 0.5V below it, and it stays there for some time?

Let's assume the battery has 2.7V across it, and our MCU needs 2.5V. The battery will not be able to supply 100uA until the power supply voltage drops below 2.2V. If it stays there (say at 2.4V) for too long, the charge stored in the capacitor will be exhausted, and the MCU will reset (and here is the point that software could try a last gasp of forcing the battery power on).

How long would that take? Who knows? It depends on so many variables that I wouldn't hazzard more than a very rough guess that the voltage would want to drop at about 1V/second or faster.

One way of making this faster is to reduce R1. This provides a load on the external power supply. A lower value here will discharge any output capacitors faster and cause the voltage to fall faster. You could drop it to 1k, for example to draw 3.3mA

Actually i have ordered pieces to mockup a relay (with a calculated capacitor to absorbate the 5ms voltage switch) + flyback diode. Notice any 100mA on external power pack is not a problem, but your solutions are what i consider a real hardware design, and my own totally lacks of skills/elegance.

You probably don't need a flyback diode in this case, but it can't hurt.

And reading about the problems of the slowly falling voltage, you might think that a relay would just be plain easier. You might be right.

HOWEVER...

The voltage that the relay pulls in is higher than the voltage at which it drops out. Added to this, the relay switches slowly if the voltage falls slowly. The first of these is more important than the second. If the relay holds in at a voltage lower than the MCU minimum voltage, the same thing can happen.

In the relay's defence, it will draw more current and (all other things being equal) will cause the plugpack voltage to fall faster.

I'll test on LTSPICE you own design to really understand the drawbacks and see if i can meet them. Need to understand what a MOSFET is, vs classic NPN/PNP.

Low current ? High speed switch ?

Many thanks Steve for theses toughts and help.

I'll not explain mosfets other than to say that they're voltage controlled devices and that they have a lower voltage drop across them at low currents.

Given that this circuit is getting more and more complex, it may actually be smaller and simpler to use a relay. The swap in the voltages from the plugpack to the battery having the highest voltage was really the killer.
 
Top