Re: Cheap UPS?
Posted: Mon Nov 04, 2013 6:43 pm
by PiModules
Hi,
Please make the following calculation, for each listed below functionality count 4 euro, no more (as you know some features costs much more). Then multiply it by 25 (this is the number of features), then you will have number of 100 euro. However if you count a normal price of each one, the total costs will be around 150 - 200 euro. You have all of these in a single board, working together, compact All-in-One in one of third of normal price. So, it depends to your needs, if you prefer to have 5 or 10 PCBs doing these jobs, or to have everything in a single solution. Here below are listed features:
1. Supervised and Protected Powering from all cable sources
a. RaspberryPi ® micro USB (5 VDC) – available from firmware release V1.20
b. Additional micro USB (5V DC)
c. Extended External Powering Input (7V DC – 18V DC) [Advanced version only]
2. Battery Power Backup on each cable powering source (including original RaspberryPi® micro USB – optional after firmware activation) – the UPS feature
3. Onboard Rechargeable LiPO Battery (1150/2600 mAh) – battery working time is about 2 or 5 hours, but depending from the version, system load and configuration
4. Onboard enhanced multiple level protection system for the LiPO battery:
a. Cut-off jumper
b. PTC fuse
c. Onboard Thermometer
d. Over-charge and Over-discharge protection
e. Over-voltage and Under-voltage protection
5. Onboard Intelligent Automatic LiPO Battery Charger (Charges the battery automatically but only if the supply voltage is present and can provide enough current to feed the RaspberryPi® and to charge the battery)
6. RaspberryPi® Hardware ON/OFF Switch
7. Embedded Emulated RTC (Real Time Clock – DS1307) accessible via RaspberryPi® I2C and/or RS232 provided from the System
8. Onboard Analog Thermometer (accessible via RaspberryPi® RS232)
9. Onboard True USB interface (can be used as RS232 – USB Bridge)
10. Programmable Time, RaspberryPi® File Safe Shutdown Button
11. Full monitoring of all UPiS Powering Parameters via RaspberryPi® RS232 port:
a. Current Consumption
b. Voltage on each Power source
c. System Temperature
d. Battery Level
e. Powering source
12. RTC based programmed Startup/Shutdown
13. Onboard UPiS Reset Button (resets UPiS and RaspberryPi® but not RTC by cutting the powering of the RaspberryPi® for a very short time)
14. Onboard NO RELAY controlled via RS232 or RaspberryPi® Pin (selectable by jumper GPIO_GEN0)
15. Onboard ESD Protected 1-wire interface, controlled via RS232 or RaspberryPi® Pin (selectable by jumper GPIO_GEN3) with separate 3.3V supply pull-up resistor.
16. Onboard ESD Protected I/O pin, controlled via RS232 or RaspberryPi® Pin (selectable by jumper GPIO_GEN3)
17. Onboard True 12 V RS232 interface to the external world (with level converter)
18. Protected (Resettable fuse 140 mA) 5 VDC output for user applications, with battery backup feature
19. Non-protected 3.3 VDC output for user applications (usually used for 1-wire application), separate and independent from the RaspberryPi® 3.3 supply.
20. Extended Tiny Encryption Algorithm (XTEA) cryptographic Customer Software Protection System (with custom defined protection keys)
21. Scripting language
22. LED-based Status Information System
23. Bootloader feature for lifetime firmware update.
Warmest Regards
PiMaster
Re: Cheap UPS?
Posted: Tue Nov 05, 2013 1:50 pm
by PiModules
Hi,
You have to buy, with higher P1 connector (the stack version - see the photos), it should be OK, but I have not tested it. Or wait until next production lot, the hardware version VCO4 where will be a slot on the PCB for that reason. We take care about that, but RaspberryPi developments are faster than ours, se we just follow them, and make a slot in the next version of PCB.
Warmest Regards
PiMaster
Re: Cheap UPS?
Posted: Fri Nov 08, 2013 10:52 pm
by metacollin
Holy crap this turned into possibly the longest post I've ever written on any forum.
Anyway, I solved your problem more than once different ways if you're willing to read =P.
Sweden? That's perfect! There is a Swedish invention that does exactly what you need: A power supply that will prevent the Pi from shutting off unexpectedly. And just one corrupt card? Hah! I had a micro usb cable with a loose connector. It would slide out from gravity if tilted too steeply. Or if I breathed on it wrong. I understand your pain all to well. Pis are like dictators, they love power, and if you remove them from it, they enact scorched earth Gaddafi tactics and destroy as much of your SD card's filesystem as they can (which is all of it, usually). They are despotic data demons of SD card destruction.
Anyway, there is no such thing as a cheap UPS. The U means uninterruptible. For any reason. Batteries wear out silently, as well as the UPSes themselves, and they have tons of smart circuitry that tells you BEFORE it happens so you can replace the battery or UPS without any interruption, ever. For decades. And they are insured. $100 *is* a cheap UPS. The good ones are a lot more. Most of the cost is the features and smarts, even low power ones are still going to be $100. I would also add that those Pi UPSes look very good and are very reasonably priced, especially given that they include a lot of the most popular additions to Pis (thermometer, clock, high voltage RS232, USB<>Serial bridge which can go for $20 by themselves). It looks like a terrific product, honestly. But you don't need or want a UPS.
All you need is a battery backup. It's a battery. That's, uh, the backup. The Pi will lose power during an outage some day after the battery has worn out some years from now (unless you replace them sooner than is necessary), so it's not uninterruptible, but it will give useful year to years of immunity from brown outs and black outs. Which is all you need. Here is the good part: its as cheap as can be. In fact, its just the cost of the batteries. Because its just a battery. Used as a backup. No circuitry, no charger (though it does recharge automatically), all you need is the battery and some means of connecting it to the pi other than the USB port (solder to TP 1 and 2, or use push-on jumpers to the 5V and Ground GPIO pins).
Get a NiCd (invented in Sweden, yay!) battery pack that is 4.8V. Nickel Cadmium/NiCad/NiCd. a 4 AA pack will work, as long as they are at least 800mah, but this will get you at most 15 minutes run time at full load, a bit more if your Pi is using less than that. Ideally, you want 4 C or Sub C cells though, something with ~2000mah. This will give you closer, but still less than, an hour run time. NiMH cells will work too, but they must be higher capacity, 2300-2400mah minimum, more is better. They also will produce a little heat (not nearly as much as the Pi) and will likely need to be replaced in as little as a year, while NiCads will work reliably for 3 years minimum, but 5 years is not uncommon. You'll find NiCads will be less than half the capacity of similar NiMHs, but will also be cheaper. You can buy 2 4.8V packs as long as they are identical, the same packs on from the same shelf at the same store, and turn them into one 4.8v pack with double the capacity by connecting both positive leads together, and both negative leads together. I highly recommend doing this, as ~2000mah is really the minimum if you want to actually run the Pi for a while, rather than just have time to halt it properly to avoid SD card corruption.
Just connect like colors and you're fine and the packs are wired correctly. NEVER connect a lead to one of a different color/sign, or you will die. Kidding. But seriously, don't do it. It will be a short or a series circuit, one of which makes a big scary spark and the other is useless for this application. Also, if you choose NiMH cells, MAKE SURE THEY AREN'T THE READY TO USE KIND. Some NiMHs are low self-discharge, and are sold already charged and do not need to be charged before use. In America, Eneloop is one such brand. Avoid these. They will fry your Pi.
Your power supply *MUST* be a USB 2.0 Specification compliant, or be a USB 2.0 Specification compliant charging downstream port or dedicated downstream port. If it has the USB logo on it and a micro usb port and wasn't soldered together by you but bought from a store, it should be ok. 1A minimum. It will be 1 to 1.5A if it is a compliant CDP or DCP, or AC adapter (which is classified as a DCP). 1.1A is ideal, many mobile phone chargers output this (for some reason), so should be a good place to start looking. But you should already have one, since something is powering your Pi. At the end of the post I do detail a means of protecting basic linear supplies often used for DIY raspberry pi supplies, it doesn't require changing anything, only adding one component on the output (not a diode).
Anyway, once you have the battery pack as laid out by my criteria, all you do is hook it up, preferrably via push-on jumpers with the + red leads to 5V, and the - black leads to ground. Now plug in your power supply, but the Pi probably will *not* turn on, and it is a good idea to remove the SD card for now. If you see the power LED come on, everything is working but you must leave it in this state for a while, the time depends on your power supply and size of battery, I would leave it like this for a few hours. If you have a multimeter, simply measure the voltage from TP1 to TP2, once it has reached 4.8V or higher, disconnect both the battery and power supply, insert the SD card, connect the power supply THEN the battery (yes, it will be booting as we connect the battery, and try not to let the battery sit disconnected for long if the voltage is right at 4.8V). Otherwise, just let it sit while and it will be ready in a matter of hours.
A lot of people may be wondering how this could possibly be safe or stable or work, and I will explain.
Batteries do not produce constant voltage, it varies and to a significant degree by remaining charge, temperature, how big or small the load present is, and even if you squeeze them with your hand. NiCd and NiMH cells actually produce 1.4V to 1.5V per cell (and are charged at this voltage) when at full charge. NiCd especially, and this is why they can be a better choice, has an exceptionally flat discharge curve. They put out very nearly 1.2V for most of their capacity. When connected in parallel with your Pi's power supply, it will pull the voltage from it down to it's terminal voltage which, during the initial first hookup, is far too low for the Pi, and most of the current is going into the battery and not the Pi anyway. This will do a constant current/constant voltage (minus 80 milliamps or so that a non-booted Pi consumes, which doesn't really matter). Eventually, the 4.8V pack will be charged to 5V, or 1.25V per cell. This is not a full charge, but it is still on the order of a 70-80% charge, for NiMH or NiCd (NiMh has a less flat discharge curve, but it is still fairly flat overall). After this, almost no current goes into the battery, in fact, exactly the amount needed to counteract self-discharge and keep it at that charge is all it will consume, and the rest goes to the Pi. This is an extra load of a few milliamps, it won't effect the Pi. But, the moment there is a power outage or other interruption....nothing happens because the voltage, perfectly equalized between the battery and supply, is still there, only the current powering the pi is drawn from the battery, and not the supply. The electrons don't "know" what they are supposed to do or anything, this all happens instantly and seemlessly due to simple Ohm and Kirkoff law stuff. "It just works." The Pi can operate down to 4.75V, or 1.1875V per cell. Due to the flat discharge curves, this will allow us to use a large swath of the battery's charge, 30-50%, before they drain too much and drop below 1.1875V per cell (generally, full discharge is 1 volt per cell). Bigger cells will have a larger percentage of their capacity that is able to be used, because current load also contributes to how much their voltage drops, but as percentage of their capacity. 1A from a 1000mah cell is discharged at a 1C, rate, or will be dead in an hour. But 1A from a 2000mah cell will be a 0.5C rate, and thus the drop from that discharge will be proportionally less than drawing 1A from a smaller, 1000mah cell. This is important for NiMH cells, and why their minimum capacity is so much more than for NiCd cells, to account for current draw dropping the voltage and narrowing the window of useful capacity to the Pi. NiCds are basically 500 pound guerillas and a AA NiCad will happily dump its charge at 10C, or around 10A, and average just one tenth of a volt less than a slow drain the whole time. NiMH batteries....well, they generally won't be happy much above a 2C rate, and the voltage drop is too much to be useful for the Pi unless its at or below a 0.5C rate.
So to be clear, you will get, at best, half of the capacity of the battery as 'available' to the Pi, due to not being charged all the way and the Pi being unable to utilize the low voltages as they discharge beyond a certain point. Larger batteries will improve the situation, to a point, and if you use a tuned power supply that puts out 5.2V (the Pi can run off of up to 5.25V), this will gain you maybe 5% or 10% being really optimistic more useful capacity. Most of the waste is from the voltage lowering due to discharge, which is constant across a given battery chemistry, so there isn't much that can be done about that.
When the power comes back online, the battery will charge, but only with whatever current is left over and isn't being used by the Pi. It's all thanks to batteries pulling voltage down to their terminal voltage in open-loop power supplies (USB is open loop), but only enough to charge on the leftovers, its all ohms law and I totally sucked at explaining it well, but it works. I tested it, to a limited degree.
Pros:
Cheap as you can get, costs the batteries and nothing more.
Simple, can be implemented without any knowledge of circuits, electricity, or soldering.
It works flawlessly and passively with your own power supply.
Batteries will love it and age slowly and languish in what is effectively battery heaven while in service. Kept at an 80% discharge-replacement trickle charge, and never discharged below 40%. Seriously, battery nirvana.
Cons:
It sucks in every way except difficulty and cost. It wastes the majority of the battery capacity. There is no undervoltage lockout, so if the batteries drain to far, the Pi just loses itself and, because this is what Pis do when they get unhappy, it corrupts your SD Card. It's like the only failure mode they know.
Conclusion: It works. It's cheap. It's avquick and dirty way to give some sort-of portable black out and brown-out immunity to your Pi for $20 or less. It's great for people who wanted to buy a device to do this for them for cheap, it can't damage the Pi but will trip the polyfuse if you choose poorly (like in The Last Crusade) powersupply-wise.
Also, this can be achieved with significant improvement if you can find a battery usb pack that can source 1A on a usb port, and can simultaenously sink 1A or more of current from the charging port. Due to the same convenient ohms law stuff that makes this work, the power will mostly pass through to the pi and only charge the battery when needed, but due to size and thermal constrains, will almost certainly use a basic buck/boost topology which allows full use of battery capacity.
Option 3 is do Option 2 yourself, and Option 2 is just Option 1 done in a smart way.
Use any battery, I like LiFePo4 cells which don't explode/catch fire/murder your family like other lithium secondary cells can, last forever and 2000 charge cycles, are cheap, and put out a still useable 3.2V. Buy a buck converter set to the voltage to charge the battery at around an amp, (3.65V for LiFePo4s, 4.2 for LiIon or 4.3 for Lipo) and a boost that puts out 5V from 3V to at least 3.65V in, also an amp out, wire them both to the battery, all in parallel with your power supply, no change. You use the buck/boosts to make, on the outside, a 5V 3 terminal battery, with Vin, ground, and Vout. But Vin takes 5V and Vout puts out 5V, so just tie them together, and its like a 5V battery with really bad self-discharge (the output of the boost feeding the input of the buck will eat up the combined minimum load and quiescent current of both, typically several milliamps to tens of milliamps, but for battery backup, who cares. USB packs can't be so simple, but this can, and the buck and boost converters that would work for this exact thing are like $1 each on ebay from Hong Kong.
BUILD STUFF
IT WORKS
ONLY FOR PEOPLE WHO MADE THEIR OWN SUPPLIES
If it is not USB compliant, i.e. homemade, it must accept Vout > Vin conditions with reverse leakage similar to a diode's (micro amps). This can be added to any linear (LM7805 LM317 etc) based supplies in the form of a sub 100mΩ (0.1Ω) P-channel protection mosfet on the output. Wire Drain to Vout from the regulator, wire the gate to ground, and source is the new Vout. This works exactly like a diode on the output, and prevents reverse current to sink through the regulator from voltage present on Vout (like, say, from a battery) when the power feeding the regulator (Vin) drops too far or disappears entirely. Only, the P-FET does not have a voltage drop and will not meaningfully impact the output voltage, where diodes drop it too far for use with the Raspberry Pi. All USB 2.0 Compliant AC adapters and ports can accept voltage on their pins when unpowered without any reverse current flowing, though some means or another.
Re: Cheap UPS?
Posted: Mon Nov 11, 2013 11:12 am
by Whettingstone
Holy wall of text.
Thanks a lot for the information though.
However I felt that a lot of this went way over my head. I understand the basics of what you explain but... I think I have too little knowledge about currency and the hardware part of this. I am a software engineer damnit!
Anyway, if you do a write up in another thread then I'll make sure to read it.
Just a quick question about the whole thing:
You said that the above (the advertised by PiModules) was a good choice. Right?
What would you suggest to use?
Your way seems way cheaper but more to do myself.
The PiModule is basically plug and play it seems.
Re: Cheap UPS?
Posted: Sun Oct 09, 2016 5:43 am
by haringstad
Nice thread! The things I read here, make my fingers itch, to start to build stuff myself again!!!
Luckely I am living in The Netherlands, where we hardly have black/brown outs, and also are not faced with the "end of the line" issues that are very common in, for example, Canada, the US and in some parts, the UK.
For a friend, who lives in the US, I did builld an environment, that provides a full service, both to Internet and phone, even when the power is blacked out. ISP's do have their UBR's on UPS, so there is most of the time signal on the cable. And with nowadays having phone over cable, it is important that your (cable) modem keeps operating, else you are unable to use the landline. This friend is also faced with regular brown-outs, because this friend lives at the "end" of a power-line. Fluctuations in the net, by the Fridge, or dishwasher, or even the washer & dryer starting, cause issues with both the Pi and the modems.
The setup used and hooked up to the UPS:
- Motorola Cable Modem (More stable than the provided Ubee) for Internet
- Ubee Cable Modem, only used for the phone line
- Raspberry Pi 3B, used as Pi-Hole and Unifi Configuration station, OpenVPN client/server
- Unifi Long Range PoE Access point for 2.4/5Ghz Wifi
Before I did hook them up to the UPS, the Pi would see that eth0 was disconnected, and the modems would start to disbehave. Hooking them up on a $60 UPS, solved this issue for ever.
So, maybe it might be a suggestion to see, whatever other hardware, that could be influenced by Black/Brown outs, you can hook up to an UPS. Because, your SD card being corrupted, is to me, the last thing to worry about...... Specially when you have your telephone provided over cable!