Hi
I'm trying to use an LM339 Quad Op Amp as 4 comparators for making a light intensity sensor (LED,LDR pair). The problem is, if i bias the non-inverting input(reference) to half d Vcc, when i change the inverting input, the ouput gradually changes from 0 to Vcc/2, instead of abrupt change from 0 to Vcc. In fact I checked the voltage at the non-inverting reference: instead of remaining at Vcc/2 all the time, it changes linearly as the inverting input voltage is changed!! What's wrong??
This is using a pot and a potential divider, just to check the comparator operation...even this fails...(i've used both the configurations shown in the figure)
What is your VCC? Are you using an opamp or the LM339? If you are using an opamp in place of an LM339, chances are that your op-amp is not rail-to-rail, so its output will only pull up to about 2V less than VCC. It will pull down to near ground going the other way. Look up what "rail-to-rail output" means.
If you are using the LM339, do you have the pullup resistor on the output?
I know, and there was nothing wrong with it.
My comment was intended to keep the OP from being confused by your comment.
You gotta admit, though, that the "something" you are wanting to pull low generally has resistance (although it could be a capacitor or inductor). I guess your point was that it does not have to be a physical resistor, e.g., it might be a relay.
Ok. Thanks guys, it works now! Guess i had no idea of the function of pullup resistors.
Now with my trusty multimeter, i tried getting to understand why we need them. This is what i realized. Guys, please say if i'm right:
The op amp can only pull the output pin low. Otherwise its technically unconnected. So, to get the Vcc in the other state, we need to provide it through a pull up resistor. Am i going on the right track?
So, since i'm finally going to connect it to the input pins of my AVR MVU, would i need the pull up resistors, since the MCU has pull up resistors which can be enabled?
No. It does not have much output current because it is a low power IC.
The minimum output current is only 6mA when its saturation voltage loss is as high as 1.5V.
If its output current is only 4mA then its max saturation voltage loss is 0.4V at 25 degrees C.
Hey!! I'm having aproblem again! This time, when i use an LDR. I'm using an LDr an 10K resistor as voltage divider, and the voltage at LDR is put in invertinginput. Reference voltage is bing set wid a 22K pot. In this case, the output gradually changes from 0 to Vcc as the light falling on LDR is changed. But when not using an LDR it changes abruptly as it should. Please help...
The datasheet for the LM339 quad comparators and for the LM393 dual comparators explains that a small amount of hysteresis (positive feedback) should be added with a high value resistor from the output to the (+) input to cause a very abrupt snap action of the output when the inputs slowly pass the threshold voltage. The hysteresis also prevents oscillation at the threshold voltage.