0
\$\begingroup\$

I am putting together a circuitry, and I want the circuit to continue running even after main power goes out. So I was thinking about this idea of using a PNP transistor and a one-way diode to possibly wire up a 9V battery backup. My idea looks like this:

Circuit scheme for my idea

Basically: When the main power goes out: The PNP transistor (Q1) loses power on the base line: Making it close the emitter. So the battery is now connected to the circuit. While Q1 and Q2 closes, Q3 opens so that GND is closed of to make sure the electricity flows back into the cathode of the battery.

When power is restored: Q1 and Q2 opens to isolate the battery, and Q3 closes back up to connect GND again.

I have also connected a Capacitor (C1) to prevent a bigger fluctuation during the switch-over.

The problem is is that I am not very familiar with electricity, so I am a little terrified to plug this thing in and break something. Is there anything I need to be aware of, or will this not work as I expect it to at all? And when I plug the power source back in: Is there a danger it will overload, or damage the battery during transition?

\$\endgroup\$
  • \$\begingroup\$ will +5V be available only when mains is available? What is the purpose of backup circuit? How much power and voltage does the 'circuit' need that needs to be kept running? \$\endgroup\$ – Umar Jul 9 '15 at 9:38
  • \$\begingroup\$ @Umar This is a circuit that will run behind a door lock. And a battery backup is required for fire safety. the 5V represents the mains power supply, yes. The reason for 5V is because that is what the Arduino supplies, and what I plan to use. I only connected a LED here to illustrate where the usage part lays. \$\endgroup\$ – Alexander Johansen Jul 9 '15 at 9:42
  • \$\begingroup\$ C1 is shorted, it does nothing ! I see no resistors in series with the base of the transistors, that scares me. The circuit would be much simpler if you connect the - of the 9V battery to ground and not try to switch it with Q2, switching only + is enough. \$\endgroup\$ – Bimpelrekkie Jul 9 '15 at 9:46
  • \$\begingroup\$ electronics.stackexchange.com/questions/79512/… Can you check this? \$\endgroup\$ – Umar Jul 9 '15 at 9:48
  • \$\begingroup\$ Indeed, this is how it is normally done but problem here is that the 9V battery is always higher than the 5V external supply so with this diode circuit the battery would always be used. The solution would be to not use a 9V battery but 4.5 V (3 x 1.5 V in series). Then when the 5V supply is off, the circuit will get less than 4.5 V but an Arduino can handle this, it works down to 3.3 V (the 8 MHz version that is). \$\endgroup\$ – Bimpelrekkie Jul 9 '15 at 10:05
2
\$\begingroup\$

Yes, you should be aware of several things, and no, it will not work as you intend.

Let's start with step one: A transistor, NPN or PNP, used as a switch should always have a base resistor. If you're using simple types, stick to 510 Ohm or more. In many cases 5kOhm or 10kOhm will do fine. Because the bipolar transistor is a current amplifier and it wants to keep its base at a fixed voltage (about 0.7V away from emitter for simple types, up to 4V for darlingtons and other "specials"), so any voltage you apply will cause current to flow into the base and if that is not limited by a resistor: Poof! Transistor dead.

(An answer I wrote to design an on/off circuit using transistors, it skips a few important characteristics of transistors, but for your first experiments with NPN and PNP transistors as switches, if you have the time, you may find it interesting)

Step two is: Your 5V will always be 4V below the 9V, so with the extra resistor you have actually made an emitter follower that sort of "demands" a certain current to flow through dictated by the battery voltage and the resistor. How that works exactly is something for another time, as I expect that to become way too complex right now (more complex than the link there ^^).

Step three is: You don't need that many NPN transistors. You might need one to prevent the battery from powering something else on the 5V rail, but if your circuit is as tollerant as the LED you drew, that can be fixed differently. Current from a battery will always flow back into the battery. Current only ever goes in loops, it cannot just wander off into the world. As I said, it may "loop through other parts", but it cannot just meander off into the world through just the VCC or the GND.

The last step is:

