A quick update on the Raspberry Pi UPS board, it’s been too long. The boards arrived, and look lovely. As ever, OSHPark purple PCBs are excellent quality, and even routed out the Model B cut outs smoothly. Routing on prototype PCBs is definitely something I will use in the future..! Anyway, I got the boards mostly built up except for a couple of wrong parts and haven’t had time with work in the run up to Christmas. As a festive preview of what’s to come in the New Year, here are some pictures of the mostly complete board. Merry Christmas all, and thanks for all the views this year – well over 10k now!
Introduction: A previous comment, a couple of weeks off, and the release of the Raspberry Pi B+ HATS specification. led to the development of this uninterruptible power supply (UPS). While laid out with the Raspberry Pi specifically in mind, it’s a very flexible design that can be used with any number of low voltage systems. I’ll elaborate in a future post(s) the steps and changes needed. In the first instance, the battery supply is intended to be a sealed lead acid (SLA), but can be anything you need to fit your own requirements within certain parameters. I am also going to work through the rationale behind parts choices, and also in choosing component types and values. This is an all analog design (excluding the EEPROM, more to follow), and for a lot of people just starting out, the values are seemingly plucked from the air. This project is completely open to suggestions and comments, and you’ll be able to find the thread on the Raspberry Pi forum.
Operating Principles: a UPS is required for two broad categories of need: 1) intermittent mains power, and 2) critical systems. An example of the first kind would be perhaps an isolated or underdeveloped area where mains supply is rationed. The second need covers things from a medical device which must function, to a security system that needs to be on constantly. Or, of course, if you just want your RPi to keep the time if the lights go out..! The UPS must, therefore, swap seamlessly and instantly between the mains supply, and your chosen backup power supply. In this case, I’ve chosen a battery (I’ll explain why later), but you could use a bank of capacitors, or a mechanical flywheel, or anything else that can store electrical or potential energy, perhaps a reservoir if you have the luxury!
Electrically. the simplest way to achieve this is with a diode OR bridge. This is a very simple circuit that consists of two (or any number of) diodes connected at their cathodes. The individual anodes are then connected to, in this case, the individual power supplies. As diodes only conduct when the anode-to-cathode voltage is greater than 0.6 V (for a standard silicon diode), the supply with the highest voltage will power the downstream circuit. This also means, importantly, that there is no gap if one supply drops out and so this is the basis of our UPS. In the schematic (you can open it above), the diode OR bridge is made up of D1 & D2. They connect to +9V and V+ respectively, which is how I’ve chosen to label the external supply and the battery supply. While the external power source is present, it would be good to keep the backup battery topped up with charge. This is achieved with the components in the top left of the schematic (R2, R3, R15, R21, R16, LED1, C4, Q1, Q2, IC3), which provides a steady ~50 mA to keep the battery charged. There is a lot of scope for variation here depending on battery types, supply voltages etc, which I’ll cover more fully later.
The output from this circuit needs to be 5 V. As shown above, one supply has to be at a higher voltage than the other, and there are the added problems of the voltage drop across the diode OR (0.6 V) and the fact that batteries aren’t a constant voltage – they change with their state of charge or discharge. This means that a voltage regulator is required to provide power within certain bounds. The block which does this is located in the bottom right of the schematic. I’ve chosen to use a buck switching regulator to do this on the grounds of efficiency. While linear power supplies are generally cheaper and much simpler electronically and physically, they literally burn the excess energy as heat. I’ll elaborate on the switching regulator and its values and layout in a further post.
This leaves the circuit in the top right centred around comparator IC2. The power supply should be able to communicate with the target, and in particular two pieces of information are useful: 1) the target is running on backup power, and 2) that backup power is running low. This is implemented by simply comparing the battery and external power supply voltages, and then comparing the battery voltage against a stable reference respectively. The reference is formed by IC1, which also provides the regulated 3.3 V supply required for communication with RPi. The design also provides visual feedback in the form of LED2 and LED3. The external/backup supply indication is centred around IC2A, and the low-battery voltage sense is centred around IC2B. You may notice that there is positive feedback (R13) implemented in IC2B; this introduces hysteresis to the system, and I’ll rationalise the values in a later post.
This will be a fully open-source project, and the files will be hosted at: https://github.com/awjlogan/RPiUPS