Op Amp Comparator Battery Charger Indicator - Page 1
Forum section: electronics / beginners

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: May 02, 2014, 12:02:55 pm
content: Hello recently i saw Daves video about op amps and the thing that they can also be used as comparators intrigued me.So i created a schematic using one as a comparator but it does not work when i tried it on the breadboard.Look at a picture of the schematic.

author: yashrk
author_rank: Frequent Contributor
timestamp: May 02, 2014, 12:41:03 pm
content: I dont think you need those couple of 100R resistor instead you should calculate the current going to transistor base with respect to its gain and then add a resistor on the base if needed. I guess in your case there not enough current to drive the led

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: May 02, 2014, 12:57:55 pm
content: I need the resistors so the non inverting input of the op amp has 1.1 v (batteries charge to 1.2 so when they are charged the output voltage triggers the transistor).Because its an open loop configuration the output voltage and current wont have a problem driving the led

author: madshaman
author_rank: Frequent Contributor
timestamp: May 02, 2014, 01:51:47 pm
content: Is it by any chance a blue LED?

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: May 02, 2014, 03:03:04 pm
content: No used a red low power one .

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: May 02, 2014, 03:06:54 pm
content: Update : i connected the inverting input to ground and the led came on.But it should light up when the inverting input goes high (1.2 volts or more )....

author: Galaxyrise
author_rank: Frequent Contributor
timestamp: May 02, 2014, 03:31:53 pm
content: Opamps raise their output voltage when IN- isless thanIN+. So as you have it wired now, the LED should come on when the battery voltage is lower than your divider voltage, which is consistent with coming on when you attach IN- to ground. If you want a "battery ok" light instead of a "battery low" light, then swap the inputs to the opamp.I'm also curious why you have that parallel bunch of resistors coming off the voltage divider. I don't see how that helps get 1.1V at IN+; there's not going to be any current through them except the bias current for the opamp.

author: rdl
author_rank: Super Contributor
timestamp: May 02, 2014, 04:28:40 pm
content: The two 100R resistors aren't doing anything. To get 1.1 volts on the op amp input your divider resistors need to be in the ratio of 3.545 : 1You'll probably have to use a trimmer (or multiple individual resistors in series) because two standard value resistors probably won't get you close enough.

author: madshaman
author_rank: Frequent Contributor
timestamp: May 02, 2014, 05:14:02 pm
content: Can you post a picture of your circuit please?

author: Fank1
author_rank: Regular Contributor
timestamp: May 02, 2014, 09:53:19 pm
content: I suspect your circuit is OK.But I also suspect you are floating the (-) side of the op amp when you tested it.Tie the (-) side down to ground with a 10K or so resistor and try it again.Op amps don't like unconnected pins.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: May 02, 2014, 10:09:15 pm
content: First of all thank you all for your responses.Ill try to figure out what the resistor values need to be so i get 1.1 v out(i still have not figured out exactly how to calculate the voltage drop across a resistor i saw many tutorials online but i am still quite confused.I know the basic ohms law I=V/R but i do not know how to use it to calculate the drop )Also the inverting input is connected with a 100k ohm resistor to ground.I thought that this low voltage will stimulate the 2 charging batteries.(because i want the op amp to output 5 volts when the inverting input voltage is over the non inverting)The op amp i use is a double op amp (LM358)i have the other pins disconnected but i dont think that interferes with the op amp im using.

author: AG6QR
author_rank: Frequent Contributor
timestamp: May 02, 2014, 10:34:18 pm
content: Comments on the circuit as hand-drawn in the original posting:1. You have no current limit on the LED, nor on the base-emitter diode of your drive transistor. Remember that the op-amp output is a relatively low-impedance voltage output, so when it is high, it is able to source fairly high currents (see the data sheet for details). The output of the op-amp is connected through the base-emitter diode to the LED. You have a resistor on the collector of your drive transistor, but nothing to limit the current going from op-amp to base to emitter to LED. You don't say what kind of op amp you're using -- maybe the output won't mind this, but maybe it will. A suitable resistor between the op amp output and the transistor base will make sure you don't stress the op amp output, and will help you avoid blowing out the LED or drive transistor.2. Remember one of the basic rules of op-amps, no current goes in our out of the inputs (this isn't strictly true, but it's a close approximation to the truth). So your two paralleled resistors on the + input have no current going through them, thus no voltage across them, so they're not doing anything useful. You can replace them with a wire directly connecting the voltage divider to the + input, without changing the behavior of your circuit significantly. Others have pointed this out.I see in your latest post you say you've connected the inverting input to ground through a resistor, but again, there's no reason for the resistor, since no significant current will flow through it, so no voltage will appear across it. If you connect the inverting input to ground, then the output of the op amp will be high any time the non-inverting input has any voltage above ground. Is that what you want?3. As has been pointed out, you've drawn it so that it will light up when the battery voltage is less than the output of the voltage divider. If you want it to light up when the battery is high instead of low, then swap the + and - inputs.4. Dave said it was possible to use an op amp as a comparator, but he didn't claim it was a great idea. Some op amps aren't necessarily designed to work well when the inputs are at radically different voltages and the output is being driven hard to one end or the other.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: May 03, 2014, 09:33:42 pm
content: Thanks for your answer.1) I do not think i need a resistor because i supply the circuit with an ATMEGAdoes that mess up the circuit function ?2) Right and now i know the ration of the resistors thank you for thati removed them2) ii) yes thats what i want!! and i tried experimenting with it (changing the (-) and (+) inputs.4) i just wanted something fast because i could not wait for a comparator chip to arrive.I dont know what comparator to get that fits my needs but ill search a bit and find outAnyway its working now but i dont know why the led light up dimmer that usually.....

author: madshaman
author_rank: Frequent Contributor
timestamp: May 04, 2014, 07:41:25 pm
content: Hi ChrisGreece52.The next step you need after learning V = IR, Ohm's law, is to learn Kirchhoff's voltage and current laws.Those will help you calculate things like voltage drops, in fact they will let you calculate any current through or voltage across a device.You should also learn the golden rules for opamps.Also, the reason I asked for a picture of the actual circuit is that sometimes a circuit won't match the schematic and troubleshooting becomes confusing.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: May 04, 2014, 09:02:31 pm
content: Thanks for your advice i double checked the connections everything is fine :-) also as for the basics do you need any article or website to read and learn? I hate being a noobSent from my C5303 using Tapatalk

author: madshaman
author_rank: Frequent Contributor
timestamp: May 06, 2014, 01:16:42 pm
content: Google MIT open courseware.Find the EE courses; there should be a basic circuit theory-like one. You can watch all the videos as if you were attending MIT.Pretty nice of them huh?(There are also many other online learning resources, google and wikipedia are your friends)

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: May 06, 2014, 01:23:55 pm
content: Did not know about that :-) thank you I'll start right nowSent from my C5303 using Tapatalk