Tuesday, 30 December 2014

Do it Yourself Power-Bank Part-2


This is the 2nd Part of the DIY Powerbank Tutorial. Link to the first part is here

So far we have covered the basic working principle of the Powerbank. List of Parts required and description of some parts.

Now we will work on the part called "Control circuit". This will work as the Brain of the Powerbank. Let me just give you a brief idea of the functions the control circuit will deal with.

  • It will show you the battery level of the Powerbank.
  • Provide a soft turn-on and turn-off mechanism. It is necessary to turn-off the device when not in use otherwise a lot of power will be wasted by the boost converter.
  • Provide indication of charging while the powerbank is charging.
  • Turn-off the boost converter when the internal battery is very low, otherwise the powerbank battery will be so depleted that it can't be charged anymore.
Well to say precisely it is control circuit that can be used for any battery operated device. Because any device that operates on rechargeable batteries requires those above mentioned functions to be carried out by some circuit.


So in the picture the control circuit in the center is shown, on the right is Step-up/boost converter and below it is the Usb socket mounted on a DOT-PCB.

You can see that the circuit is not clean because while designing the circuit i selected a component which was not available in the market and realised the mistake after fabricating the circuit. So i had to fork my way around by cutting traces and using jumpers.

But now i have corrected that error and redesigned the circuit completely. So that anyone can easily fabricate it.

The major components in this circuit are ATTINY45 microcontroller, 74HCT595 shift-register, and BSO119N03S a N-channel Power E-MOSFET, which drops minimum voltage and has very low leakage.

Below is the schematic of the Control circuit.

 However you can download the schematic and board layout files designed in EAGLE from https://github.com/neutronstriker/Powerbank_EC.

And this is the layout

This version is little different than what mine looks like because my actually prototype had some problems. 

Mind that the above image is not according to scale so just download Powerbank_EC.pdf and print in on paper without any scaling then you will get the correct size, or you could download the whole repository from link above and download the eagle files and print them.



After you have fabricated the board you can solder the components on to it by taking help from the above image.

Now the Working:

So i will just briefly explain the working of the circuit. 

The attiny45 is loaded with a program which continuously monitors the battery level of the Powerbank using ADC and Voltage divider configuration. When it falls below the programmed minimum value it will display warning, but when battery falls below reserve threshold the Control Circuit turns of the powerbank automatically.

While the device is off the attiny45 is in powerdown(sleep) mode and boost converter is off because of the MOSFET. 

The switch is connected to INT0 and when the powerbank is off and we press the switch for 3 seconds then it turns on. If i press the switch for 3 seconds when the device is ON it turns off.

When the device is ON and if press the switch for only 1 second then it displays battery level.

The charging socket is connected to PCINT0 and when external charger is connected the Powerbank starts charging and the battery animation is shown.

In this circuit 6 leds are connected to a 74hc595 shift-register which takes input from Attiny45 to drive the leds. But data is sent to 74HC595 using only 1 pin instead of 3 requied(SH_CP, ST_CP, DATA) it has been possible because i am using a modified version of Shift1 technique. You should read more about shift1 it is really very useful tool to multiplex your output pins when you have less number of IO pins.

Even if you don't understand the working now don't worry you can understand it clearly if you read the whole program source code. I have explained the working of the code and its relation and effect on the circuit in the code itself.

So below is the code just read through it and you will be able to understand how it works as i have explained what the code does where ever required.


https://github.com/neutronstriker/Powerbank_TINY  is the link to the source and hex files. It was written using AVR Studio 4 and Winavr. 

Note that in the fusebit settings of ATTINY45, the clock was set to internal 8Mhz RC oscillator, brown out(BOD) was disabled, CKDIV was UNPROGRAMMED and SUT was set to default.

Thats it for now in the next part will be final assembly and demo of its working.

Click here to goto Part-3 of this project.
Unknown An Electronics and Tech Enthusiast

I am a Tech enthusiast who loves to build stuff like new gadgets and tinker around with electronic devices doing some DIY stuff, writing some code and in the process providing something back to the community.

No comments :

Post a Comment