op amp as comparator basics?

well... I'm making this battery charger cum level indicator, which should turn off the battery supply when its voltage drops below 10V.
Im using an opamp as a comparator to do that. I have been scratching my head for 3 days but cant get this sorted.

From what I have been experiencing for years, on an op amp if the potential on the in+ pin is higher than that on the in- pin, then the output pin goes high, else low. Right? 
Now in this particular case (and the first time in my life) the ic gives 4.xx Volts on the output pin when in+ is higher than in- and 11.xx volts when in- is higher. Vcc is 12V. 
Im bugged... I have attached the part of the Schematic that shows the IC and its connections. Please have a look.

I haven't changed the IC yet, im doing that in a minute anyway. I'll mark this solved if the new IC does the trick. :)

Picture of op amp as comparator basics?
sort by: active | newest | oldest

I notice on the comparator that when it reaches the trigger point, it gradually changes the output voltage, which in my use is not terribly bad, but I would have preffered it to be either on or off (0V)... But for now its okay.. :)

Adding hysteresis can also speed up transitions, which is better for your output driver. If you aren't careful, you will burn out the output transistor, since it won't be driven into saturation quickly.

pro2xy (author)  steveastrouk4 years ago
There you go!

I was wondering about burning out the output MOSFET because of slow saturation, but I didn't think it would really be an issue. Now I know it is. :P

I added a 100k resistor b/w the output pin and '+in' pin on the opamp for hysteresis, and its done the job well..! :)
pro2xy (author)  steveastrouk4 years ago
Right! I'm google-ing it right now...
BTW, you only need one relay with two poles - unless you can only GET one pole relays !
pro2xy (author)  steveastrouk4 years ago
Thats what I had in hand... But Im thinking against relays, because the switching here is not immediate, there is a delay of atleast 1/4 of a second, more than enough to reset any circuit. :P
Yes, that can be an issue. You can get a faster switch than that - try whacking the relay coils with more volts, off a big fat capacitor, and then use a resistor to bleed the sustain current into the coil. If you can't get <<0.1 second then, I'll be surprised.

pro2xy (author)  steveastrouk4 years ago
I'll try that.. Thanks, I might as well add a big fat cap on the output as well. :P
pro2xy (author)  steveastrouk4 years ago
Thanks for the link, it gives a good insight into hysteresis.
Check the tolerance on your zener. They're usually at least 10% to 20% and they fluctuate a lot with temperature.
pro2xy (author)  piles.of.spam4 years ago
That must be true. I feel thats why I didn't get very accurate results. But changing the 10k to 1k brought the voltage to 3.36V which is fine for me. :)
pro2xy (author) 4 years ago
Hey! Changing the IC worked...

Now I would like to have some expert comments.. I am trying to build a battery backup for my bench. I want to make it an overkill, so that the battery only comes into action when power is out (i.e. it should not be in parallel with the power from the transformer and regulator)

I chose to put in relays to do the switching. I dont know if that was a good idea. On the other hand I put in 2 relays to separate both the terminals of the battery from the rest of the circuit (except the charger)

There is also a battery monitor that I made using an atmega8 and its ADC. Thats what that 'REF' pin is for (it goes into the ADC1). It shows the battery status on a 7 seg display and beeps when the battery voltage is too high or too low...

One more problem I did not mention earlier was that I am getting 3.56 V from my zener instead of 3.3....... Any clue why?
What's "V-" as opposed to "gnd" ?

The diode isn't biased on well enough, it needs probably a 1K resistor, not a 10.

There's no hysteresis on the comparator, so it will tend to oscillate horribly close to the trigger point.
pro2xy (author)  steveastrouk4 years ago
Hello, sorry. Just when I was about to write the reply to you last night I heard a loud bang and the electricity went off. The local transformer had caught fire :/

V - is the battery '-ve' terminal

I changed it to 1k and its better now (though the zener giving 3.36V but thats fine).

I notice on the comparator that when it reaches the trigger point, it gradually changes the output voltage, which in my use is not terribly bad, but I would have preffered it to be either on or off (0V)... But for now its okay.. :)

Sadly I can't rank you the best answer, cause its not an 'answer'! its a comment to an answer :/