Li-Ion Discharger

Introduction: Li-Ion Discharger

Note: new firmware 2.0.1. Changed voltage measurement to Open Circuit Voltage. Environment changed to PlatformIO and code hosting changed from codebender to gitlab.

I had a couple of Li-Ion cells laying around, mostly salvaged from old phones and laptops. I tend to use these in little gadget projects, using the little EUR 0.50 TP4056 boards as chargers. However and as usual, time often gets in the way. Setting aside Li-Ion cells fully charged is not a good idea as it degrades the cells much faster than needed. Ideally they are stored at 40% State of Charge (SOH), but you need an advanced and expensive charger to do that. I decided to take a different approach and see if I could slam something together from the stack of stuff laying around.

First, charge the cell i.e. using said TP4056 board and a USB power supply. Then this circuit is connected and it will discharge the cell to 3.77 volt or storage, or 3.00 volt for complete discharge, but not further. For 3.77 Open Circuit Voltage, the cell is now under low stress and can be stored for quite a long time.

It's build around my favorite tiny microcontroller, the Atmel ATtiny85. It's an offspring of the processors used in the Arduino family, is used in the Digispark boards and programmable through the Arduino IDE.

Here is what it does the moment you hook it to a cell.

  • it beeps once, indicating 3.77 volt cutoff or twice, indicating 3.00, and blinks a LED in a short-long-short (201) pattern to show it's version. To switch between 3.77 and 3.00 volt, just remove and reattach the battery.
  • it check it's main voltage without load and assuming it is at or above 3.77 or 3.00 volt, it starts a constant current (300 mA) discharge;
  • while discharging it flashes the LED indicating the battery voltage at this moment (see below);
  • after each display cycle, it stops discharging for 100 ms and then it takes another measurement
  • As soon as the voltage drops below 3.77 or 3.00 volt, the discharging circuit is disabled and the processor goes into an extremely low power state, only to wake up every 8 seconds to sound a piezo buzzer.

There is no automatic restarting. The power leads need to be removed an re-attached to restart the the device.

The LED repeatedly flashes three sequences to represent a three digit number, with a single long flash indicating a 0 and numbers greater than 3 separated in groups of three. So when we represent a long flash with an underscore and a short one with a dot, two examples are:

... .   _    ..        ... .    _    ..           4.02 volt

...   ... ... ..   _        ...   ... ... ..   _  3.80 volt

The actual design is a mash-up of the Laser Gun project and the Li-Ion protection circuit.

Step 1: The Hardware

Let's start with the part list

  • an ATtiny85
  • an 8 pin DIL socket (optional)
  • a small piece of perfboard
  • resistors (1 x 150R, 1 x 120R, 4 x 10R)
  • two 1N4148 diodes
  • a BD139 transistor
  • a small aluminium heatsink
  • a piezo buzzer (active type)
  • an LED
  • crocodile leads

The hardware is extremely simple. It is just an ATtiny85 micro-controller with attached to it an LED, a piezo buzzer and a constant current discharger. Simply follow the schematic. The discharger was based on (and explained in) the Laser Gun project, it is just using other values and a beefier transistor to allow for the 300 mA discharge current and approximately 1 watt of heat dissipation. Just build the device on a small piece of perfboard.

Note I used 4 resistors in parallel so they don't warm up too much. And in all honesty, I didn't have lower values laying around. The transistor dissipates most of the energy and can get quite hot. A small heatsink is needed.

Since the latest firmware (2.0.1) it measures the voltage while the cell it is not under load, and the design is a constant current one, the wire gauge to the cell is not very critical.

Cost is at most a few Euro's, well worth the longer shelf life of your Li-Ion cells.

Step 2: The Software

The software is reasonably straightforward and well documented. There are two functions that are a bit out of the ordinary as they manipulate the internal registers of the micro-controller. It is probably best to simply assume they work.

system_sleep () puts the processor in a very low power state.

battery_voltage () does the actual measurement of the supply voltage of the chip, called Vcc.

You can find the source code here https://gitlab.com/jeroenmeijer/dischargeliionbattery It is structured as a PlatformIO project.

And as always on ATtiny85 based projects: You need some sort of device to put your programs (or sketches as
they are called in Arduino parlance) into the chip's flash memory. Such devices are called ISP's. This instructable is not about how to build yourself an ISP nor how to use the Arduino IDE. If you're new to programming ATtiny85 chips, please read my "Butt Light" instructable, as it contains links to building your own ISP and how to use the Arduino IDE to compile and upload your firmware. The repository on gitlab assumes an STK500v1 programmer. This is exactly the same as an "Arduino as ISP".

Happy discharging!

Be the First to Share

    Recommendations

    • The 1000th Contest

      The 1000th Contest
    • Battery Powered Contest

      Battery Powered Contest
    • Hand Tools Only Challenge

      Hand Tools Only Challenge

    Discussions