Introduction: Programmable Battery Protection [Open Source]

Every battery needs protection.

When I couldn't find a board that suited my needs, I set out to create one myself.

If you discharge a battery completely it can be permanently damaged. This PCB monitors the voltage (and thus the State Of Charge) and if it dips below the programmed voltage it will disconnect the load. For a lead-acid battery this is ~11.5V for example. Please note that this battery monitors total pack voltage, it doesn't offer individual cell protection. It can be used on any battery chemistry you want, as long as the pack voltage is between 5.5 and 29V.

This solution is based on an ATTiny microcontroller which remains in very low power shutdown unless the button is pressed. If the battery voltage is above the programmed treshold the load will be switched 'on' using a mosfet.

A couple of key features include: reverse battery protection, very low power consumption, able to switch high current loads, compact board, cheap to make.

In the video you will see the design process step by step. A more detailed explanation in text format can be found on the following pages. On the last page you can download all the files, including schematic, layout, GERBERs and code.

Step 1: R&D

The three main things I wanted to achieve:

-low cost

-small footprint

-high flexibility

This project doesn't require many pins, so I chose the popular ATTINY85 microcontroller (6 I/O's) in a SOIC package. An ATTiny gives a very flexible solution that is cheap and requires almost no external parts.

For the mosfet I needed something that was small, cheap and can switch 8A+. N-Channel would be the most practical, because then you can connect one side to the ground plane of the PCB. It can switch about 13A continuous and 110A (!) pulsed.

For the voltage regulator I needed something that has low quiescent (idle) current, because the power usage has to be almost zero when 'off'. The LM2936 satifies this requirement with only 15uA of idle current.

Step 2: Schematic

I was able to keep the required part count very low.

Couple design notes;

-The voltage divider on the input has to have high resistance to keep power dissipation low

-Max input voltage times the divider ratio should be about 3.3V (Vcc)

-1%+ tolerance resistors should be used to guarantee precision

-Pull down resistances prevent parasitic toggling of the mosfet and switch

-Small decoupling capacitors keep voltage stable

-LED current limiting resistors can be increased to decrease power consumption at the cost of brightness

I was not aware that the ATTiny came in a different SOIC package than the mosfet and regulator. That's why they don't fit properly on my PCB's. It's fixed in the downloadable files at the end of this Instructable.

-

Step 3: Breadboard Testing (AutoCAD)

I have made a 'breadboard schematic' of how I tested my plan. This setup allows me to see if my powerdown, treshold and mosfet output is working. It's best to use a labbench to power the circuit. This way you can vary the voltage and test the switching treshold.

Step 4: Layout

Layout is pretty simple. It's a 2 layer PCB with stitched groundplane on both sides.

In/Output terminal on the left, programming header on the right.

JST 2P for the switch at the top, JST 3P for the bicolor status LED on the bottom

Step 5: Code

A microcontroller in powerdown uses almost no current (I measured ~300nA). That's a lot less than the self-discharge of the battery itself. You can wake a microcontroller from its sleep by using a pin-change interrupt. I commented my code so it's easier to understand.

Current consumption when active is 2,06mA. It's the same at all voltages because a linear voltage regulator is used.

There is a download link to the .INO arduino file on the last step. Attached code doesn't have the lines for the led control, I might change the file later. If you need help with that, message me.

The Arduino UNO can be used as ISP to program the ATTiny as seen here: https://create.arduino.cc/projecthub/arjun/program...

Edit:

Thanks to user frarugi87 for noticing some flaws in the code I uploaded. The picture above and the file in the download now have been corrected to a fixed and optimized version of the code.

Step 6: BoM and Files Download

Bill of Materials (ordercode at Farnell):

-ATTiny85 [1455164]

-Mosfet, N-Channel SOIC [2322618]

-Resistors, 1% tol 0805 [9332405; 9333606; 9333509]

-Capacitors, 35V+ 0805 [2496944]

-Terminal block, 6way 5mm [9633006]

-Regulator, 3.3V SOIC low IQ [2492178]

I got my JST 2P and JST 3P connectors plus cables from eBay.

As you can see, I listed the key specs so you can find replacement parts if needed/wanted.

Minimum PCB order quantity is 10 pieces. At that quantity BoM is around 5$ per board.

Files can be downloaded here

https://www.dropbox.com/s/i2uzpflp5yaifob/BatteryP...

-Production ready GERBERs

https://www.dropbox.com/s/i7a2kicuiqnb4en/Code%2C%...

-.INO Arduino C code

-Schematic and Layout [DipTrace]

If you need help with ordering pcb's, modifying code, programming the chip or anything else; send me a message.

Circuits Contest 2016

Participated in the
Circuits Contest 2016