Automatic switchover of 12v DC power with diodes? (A UPS basically)

Thread Starter

zirconx

Joined Mar 10, 2010
171
I want my raspberry pi to keep running even when the power goes out. I have a large deep cycle 12v battery that will power the pi, and my backup sump pump when the power is out. I power the pi + it's additional sensors with a single 12v feed. From there I power my 12v sensors, and power a buck converter to power the pi through the 5v pin.

My plan was to always power the pi from the marine battery, and keep a charger on the battery to make sure it doesn't discharge. But I think what I am running into is the parasitic drain of the pi is causing my chargers (I've tried 3) to over charge the battery (almost to 15v in one case).

So new plan - run the pi from a 12v power supply, and somehow automatically switch over to the battery when the power goes out. I see they sell circuit boards that do this on ebay, here's one for $3.35. I wonder if the relay switching delay might ever cause the pi to reboot though?

Could I solve this problem with diodes? The 12v/pi system (my pi + sensors) draws less than 1A. Could I put a diode on the positive lines of both the battery and the power supply? My buck converter is not picky about it's input voltage, and my 12v sensor is not either. So the diode should prevent the power supply from charging the battery. But will the 12v/pi system draw power from both the power supply and the battery at the same time? That defeats the purpose. If I made the power supply always higher than the battery voltage (say 15v), then would that prevent current from flowing from the battery into the 12v/pi circuit?

Thanks.

Here is a rough diagram

Screenshot 2020-01-06 at 10.35.28 PM.png
 

Bordodynov

Joined May 20, 2015
3,177
Look at my circuitry, which guarantees the battery connection only when the power supply is off. Using two diodes does not guarantee this. In this case, the current comes from a source with a higher voltage. Look at the case when the battery pack is newly charged. I simulated the operation of my circuit by switching the external power supply on and off with switch SW1 once per second. I used a dual p-channel transistor.Power_Vs_Akk.png
 

Thread Starter

zirconx

Joined Mar 10, 2010
171
You can configure a MOSFET as a diode with a much smaller voltage drop.
https://www.electro-tech-online.com/threads/using-a-mosfet-as-a-diode-replacement.32118/
Does that mean the diode idea would work? Like I said, my devices are not sensitive about their voltage, I don't see any problems with having a voltage drop across a diode.

Look at my circuitry, which guarantees the battery connection only when the power supply is off. Using two diodes does not guarantee this. In this case, the current comes from a source with a higher voltage. Look at the case when the battery pack is newly charged. I simulated the operation of my circuit by switching the external power supply on and off with switch SW1 once per second. I used a dual p-channel transistor.
..
Thank you, but that is way more complicated than I want to build.

To what in that thread were you referring? I saw someone suggesting diodes (so that will work?), and someone else suggesting just charging the battery while drawing from it - I could not get that to work. See attachment of graph of charging current & voltage. Ignore the width of the two spikes (time), that was just how long I happened to test. But you can see in the first attempt, voltage goes way too high (15v) and stays there. In the 2nd attempt, without the pi drawing power, it only goes to 13.7.
 

Attachments

Bordodynov

Joined May 20, 2015
3,177
A simple dual diode circuit does not solve your problem. It was no coincidence that I gave a 12.6V voltage to the battery and a 12V power supply. And a freshly charged battery can have a higher voltage than 12.6V. In that case, the circuit will run on battery power. With my circuitry, your device will work longer when the power supply is turned off because a charged battery has more power than a battery discharged to 12V.
 

Thread Starter

zirconx

Joined Mar 10, 2010
171
A simple dual diode circuit does not solve your problem. It was no coincidence that I gave a 12.6V voltage to the battery and a 12V power supply. And a freshly charged battery can have a higher voltage than 12.6V. In that case, the circuit will run on battery power. With my circuitry, your device will work longer when the power supply is turned off because a charged battery has more power than a battery discharged to 12V.
Sorry I'm still not following why it won't work. With the two diode setup - won't the source with the higher voltage be used? So if I use a 19v power supply for example (I have a laptop power supply laying around), won't the 12v buck converter be drawing it from it, until the 19v supply turns off, then the buck converter will draw from the battery?

I found this similar discussion on https://electronics.stackexchange.com/a/302283/161606
 

Bordodynov

Joined May 20, 2015
3,177
Yeah, I agree that if the battery voltage is lower than the power supply, it'll be fine. If you're comfortable with that high voltage.
 

Thread Starter

zirconx

Joined Mar 10, 2010
171
Yeah, I agree that if the battery voltage is lower than the power supply, it'll be fine. If you're comfortable with that high voltage.
I figure that is one way to solve it - use a power supply voltage that will always be higher than the battery. My buck converter will take up to 23v, and my 12v sensor is actually a 24v sensor that runs fine at 12v. So the higher voltage should be no problem.

Do I need to use a certain type of diode? Or would pretty much any kind work, as long as it's rated for the proper current?
 

Ramussons

Joined May 3, 2013
1,404
Does that mean the diode idea would work? Like I said, my devices are not sensitive about their voltage, I don't see any problems with having a voltage drop across a diode.
The diode idea works fine when feeding power from 2 sources.

But, as I understand, in your case, if you are particular about charging the battery the proper way, the charger will need to monitor the battery current. In such a situation, the Diode technique will not work since the charger feeds both the battery and the load and has no way of monitoring the battery current alone.

However, if you are going to maintain the battery only at the float voltage of 13.8 V, the diode setup will work fine.
 

Rich2

Joined Mar 3, 2014
254
The problem you had was the 'smart chargers'. Quite simply use a 13.4 to 13.6v power supply (the latest thinking is this voltage is better than 13.8 for long standby periods) , no diodes, connect everything up and nothing more needs to be done.

