sora03
Posts: 193
Joined: Mon Dec 29, 2014 4:11 pm
Contact: Website

[SOLVED]12v UPS DIY circuit attiny85 lm317

Sun Aug 21, 2016 3:12 am

I am planning to create a 12v UPS since I cannot find any 12v output UPS in my area. No one seems to sell any CCTV UPS so I just have to create my own. I have a DC DC Step down LM2596S module and it works fine. I've set it to 5v3 3A output from a Router power supply [12V 2A]. To the main question, I have found a simple 12v UPS schematics but it does not have any documentation on what it does.

here is the source: http://www.simple-electronics.com/2011/ ... rcuit.html

Image

Does this circuit safe to not overcharge the 12v lead acid battery? And what should be the input of it. 12V 2A router AC-DC adaptor will work or do i need a 19V laptop charger . And what Ah of 12v lead acid battery should I use? I just want a 12v uniterruptable power supply. So it should charge the battery while there is an AC Input but if the outage occurs it should switch to the battery without interrupting the Pi 2. Since this is only the circuit that I can possibly afford because it is hard to search for parts in my area.

Summary:
-Does the circuit not overcharge the battery? [does it just trickle/float charge it?]
-What is the input of the circuit?
-How much time does it take for a 1.2 Ah battery charge and discharge when using the Pi 2
-Does this circuit may overdischarge the battery if the Mains power not restored for x time.?

Thanks.



update heres my final circuit:
Image
the attiny85 code is on page 3 and the other code will be uploaded but theg can be fetched from other tutorials like: adding push button switch to RPi, adding p6 header pins jumper and python scripts to sense gpio status
Last edited by sora03 on Tue Nov 07, 2017 2:27 am, edited 2 times in total.
FLOSS enthusiast, Debian user (linux-libre)

mosespi
Posts: 508
Joined: Mon May 12, 2014 3:35 pm
Location: 34,-118
Contact: Website

Re: 12v UPS DIY Help

Sun Aug 21, 2016 5:40 am

I'll try to answer your questions. There is a good explanation of the circuit and what it does on the link you attached as well.

- If the LM317 output is 13.9 volts it should not overcharge a 12v lead acid battery, there is a diode drop and resistor after the lm317 as well, giving you a bit less then 13.9 volts which is good for a trickle charge end voltage.
- The minimum input would be about the drop of the LM317 + the desired output, probably around 16 volts. For max voltage you would check your particular LM317 and the max voltage of C. A 12v adapter will likely not charge your battery, a 19v one would likely work. You may need to heatsink the LM317 depending on your output.
- The capacity of the battery is up to you really, within reason. How long it takes to charge is another issue.
- R3 sets the max charge current, which on that page is 56 ohms or about 250ma. It is hard to give you an exact number as to how long a 1.2A battery will take to charge, since the current will start tapering off on a lead acid battery as it nears full charge. I would guess about 6-8 hours? Discharge would all depend on your load.
- The circuit will overdischarge a 12v lead acid battery, likely all the way down to 5 or 6 volts, which is not very good for a lead acid battery. You generally don't want to go much past 11.8v, which is about 0 capacity for a lead acid battery.

Regards,
-Moses
Power problems? MoPower UPS for the Pi
http://www.allspectrum.com/mopower/

mosespi
Posts: 508
Joined: Mon May 12, 2014 3:35 pm
Location: 34,-118
Contact: Website

Re: 12v UPS DIY Help

Sun Aug 21, 2016 5:50 am

One more note, you could rearrange the diodes and use the input power directly on your DC-DC converter (if it will take the input votlage). That way you may not need such a big heatsink on the LM317 and will save some power since your DC-DC converter is likely more efficient then the linear LM317.

I have a similar 'diode OR' UPS setup. See the PDF user manual for a schematic here:
http://www.allspectrum.com/mopower/

My LM317 is setup as a constant current charger intended mainly for NIMH batteries. Maybe you can also consider NIMH batteries, possibly cheaper where you are located.

Regards,
-Moses
Power problems? MoPower UPS for the Pi
http://www.allspectrum.com/mopower/

steveb4pi
Posts: 62
Joined: Sun Aug 11, 2013 6:12 pm

Re: 12v UPS DIY Help

Sun Aug 21, 2016 9:34 am

Hi there,
I assume you need the UPS to keep the Pi camera running over a power cut ?

