Just as I was going up a hill, the lights began to dim and the engine coughed. A large semi-trailer loomed in the rear-vision mirror as I pushed the clutch in and tried to restart. My speed was falling rapidly and my lights were blacked out - I was like a sitting duck in the middle of the road, as the semi-trailer came rapidly bearing down on me. I just managed to pull the car off the road, as the semi-trailer came screaming past, missing me by inches! After calling for assistance from the NRMA, the problem was found to be a fault in the alternator, which was failing to charge the battery. The battery voltage had been falling under the heavy load of the lights and at the worst possible time, there was not sufficient power for the lights or the motor.
After the initial shock wore off, I put on my thinking cap to come up with a PIC-based solution to the problem. What was really needed was a display and a buzzer, to get my attention should the voltage fall outside a specified range. So my design criteria was set, a series of LEDs could indicate the voltage and a buzzer would also be used to warn of problems.
- Visual indication of battery voltage
- Audible warning when voltage becomes low
- Screw terminals for easy connection
- Simple and easy to build
The circuit is based on PIC16F819 18-pin microcontroller which has an analog-to-digital (A/D) input to monitor the battery voltage and outputs capable of driving LEDs directly, to keep the component count down. There are seven LEDs in all, giving a good range of voltage indication. The topmost LED, LED1, comes on for voltages above 14V which will occur when the battery is fully charged. LED2 indicates for voltages between 13.5V and 14V while LED3 indicates between 13V and 13.5V. Normally, one of these LEDs will be on. LED4 covers 12.5V to 13V while LED5 covers 12V to 12.5V. LED6 covers from 11.5V to 12V while LED7 comes on for voltages below 11.5V. These two LEDs are backed up by the piezo chime which beeps for voltages between 11.5V and 12V and becomes more insistent for voltages below 11.5V.
That might seem fairly conservative. After all, most cars will start with no troubles, even though the battery voltage might be a touch below 12V, won't they? Well, no. Some modern cars will happily crank the motor at voltages below 11V but their engine management will not let the motor start unless the voltage is above 11V. So don't think that a modern car will always start reliably. This little battery monitor could easily prevent a very inconvenient failure to start! So let's describe the rest of the circuit. The incoming supply is connected via diode D1 which provides protection against reverse polarity while zener diode ZD1 provides protection from spike voltages.
A standard 7805 3-terminal regulator is then used to provide a stable 5V to the microcontroller. The battery voltage is sensed via a voltage divider using 33kΩ and 100kΩ resistors. This brings the voltage down to within the 0-5V range for the A/D input of the PIC16F819. Port B (RB0 to RB7) of the microcontroller is then used to drive the various LEDs, with current limiting provided via the 330Ω resistor network. RB7, pin 13, drives a switching transistor for the piezo buzzer.
Software:
All the parts are mounted on a small PC board measuring 46 x 46mm (available from Futurlec). The starting point should be the IC socket for the PIC16F819, as this is easiest to mount while the board is bare. The next item can be the PC terminal block. The resistors and capacitors can then follow. Make sure the electrolytics are inserted with correct polarity.
Make sure that you do not confuse the zener (ZD1) with the diode when you are installing them; the diode is the larger package of the two.