## The HLVD Module for Low Battery Indication

This is a continuation of Using the HLVD Module in Swordfish Basic.  Here's a detailed look at using the HLVD module for detecting a low battery as I touched on in the previous artile.

A lot of variables go into the viability of this technique including the battery chemistry, the number of cells, the current drawn from the cells and whether the load is steady or intermittent.  Conclusions based on these NiCAD batteries will generally apply to NiMD batteries as well.  Li-Ion and Li-PO batteries have some very specific requirements for charging, discharging and maximum and minimum voltage and won't be covered here.

We need to define some terms to get started.  Batteries are rated in terms of mAh (milliamp-hours).  This is based on a particular load profile and serves as a rough guide as to the life to expect.  For example, if a circuit draws 100 mA from a battery rated at 1000 mAh, it could be expected to run for about 10 hours:

Unfortunately, the length of time a battery of time a battery will supply current isn't quite as simple as this relationship.  Batteries supplying low-current loads usually last longer than expected while batteries supplying higher currents usually have a shorter life than would be expected.

Charge and discharge rates are based on the mAh rating.  C, the rate of charge, is the mAh rating divided by 1 hour.  For a 1000 mAh battery, C = 1000 mA.  If this battery is charged at a 1C rate, the charging current would be 1000 mA;  if the battery is charged at a 0.1C (or C/10) rate, the charging current would be 100 mA.  This is a common charge rate and is safe for NiCAD and NiMD batteries without further monitoring.

The batteries used for testing were four 2/3 AA NiCAD cells rated at 250 mAh connected in series.  These were removed from some cheap solar-powered path lights which had never been used.  The batteries were discharged using a constant current load at a 0.1C rate and a 1C rate; the results are shown in this plot.  The plots show an inflection point at about 3 volts; this is an artifact caused by my constant current load - the load falls below 3 volts.  The 4 cell pack is essentially dead at this point.

The pack lasted for 613 minutes at the 0.1 discharge rate, for a total of 255 mAh delivered.  At the 1C discharge rate, the pack lasted for 51.7 minutes, a total of only 215 mAh delivered.

The HLVD module trip points have some variability caused by manufacturing tolerances.  For each possible setting, a minimum and maximum trip point are given.  For a given set point, the actual value will fall somewhere in this range as shown in the table below.  This is for a PIC18F2520.  For other devices, the ranges may be different.

The tolerance in the HLVD settings will  impact the ability to detect a low battery.  The desired set point depends on the goals of detecting a low battery.  For some applications, only short warning of a low battery is needed to allow an orderly shutdown possibly including saving data.  In other applications, more warning of low battery may be desired to allow time to use the circuit before the battery is too low.  The following plots show battery discharge curve with the HLVD ranges overlaid.

The first plot shows the <1110> setting for the HLVD module, the highest setting overlaid on the 1C and 0.1C discharge curves.  The trip point is somewhere in the region between the low tolerance and upper tolerance limits and will vary between chips.  As you can see, the appropriate HLVD setting is extremely dependent on circuit current draw.  If the current draw is 0.1C, the <1110> setting for the HLVD module would trip when the battery is somewhere has between 5% - 20% of life remaining.  This is probably a reasonable setting for a low battery warning.  On the other hand, if the current draw is 1C, the battery has somewhere between 20% - 90% of battery life remaining.

The next plot shows the<1101> setting for the HLVD module.  The trip point for a current draw of 0.1C is somewhere between nothing and 3%.  But the trip point for a 1C current draw is between 6% - 18%.

Plots for <1100>, <1011> and <1010> are shown below.

For the NiCAD batteries tested, the HLVD module trip point may be the basis of an adequate but not very precise low battery warning.  Because of the large steps and the tolerance of those steps, tight control is not possible.  It should be clear from the graphs above that the appropriate trip point is very dependent on battery load.  For alkaline (non-rechargeable) batteries, the situation is better because the discharge curve is not as flat - the voltage drop vs. discharge state is larger.

#### But there's more....

Terminal voltage is not a very reliable indicator of battery condition, or more accurately, high voltage doesn't always relate to the state of depletion.  The plot below is the same four cells as above, starting from a mostly charged state.  The batteries were discharged at a 1C rate down to 4.8 volts where the load was removed.  The battery voltage returned to approximately the initial state, and the discharge was repeated.  It can be seen that the time period to reach the trip point decreased with each cycle, and after the first cycle, the discharge period was very short.

#### Conclusions

The HLVD module provides a simple, easy to implement battery check for microcontrollers powered directly from a battery.  The current draw is nearly zero, no external parts are required and no port pins are sacrificed in the process.  The finesse depends on the battery type and load, and the test is of limited utility.  Keeping these limitations in mind, the HLVD module is a simple tool to keep in the arsenal.