Main Site Documentation

How to build an "intelligent" power supply


So I have a Panda II project that is designed to plug into a wall via a 6-9 Volt adapter. It will be plugged in all the time (i.e.; the board is continuously powered).

However, I do not want to contribute to “vampire loads” in the house, so I want to build in an intelligent recharable battery IC that will use the power outlet to charge battery and then (using a relay I guess) close the power source from the wall outlet and switch over to running 100% off of the battery.

The board would then intelligently monitor the battery until such time it comes within say 10% of being depleted and then switch back on the relay to charge the battery again - starting the cycle all over again.

I have to assume such an IC already exists somewhere on the planet but can’t seem to find such a beast.

Any thoughts on how I might buy/build this IC??



That is an interesting idea Rod. I suspect if you take into account the losses in charging/using the battery that an efficient switch mode wall wart might consume less power over all.


If you assume the actual project on the board is in “idle” mode most of the time (i.e.; not drawing a lot of power) and only wakes up periodically to do real work (i.e.; turn on/off a motor) than I don’t see how an efficient wall wart would be a better a solution. This is by its very definition “vampire load” which is what I am trying to avoid by intelligently switching to a battery.

But then again I know virtually nothing about this stuff, thus my original question.




Converting energy from one for to another is not 100% efficient. When charging a battery you are converting electrical energy to chemical energy at maybe 70% efficiency. The battery cell will also self discharge over time loosing 5%~10% of its charge per month. When you draw power from a battery the conversion form chemical to electrical energy is also not 100% efficient. With low current draws let’s assume you get 95% efficiency. So you are only able to use 95% of the 70% of the power you used to charge the battery. Now factor in the extra power and expense used to control all of the extra circuitry needed for this automatic battery charging arrangement.

A switch mode wall wart type power supply will be 70%~90% efficient and can have a very low power consumption at no load. For example this model uses less than 0.3W at idle:

Here is some more general information.

You have to look at the efficiency of the entire system and see which method of operation would be better for your needs. My guess would be that using an switch type wall wart will be more efficient and less expensive.


It maybe worth looking here,

to get an idea of what is already on offer dependent on what type of battery you want to use.



I had no idea that reading the voltage level of a battery (I don’t have to do it continuously - I would think once every few minutes would be sufficient) would be so “expensive”. Is the “cost” in powering the voltage divider? Why can’t I read the power levels of my battery directly? Why do I need to scale it into 0-3v3?

(please excuse my ignornance…)



[quote]However, I do not want to contribute to “vampire loads” in the house, so I want to build in an intelligent recharable battery IC that will use the power outlet to charge battery and then (using a relay I guess) close the power source from the wall outlet and switch over to running 100% off of the battery.

The only way to deal with this unfortunately is to turn the device off.

You have to think about total embodied energy here, and unfortunately batteries are not cheap nor are they “endless”. You certainly could design a device to operate the way you suggest, but batteries that are charged and discharged like you’re suggesting will not last very long. That means your operating cost will also need to include the periodic replacement cost of the batteries. Battery life is maximised when they are charged to full and then kept as close as possible to full; if you “deep cycle” them by going to 10% (whatever that means) and then recharging, you’ll get very short life out of most commercial batteries. For practical examples, you should look at off-grid solar installations, they charge batteries when the sun shines and are in constant discharge overnight; the batteries they use are built to handle this cycle, and are more expensive than others that are not.


as for needing the voltage divider and scaling the voltage, the Fez analog input pins are only 3v3 capable, meaning if you put more than that into those pins you’ll damage the processor.

Have you analysed how much power your device draws? Have you figured out how much that costs you?


Okay. Lot’s to digest here.

Many thanks for taking the time to explain. I appreciate it.



The analog pins are 5V capable, I don’t believe you’ll harm anything. According to the user manual, however, you won’t get correct readings above 3.3V, possibly even for other pins:

[quote]while the ADC pins are specified as 5 V tolerant (see Section 8–1), the analog multiplexing
in the ADC block is not. More than VDD(3V3)/VREF/3.3 V (VDDA) should not be applied to any pin
that is selected as an ADC input, or the ADC reading will be incorrect. If for example AD0.0 and
AD0.1 are used as the ADC0 inputs and voltage on AD0.0 = 4.5 V while AD0.1 = 2.5 V, an
excessive voltage on the AD0.0 can cause an incorrect reading of the AD0.1, although the AD0.1
input voltage is within the right range.[/quote]


If you’re really using so little energy then maybe a solar recharger is an option?


No, I can’t assume sunlight (its not an “outdoor” application".



Uhhh… the Panda II is going to use the same amount of power in hibernate mode for x number of days whether it’s running from a battery or running from your DC adapter.

Since charging the battery isn’t 100% efficient, your idea is actually going to use more power.


And I just want to add… the Panda II hibernate power is 3.75mA. You could probably run it for a year on $1 worth of energy.


I am a little confused here. What I am trying to do is develop an intellent power supply.

Let’s take my cheap (i.e.; dumb) flip-phone cellphone for example. If I plug in my cellphone to my wallwart charger it takes about 2 - 4 hours to fully charge. Then I can unplug it and use it for days in low power mode. The battery runs down (in some cases it runs completely out) and then I charge it again. I have used this phone for years and the cycle seems to work great.

So I want to do a similar thing with my Panda II project - with the exception that instead of unpluggnig my board and walking around with it, I am leaving the board “plugged in” but I want to run off battery - hoepfully for days at a time as the board generally is in lower power mode.

My big ask is that the charger IC not draw any power from the outlet (i.e.; vampire load) durng this time. Thus I am thinking a relay could “turn off” the power to the IC. The magic piece here seems to be a power efficient way to measure the battery life so I know when to turn the “power” back on to the recharging circuitry.

Does this soud feasable? I am not following the “power efficiency” conversation in this thread. In my mind 2-4 hours of full (6V power from the plug) should be able to buy me days of low-power running. What am I missing.



What you’re missing is the fact that using a battery inherently creates lots of “vampire load”, it’s just in short bursts whenever you charge the battery (and that’s not including all the “vampire load” that went into the production of the battery in the first place).

[ulist]Charging the battery uses significantly more power than what is actually stored in the battery -> VAMPIRE LOAD
Using the battery, more energy is drained than is actually provided to the device (some goes to heat up the battery) -> VAMPIRE LOAD
Someone had to build a factory and produce batteries (and you’ll be destroying your batteries quickly by doing deep charge/discharge cycles) -> VAMPIRE LOAD[/ulist]

Your power brick / battery charger has a certain “efficiency”, meaning it “loses” some percentage of the electricity it takes from the wall (wastes it as heat, generally), and this happens whether it’s charging a battery or running the device directly. Wasting a bunch of energy in short bursts, or wasting a little over long periods, the efficiency of the power brick doesn’t change.

In short, your idea is noble, but the facts of physics dictate that it cannot work, and in fact, would be worse than the current state of affairs.


Let’s say your device draws 100ma all the time (nice round number). Now it is going to draw 100ma what ever is powering it, battery or wall adapter. Now, 100ma @ 3.3V = .33W, in 24 hours your device will consume 7.92W/h. In a week that is 55.44W/h.

Let us also assume that you can charge this device once a week, the charging efficiency is say 65%. So you will have to put about 85.3W of power into it while charging to get the 55.44W out when using the device. Basically your device is using 85.3W of power every week.

If you power the same device with a 85% efficient wall wart it would use 64.7w/h a week (and you have not extra batteries to buy and maintain.)

This is a made up example, but you can do the match yourself for your situation.