• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

LM339 as comparators

Status
Not open for further replies.

apakhira

New Member
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??

Thanks guys.
 

apakhira

New Member



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)

Ignore the prvous post please...
 
Last edited:

MikeMl

Well-Known Member
Most Helpful Member
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?
 
Last edited:

apakhira

New Member
My Vcc is 5V. And im using the LM339. I haven't used the pullup resistor. Will i need that if i pull an LED to ground??
 

QuietMan

Member
Pullup resistors are manditory with the LM339. Check the datasheet.
 

indulis

New Member
No, pull-up resistors are not mandatory in all applications.

If the circuit just needs to pull "something low", you don't need one.
 

Roff

Well-Known Member
No, pull-up resistors are not mandatory in all applications.

If the circuit just needs to pull "something low", you don't need one.
In his test circuit, they are mandatory if he actually wants to see the output change state.
 

Roff

Well-Known Member
I was responding to QuietMan's post, not commenting on the test circuit.
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.
 
Last edited:

apakhira

New Member
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?
 
Last edited:

kinarfi

Well-Known Member
The way I saw it when I first looked at the spec sheet was that it is a sink to ground (low), but notice, it is limited to 20ma current.
Kinarfi
 

Roff

Well-Known Member
The way I saw it when I first looked at the spec sheet was that it is a sink to ground (low), but notice, it is limited to 20ma current.
Kinarfi
Worst case sink current is 6mA, and that is with Vout=1.5V. I generally use 5mA as max sink current.
 

audioguru

Well-Known Member
Most Helpful Member
The way I saw it when I first looked at the spec sheet was that it is a sink to ground (low), but notice, it is limited to 20ma current.
Kinarfi
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.

EDIT: Correction
 
Last edited:

apakhira

New Member
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...
 

audioguru

Well-Known Member
Most Helpful Member
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.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top