# Voltage comparator

#### Misieek

Joined Mar 17, 2021
24
Hello guys!

I want to build some kind of voltage comparator, which will turn the P MOSFET transistor on (conduct), when the voltage drops below threshold voltage, given by the zener diode. I want to achieve small hysteresis, and fast response. The supply voltage is 12V.

I figured out something like this... but the hystheresis is around 0.5V which is too much, and sometimes the mosfet heats up.

What can I improve?

#### Papabravo

Joined Feb 24, 2006
15,431
Why not use an actual comparator?

#### Misieek

Joined Mar 17, 2021
24
Why not use an actual comparator?
Hmm, I think that to compare that voltage I would have to supply the comparator with higher voltage than I actually want to measure. That would force me to use boost step-up converter. That leads to reduction in simplicity, but I would do that if there is no simpler solution.

#### AlbertHall

Joined Jun 4, 2014
11,095
Your circuit has a 12V supply and a 15V zener. That zener will never conduct so the MOSFET will be always on.
I am confused. What is this circuit supposed to do?

#### Misieek

Joined Mar 17, 2021
24
Your circuit has a 12V supply and a 15V zener. That zener will never conduct so the MOSFET will be always on.
I am confused. What is this circuit supposed to do?
Yeah, you're right, that can be confusing. I want to use this circuit as a voltage reglator for car genrator. When mosfet conducts, the current flows through the rotor, increasing voltage in car instalation to 15V. When the voltage reaches that value, the mosfet cuts off the current, so the voltage drops down. This process occurs constantly, making car voltage remain around 15V.

#### BobTPH

Joined Jun 5, 2013
2,989
Hmm, I think that to compare that voltage I would have to supply the comparator with higher voltage than I actually want to measure.
No, you can divide down the input voltage and compare to a lower voltage. For example, two equal resistors to divide the voltage in half, then compare to 7.5V.

Bob

#### Misieek

Joined Mar 17, 2021
24
No, you can divide down the input voltage and compare to a lower voltage. For example, two equal resistors to divide the voltage in half, then compare to 7.5V.

Bob
Great idea @BobTPH ! I utilized LM358 and it compares voltage well. One more thing left to do. I don't know how to drive mosfet since the output voltage 15V would be too great for IRF4905's gate.

Can I divide it one more time using zener diode 4V, and 100k resistor? Wouldn't be that too much output current for LM358?

#### AlbertHall

Joined Jun 4, 2014
11,095
I don't know how to drive mosfet since the output voltage 15V would be too great for IRF4905's gate.
The maximum gate voltage for that MOSFET is 20V.

#### AnalogKid

Joined Aug 1, 2013
9,039
There is no hysteresis designed into the circuit in post #1. Because of that, the MOSFET does not "snap" on and off; it goes through a transition region between completely off and fully enhanced (lowest Rdson) slowly enough to heat up. Also, because the circuit is an open-loop linear amplifier, there is a value for Vcc where the FET is partially conducting, causing maximum power dissipation, and there is nothing in the design to prevent the circuit from staying at that operating point long enough for Q? to overheat. A large value positive feedback resistor from Q? to R? will add a small amount of hysteresis and should reduce Q? power dissipation.

ak

ps. Reference designators work only if they are unique.

#### crutschow

Joined Mar 14, 2008
26,721
I would use a stable reference voltage for the comparator, such as a TL431, instead of a Zener.
The 15V Zener has a positive temperature of about 10mV/°C whereas a lead-acid battery has a negative temperature coefficient of about -3mV/°C per cell, or -18mV/°C for a 12V battery.

For the most accurate charging you could add some junction diode in series with the TL431 to give the desired -18mV/°C change in the battery charging voltage with ambient temperature.
If you use 2.5V from the TL431 as a reference , then two diodes in series with that reference (giving a reference voltage of about 3.9V) should provide fairly good compensation (about -15mv/°C).
The diodes should be on or near the battery so they see the same temperature as the battery.

#### Misieek

Joined Mar 17, 2021
24
I would use a stable reference voltage for the comparator, such as a TL431, instead of a Zener.
Great idea, thank you. I will use TL431 in the final board.

But now... I made something like this. It is set to 15V.

It works pretty well, with 0.1V hystheresis, which is great, but only with 1k resistor load. When I connect 5W light bulb, the hysteresis is starting to become bigger, around 0.6V. What is the possible cause?

#### sghioto

Joined Dec 31, 2017
2,264
When I connect 5W light bulb, the hysteresis is starting to become bigger, around 0.6V. What is the possible cause?
The supply voltage is probably dropping with the heavier load. Change R4 to 10K.

#### Misieek

Joined Mar 17, 2021
24
Change R4 to 10K.
Didn't work for me :/ I supply and test the circuit with Korad KA3005D.

Edit: I measured the voltage of the power supply and it drops 0.6V when the light goes on. Lol I thought I have good power supply. Perhaps not...

#### sghioto

Joined Dec 31, 2017
2,264
Didn't work for me :/ I supply and test the circuit with Korad KA3005D.
10K is the usual value pullup resistor for a P channel mosfet.

#### AnalogKid

Joined Aug 1, 2013
9,039
Check the output voltage range of the 358. Q1 might not be turning completely off. Try changing R4 to 4.7K and adding another 4.7K between the bottom of R4 and pin 7.

ak

#### sghioto

Joined Dec 31, 2017
2,264
adding another 4.7K between the bottom of R4 and pin 7.
What's the purpose of that?

#### AnalogKid

Joined Aug 1, 2013
9,039
It divides the voltage difference between the opamp max output voltage and Vcc. This gets Vgs down below the FET's threshold voltage in the off state.

Example: Vcc = 16 V. The FET minimum threshold voltage is -2 V, or 14 V, but the LM358 minimum max output voltage is Vcc - 4 V, or 12 V. That is more than enough to wake up the FET. With a 2:1 divider, the worst case opamp output voltage equals the worst case FET threshold voltage for less than 1 mA drain current.

ak

Last edited:

#### crutschow

Joined Mar 14, 2008
26,721
A comparator such as an LM339 or LM393 may work better as their output is open-collector so the output resistor can pull up the voltage to equal the supply voltage and fully turn off the P-MOSFET.

#### Ian0

Joined Aug 7, 2020
1,540
Great idea, thank you. I will use TL431 in the final board.

But now... I made something like this. It is set to 15V.
View attachment 233111
It works pretty well, with 0.1V hystheresis, which is great, but only with 1k resistor load. When I connect 5W light bulb, the hysteresis is starting to become bigger, around 0.6V. What is the possible cause?
Use a reference such as a LM4040, you'll never get a zener to be accurate enough. The zener will only be accurate at 5mA current, and yours has <1mA. A reference IC will stay accurate down to 60uA.
Be careful using a LM358 to switch a P-channel MOSFET, its output is only guaranteed to get to Vcc-2, which means it may not be capable of turning off some low-Vgs(th) MOSFETS. LM393 might be a better choice or a comparator with push-pull outputs.  as @crutschow has just said
Then add a high-value resistor from pin 7 to pin 5 to give a known and repeatable amount of hysteresis.

Last edited: