Introduction: 12V Battery State of Charge Indicator
With the use of 12V batteries becoming more popular (typically the 7Ah sealed lead acid), I have been requested several times to build a state of charge (SOC) meter displaying the voltage on LEDs. However, each person wants something a little different. The biggest difference is the required minimum and maximum voltage to be displayed.
If a low level warning is also required, this will then result in three voltage levels to be monitored. Using pots for adjustments, is the normal method used. However, add a second or third warning, this can become a problem.
Lastly, the current drawn by circuits I have tested, ranged between 45mA and 150mA. With a standard LM3914 battery monitor, the battery monitor itself will drain a 7Ah battery in about 46 hours.
The aim was then to design a battery indicator with the following specifications:
- LED Display
- Adjustable maximum voltage level
- Adjustable minimum voltage level
- 3 Adjustable alarms (typically 50%, 30%, 20%)
- Alarms to be non-irritating, and have a mute function
- Minimum buttons
- Low power consumption
For my design, I opted for the AtMega328P micro.
Step 1: LED Display
The LED display was designed to be simple and easy to interpret. There are 6 LEDs, indicating the voltage level in a LED BAR method:
Led 6 - 100%
Led 5 - 80%
Led 4 - 60%
Led 3 - 40%
Led 2 - 20%
Led 1 - 0%
The 0% Led is to be linked to the programmed minimum voltage level
The 100% Led is to be linked to the programmed maximum voltage level.
The scaling between 0% and 100% is linear. For 0%, only Led 1 will be on, and for 100%, all Leds will be on.
For power saving, the LED display does not stay on. To turn on the display, a button needs to be pressed, and the display will turn off after 30 seconds.
Step 2: Voltage and Alarm Levels
To be able to measure the voltage, the battery voltage needs to be down scaled. Using a resistor divider, the voltage is scaled down to 1.1V with a 1M and 82K resistor. With the A/D converter set to the internal 1.1V reference, this means that the maximum measureable voltage will be around 14.45V, high enough for the design.
There are 5 voltage levels that needs to be monitored:
- maximum voltage level
- minimum voltage level
- alarm 1 voltage level
- alarm 2 voltage level
- alarm 3 voltage level
Instead of using trimpots, I decided to go for a more unconventional way. Via a programming procedure, apply the specific voltage levels in turn, and save the various A/D results in EEPROM.
The LEDs are used to indicate the programming sequence, and the same button used for the display, is used for programming.
Step 3: Audible Alarm
A normal piezo buzzer is used for the alarm. as this should be load enough. Provision for three alarms were made, with the following properties:
- Alarm 1, to beep once every few seconds. Should be able to silence this alarm
- Alarm 2, to beep twice every few seconds. Should be able to silence this alarm
- Alarm 3, to beep three times every few seconds. This alarm can not be silenced.
Once an alarm is silenced, I needed an automatic reset function to enable the alarms again if the battery has been charged. I included a reset function that will enable all alarms again if the battery voltage exceeds 60% again.
To silence the alarms, the same button used for the display is used.
I tested these alarm sounds in my house, without any complaints from my wife and son, so I am sure it will not be irritating in the outdoors world.
Step 4: Minimum Buttons
All functions are done using a single button.
To turn on the display, press the button. The LED dislpay will come on, and turn off automatically after 30 seconds.
Alarm 1 and Alarm 2 are silenced by pressing the buttom.
To enter programming mode, press and hold the button while powering up the unit. Keep the button pressed for 5 seconds.
Step 5: Low Power . . .
There are several ways to reduce the overall power used by the circuit. I used the following methods:
By pressing the button, the LED display is turned on, and automatically turns off the LEDs after 30 seconds. This results in a saving of 120mA.
Running the AtMega328P at 5V, uses more power than running at 3.3V. I opted for a 3.3V low drop out regulator.
A standard 7805 regulator has a quesent current of around 20mA. Using a 78L05, this is reduced to 3.5mA. But, by using a low drop out regulator like the LP2950 3.3V, this can be dropped to as low as 0.1mA.
If you do not require the power saving, you can use a 78L05
Oscillator speed and selection
From the datasheets, the AtMega328P current can be dropped from around 10mA to 1mA by selecting the internal 8MHz oscillator, as compared to the external 16MHz crystal.
I opted to use the internal oscillator running at 8MHz for the design, as it gives the best speed/power performance. However, the drawback is that the AtMega328P config registers needs to be programmed using AVRDude. I make use of this site (http://www.engbedded.com/cgi-bin/fcx.cgi?P_PREV=&P... to get the correct register configs.
If you do not want to change the config fuses, the MCU must run on an external 16MHz oscillator. Please change any delay() and Millis() values to actual ms values.
By placing the AtMega328P in SLEEP mode, one can further reduce the power. In SLEEP mode, most of the MCU interfaces are turned off. In this mode, the MCU can draw as little as 0.001mA. However, the MCU is no longer running, or in this case, measuring the voltage.
A watchdog time is used to wake the MCU from SLEEP. Setting up the watchdog timer to wake up the MCU every 8 seconds, will ensure that the power used is even less.
More information about the power saving modes can be found at http://www.gammon.com.au/forum/?id=11497.
Results of power saving
By using the above power saving techniques, I was able to reduce the current of the circuit down from 80mA to as low as 0.12mA when the device is in SLEEP mode. Overall, the circuit uses about 0.28mA.
Thus, before power saving the circuit will drain a 7Ah battery in about 2.8 days.
After power saving, it will take around 3.5 years for the circuit to drain the same battery.
Step 6: Building the Circuit
I used the free version of Eagle to design the PCB. All components, except the push button, are mounted onto the PCB. Assembly is easy, with the exception of soldering the LEDs. Ensure all LEDs are the same height. I used 20mm spacer to mount the unit, and used this as reference for the LED height.
Because my design uses a 3.3V regulator, some standard 5V piezo buzzers does not work. The buzzer in the design is connected across 12V, and switched with a transistor. Play around with the value of R6 to get a decent sound out of the buzzer, without destroying it. Apart from this, there is no other tricks in building the circuit.
Step 7: Calibrating the Unit
You will need a variable power supply and a multi meter to calibrate the unit.
Entering Calibration Mode
- Press and hold the button
- Connect unit to power supply
- After 5 seconds, the unit will beep continuously
- Release the button
- Unit will give 6 beeps (setting maximum voltage)
- Top LED will be on
- Uit is now in CALIBRATE mode. To exit this mode, remove power from the unit without pressing the button.
- Adjust power supply output to the maximum voltage to be displayed on the LED display (typical 12.7V)
- Press the button
- Unit will give 5 beeps (setting minimum voltage)
- Bottom LED will be on
- Adjust power supply output to the minimum voltage to be displayed on the LED display (typical 11.8V)
- Press the button
- Unit will give 4 beeps (setting Alarm 1)
- Bottom 4 LEDs will be on
- Adjust power supply output to Alarm 1 voltage level (typical 12.4V)
- Press the button
- Unit will give 3 beeps (setting Alarm 2)
- Bottom 3 LEDs will be on
- Adjust power supply output to Alarm 2 voltage level (typical 12.2V)
- Press the button
- Unit will give 2 beeps (setting Alarm 3)
- Bottom 2 LEDs will be on
- Adjust power supply output to Alarm 3 voltage level (typical 12.0V)
- Press the button
- Unit will give 1 long beep to indicate end of calibration, and LED display will turn on for 30 seconds.
All programming values are stored in EEPROM, so the unit only needs to be calibrated once.
We have a be nice policy.
Please be positive and constructive.