# Circuit design to measure battery voltage using LED's

#### idosol

Joined Apr 28, 2022
6
I need to design a circuit to measure battery voltage using LED's.
V_in=V_max= 12v , V_min=8v
When V_in ≥ 9v LED1 will light up
When V_in ≥ 10v LED2 will light up
When V_in ≥ 11v LED3 will light up
When V_in < 9v RED_LED will light up
you can use a one channel power supply (positive), transformer, resistors, capacitors, op-amps etc.

#### crutschow

Joined Mar 14, 2008
29,792
The usual way to do such a task is to use IC analog comparators, biased to turn on at the desired voltage.

Do you understand how analog comparators work?

Last edited:

#### idosol

Joined Apr 28, 2022
6
The usual way to do such a task is to use IC analog comparators, biased to turn on at the desired voltage.

Do you understand how analog comparators work?
If I'm not mistaken I think you refer to what I know as a comparator op-amp.
if v+>v- then v_out =+Vcc
if v->v+ then v_out =-Vcc
But how can I use them? If I can only use one positive power supply channel, how will I get -Vcc for the op-amp?

#### Alec_t

Joined Sep 17, 2013
12,808
If I can only use one positive power supply channel, how will I get -Vcc for the op-amp?
You can use a 'virtual earth' point at half the +ve supply voltage V. That give you three rails: +V/2, 0, -V/2.

#### dl324

Joined Mar 30, 2015
14,462
Welcome to AAC!
if v+>v- then v_out =+Vcc
if v->v+ then v_out =-Vcc
But how can I use them? If I can only use one positive power supply channel, how will I get -Vcc for the op-amp?
When the difference between the non-inverting and inverting inputs is negative, the output will be whatever the comparator lower rail supply is. In any case, you don't require a negative supply.

#### idosol

Joined Apr 28, 2022
6
Use the LM339 or LM393
Thank you but I failed to mention that I can only use TL071 op-amp

#### idosol

Joined Apr 28, 2022
6
You can use a 'virtual earth' point at half the +ve supply voltage V. That give you three rails: +V/2, 0, -V/2.
Can you please elaborate how to connect the virtual ground I didn't understand how to do it

#### Ian0

Joined Aug 7, 2020
5,136
Don't use the TL071 as a comparator - it has a problem - it's caused phase reversal, and it happens when one input is taken close to the negative supply: the output swaps polarity. It's not the only op-amp with this problem, but it does make it almost impossible to use as a comparator.
Generally, it's a bad idea to use an op-amp as a comparator. Some of them (NE5534, for instance) cannot be used as comparators. If you need a comparator - BUY A COMPARATOR.
There's a discussion about it here:
https://electronics.stackexchange.c...n-inverting-input-low-cause-output-to-go-high

#### crutschow

Joined Mar 14, 2008
29,792
If I'm not mistaken I think you refer to what I know as a comparator op-amp.
A comparator is similar to an op amp, but it has no internal frequency operation, and is optimized for fast switching response.
Op amps can be used as comparators but tend to be slow due to the compensation.
if v+>v- then v_out =+Vcc
if v->v+ then v_out =-Vcc
But how can I use them? If I can only use one positive power supply channel, how will I get -Vcc for the op-amp?
Most comparators operate from a single-supply with -Vcc connected to ground.

So you use a voltage divider to get the various voltages where you want the comparator to change state.
One of the comparator inputs goes to this reference voltage, and the other input goes to the battery voltage.

#### dl324

Joined Mar 30, 2015
14,462
Thank you but I failed to mention that I can only use TL071 op-amp
You could use them as slow comparators, but the output voltage swing limitations could require you to jump through some hoops. Heavily loaded, the output will only swing to 5V from the rails. With a 12V supply, a worst case part would only give 5-7V. Input voltage range on a worst case part would also be a problem.

I find it difficult to believe that an instructor would handicap you like that.

#### Alec_t

Joined Sep 17, 2013
12,808
Can you please elaborate how to connect the virtual ground
This is the principle. In practice you would normally follow the virtual ground with a unity-gain buffer amplifier to provide a low impedance ground connection.

#### crutschow

Joined Mar 14, 2008
29,792
Okay, using a TL071 needs consideration of the input voltages versus the supply voltages to avoid any problems.

For measuring the 12V battery, use a minimum single supply voltage of >16V (needs to be at least 4V above the highest battery voltage to avoid input common-mode problems).
(You don't need to generate a virtual ground point).

Connect a 4 resistor voltage divider from the supply to generate the voltages (9V, 10V, & 11V) you want the LEDs to light.
One easy way to do that is to start with a bottom resistor of an arbitrary value (say 10kΩ), and calculate the current through that for the 9V point
Then you can calculate the resistor values for the other resistors, since you know the current through them and the amount of voltage they each must drop to get the desired divider voltages.

You then connect each of those divider voltages to the 3 op amps respectively.
Connect the other inputs to the battery voltage.

If the LEDs can operate on no more that about 6mA, you can correct them directly to the op amp output (with the appropriate series limiting resistor).

Last edited:

#### click_here

Joined Sep 22, 2020
541
Keep it simple - Can you make a simple comparitor circuit that lights an LED when the input is larger than 11V?

#### idosol

Joined Apr 28, 2022
6
Connect a 4 resistor voltage divider from the supply to generate the voltages (9V, 10V, & 11V) you want the LEDs to light.
One easy way to do that is to start with a bottom resistor of an arbitrary value (say 10kΩ), and calculate the current through that for the 9V point
Then you can calculate the resistor values for the other resistors, since you know the current through them and the amount of voltage they each must drop to get the desired divider voltages.
Thank you for the very informative replay, but in the end I didn't manage to get the reference voltage I wanted from the voltage divider. Do you perhaps know of some book or article I can read to better understand the concept of designing a voltage divider for specific reference voltages?

#### Ian0

Joined Aug 7, 2020
5,136
You need a voltage divider which outputs a given fraction of the input voltage.
Then you need a fixed voltage reference to which you are going to compare it.
Look up LM4040 for references.

#### dl324

Joined Mar 30, 2015
14,462
I didn't manage to get the reference voltage I wanted from the voltage divider
Show us a schematic of your circuit.

#### crutschow

Joined Mar 14, 2008
29,792
Do you perhaps know of some book or article I can read to better understand the concept of designing a voltage divider for specific reference voltages?
I explained how in the third paragraph of my post #13
What don't you understand about that?

Did you put the four resistors in series from the plus supply to ground?
Show us what you tried.

#### prairiemystic

Joined Jun 5, 2018
240
TL072 only? You still need a reference voltage, something to measure by.

In the better quality car LED volt gauges, they use zener+BJT stage per LED. It's not that accurate.
The TL431 cascade is pretty good, to make a window-comparator- one stage overrides the other. I've seen it built up to 3-4 LEDs.