The battery will love being floated at 13.4v, it won't overcharge or lose electrolyte, and if power fails will just start powering your circuit.

After the power returns you could connect the smart charger separately to give a full 14.4v charge, then back to the 13.4v power supply.
 

Thread Starter

zirconx

Joined Mar 10, 2010
171
The problem you had was the 'smart chargers'. Quite simply use a 13.4 to 13.6v power supply (the latest thinking is this voltage is better than 13.8 for long standby periods) , no diodes, connect everything up and nothing more needs to be done.

The battery will love being floated at 13.4v, it won't overcharge or lose electrolyte, and if power fails will just start powering your circuit.

After the power returns you could connect the smart charger separately to give a full 14.4v charge, then back to the 13.4v power supply.
This is an interesting idea. That sounds like exactly what I was trying to achieve. So I could just use an adjustable buck power converter, fed with my 19.5v laptop power supply, and adjust the buck converter output to output 13.2v?

What happens when the battery is deeply discharged, for example the power went out for 8 hours and is now back on? (It will be running my backup sump pump and so will be discharged). The battery will want to draw more power than the buck converter can provide, won't it overheat and die?

Maybe a buck converter like this can limit the current? https://www.ebay.com/itm/5A-DC-DC-C...k-Step-Down-Converter-5V-12V-24V/401753075558 I know it can run in either constant voltage or constant current mode, I don't know if if you can limit the current at a constant voltage though.
 
Last edited:

Tonyr1084

Joined Sep 24, 2015
7,853
I have a battery powered clock. When the batteries need replacing I am forced to completely re-program the time, date and time zone. Doesn't sound so hard, but if you only have to replace batteries every 3 years - you tend to forget how to set those features. So I put a large capacitor across the batteries. This has resulted in slightly shorter lifespan of the batteries due to voltage leakage with the cap, but it's negligible. Here's the thing: When I remove one set of batteries I have around 30 seconds to install new batteries. If I don't waste time I don't have to reset the clock.

I only mention this because you can make a switching supply where a power source (not battery) runs the equipment. And holds a relay latched. When power fails, for the instant it can take for the relay to switch over - you can lose sufficient power and end up having to reset your equipment. Not so if you're not drawing a lot of current. A cap can possibly carry the changeover from the PS to the battery. Similar to my clock situation, the interruption in power is short enough that a cap can maintain the clock settings.

I don't recall seeing a statement of how much power your system is using. If it's not a lot then a cap can get you through the switch-over from a relay. If you don't want to go with a relay you can go with a solid state relay (transistor or MOSFET of some sort). Switching time would definitely be faster than a relay.

Diodes ? ? ? They can work I think. But they drop some voltage. And if you're drawing a lot of amps - the diodes need to be able to handle it. So if you're charging through a diode, a weak battery can draw a lot of amps. Food for thought.
 

Rich2

Joined Mar 3, 2014
254
This is an interesting idea. That sounds like exactly what I was trying to achieve. So I could just use an adjustable buck power converter, fed with my 19.5v laptop power supply, and adjust the buck converter output to output 13.2v?

What happens when the battery is deeply discharged, for example the power went out for 8 hours and is now back on? (It will be running my backup sump pump and so will be discharged). The battery will want to draw more power than the buck converter can provide, won't it overheat and die?

Maybe a buck converter like this can limit the current? https://www.ebay.com/itm/5A-DC-DC-C...k-Step-Down-Converter-5V-12V-24V/401753075558 I know it can run in either constant voltage or constant current mode, I don't know if if you can limit the current at a constant voltage though.
Yes it would probably overheat and die. How many power outages do you have? I suppose it would get tiresome if you had them every week but connecting a proper charger doesn't seem too much of a chore on occasion. Then the buck converter can maintain it :)
 

Rich2

Joined Mar 3, 2014
254
A cap can possibly carry the changeover from the PS to the battery. Similar to my clock situation, the interruption in power is short enough
I do the same on my energy monitor and remote thermometer, which eats batteries, but have a switch on it to bring the capacitor in while I change the battery.
 

Thread Starter

zirconx

Joined Mar 10, 2010
171
Yes it would probably overheat and die. How many power outages do you have? I suppose it would get tiresome if you had them every week but connecting a proper charger doesn't seem too much of a chore on occasion. Then the buck converter can maintain it :)
I don't have many power outages, I have no problem connecting a regular charger when I need to fully recharge the battery. But when the power does go out, I don't want to have to make sure I'm home to prevent the buck converter from burning out when the power does come back on.
 

Rich2

Joined Mar 3, 2014
254
Ok then, maybe a 10ohm 10w wire wound resistor in series between the buck converter and the battery +ve will limit the current and keep things going until you get back.
 

Tonyr1084

Joined Sep 24, 2015
7,853
38 years ago I worked for a lighting services company. My job was to service emergency lighting - mostly the kind with a 12 V SLA / 7 Ah battery. Some bigger units used what amounted to some fairly large motorcycle battery type batteries. Their float voltage was maintained at 13.6 volts. When power failed a relay would click in and provide power to two (or more) flood lights. When power came back on the battery would recharge through a light bulb. I don't remember the rating of the bulbs, but when charge current was high the light bulb would glow brightly. As the charge current dropped to near zero the lamp would extinguish. Also serviced larger systems, 32 VDC with 50 Ah Ni-Cad cells. A few generators and every now and then a diesel or natural gas powered generator that was intended to support the electrical needs of a hospital.

But the key point I'm looking at is the lamp that would glow bright. They're relatively low resistance. When lit they would increase their resistance and limit the amount of current going to the battery. Perhaps you might consider using a light bulb in series with the battery charger and the battery. Just a thought.
 
Top