EDIT: Assuming you want the 9V directly as backup, that is. Which you probably don't judging by the comments and their progression. 9V will kill an arduino and no fixed resistor will help you there. See below for further edited updates

schematic

simulate this circuit – Schematic created using CircuitLab

D1 prevents current from the back-up battery to flow into the main power or the other devices, but does lower the voltage for the LED a little. If you use a 1N4148 (maximum current = 100mA, keep that in mind!) it will cost about 0.7V. You can also use a Schottky diode, that usually costs between 0.15V to 0.4V depending on the type you pick and at what effective current.

It should not leak too much, so don't pick a 100A diode, or the reverse leakage could turn off your battery and cause some high-frequency oscillations. (Just assume that as a fact for now).

Now, if the Main Supply now falls off, the current into the base of Q3 will decrease to a point that Q3 turns off. Q3 was on while Main Power was there and that caused it to pull down the base of Q2, in turn turning it off. With Q2 turned off the base of Q1 was pulled high by R7, so that was off too.

If now Q3 is turned off, the Q2 will suddenly get current into its base through R4 (make sure R4 is powered by the battery, so before Q1!). This turns on Q2, which then pulls the base of Q1 low, pulling current out of that base, allowing Q1 to turn on. You then have backup power.

The balance between R5 and R6 will have some influence on when the battery will turn on, if you need it to turn on sooner because you see the LED turning off, you need to increase R5 or decrease R6. If you need it to turn on later, increase R6 or decrease R5. Try to keep R5 and R6 between 1k and 100k if at all possible.

D2 is just there as an extra protection. It should in normal cases not be needed, but because bipolar transistors can act very strangely if the battery gets shorted or reversed, it's smart to add it anyway. Better safe than sorry.

Of course, R4 will cause there to be a leakage current of 90μA at all times while the Main Power is on (because Q3 shorts that resistor to ground when the Main Power is on). If you need that leakage to be much lower further tricks are needed, but with a standard 9V alkaline, I'm betting that 90μA will not make the biggest difference on its lifespan.

EDIT: Solution as suggested in the comments, now knowing that you are powering an Arduino:

schematic

simulate this circuit

As long as the battery voltage is lower than the main power and the diodes are of the same type, you will normally be drain 99.9999% (0.0001% for leakage from the batteries) of your power from the Main Power. When the Main Power falls away you get 100% from the batteries with no delay at all, since the diodes will cross over smoothly from one source to the next.

When your batteries are at 4V-ish (not really empty yet, but it'll take some time before they get there) the supply may fall below 3.3V that the arduino likes.

If you then use Schottky diodes with a 0.1V forward voltage that'll take much longer.

You could also use a 5V fixed voltage regulator after a 9V battery, but you should then find one with a low quiescent current and all that, the 3x AA option, in all cases, is simply the easiest. Especially if you need only small amounts of back-up power and can afford to check and change the batteries regularly as should be the case with a door lock.

\$\endgroup\$
  • \$\begingroup\$ is 12 V okay for OP's LED? \$\endgroup\$ – Umar Jul 9 '15 at 10:18
  • \$\begingroup\$ @Umar Eh? What do you mean? \$\endgroup\$ – Asmyldof Jul 9 '15 at 10:25
  • \$\begingroup\$ +1 for Asmyldof for writing down my thoughts exactly :-) \$\endgroup\$ – Bimpelrekkie Jul 9 '15 at 10:25
  • \$\begingroup\$ @IC_designer_Rimpelbekkie I had already "wasted" all that energy on the 9V solution when your comment-chain trickled in, so I decided to edit it in and leave the rest as the answer to the actual question using a LED and 9V. \$\endgroup\$ – Asmyldof Jul 9 '15 at 10:28
  • \$\begingroup\$ I was thinking of Arduino expecting 5 V there when mains is not available \$\endgroup\$ – Umar Jul 9 '15 at 10:43
0
\$\begingroup\$

When the mains is active, the power supply energizes the relay and the power supply is connected to the load through the normally open and common contacts of the relay.

When the mains fails, the relay reverts to its stable state and the battery will be connected to the load through the relay's normally-closed and common contacts.

enter image description here

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.