Friday 3 July 2020

Creating a 5 Volt DC Power Supply

 Just over a year ago I bought myself a robotics experiment kit from Amazon to play with during some downtime.

Naturally, a lot of us have had a lot of spare time (sort of) on our hands lately. So this gave me the opportunity to get this kit out and start playing around.

On opening it up, I discovered that it wasn't just a robotics kit, it was actually an Arduino based experiments kit. For those of you who don't know, Arduino itself is an open source hardware electronics platform. The open source bit is how their kit works, naturally you need to buy the hardware itself - or if you are skilled enough, you can make it yourself from the schematics and tools Arduino provides.

You can get more information about Arduino gear on their site as well as browse their store. I need to point out that I am in no way affiliated with Arduino, or get anything for writing about them.

In fact, it is often cheaper to browse eBay for Arduino clone boards than it is to buy the official ones, but that is a story for another day.

Now, back to the point. Once I had finished all the experiments described in the kit, I decided to try my hand at building some actual devices for myself. Of course at this point, I wasn't quite sure what to build, but I knew one thing, what ever it is I decided to build, it would need to be powered in some way.

One of the interesting things I discovered working with these electronics is that pretty much everything, including consumer electronics, runs from a DC power source. This means when you are building something, powering it from a wall outlet or a battery is usually interchangeable. The work you have to put in is how you condition this power source (for want of a better phrase).

To do this, we need to use a voltage regulator. A voltage regulator is an electronics component that is designed to control the forward flow of power from a power source, like a USB lead or a battery, onwards to your circuit. Wikipedia has a very good article on the subject here if you are a newbie like me and want to learn some more. In their simplest form, they will have three pins, voltage in, voltage out and a ground pin.

