Power Cell LiPo Charger - Booster Tutorial from codebender on Vimeo.
This is a tutorial on the Power Cell LiPo Charger/Booster
from Sparkfun. This module is used with the prevailing choice of LiPo
batteries and is comprised of two separate circuits. One of those is a Boost Converter
that its purpose is to supply a fixed and stable output voltage for a range of input voltages. The other circuit is a LiPo Charger
that can charge a single cell LiPo battery either from an external 5V source or a USB port.
The module has some extra features. One feature is the solder jumpers next to the JST connector that can pick a 3.3V or 5V output for the boost converter. Then, there are the EN
and PS
pins that are tied to the operation of the boost converter. The EN
pin, when driven LOW, disables the boost converter, and so the VCC output pin doesn't supply any power. The purpose of the PS
pin is somewhat more involved, but basically when driven LOW, it makes the boost converter more efficient and consequently consumes less power. Lastly, there is a status LED controlled by the charger and it goes off when the battery is charged.
The Power Cell
module was built both with the boost converter and the charger on board for one specific reason... so, you don't to take the battery away from your project, plug it in your charger, and then put it back again, every time the battery needs charging. Now, you can just plug your USB cable in and wait for the battery to charge. But as long as your project is connected to the VCC and GND pins, it's going to consume energy. This means that the battery will be supplying power while is charging, and the whole process will take longer to finish (when the charging process alone normally takes quite some time). So, with the project connected, the battery might take forever to charge.
So, if you have built your project and you've placed it inside an enclosure, ideally you'd want to just plug the USB cable in, let the battery charge as quickly as possible, and then have an indication to let you know that the process is finished. For these reasons, we will introduce 2 hacks to the current design of the Power Cell
module. The first hack will drive the EN
pin LOW when we plug a USB cable in, cutting off that way the rest of the project and letting the battery charge alone. The second hack will drive an LED that will light up when the battery is charged (this will only work with the MCP73831).
Let's begin... this is the schematic of the finished circuit.
We'll need to do some soldering on the Power Cell PCB
. Take a wire and solder its one end on pin 1 of the charger IC
, like in the figure.
The rest of the components are a 3 mm green LED, a 330 Ohm resistor, a 2.2 kOhm resistor, and a generic NPN BJT transistor. Now... place the BJT on the breadboard. Connect one end of the 2K2 resistor to the base of the BJT (lead 2) and the other end of the resistor to a nearby column. Connect the 5V pin of the charge input to the other end of the 2K2 resistor. Connect the GND pin of the charge input to the emitter of the BJT (lead 1). Connect the collector of the BJT (lead 3) to the EN
pin. Place the LED on the breadboard. Connect one end of the 330R resistor to the negative lead of the LED and the other end to a nearby column. Connect the other end of the 330R resistor to ground. Connect the other end of the wire you soldered earlier on the PCB, to the positive lead of the LED. Connect the VCC and GND pins of the Power Cell
to the 5V and GND pins on the Arduino, respectively. Connect the PS
pin to PIN7 on the Arduino. And finally connect the battery to the JST connector of the Power Cell
.
When we connect the battery, the status LED on the Arduino lights up, and later when we plug the USB cable in, it turns off... so the Arduino draws no power, the battery is charging, and when the charging ends, the green LED lights up and we can take the USB cable away.
That's all but one thing about the operation of the Power Cell
module. This one thing is the PS
pin that we will interface with the Arduino. The PS
(Power Save) pin is driven HIGH with a pullup resistor on the PCB. In this configuration, the boost converter operates in normal mode where it does some work to provide a reliable output voltage. But that work doesn't come free, it consumes energy from the battery. In situations where our project doesn't need that much power, we can drive the PS
pin LOW and put the boost converter in power save mode where it stops and only kicks in when the output voltage tries to fall below a nominal value.
So, let's build an example application and see how we could make use of the PS
pin. We will simulate a high load situation with an LED Matrix
. Operating an LED Matrix
doesn't really need that much power, but if we try to build a bigger display with, say, a dozen matrices, then that will demand a considerable amount of power. The LED Matrix
will be a bicolor red/green common cathode one, and from the two colors we will be using the green one. We will interface the LED Matrix
with a MAX7219
driver, and then we will communicate with the driver through the SPI
bus. We will also use a push button to turn the system on and off, and accordingly put the boost converter in power save mode.
This is the schematic for the LED Matrix part of the system. It's pretty big, so take your time and make sure to do the right connections. The ceramic capacitor is 100 nF. The electrolytic capacitor is 10 uF (pay attention to its polarity). The resistor is 12 KOhms.
This is the schematic of the push button. It has a pullup resistor and an RC filter. The output of the RC filter connects to interrupt INT0 on the Arduino.
Normally the output of the RC filter would connect to a schmitt trigger inverter to provide a clean output that would drive the interrupt pin, but since I didn't have such a part, I had to improvise. I tested and picked some values for the components and then I did a software debouncing of the switch. The result I got isn't perfect, it works most of the time, but if a button press doesn't do anything permanent to your project (such that multiple presses would mess things up), you can use this approach with no worries. The two resistors are 10 KOhms and the capacitor is 0.1 uF.
This should be the final project.
Now let's look at the code. For details on what the example does, you can read the comments.
The one thing I want to emphasize is what happens with the PS
pin of the Power Cell
when the button is pressed. On a press of the button, an interrupt is generated and the statusUpdate
function is executed. There, the status and done flags are updated, and when the program flow returns to the loop function, the LED driver will go either in normal or shutdown mode, and the boost converter will go either in normal or power save mode.
That's all folks. We hope you enjoy this project, and if you have any comments or suggestions you can contact us at girder [at] codebender [dot] cc
Sounds are from freesound.org. Schematics were based on Fritzing.