Introduction: Variable Powerbank Supply

A variable power supply is a must have for anyone wanting to do some serious electronics. There are many guides and videos about making a simple adjustable power supply. The things that make this power supply special is that it is digitally controlled via an encoder, the powerbank is part of the design and it is portable. In this instructable I will show you how I made my variable power supply powered by an Anker powerbank.

Step 1: The Plan

The goal of this project is to create a variable power supply with the 5v 2A input of my powerbank. Since the only voltage the powerbank will provide is 5v, I will use a dc-dc converter to step up and step down that voltage to any desired level.

Normally, a cheap dc-dc converter uses a potentiometer to regulate the output voltage. These potentiometers are usually the small blue multiturn ones. The advantage of multi turn pots is that they can be used to adjust the output voltage very precisely (theoretically). A serious downside of multiturn pots are the amount of turns (duh). This means that in normal usage if I want to change the voltage from, say, 2v to 30v, I have to turn the pot quite a few times. For use in an enclosure I could have used a bigger multi turn potentiometer to adjust my converter to the desired voltage. I decided, however, to use a rotary encoder instead, because, since they are digital, I can program the 'turning speed'. This way I can change voltages far quicker while still maintaining a high resolution in adjusting the voltage. Where I first had to turn the pot multiple times to go to a certain value, I can now go through the full range in one, maybe two turns. Also, I can instantly change the voltage to a set voltage by pressing the rotary encoder's switch.

To realize this plan, I needed a way to have the rotary encoder 'communicate' with the dc-dc converter. An Arduino was my go to choice for this. And to give the arduino a proper analog output to control the dc-dc converter I decided to use a DAC (digital to analog converter).

All the parts can be found in the next step.

Step 2: Supplies

Whoohee, ain't this part fun?

