Figure comperator out LM339

Hello im trying for days to get a comperator to working im using the LM339 that has a Open Collector at the output.
So i built up exactly this circuit

It is working fine when i build it up like this, the output switches to 5V when VIN is over 2,5V but now we get to my problem. So now i want the output switching to 5V when VIN is over 4V. As i understood all i have to do is change the R5 to 39kOhm so that way VREF is 4V ? I did that way but then i have recieved litteraly nothing at the output by changing 1 resistor? ( recieved like a really low signal at like 50mV)

Really would enjoy if anyone could help me out.. thanks

When you measure it with a voltmeter, is your Vref 4 volts?

Your issue is the common mode voltage of the LM339 is Vs - 1.5 V.

This means both the + and - inputs cannot go above 3.5V when powered with 5V.

This is a very old part. I'm sure there are newer comparators available that are designed for 5V operation (with a larger common mode voltage). I don't know any off hand but perhaps digikey website can help.

Hello im trying for days to get a comperator to working im using the LM339

Then why does the diagram say it uses a LM393?

An LM339/393 is still a good comparator for this.

I like using the inverting 339 comparator circuit.

Your R1 should be close to the parallel value R4 and R5.

You may have to tune the hysteresis.

With Vcc = 5V
“ change the R5 to 39kOhm so that way VREF is 4V ?”
39k is reasonable.

Show us your wiring with the 39k

Try 3.5v as mentioned.

.

As stated in reply #2, the LM339 comparator WILL NOT WORK with 4V on the inputs, if powered by 5V.

Use a 9V power supply for the comparator instead of 5V.

The LM393 might work in this case with 5V, as the common mode input voltage is guaranteed to be (Vcc - 1) V maximum. But neither are good for your project.

JohnRob:
Your issue is the common mode voltage of the LM339 is Vs - 1.5 V.

This means both the + and - inputs cannot go above 3.5V when powered with 5V.

This is a very old part. I'm sure there are newer comparators available that are designed for 5V operation (with a larger common mode voltage). I don't know any off hand but perhaps digikey website can help.

Okey so summed up my VREF cant go higher then 3.5V ?

Grumpy_Mike:
Then why does the diagram say it uses a LM393?

I guess LM393 and LM339 are the same comperators only difference LM339 has 4 of them integrated

larryd:
An LM339/393 is still a good comparator for this.

I like using the inverting 339 comparator circuit.

Your R1 should be close to the parallel value R4 and R5.

You may have to tune the hysteresis.

With Vcc = 5V
“ change the R5 to 39kOhm so that way VREF is 4V ?”
39k is reasonable.

Show us your wiring with the 39k

Try 3.5v as mentioned.

.

As im doing this in school i will try tommorow chaning VREF to about 3.5V and afterward make a picture if it still doenst work. But finally I got an clue what it could be thanks to you guys.

jremington:
As stated in reply #2, the LM339 comparator WILL NOT WORK with 4V on the inputs, if powered by 5V.

Use a 9V power supply for the comparator instead of 5V.

So if use then a 9V Power Supply will the output will jump onto 9V? or am i wrong?

//EDIT: And yea i measured VREF 4V are on it
One more question where can i find Vs= 1.5 V in datasheet so if needed i can look for a different comperator? What is it normaly named? Cause in the LM393 or LM339 Datasheets i cant really find it

I guess LM393 and LM339 are the same comperators

They are similar, but not the same. Read the data sheets.

So if use then a 9V Power Supply will the output will jump onto 9V?

Not if your pullup resistor is to 5V. An important purpose of an open collector output is to let you choose the output voltage when the output is OFF.

If 5v is needed.

If you use Vcc=9v, connect your pullup from the output to a 5v level/powersupply.

Since the O/P is open collector, it will go between 0v to 5v.

.

jremington:
They most certainly are not the same. Read the data sheets.
Not if your pullup resistor is to 5V. An important purpose of an open collector output is to let you choose the output voltage when the output is OFF.

larryd:
If 5v is needed.

If you use Vcc=9v, connect your pullup from the output to a 5v level/powersupply.

Since the O/P is open collector, it will go between 0v to 5v.

.

I will defintely look again in the datasheets and i wanna really thank you guys helped me really out understanding it more !! Thanks

For a regular comparator you don't need R1 & R2. These add [u]hysteresis[/u]… When the output is low, the input will have to be slightly above the reference before it switches to high, and when the output is high the input will have to be slightly-below the reference before it switches back to low.

To detect 4V with a non-rail-to-rail comparator, put a voltage divider on your input.
(add a resistor of about 17k from pin3 to gnd.)

Small comment about your schematic drawing.

In general it is best to not make cross connections (like R4, R3, Pin 8 and VCC). It is real easy for someone to miss the dot and not see they are connected.

If you simply offset the line from R3 or R4 you would reduce the chance of error.

I understand this is a very simple diagram and likely not an issue but as the diagrams get more complex it is a good practice.

Recovery:
Hello im trying for days to get a comperator to working im using the LM339 that has a Open Collector at the output.
So i built up exactly this circuit

It is working fine when i build it up like this, the output switches to 5V when VIN is over 2,5V but now we get to my problem. So now i want the output switching to 5V when VIN is over 4V. As i understood all i have to do is change the R5 to 39kOhm so that way VREF is 4V ? I did that way but then i have recieved litteraly nothing at the output by changing 1 resistor? ( recieved like a really low signal at like 50mV)

Really would enjoy if anyone could help me out.. thanks

That comparator input voltage range doesn't go all the way to the +5V rail. The datasheet indicates it
will work upto Vcc - 1.5V at 25 degC, Vcc - 2V over the full temperature range.

A quick search on Farnell's website revealed the MCP6564 quad-comparator, different pinout to
LM339, and SOIC only, but fast, rail-to-rail, low power, push-pull output, 1.8V to 5.5V operation

A point about the circuit - with comparators driving a microcontroller you always have the choice of
whether to route the input to the inverting or non-inverting pin (as you can invert the sense of the
output digital signal in software).

If you route the input to the inverting pin, then any hysteresis components go on the reference
network and don't affect the input impedance of the circuit, ie allow the input to be high impedance.