When building my own power supply, I wanted to use the same voltage regulator that came with the micro controller that came in my experiments kit - this was a Mega 2650. In order to find out where the voltage regulator might be (don't forget, my knowledge of electronics is very basic at this point) I referred to the boards schematics. I don't really understand how to read these very well at this point, but was easily able to see where the power for the board comes in, you can take a look at them here the power input is in the top left hand corner. After googling the name of all the components, I found what I was looking for, the MC33269D 5. This little guy is intended to take a DC current through the barrel connector and drop it down to 5 volts DC for the board to operate. Most people will never use this method though, as most of us will be powering the device via USB, which will also give you 5 volts DC.

However, when I went to look for this component on my board, it was missing. Mine seems to come from a company called Elegoo, which are a good place to get hobby electronics kit, so wasn't a cheap clone. In its place, we have an AMS1117-5, after a quick search I discovered that this is also a 5 volt DC regulator, I also found the same component on a few other boards I have. So it made sense to build my power supply around this component, it is cheap and readily available from places like eBay, Amazon as well as Mouser etc.

Another new thing for this bit of work that I am using is a tool to help me plan and design my build. Previously, if I was working on a largish experiment on the breadboard the most work I would put in to designing something was maybe a scribble in a notepad. That's fine when you can change any wire or component when ever you like, but when you are soldering things down you want to be 100% sure that you are putting the right thing in the right place and its orientated in the right way. Otherwise you can ruin a whole build and you may need to start from scratch... This is the voice of experience talking.

When looking for examples of Arduino circuits, you will often run in to these wonderful little images that simulate the layout on a breadboard. I wanted to use this in my posts going forwards, so I tracked down the tool used to make them. Again, I am not affiliated with this company, and I dont get anything from them and you need to pay for this tool, but it is available from Fritzing. In my humble opinion, the license is very cheap for what you get and for those who are inclined, you can download the source for free and compile it yourself. However I am not going to go into that here. This isnt going to be a tutorial on how to use Fritzing either, its a really easy to use package and is essentially drag and drop. As a tool for helping me with my little builds, it has been extremely helpful and has enabled me to learn more about what it is I am doing.

So, lets get started by creating a new design and putting a voltage regulator on it. Fritzing doesnt have a dedicated symbol for the AMS1117, so a search for this will give you pretty much nothing you can use. However if you search for 1117, you will get something called a "V_REG_LD1117VXX". This will do for the purposes of design, layout and even construction, depending on how you build this. The LD1117 precedes the AMS117, so lets get this out on to the board:

Before we go any further, we need to take a step back and address reality here for a second. If you found this article after looking for ways to create a 5 volt DC power supply for real then we need to talk about the package the AMS1117 family comes in. For the sake of illustration, I am using a TO-220 package to represent the voltage regulator. In reality, the AMS1117 family are all in the SOT-23 package (to the best of my knowledge). This is a lot smaller than the one pictured here and while it is possible to solder one of these by hand to some 2.54mm pitch protoboard, you are not going to be able to use one on a breadboard easily.

However, you can get adapters that will allow you to mount pins to a SOT-23 package, these are basically SOT-23 to DIP adapter plates. You can get them from all the major stockists online, but I found the cheapest place to get them so far is eBay, an example of some can be found here. This is what an AMS1117-5 looks like when it has been installed to one of these adapters, you can see how this will make things easier:




AMS117-5 next to SOT 23 to DIP adapter





You can use some flux to hold the regulator in place for soldering.


Try to solder one of the outer pins first. This will make the rest easier.


To finish off, you just need to add some 2.54mm pitch header pins and you are done. An easy way to solder components like this is to use a breadboard for support:

Some extra headers are laid flat at the other end for support.



Get some flux on and get one of the pins soldered into place, you can make sure it is square here before continuing to solder the remaining pins. Don't worry about getting it done perfectly at this point, we don't want the plastic on the headers to melt.

If you need to, go back over the joints to make sure they are even and then you are done. You should end up with something like this:





If this is the first time you have done something like this - well done, you just made your first very own component! You can now go on and use this in your own breadboarding as a 5v DC voltage regulator!

Now, back to the design. I need to make a few changes here to the symbols properties in order to make it more visually relevant to the build. The changes I make are as follows:


Now we need to push some power into this, you could assume that it is coming from a 9 volt battery, such as a PP9. Technically, you could connect the plus and minus pins from the battery directly to the battery and it could output a 5 volt supply, however that's not really how it works. We need to get a few more components in there before we can actually start using this. To start with, we want to make sure that power cant come back through the circuit and damage the battery - or whatever power source you are using. So we need to stick a diode between the battery's cathode, positive line, and the forward flow to the voltage regulator. A diode is essentially a one way gate, a current can flow through it one way, but not the other. This makes it ideal for protecting your power source.

With this done, I need to add in some capacitors. If you take a look at the NCP1117-5 datasheet, which is also very similar to the AMS117 family, you can see a breakdown of the output capacitance vs the  equivalent series resistance (ESR). Output capacitance here refers to the capacitors we need to put in to the circuit as power leaves the voltage regulator and from looking at the graphs on page six of the datasheet, we can see that a 100uf electrolytic capacitor flowing to a 100nf ceramic capacitor will provide what we need. This will help smooth out the flow of power as it moves through the circuit - I am also going to do the same thing as power goes in to the voltage regulator as well for the same reason.

Next up is to simply add something in to indicate that there is power running through the circuit, this can easily be done with a 1k resistor and a red LED. The completed breadboard could look something like this:





Naturally, this probably isnt the best way to illustrate the layout. I am still getting used to the tool, but it certainly makes you think about what you are doing before you do it and why you are doing it. For the above to work, you simply need to provide a DC power source greater than 5 volts on one end. The LED will light up to show the circuit is working, to test it you can get your meter out and measure the incoming supply before it hits the voltage regulator to see what is being fed into it. The design above ends in a screw terminal providing both positive and negative, you can measure here as well to see that you get a steady 5 volts, or there about. 

Don't worry if it is slightly under or over, what we need to check is the stability of the voltage. If you are seriously over or under 5 volts, then it is highly likely your regulator is either broken, or an incredibly poor quality copy.

Now, if you want to, you can go ahead and build this on a piece of protoboard, but - before you do, why not model that in Fritzing as well? You can actually design on protoboards of different types in this application as well as use a breadboard, so if you are like me, you can design what you want on screen first before you commit it to the board. As long as it has been designed correctly - which you test out on the breadboard first - all you need to do is make a physical copy. Its also good for documenting what you have done if you commit your work to source control.

The protoboard version of this build could look like this:


The board I ended up making looked like this:


When designing the protoboard version in software, I specifically used the same size and layout that I have for in my collection of physical protoboards. My soldering isnt great, neither is my use of space, layout etc. Also, please note that I didn't install the LED, despite putting the resistor for it in place.

However, this works. I have feed it up to 10 volts so far and it has maintained a steady 5v DC with very little heat. This is a relatively small build, if you look at the photo this is being propped up by a pen, the whole board is about half the size of the pen, so it gives you some idea of scale.

But, it wont stop here. There are a couple of improvements that I can think of already, such as adding a switch. It would be good to see how small I can get this as well.

One interesting thing to note about this design is that you can swap out the voltage regulator for the 3.3 volt version and it will still work. You don't need to change the capacitors. I guess you could probably make a switched power supply that could let you select either 5 or 3.3 volts.



No comments:

Post a Comment