Comparator open collector output

Thread Starter

strantor

Joined Oct 3, 2010
6,338
I'm doing a circuit, I was helped by wayneh to figure it out. It works in SIM, but I don't understand how or why. I have 2 comparators configured in a OR, according to LM393 datasheet.

Now, this confuses me. I understand that *what supposedly happens* is that if either comparator goes high, the output goes high. The way I see it though, these comparator outputs are open collector, so with the pullup resistor, the output should be high if both comparators are low. If one of them goes high, it will sink the current and the output will go low. I know I'm wrong, but I have no clue why I'm wrong. can someone set me straight?

What confuses me further is that this actually functions as an AND gate in my sim. When both of my comparators are high, the output is high. When I send one of my comparators low, the output is low. WTH?
 

Attachments

Audioguru

Joined Dec 20, 2007
11,248
When both outputs are high then they are turned off and the pullup resistor provides a high.
When one output is high then it is turned off and does nothing. Then if the other output goes low it makes the output low. Why do you think the output will be high?

The two comparators together form an AND gate. The output is high only when both output are high.
 

MrChips

Joined Oct 2, 2009
27,691
This is also called a WIRED-OR circuit.
This may sound confusing. That is because party-line bus systems are implemented using NEGATIVE LOGIC.

Consider an INTERRUPT line on an MCU. This is usually implemented as IRQ'
(IRQ inverted). (I would normally show this as IRQ overstrike, but don't see how to do this).

This means that IRQ' line has to go LOW to request an interrupt.
You can put multiple devices on the IRQ' line such as two or more comparators as in your example.

Any one of the comparators can pull the IRQ' line LOW to trigger an interrupt.
Hence it is an OR function for NEGATIVE LOGIC signals.

(If you look at DeMorgan's equivalent circuits, an OR gate with negated inputs and output is equivalent to an AND gate.)
 

Bernard

Joined Aug 7, 2008
5,784
Comparators can be configured as inverting or non inverting, so with inverting the ckt is a NOR gate, with non inverting ckt is a AND gate.
 

crutschow

Joined Mar 14, 2008
31,128
......................

Now, this confuses me. I understand that *what supposedly happens* is that if either comparator goes high, the output goes high. The way I see it though, these comparator outputs are open collector, so with the pullup resistor, the output should be high if both comparators are low. If one of them goes high, it will sink the current and the output will go low. I know I'm wrong, but I have no clue why I'm wrong. can someone set me straight?

...........
You are just confused about the definition. When the output of the comparator is "high" (plus input voltage higher than the negative input voltage), the output transistor is off, not on, and thus the output voltages goes to a high voltage from the pullup resistor.
 

Thread Starter

strantor

Joined Oct 3, 2010
6,338
When both outputs are high then they are turned off and the pullup resistor provides a high.
When one output is high then it is turned off and does nothing. Then if the other output goes low it makes the output low. Why do you think the output will be high?

The two comparators together form an AND gate. The output is high only when both output are high.
ok that makes sense, and that's what I observe. When it's high, the output transistor is off.
But, that's not what I read here:
The comparator output satisfies the following rules:
  • When V+ is larger than V- the output bit is 1.
  • When V+ is smaller than V- the output bit is 0
........
  • When the output of the comparator is a 1, current flows from the comparator through the base of the transistor, out the emitter to ground, as shown.
  • When that current flows, the transistor acts like a switch that permits current to flow from the collect to the emitter to ground.

In my circuit, the voltage on the + terminal is 6V. The voltage on the - terminal is 156mV. With these 2 voltage inputs, according to the quoted piece (as I interpret it) both of my comparator output transistors should be conducting (LOW output from the wired-OR gate).

If I'm not mistaken, theres a disparity between what that page says and what you guys are saying. I totally agree with you though, because that's what I saw. Is there some scenario where what the page says is correct?
 

MrChips

Joined Oct 2, 2009
27,691
It depends on if that transistor is part of the comparator or external to the comparator.
A single common emitter transistor stage acts as a logic inverter.
 

Jony130

Joined Feb 17, 2009
5,435
I think that in the article they treat transistor as a part of the comparator.
So I don't see any error in the article.
 

MrChips

Joined Oct 2, 2009
27,691
Just the opposite.

If you define a comparator as HIGH OUTPUT when V+ exceeds V-
then the transistor is outside of the comparator.

In either case, there is nothing wrong with the article.
 

wayneh

Joined Sep 9, 2010
17,189
The article you found about comparators is completely WRONG!
+1
Misleading may be the better term. It specifically mentions using an LM339 quad and appears to show an external transistor, although the text refers to it as internal. But it makes zero mention of using a pull-up resistor, and that's simply wrong, since this is the most frequent boo-boo when using this chip.

The text also describes current flowing when the + input is higher than the - input. Wrong. Current flows when output goes low, not high.
 
Last edited:

crutschow

Joined Mar 14, 2008
31,128
My understanding, after reading the article, is that the transistor they are referring to is part of the comparator output and, in that case, they have the polarity of input to output wrong.
 

Audioguru

Joined Dec 20, 2007
11,248
My understanding, after reading the article, is that the transistor they are referring to is part of the comparator output and, in that case, they have the polarity of input to output wrong.
I agree. They are stupid to claim that the transistor is separate from the comparator when actually it is built in.
I think they are just trying to confuse the nOObs.
 

Audioguru

Joined Dec 20, 2007
11,248
My understanding, after reading the article, is that the transistor they are referring to is part of the comparator output and, in that case, they have the polarity of input to output wrong.
I agree. They are stupid to claim that the transistor is separate from the comparator when actually it is built in.
I think they are just trying to confuse the nOObs.
Maybe they are confused nOObs.
 
Top