Battery voltage detection

Thread Starter

mike_canada

Joined Feb 21, 2020
39
What I want to do is use a 2-transistor circuit on the left to let the microcontroller determine if the battery is supplying sufficient voltages to the LCD. Ok, the LCD isn't wired well, but the important thing to note is that everything but the transistors is powered through an LM2940 voltage regulator. Yes I deliberately forgot to include the coupling capacitors to make things simple, because my problem is on the left side and I already made the PCB but I don't know the optimal values to use for resistors and zener diodes.

The LCD is an HD44780 compatible LCD with a backlight always on but I usually feed the backlight power through a 10 ohm resistor to try to extend battery life. The transistors I thought of using were PN2222 but I could also use 2N3904 if thats better.
I did use 10K resistors from each NPN base to ground and I'm tempted to make the other resistors 2K.

Somehow I think the formula for the perfect diode is this:

Battery voltage (7.2V on full charge) minus zener voltage minus transistor emitter-base voltage >= 0 to turn GPIO line off.

I didn't use resistors at the NPN collector because I'm relying on the internal resistors installed in the AT89S52 micro. As of last measurement on the multimeter, they came to about 82K.

Did I get the formula right? and do I need different resistor values from what I mentioned?



circuit.png
 

crutschow

Joined Mar 14, 2008
25,135
That circuit will not detect the voltages very accurately.
A TL431 programmable reference instead of a Zener would be much more accurate.

How accurate does that detection voltage need to be?

What two voltage levels do you want to detect?
 

Irving

Joined Jan 30, 2016
823
A simple voltage divider off the battery to an analog input would allow you to monitor the battery voltage. If you want an interrupt to warn of low volts, set up a timer interrupt to read the ADC and generate a software interrupt on low volts. A 33k to BAT+ and a 68k to ground will give a ratio of 67% so 7.2v translates to an ADC reading of around 4.8v. Use 1% resistors.

If you must have a digital input then the TL431 as already suggested is the best solution as its transition from high to low is much sharper than a zener.
 

Alec_t

Joined Sep 17, 2013
11,419
I did use 10K resistors from each NPN base to ground
There will be so little current going through the zeners that they will be operating on a very rounded knee of their characteristic. That, coupled with the temperature dependence of the zeners and the transistors, will give a very vague and variable switching threshold. Consider using one of the alternative solutions already suggested.
 

crutschow

Joined Mar 14, 2008
25,135
Below is the LTspice simulation of a voltage detect circuit using the TLV431 programmable reference (low power version of the TL431) as a comparator switch.

Its switch-point is when the Ref voltage is 1.24V, so you select the values of R2 and R3 to give that voltage at your desired detect value.
The values shown give a nominal trip point of 7V.

1594562248486.png
 

Thread Starter

mike_canada

Joined Feb 21, 2020
39
That circuit will not detect the voltages very accurately.
A TL431 programmable reference instead of a Zener would be much more accurate.

How accurate does that detection voltage need to be?

What two voltage levels do you want to detect?
Its better than nothing. And I don't need super accurate. I just want to be able to see characters on the LCD before the battery ultimately dies off so maybe 4V and 5.5V?

4V is I believe the absolute minimum required to turn on a backlit LCD

and 5.5V is the maximum that one would get from an LM2940 regulator regardless of the input voltage.

The detection does not have to be super accurate, just as long as I can detect when the battery is almost new and when the LCD is almost ready to die.
 

Thread Starter

mike_canada

Joined Feb 21, 2020
39
I'm using NI-MH 7.2V 6800mAh RC toy-car batteries with a tamiya connector but I will consider changing the batteries if it makes that much of a difference.
 

Irving

Joined Jan 30, 2016
823
You probably don't want to go below 4.5v (0.9v/cell) if you want any life from them. Discharging to 0.8v/cell (4v for pack) will be potentially damaging.
 
Top