Continue to Site

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.

  • 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.

Basic Comparator question

Status
Not open for further replies.

MusicTech

New Member
I am new to comparators and I just found this LM339N in my washing machine and decided to take it out because I wanted it. Now I want to learn about comparators, so I have a couple really basic questions after doing a little research:

1) when V+ is greater than V- and the output goes high, is the is the high voltage VSS?

2) Now, if ground is 0 volts, which it usually is, how would you get V+ below it to make the output go low?

3) Does low=ground voltage

Thanks
 
The LM339 quad comparator and most other conparators have the output just a collector of an NPN transistor to pull the output to ground as a low. It needs a resistor from the output to the positive supply to make the output go high when the output transistor turns off. This way, outputs can be added together as an AND gate.
 
Hi,

A comparator does exactly that...it compares two voltages and makes the
output go either high or low depending on what those two voltages were.

Calling the non inverting input V+ and the inverting input V-,
when V+ goes higher than V- the output goes high, and when V+ goes lower
than V- the output goes low. You can design lots of things just knowing
this.

There is a little bit more to it however, when you start to think about what
voltages the inputs can handle. Sometimes the input can handle voltages
near or even at ground (0v) and sometimes they cant. Similarly, sometimes
the inputs can handle voltages near Vcc, and sometimes they cant. These
usually depend on the specific device being used, ie the part number.
There are even some comparators that can handle a tiny bit negative on
their inputs even though they dont have a negative supply voltage.

Take the LM339 for example. The inputs you can use range from 0v (ground)
up to Vcc minus 1.5 volts. This means you can use 0v but you can not use
Vcc on the inputs if you expect the device to work as a comparator.

To answer your question about 0v and negative voltages, you can use
'negative' voltages (relative to ground) when you also use a negative supply
to power the device. In this case you have a positive supply voltage (like
+5v) and a negative supply voltage (like -5v) and now you call ground 0v,
which is between the two.
In the case where you only use a positive supply voltage (like +5v) and you
ground the minus power input to the device ground is still 0v but now it is not
possible to use a negative input because the min spec for the LM339 is 0v.
When we use the negative supply (such as -5v) then we can use a voltage
as low as -5v, but without a negative supply we can only go down to 0v.

To recap LM339 operation:

With a +5 and -5 power supply (0v=ground) we can use any voltage from
-5v up to +3.5v on the input for correct operation.
With a single +5v power supply (0v=ground) we can use any voltage from
0v up to +3.5v on the input for correct operation.

One other thing that has already been mentioned by others here is that for
the LM339 we have to connect a resistor from the output pin to the positive
supply voltage to get the device to work correctly. This value can be around
1k to 10k for decent operation.

When the output goes "Low", this means it goes close to the negative supply
voltage (-5v) or with no negative supply it goes down close to 0v.
When the output goes "High" this means the output goes to a rather high
resistance, which gets 'pulled' up by the output resistor talked about above
(1k to 10k roughly), and this means it goes just about up to the positive
supply voltage (+5v) with no load. With a load the output will not reach +5v
but will be somewhat lower depending on what the load resistance is. For
example, with a 10k pullup and a 10k load to ground the output will only go up
to +2.5v and that's it, but sometimes the output load goes to +5v and so
sometimes we dont need a pullup resistor. A small relay coil wired from the
output to +5v would still function normally because it does not need a pullup
resistor. On the other hand, a TTL gate load would need a pullup resistor to
get the switching time within reason.
 
Last edited:
This way, outputs can be added together as an AND gate.
You mean OR gate.

Also unless the rise time of the waveform is pretty fast a feedback resistor is normally required form the output to the non-inverting input to provide hysteresis.
 
You mean OR gate.

Also unless the rise time of the waveform is pretty fast a feedback resistor is normally required form the output to the non-inverting input to provide hysteresis.
With positive logic, it's an AND. If both outputs are off, the wired-AND goes high.
With negative logic, it's an OR. With either output is on, the wired-OR output goes low.
 
Last edited:
With positive logic, it's an AND. If both outputs are off, the wired-AND goes high.
With negative logic, it's an OR. With either output is on, the wired-OR output goes low.

Negative logic or not, you still have an AND gate. If both are on, the output is low. If one is on the output is low. Both must be off for the output to be high. Where would you use negative logic and why?
 
Where would you use negative logic and why?

Its usual to pull a line on a computer shared data bus, connected as an OR. to a low level.


**broken link removed**
 
Last edited:
How do you supply negative voltage, I mean you couldn't just wire it to the negative of a double and get negative 1.5 volts, could you? Isn't that 0v? Also, how would the resistor lower voltage? wouldn't it just decrease amperage?
 
Hi,

Well, one way to supply a negative voltage is to connect a battery plus (+)
terminal to ground and use that battery negative terminal (-) as the
negative voltage supply.
The positive supply would have it's battery negative to ground and use the
positive terminal as the positive power supply.
In this way you can create a plus and minus power supply with two batteries.
If you use two 9v batteries and two 9v battery clips you can make a quick
plus and minus 9v power supply, for limited current of course.

As for the other posts perhaps this might help...

A two input AND gate is a gate where when the two inputs are both 'TRUE'
the output goes to a TRUE also.
A two input OR gate is a gate where when either one of the inputs goes to
a TRUE the output goes TRUE also.

Note that by implication we can define these two another way also...

A two input AND gate is a gate where when either one of it's inputs goes
to a FALSE the output goes to FALSE (negative logic OR gate).
A two input OR gate is a gate where when both of its inputs goes to
a FALSE the output goes to a FALSE (negative logic AND gate).

A useful rule here is that when you invert all the inputs and outputs you
also have to invert the logical connective.

An example of a negative logic OR gate would be two switches wired in parallel
and one side wired to ground, with the other side wired to a relay and the other
side of the relay coil wired to some positive voltage like 12 volts.
When either switch is turned on, the relay turns on, hence an OR gate.
This might be used when two circuits might want to turn on a single relay,
and those two circuits might be used where two operators have the choice
to turn the relay on...either one can turn it on, so it's an 'OR' function.

On the other hand, we might use that very same circuit where we want
BOTH operators to have to agree to turn the relay OFF, so both operators
have to have their switches OPEN (logical AND).

Both circuits were exactly the same, yet the meaning behind using the
circuits in these two examples was different. That's negative and positive
logic for ya.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top