As I started doing my next project. I soon came to a conclusion that the Li-Ion solution I had with a charger module and a separate buck boost module was not exactly ideal. Sure it worked, but I kind of disliked the idea that I "glue together" two modules that are not really designed to work together, and the initial idea of having everything on a single board was actually not good, it meant a bigger board with less options on how to place it. Also I managed to fry some of them due to small mishaps, and the output from the setup was quite noisy. And did I mention, that the charging module can get really really hot when charging !
So I decided to make a better solution myself.
DISCLAIMER ! If you decide to do this project and end up burning up you house, do not come sueing me. Do this at your own risk. Short circuiting a Li-Ion battery can start a fire, so be carefull !
Design Goals
- One integrated circuit that can provide 5V/2A to client projects. Client project is a term I came up with to mean any load that is supposed to be powered by this thing.
- Provides power to the load separately from charging. ie you can safely leave the device plugged in long term, it does not degrade the battery.
- Charges Li-Ion batteries safely, provides overvoltage, over charge, over discharge and short circuit protection.
- Provides information of it's state to client projects (battery voltage, charging, battery full etc). This is usefull because then the client project can know if the device is plugged in or not and apply power saving measures accordingly.
- Does not produce too much heat.
- Compact size to allow for flexibility in mechanical assembly for client projects.
Tools Used in this project
During the project I ended up buying some more tools. Not all of them are required, but they helped a lot. I marked with an asterisk (*) those tools that provide convenience rather than are mandatory. Also if you decide to do this yourself, you don't necessarily need some of these tools as the design is already done.
- ChatGPT to help with the design and troubleshooting *
- Hot Air station (there is a QFN chip in the design)
- Soldering Iron (there are 3 THT components in the design, and for fixing bad solders)
- Hot plate * (see my previous article)
- Digital Microscope *
- Good Magnifying glass
- Good tweezers
- Wire grimping tool for JST connectors
- Oscilloscope for troubleshooting *
- Multimeter for testing and troubleshooting
- Laboratory power supply. This is mandatory for safe testing !
- KiCad for board desing
Bill of Materials
Instead of listing it here, I attached this
PDF BOM from KiCad.
In addition to those, you obviously need consumables such as solder paste, flux and IPA (not the beer, that would not help). And to make the harness from this board to the client board you need .... wires and JST-XH female connectors.
You can find the Gerber files for ordering the PCB
here. If you would like to order them from PCBWay, please consider using
my affiliate link .
The design journey
I used ChatGPT a lot in this design, and while it did help me reach the final design, it also made quite a few missteps along the way. It for example guided me to make the first version with a boost chip that in the end was not up to the task. Also during the trip it did suggest quite a few over complicated solutions to individual cases. But it did quide me to make a correct power rail solution. Initially I was thinking to make the board so, that when the USB is connected it would simply be routed directly to the load bypassing the boost circuitry. That would have required complicated mosfet based switching circuits to cut the battery out when the USB is plugged in, and since it required a diode on the output, the client project would not receive 5V. I did order one revision of PCBs that was implemented this way. It simply did not work safely, the mosfet always leaked current to the wrong place and I was not able to make it work correctly. In the end, I ended up with a solution where both the battery and the USB in (I call it VBUS in the diagram) feed the boost circuit, but there are schotky diodes in between so that if the USB is connected, it has higher voltage than the battery would ever have so that will not leak to the battery load side and vice versa.
Prototyping was actually one key problem with this project. I could not make iterations on a breadboard, because the boost circuitry in particular is quite strict about how it is layed out. It is a QFN chip, and you need to place capacitators only a millimeter or so away from its pins. That just cannot be done on a breadboard. I ended up ordering four or so revisions of the PCB before I got it right. During this journey I also managed to fry a couple of boards. More about that later.
The final design
Here is the final design !
I settled for the TP4057 charging chip, although it can charge with maximum of 500mA. My devices are usually left plugged in long term, so that is not really an issue. And 500 mA is much gentler to the battery than say aggressive 1A.
The circuit only has three connectors, USB for plugging it in, 2 pole JST-XH for connecting the battery (it enforces correct polarity), and a 5 pin JST-XH to connect the load. Pins 1 and 2 are pretty self explanatory, but pin 3 is meant for monitoring the battery voltage by the client project, and pins 4 and 5 tell the state of the charger. You can monitor them for HI/LO condition by connecting them to a GPIO pin on the microcontroller with a pull up configuration. If they are both HI, it means that the power is not connected to the board. Pin 4 HI means that the battery is full and not being charged and pin 5 HI means that the battery is being charged. Both pins LO would be an error, that should not happen.
There is one design requirement for the client projects that should be followed. The client project needs to make sure, that they don't accidentally backfeed current to this board. Typically this could happen for example if you power a Raspberry Pico with this, and then also plug the Pico to it's own USB. Put a Schotky diode on the Picos VSYS pin to prevent this ! That will drop the voltage a bit, if you need also 5V in the project, that rail needs to be branched out before the diode.
The build
I chose to build this (I've done multiple already) without using a stencil. The main reason for that is the QFN chip, I could not solder it with paste so I used the method I described in my previous
article. Only one of the builds so far was initially a failure, the QFN chip was not properly soldered. I used hot air to reflow it and it worked fine after that. The tricky components to solder are the QFN chip, the inductor and the USB connector. All others are pretty straight forward. It is a good idea to test for shorts on the IC chips and the USB right after soldering them, it is easier to fix them before the board is too crowded.
It turned out just fine !
 |
| My board compared to the previous solution |
Testing
I tested the very first revision with plugging in the actual Li-Ion battery. Big mistake ! After the smoke had cleared, I detected a short in the boost chip and I had no idea how many components had actually burned. So I needed to make a new one. Before I started testing that, I of course checked for shorts with a multimeter, but more importantly I introduced a PTC Fuse in the BAT IN rail. I also changed the testing procedure so, that instead of plugging in the battery straight away, I first used the laboratory power supply to simulate the battery and limited its current to 100mA in the first tests. After these changes I no longer had smoke coming out of the PCBs. I even ended up making a written
test plan to test the boards after assembly. I cannot overemphasize the importance of carefull testing of this thing ! A short somewhere can be catastrophic, although I did try to introduce certain protections in the design.
Conclusions
I am really pleased how this turned out. It works perfectly for my needs. All the initial design goals were met, in particular the board ended up being compact at 35.8mm x 44.8mm.
The things I learned in this project are careful testing, you can never have enough test points on the PCBs ! I also learned to solder QFN packages. If I were to make a new revision of the PCB, I would only add test points for the inductor.
This was also the first project that I made that did not actually involve a microcontroller. That made the overall project interesting in its own right.