The parts I used for this project:

  • Arduino Nano (or any other arduino board, I just like the built in USB) ($2.09)
  • DC-DC converter XL6009 step up step down ($1.52)
  • MCP4725 12bit (!) DAC ($0.74 on Aliexpress)
  • Dual Female Banana plug ($1.15)
  • Alligator test leads banana plug cable ($0.72)
  • USB Type A 4pin A male socket connector PCB 90 degree ($1.21)
  • DC 100v 10A Voltmeter Ammeter (be sure to include the ammeter search term) ($2.52
  • AC 250v 3A mini rocker switch 10pcs ($0.99)
  • Rotary encoder (it's been a while since I bought them but they are less than $1 a piece)
  • Anker PowerCore 5000 (I got this from germany) ($12)

Optional

  • USB-C socket connector 24pin ($2.65 on Aliexpress)
  • Micro usb socket pcb DIP adapter 3pcs ($0.99)

Total= $27.58 including the powerbank

Most items were bought on ebay.

The USB-C socket is useful for me because I have a 5v 3a charger and the micro usb port is in case I want to use a different power bank or a charger. These items could be bought for less maybe, but the $30 dollars should be achievable for anyone, since you can also use a different powerbank.

Step 3: Enclosure

For the design, I just use sketchup. Sketchup for me is the quickest way to get from known parts to a design since almost all parts can either be found in the sketchup component libraries, or just quickly drawn in simple shapes.

With all parts drawn in sketchup, designing the enclosure is where you could design some wickedly awesome forms and intricate plans. I just kept it kinda basic, a box with an angled side. I also used sketchup to draw lines on my design to divide it in shapes I can cut out with my jig saw.

I just printed the designs and drew them on my 4mm MDF plate with a carpenter's square and measuring tape.

Some of the edges are cut at a 45 degree angle, this can be seen in the attached picture where the beveled edges are indicated by double lines.

Step 4: Electronics

Electronics for this project are relatively simple.

The somewhat more challenging part to understand is how the DAC will control the DC-DC converter. To understand the principle behind this, it is usually valuable to download the datasheet of the part you want to manipulate and look at the information presented there.

The information we are interested in from the datasheet of the XL6009E1, is mainly the feedback pin voltage. This feedback voltage is crucial to understanding how these dc-dc converters work. A switching regulator like the type I used in this project work by making sure the feedback pin stays at a specific voltage, in my case this is 1.263v, which is within the specified range in the datasheet, this voltage can be measured using a multimeter. The regulator will try to maintain this voltage at the feedback pin by changing the output. A potentiometer in combination with a fixed value resistor form a voltage divider and by turning the potentiometer, one can change the ratio at the output vs the feedback pin, and since the feedback pin voltage is maintained the ratio determines the voltage output.

If you are interested in a better and/or more elaborate explanation, you should probably google a bit to get the finer points of these devices.

Now that we roughly know how these converters work we can try to influence it. Instead of using a potentiometer we will be applying a voltage on the feedback pin. This changes the voltage divider network in such a way that we can control the output by applying a voltage at the intersection point. A very good website that explains how this control mechanism works is this website, it even supplies a calculator. It will take you through all the steps of setting up the control circuitry.

I will be using a 500 ohm resistor on the feedback pin, where the DAC will apply a maximum of 3.3v which will result in a range from 0-40v. And because the amount of steps the DAC can do is 4096, the resolution will be a theoretical ~0.01V. Which is quite nice.

Step 5: Arduino Code

With the electronics part complete, the fun tinkering with code can begin!

The Arduino's job is to take the encoder's turns and translate it to a number between 0-4095 that the DAC can converter in a 1/4096th step of between 0-3.3v. I mentioned in a previous step that I chose a rotary encoder so that I could have an 'accelerated' increase of the voltage. This took me a while to get right, because it has been some time since I programmed an Arduino, so please forgive me any clutter in the final code.

The program works by taking into account all the possible values the rotary encoder can take and making it so clockwise and counterclockwise movement can be counted. This site explains how this works and also contains part of the Arduino code that I used as well.

The pushing of the button causes the DAC to go up to the voltage that translates to exactly 5.00 volts on the output of the device. I first had it set to go to the lowest possible voltage, but 5v seemed like a more logical choice.

Step 6: Painting

After I glued the entire box shut, it was time to make my little box look a little better.

I taped off any parts I didn't want covered in paint and mixed some acrylic paint to match my intended colour. The colour I ended up with was slightly different than I had hoped, but I think the final colour is decent enough. After painting I spray painted the result with some acrylic transparent finish paint. And that's it for the painting part, really the shortest step for me in any build process. If it works it doesn't have to be pretty (as can be seen in my not so neatly packed electronics) but some finishing always gives me more satisfaction in having build something that looks decent as well. Otherwise I might be the only person that likes it, since it doesn't look like anything anyone would want to have. Moving on.

Step 7: Result

I encountered some problems while testing my device. The accelerated steps of the encoder caused my powerbank to turn off, possible because of a sudden spike in current. I tried hooking the device up to a more capable power supply, but then my arduino would just stop responding and the voltage would stay fixed.

I hope someone with more insight in electronics can shed some light on this, because it is a rather annoying "feature". To fix the issue I just limited the amount of acceleration the code would allow, as can be seen in the final code of the previous step, where I limit "K" to be a maximum of 40. Using the encoder's push button to go to a high output voltage instantly also resulted in the same crash of the device.

While under load, specifically inductive load, the voltage would vary about 1v with a period of roughly one second. So when connecting a fan, the fan would speed up, slow down, speed up, slow down, etc. Also something I would like some insight into, since the dc-dc converter should be able to handle this? The operation during other load tests was fine, however, when flipping the switch when a load is attached, the powerbank would again have its safety triggered and turn off. When using the supply, high loads should be ramped up slowly.

Also the output voltage isn't the same on every startup, I would think the 3.3v regulator would produce a stable voltage and that the DAC would also produce a constant voltage, so then it would have to be the dc-dc converter. I should look into this some more and maybe get a simple oscilloscope one day...

If I were to make a new or other similar device, I would add an op-amp to isolate the DAC from the converter circuit. I would also look into a circuit to limit inrush current, with a microcontroller at my disposal this would be very doable (switching in and out a limiting thermistor for example). A dedicated voltage reference would also be a nice thing to have, but that would probably be for another project, where having a fixed value would be far more important.

Hopefully some of you will find this instructable interesting, I would love to hear your thoughts.

Thank you for reading!

Power Supply Contest

Participated in the
Power Supply Contest