Sep 30, 2011

Power Your Next Project

I explained an idea I had for a Halloween animation using pumpkins, LEDs, microcontrollers, and a PIR sensor in my last post. Making all these items work with each other sounds all well and good, but none of them will even turn on without a stable power supply. Being a power electronics guy I am all about power supplies and efficiency, which is why I am dedicating this post to telling you how to get a power solution for your next project that just works…as all power supplies should. I will show you an example using my Halloween animation project.

First, you need to identify all the necessary voltages and currents that your circuit elements are likely to require. The microcontrollers I am using operate on 5Vdc, the LEDs use anywhere from 2Vdc to 4.5Vdc, and the PIR sensor can accept any voltage from 5-12Vdc (a higher voltage gives you more range). To narrow this down I am going to choose 5Vdc for all my elements. The LEDs can be driven directly off the microcontroller output pins, which will output the supply voltage on any pin I set high in the code.

But there is a problem with this approach. Each microcontroller will require its own 5V supply rail and there are four of them. Running four 5 volt power supplies off some extension cord is really impractical and a mess aesthetically. Instead, the simple solution is to use batteries to power each of the devices. Go do a Google search for “5V battery” and see what you can find for me. I will be here when you get back.

*****************************************************************

Well that was fun. I’m guessing your search turned up nothing and now you have come back here looking for answers. Suckers. The truth is batteries do not come in all types of voltages because their performance is directly related to their cell chemistries.

But let’s say you were able to find a 5 volt battery. Would that be good to use to power all these devices? In short, no. Even if you were able to find a viable 5V battery, it would likely discharge below a useable voltage before too long. Batteries do not maintain their nominal voltage and then just suddenly plummet to zero at the end of their life. Instead, what tends to happen is that you will get a gradual decay in the voltage present on the battery terminals over time like in the picture on the right, but the exact curve is largely dependent on cell chemistry. Just because the system cannot run off the battery at a certain point does not necessarily mean the battery is dead. If you did try to use a 5V battery for these modules you would end up throwing away lots of energy capacity because the voltage fell too low for the circuits.

Now is about the time I tell you that if you try to use a higher voltage and count on the voltage dropping over a usable range then you will likely blow up your device. So how is it possible then to get to voltage to stay at 5V despite battery discharge when dropping too low shuts everything down and going too high blows everything up? While there are many answers to this question, the one I must shamefully recommend is the voltage regulator.

Why am I ashamed to tell you to use a voltage regulator? Well, for reasons I will go into in my entry on voltage regulators, they are very inefficient. Using a DC-DC converter like a SEPIC or a Buck would be far more efficient, but at the cost of design time, price, and complexity. Voltage regulators will provide a constant output regardless of the input voltage, though there are caveats. First, voltage regulators need the input voltage to be higher than the output voltage. If I apply this concept to my Halloween project I find that I need to apply a higher voltage to the input of the regulator than the 5Vdc I need out of it. A 9V battery should do nicely.

Secondly, voltage regulators have what’s called a “dropout voltage” rating, which tells you the minimum input voltage above your desired output. For instance, the LM7805 pictured above is one of the most famous and widely used regulators on the planet (look into the LM317 for another). It provides a stable 5Vdc output with input voltages up to 40Vdc and a typical dropout voltage of about 2 volts (for future reference, this figure can vary with loading conditions). That means that if you want an output of 5 volts, your input voltage must be at LEAST 7 volts. Certain regulators can operate down to a dropout voltage of 300mV or lower. We creatively call these regulators “Low-dropout” regulators, or LDOs for short.

Since most voltage regulators rely on feedback loops to control the output voltage, you will likely need to add some bypass capacitors on the output. This can sometimes be a hidden cost associated with voltage regulators, but they are usually not a big problem. Make sure to check out the datasheet for the regulator in question because often times it will tell you what size capacitor you need. The image below shows the sample circuit configuration for getting a stable 5 volt output from the LM7805, and you can see that they recommend using capacitors on both the input and output pins.
I will show you how I chose the regulator I am going to use in my Halloween project in another post. This entry was meant to be a high level look at how to get common voltages for your next project (3.3V, 5V, 9V, 12V). If you need something other than 5V, never fear because lots of regulators are adjustable so you can configure components around it to get the output voltage you want. Again, the part's datasheet should give you some information on how it can be done. Datasheets are an engineer’s best friend.

0 comments:

Post a Comment