I suggest getting hold of one of those 'Power Bank' phone recharger units (= plug your normal mains power block into the 'Power Bank' unit and the output of the Power Bank into the Pi.

NB one thing to watch for is some come with an 'on off' switch, which may or may not switch from 'power the Pi' to 'recharge the battery' == you want one that does both power out and recharge in at the same time ...

PPS - If you must design your own, consider Li ION rather than lead acid

mfa298
Posts: 1387
Joined: Tue Apr 22, 2014 11:18 am

Re: 12v UPS DIY Help

Sun Aug 21, 2016 10:36 am

steveb4pi wrote:PPS - If you must design your own, consider Li ION rather than lead acid
For making your own UPS SLA is probably the better choice unless you want it to be lightweight. SLAs can generally handle a lot more abuse than lithium based cells.

SLA charging will work safely with little or no intelligent control (as per the circuit in the OP) whereas Li ion/po will need an intelligent charger and I think need per cell sensing as well (so larger cells get harder to charge).

A 1.2Ah SLA will have a roughly similar capacity as a 4Ah lipo/lion as the SLA is running at a higher nominal voltage (12V vs 3.7V nominal). With SLA if you want a longer run time you can mostly just push a bigger battery in as long as the charging circuit can provide enough current to charge it in a sensible time (potentially just a case of changing a resistor value). With Lipo you can only do that whilst you stay at the same number of cells in the battery (which limits how much you can increase it)

sora03
Posts: 193
Joined: Mon Dec 29, 2014 4:11 pm
Contact: Website

Re: 12v UPS DIY Help

Mon Aug 22, 2016 5:05 am

duplicate
Last edited by sora03 on Mon Aug 22, 2016 5:18 am, edited 1 time in total.
FLOSS enthusiast, Debian user (linux-libre)

sora03
Posts: 193
Joined: Mon Dec 29, 2014 4:11 pm
Contact: Website

Re: 12v UPS DIY Help

Mon Aug 22, 2016 5:08 am

mosespi wrote:I'll try to answer your questions. There is a good explanation of the circuit and what it does on the link you attached as well.

- If the LM317 output is 13.9 volts it should not overcharge a 12v lead acid battery, there is a diode drop and resistor after the lm317 as well, giving you a bit less then 13.9 volts which is good for a trickle charge end voltage.
- The minimum input would be about the drop of the LM317 + the desired output, probably around 16 volts. For max voltage you would check your particular LM317 and the max voltage of C. A 12v adapter will likely not charge your battery, a 19v one would likely work. You may need to heatsink the LM317 depending on your output.
- The capacity of the battery is up to you really, within reason. How long it takes to charge is another issue.
- R3 sets the max charge current, which on that page is 56 ohms or about 250ma. It is hard to give you an exact number as to how long a 1.2A battery will take to charge, since the current will start tapering off on a lead acid battery as it nears full charge. I would guess about 6-8 hours? Discharge would all depend on your load.
- The circuit will overdischarge a 12v lead acid battery, likely all the way down to 5 or 6 volts, which is not very good for a lead acid battery. You generally don't want to go much past 11.8v, which is about 0 capacity for a lead acid battery.

Regards,
-Moses
Is there a way to prevent the overdischarging of the lead acid battery. But now I am considering a NiMH battery than this Lead Acid battery for the UPS but still there are many schematics on UPS via 12V Pb acid battery than NiMH. Thanks for the reply.
Your mopower has many requirements to be build. Can you give me the minimal NiMH UPS circuit without any other components.
FLOSS enthusiast, Debian user (linux-libre)

sora03
Posts: 193
Joined: Mon Dec 29, 2014 4:11 pm
Contact: Website

Re: 12v UPS DIY Help

Mon Aug 22, 2016 5:12 am

steveb4pi wrote:Hi there,
I assume you need the UPS to keep the Pi camera running over a power cut ?

I suggest getting hold of one of those 'Power Bank' phone recharger units (= plug your normal mains power block into the 'Power Bank' unit and the output of the Power Bank into the Pi.

NB one thing to watch for is some come with an 'on off' switch, which may or may not switch from 'power the Pi' to 'recharge the battery' == you want one that does both power out and recharge in at the same time ...

PPS - If you must design your own, consider Li ION rather than lead acid
I have a power bank but when I discconect the input voltage for charging, It resets after 5 seconds which will result in a power OFF to the 5v output. It cannot be used as UPS. And Li-Ion/Li-Poly batteries tend to cause fire/explosions .
FLOSS enthusiast, Debian user (linux-libre)

mosespi
Posts: 508
Joined: Mon May 12, 2014 3:35 pm
Location: 34,-118
Contact: Website

Re: 12v UPS DIY Help

Mon Aug 22, 2016 5:30 am

I would avoid home brewing or wiring up bare LI-ION chargers until you are comfortable with building at least small electronic circuits. They are very energy dense and need to be handled a bit carefully.

Search for 12v discharge protection circuit or similar on the internet. There are a variety of circuits to buy or build.

Page 4 of the manual has a circuit description and the power side of the UPS is mainly the top half of the schematic on page 21.
http://www.allspectrum.com/mopower/MoPo ... 3-2015.pdf

Note that once you build this (simple UPS) you will only have the power supply section of a UPS. It will not safely shut down or restart your Pi. Might work fine for some applications, just something to keep in mind if you haven't already.

Regards,
-Moses
Power problems? MoPower UPS for the Pi
http://www.allspectrum.com/mopower/

sora03
Posts: 193
Joined: Mon Dec 29, 2014 4:11 pm
Contact: Website

Re: 12v UPS DIY Help

Mon Aug 22, 2016 5:41 am

mosespi wrote:I would avoid home brewing or wiring up bare LI-ION chargers until you are comfortable with building at least small electronic circuits. They are very energy dense and need to be handled a bit carefully.

Search for 12v discharge protection circuit or similar on the internet. There are a variety of circuits to buy or build.

Page 4 of the manual has a circuit description and the power side of the UPS is mainly the top half of the schematic on page 21.
http://www.allspectrum.com/mopower/MoPo ... 3-2015.pdf

Note that once you build this (simple UPS) you will only have the power supply section of a UPS. It will not safely shut down or restart your Pi. Might work fine for some applications, just something to keep in mind if you haven't already.

Regards,
-Moses
Yes I am aware that it can only power the Pi not to auto shutdown or restart it.
FLOSS enthusiast, Debian user (linux-libre)

sora03
Posts: 193
Joined: Mon Dec 29, 2014 4:11 pm
Contact: Website

Re: 12v UPS DIY Help

Mon Aug 22, 2016 6:08 am

How about the 6v Lead Acid battery. Does this circuit from the same site will overdischarge the battery.
http://www.simple-electronics.com/2012/ ... y-ups.html
Image

I am considering 3 options, 12v UPS, 6V UPS and the NiMH UPS (based on mopower). Still can't decide on what to do.
the 12v only the overdischarge is the problem but brownouts are only 3-4 hours so the battery can possibly handle it. SO I may not need the overdischarge protection since I can monitor the battery voltage at home.
FLOSS enthusiast, Debian user (linux-libre)

drgeoff
Posts: 9759
Joined: Wed Jan 25, 2012 6:39 pm

Re: 12v UPS DIY Help

Mon Aug 22, 2016 8:53 am

sora03 wrote:How about the 6v Lead Acid battery. Does this circuit from the same site will overdischarge the battery.
http://www.simple-electronics.com/2012/ ... y-ups.html
Image

I am considering 3 options, 12v UPS, 6V UPS and the NiMH UPS (based on mopower). Still can't decide on what to do.
the 12v only the overdischarge is the problem but brownouts are only 3-4 hours so the battery can possibly handle it. SO I may not need the overdischarge protection since I can monitor the battery voltage at home.
That circuit has no protection against over-discharge.

User avatar
flatmax
Posts: 336
Joined: Thu May 26, 2016 10:36 pm

Re: 12v UPS DIY Help

Mon Aug 22, 2016 10:31 am

I posted previously about using a 6V battery :
viewtopic.php?f=28&t=150152&p=986959#p986959

I have been thinking more about this ... it is really a dead simple approach. There is one problem, with undervoltage protection, to stop the battery from completely depleating ... in that case why not purchase a deep cycle battery and you can keep the dead simple concept :

Code: Select all

charger  +++++++++++++ Battery +++++++++ Pi
charger  ----------- Battery ----------  Pi
Check the Ultra 2 sound card - use our shop instead of Amazon Europe (Amazon USA is live).
Sound card for the Raspberry Pi with inbuilt microphone : www.audioinjector.net
Audio Inector Octo multitrack GPIO sound card

steveb4pi
Posts: 62
Joined: Sun Aug 11, 2013 6:12 pm

Re: 12v UPS DIY Help

Mon Aug 22, 2016 12:19 pm

Re: Power Bank UPS ...

Perhaps I wasn't clear, you can't expect 'every' Power Bank' to work as a UPS = even some of those that support 'simultaneous' power 'in and out' drop the output for a few seconds when the input power is lost ...

You need to Google 'Power Bank UPS for Pi' for the current 'state of the art' == it's changing all the time. Many Power Banks that worked (and are still working) from a year ago are no longer available.

One that's still available is the https://www.amazon.co.uk/dp/B00FBD3MVA/ ... piups0f-21 (note the 'Duo-Charge function' spec.)

sora03
Posts: 193
Joined: Mon Dec 29, 2014 4:11 pm
Contact: Website

Re: 12v UPS DIY Help

Mon Aug 22, 2016 3:14 pm

I am going to go for a 6v UPS circuit above, 8x NiMH costs more than the 6v 4Ah battery but 12v 7Ah battery costs thrice than 6v 4A which is only available as of now. What may be input voltage for the 6v UPS? 9V or 12V

Here is the picture of what I am planning to buy: for 6v UPS
Image
Last edited by sora03 on Mon Aug 22, 2016 3:32 pm, edited 1 time in total.
FLOSS enthusiast, Debian user (linux-libre)

steveb4pi
Posts: 62
Joined: Sun Aug 11, 2013 6:12 pm

Re: 12v UPS DIY Help

Mon Aug 22, 2016 3:24 pm

Getting 5.2v from 6v, with an 'off the shelf' LDO Reg. (or DC - DC converter) is going to be hard .(sorry == I mean expensive)
8x 1.2v NMh is 9.6v which should be 'easy'

NB. you need to watch out for any power diodes in the curcuit = sending 1A through a typical Schotty diode can drop 0.5v ...

sora03
Posts: 193
Joined: Mon Dec 29, 2014 4:11 pm
Contact: Website

Re: 12v UPS DIY Help

Mon Aug 22, 2016 3:38 pm

steveb4pi wrote:Getting 5.2v from 6v, with an 'off the shelf' LDO Reg. (or DC - DC converter) is going to be hard .(sorry == I mean expensive)
8x 1.2v NMh is 9.6v which should be 'easy'

NB. you need to watch out for any power diodes in the curcuit = sending 1A through a typical Schotty diode can drop 0.5v ...
sorry but what do you mean expensive? I have a LM2596S-ADJ dc-dc step down module set to 5.4V so it can supply up to 3A of current. Currently I am using a Router 12v adaptor ac-dc as the Input of the DC-DC module. So the 6V may not work at all? for this UPS project?
here are the pricelist:
4xNiMH 300 [for another 4x it will be 600, does not include a battery holder which costs 300+]
6v4Ah 420 [lead acid battery alone]
12v7Ah 1300 [lead acid battery alone ] not affordable because of the high price
this does not include the assembly of the circuit, the costs of each parts required
FLOSS enthusiast, Debian user (linux-libre)

mfa298
Posts: 1387
Joined: Tue Apr 22, 2014 11:18 am

Re: 12v UPS DIY Help

Mon Aug 22, 2016 5:21 pm

sora03 wrote:I am going to go for a 6v UPS circuit above, 8x NiMH costs more than the 6v 4Ah battery but 12v 7Ah battery costs thrice than 6v 4A which is only available as of now. What may be input voltage for the 6v UPS? 9V or 12V
Don't forget that the 12V 7Ah battery will have around 4x the energy of the 6V 4Ah battery (assuming you use a decent switching regulator to drop to 5V). It's potentially also better for the battery as you're pulling less current compared to it's capacity.

sora03
Posts: 193
Joined: Mon Dec 29, 2014 4:11 pm
Contact: Website

Re: 12v UPS DIY Help

Mon Aug 22, 2016 11:55 pm

so this circuit is my option 2 from the 6v 4a UPS:
http://homediyelectronics.com/projects/ ... upscharger
Image

this circuit requires 8x NiMH batteries. If the 6v UPS is not enough I am also considering this circuit before the 12v 7Ah UPS which I do not have budget yet...
FLOSS enthusiast, Debian user (linux-libre)

FM81
Posts: 518
Joined: Wed Apr 17, 2013 4:33 pm

Re: 12v UPS DIY Help

Tue Aug 23, 2016 3:00 am

1. Polarity of your B1 seems wrong?
2. Constant-current source can also be realized by a FET and a single resistor, makes things more easy.

Best Regards, FM_81
A: What does the command 'cat /dev/urandom', can you tell me please?
B: Yeah, that's very simple: It feeds your cat with radioactive material!

User avatar
flatmax
Posts: 336
Joined: Thu May 26, 2016 10:36 pm

Re: 12v UPS DIY Help

Tue Aug 23, 2016 5:55 am

Why make this ups so complex ?
Is there a problem with supplying the pi directly from the battery and let the Pi's onboard 3.3v LDO regulator manage the voltage conversion.
Can these batteries handle being discharged ... in a deep cycle sense ? Can you chain them to be 5V or more, but not too much more then say 6V ?

If so, then connect the charger, batteries and Pi in paralell ... if the power drops the battery kicks in.

Code: Select all

charger  +++++++++++++ Battery +++++++++ Pi
charger  ----------- Battery ----------  Pi
Matt
Check the Ultra 2 sound card - use our shop instead of Amazon Europe (Amazon USA is live).
Sound card for the Raspberry Pi with inbuilt microphone : www.audioinjector.net
Audio Inector Octo multitrack GPIO sound card

sora03
Posts: 193
Joined: Mon Dec 29, 2014 4:11 pm
Contact: Website

Re: 12v UPS DIY Help

Tue Aug 23, 2016 8:13 am

Problems:
NiMH circuit parts are not available includes BC557, 1N4504. Also the 6v UPS parts are not available to my local electronics store.
However the 12V UPS parts are all available. I've already bought the parts,but still searching for a more affordable 12v Pb acid battery. Also searching for the overdischarge protection circuit. It seems that I will just go back to 12v UPS option...
FLOSS enthusiast, Debian user (linux-libre)

drgeoff
Posts: 9759
Joined: Wed Jan 25, 2012 6:39 pm

Re: 12v UPS DIY Help

Tue Aug 23, 2016 8:30 am

flatmax wrote:Why make this ups so complex ?
Is there a problem with supplying the pi directly from the battery and let the Pi's onboard 3.3v LDO regulator manage the voltage conversion.
Yes, there is a problem with connecting the RPi directly to the battery. There is no battery technology that produces a voltage within the tolerance of the RPi on the 5 volt supply.

mfa298
Posts: 1387
Joined: Tue Apr 22, 2014 11:18 am

Re: 12v UPS DIY Help

Tue Aug 23, 2016 10:16 am

sora03 wrote:Problems:
NiMH circuit parts are not available includes BC557, 1N4504. Also the 6v UPS parts are not available to my local electronics store.
However the 12V UPS parts are all available. I've already bought the parts,but still searching for a more affordable 12v Pb acid battery. Also searching for the overdischarge protection circuit. It seems that I will just go back to 12v UPS option...
When comparing your different battery solutions it's probably worth converting to Wh rather than just looking at the Ah rating. With a decent switching regulator you'll be able to use the Wh rating (with a linear regulator use the Ah rating as the excess voltage gets turned into heat).

For a NiMh battery with 8 cells if they're 2000mAH cells you'll get around 19.2Wh (9.6 x 2) - adjust for the cells your looking at.
For your 6V 4Ah battery you'll get around 24Wh (6 x 4)
For your 12v 7Ah battery you'll get around 84Wh (12 x 7)

From that you can also work out how long the battery should last, assuming you need 9W for the Pi (should power most Pis and allow for switching regulator efficiency) that's about 2hours from your NiMH, a bit longer for the 6V SLA and 9 hours for the 12V SLA. You can then also determine the cost per Wh or hour of runtime which is a better way to compare the prices.

The other things to note are:
That some battery chemistries don't like being discharged quickly 2 hours is probably ok for most. But if you had lower Ah rated NiMh cells you might have issues.
The Ah ratings are usually specified for a much lower discharge rate (commonly 20 hours for SLA) it's likely to be lower if the discharge rate is higher
The battery voltage won't be constant, a 12V SLA can vary between 11 and 13v depending on charge,
As you draw more current from a battery it's internal resistance will have more effect which will reduce the voltage you get from it.

drgeoff
Posts: 9759
Joined: Wed Jan 25, 2012 6:39 pm

Re: 12v UPS DIY Help

Tue Aug 23, 2016 10:22 am

sora03 wrote:Problems:
NiMH circuit parts are not available includes BC557, 1N4504. Also the 6v UPS parts are not available to my local electronics store.
However the 12V UPS parts are all available. I've already bought the parts,but still searching for a more affordable 12v Pb acid battery. Also searching for the overdischarge protection circuit. It seems that I will just go back to 12v UPS option...
There is nothing special about a BC557. Any small signal PNP silicon transistor will do. 1N4504 is a 200 volt zener diode. That does not seem appropriate. The link you gave does not appear to be working so I cannot see the circuit diagram..

Return to “Beginners”