Fly Electric!

Low Voltage Battery Monitor

This device switches my 12v camping fridge off when the source battery goes flat. The power to the fridge is provided via a FET which is switched off when the battery reaches 10v. This action also switches LED6 on so you know it has 'tripped'. The circuit latches (it does not rearm when the voltage rises when the load is removed).

It is also my first attempt at 'Charlieplexing'. This is a technique for driving more LEDs than you have spare pins on the PIC. I use the LEDs to reveal the voltage of the source battery when the switch is pressed.

I have used Microchip's 8 pin PIC12F683 chip. Many other PICs should work too but the code size is almost 2000 words. I have used a SUP60N06-18 N channel FET because it was what I had from an old brushed speed controller and the threshold voltages suited the PIC's 5v. I've compiled the program with the BoostC compiler.

PLEASE NOTE: THIS DESIGN IS PROVIDED WITHOUT WARRANTY AND FOR PERSONAL NON-COMMERCIAL USE ONLY.

C source code | PIC Projects | Beginners Guide


The 12v source battery is fed through a 5v regulator to the PIC. Almost any 5v regulator will do and its data sheet will specify the filter capacitors required (C2/3).

The 12v source is also fed via a resistor divider (R5/6) to pin 3 to monitor its voltage. This divides the input to the PIC by the ratio of 4.7/14.7. The values are not critical but must reduce a fully charged 12v battery to less than 5v. This input is filtered with a small cap (C1), again the value is not critical. The PIC uses its ADC function to convert the source battery voltage to a digital number. The program then uses this number to make decisions such as when to switch off the FET. The cut-off is set to 10v with my components.

Almost any N-channel FET should be suitable provided the 5v output of the PIC exceeds the FET's gate threshold. The FET also needs to be able to operate up to the maximum battery voltage (~14v) and at whatever current the load draws. My fridge draws about 4A. At this current the FET gets mildly warm so I added a simple heat sink. My FET draws 0.5mA when on and the whole circuit about 1mA. Most relay-based circuits will draw ~20mA. It's probably worth drawing attention to the fact that the + supply is common to the PIC circuit and the load; 'ground' is switched by the FET' for the purposes of driving the load.

Pin 4 is used for programming the PIC during which time it is pulled high by the programmer. So a 10k resistor has been added to bias it the 'right' way (high to +5v). The push-button switch then pulls the port low when pressed. 'Interrupt on change' is enabled so pressing the button triggers an interrupt in the PIC. This sets a flag which instructs the program to reveal the source battery voltage via 5 of the LEDs. The first LED represents 10v and each flash 0.1v (up to 10 flashes per LED). The next LED represents 11v and so on. So at any time you can check the voltage to gauge how low it is becoming.

'N' ports can be used to drive N*(N-1) LEDs using the Charlieplexing technique. So 3 pins are being used here to drive 6 LEDs (3*(3-1)). The technique exploits the fact that LEDs only work when a voltage is applied with the correct polarity. For example, 2 LEDs with opposite polarity across 2 ports can be alternated 'on' by changing the state (high/low) of the ports. The technique also uses the third state of the ports, namely that they can also be configured as inputs. This raises their impedance to a level which makes them effective 'not there', ie: not a conductive path so neither high nor low. This allows the multiplexing across multiple ports that the technique uses. It does, however, require the use of ports that are 'tri-state' (ie: can act as inputs and high/low outputs). Select resistors R1-3 to limit the LEDs current to <20mA; the 330ohm shown yields ~10mA with my LEDs.

One of the downsides of the technique is the amount of code you need. Clearly it takes more instructions to keep re-configuring ports as inputs or outputs every time you change the LED. However, the bulk of the code in this program comes from the display rules which are lengthy; perhaps there are better ways of writing this? Another challenge is that only 1 LED can be on at any time to avoid inadvertant paths that may illuminate other LEDs.

Back
Click on the links below for other pages.

Home ¦ Art of the Possible ¦ Absence of Matter ¦ Links ¦ Updates ¦ Email
SITE MAP