 # Open-Collector Comparator Output

Hi there,

I ham testing an MIC6270 open-collector comparator but one thing is bewildering me. I am making the following connections:

• V- to GND
• V+ to 12V
• IN+ to GND
• IN- either floating or 5V
• A 20k pullup resistor from OUT to 12V to make the output normally HIGH/12V

What I expected this comparator to do is output 0V when IN- is floating (which it actually does), and then when IN- is connected to 5V (or anything significantly greater than 0V) then the output of the comparator should float and the pullup would pull it high to 12V. However, when I connect IN- to 5V the output still goes to 0V! Since IN- is greater than IN+, shouldn't the comparator output be open because the differential condition is not met?

Thanks!

However, when I connect IN- to 5V the output still goes to 0V!

Translated: “VIN < Vref, Vout = -Vcc” (Exactly as expected)

Since IN- is greater than IN+

Translation:"VIN < Vref, Vout = -Vcc " (Exactly as expected)

shouldn’t the comparator output be open because the differential condition is not met?

The “Differential condition” as you put it is in fact VIN+ is VIN , and VIN- is Vref,
therefore,
as shown in the tutorial, a comparator obeys the following:

If VIN > Vref, Vout = +Vcc (device OFF)
If VIN < Vref, Vout = -Vcc (device ON)

Under NO condition should any part of this circuit be “floating” , since the definition of “floating”
is “NOT CONNECTED”

An open collector output such as this comparator must be pulled up by a resistor, which means
when the output = -Vcc, that means the transistors inside are ON, creating a direct short to -Vcc.
When the output = +Vcc, that means the internal transistors are OFF, and the voltage is pulled
up to +Vcc.

You need to think of it as a switch.
When the switch is ON, the resistor is pulled DOWN to -Vcc.
When the switch is OFF, the resistor is pulled UP to +Vcc.
The truth table for the switch is as follows:

If VIN > Vref, Vout = +Vcc (SWITCH OFF)

If VIN < Vref, Vout = -Vcc (SWITCH ON)

Capish ?

For a push-pull comparator it’s very straightforward:

• IN+ > IN- then OUT = V+
• IN+ < IN- then OUT = V-

so for this open-collector comparator isn’t it just like this?

• IN+ > IN- then OUT = V- (active low?)
• IN+ < IN- then OUT = open/floating

An open collector output does not mean that anything is floating. It means that the device does not have a load resistor connected to the output collector device. There is no active or passive pull-up. You added a passive pull-up resistor so when the open collector device is off your resistor pulls the output up.

What I expected this comparator to do is output 0V when IN- is floating (which it actually does),

I'm not saying you're wrong, but where did you find that documented? I searched the datasheet for "floating" and didn't find it. Usually an open input (floating) on a comparator is undefined and just picking-up noise.

IN+ to GND

Then ground is your reference and you have an inverting comparator.

With the (-) input greater than the ground reference (any positive voltage) the output should be low.

With the (-) input less than the ground reference (any negative voltage) the output should be high (pulled-up to 12V by the resistor).

...With a ground reference you need a negative voltage to insure an output-high.

Pause and think. Look at what the comparator is supposed to do.

If In- is lower than In+, the output transistor is off -> 12v (in your case).
If In- is higher than In+, the output transistor is on -> 0v

If In+ is connected to ground, In- will never be lower than In+ (unless you are putting a negative voltage on it, but per datasheet this is outside of spec and isn't expected to output sensible results) - the lowest it could be is equal to In+, in which case you might see noise on the output (depends how that case is handled by the comparator you're using).

I mean, think about it - a comparator compares voltages. When you are not changing which voltage is higher, why would you expect it to do something?

Instead of connecting In+ to Gnd, you want to connect it to something between 5v and Gnd. Maybe make a divider with 15k and 4.7k resistor to get ~3v? And put a pulldown on In- so it's in a defined state when not connected to 5v. If the behavior is the opposite of what you want, swap In+ and In-

Oh - and make sure the 5v device's ground is connected to ground of the comparator - voltage is only meaningful as compared to a reference (normally ground).

Thanks, what you said about the V+ never being greater than IN- makes sense now, I should have thought about that.

So you guys are basically saying that all I have to do is swap IN- and IN+ to achieve the desired logic? (Basically, tie IN- to GND and IN+ to 5V?) I was basically thinking backwards...

So if I connect IN- to GND and IN+ to 5V (or floating if not there), then the output will be 0V when IN+ is floating, and 12V when IN+ is 5V?

Now the reason the comparator outputs zero is (I think) because the input differential does not exceed the offset voltage specified in the datasheet and therefore the output saturates at its active state (0V). Now the interesting thing is I tested a push-pull comparator and it output 12V when the input was floating and IN- was at GND. If the general logic of this comparator is the same as normal ones (except that it's open collector instead of pushing to the rails), why would this one go to 0V instead of 12V?

So you guys are basically saying that all I have to do is swap IN- and IN+ to achieve the desired logic? (Basically, tie IN- to GND and IN+ to 5V?) I was basically thinking backwards…

Not necessarily, I can’t speak for the others but what I am saying is that what you need to do FIRST
before ANYTHING else, is understand that VIN+ IS the VIN, and VIN- = the Vref (as in REFERENCE)

therefore "
Given that:
If VIN > Vref, Vout = +Vcc (device OFF)

If VIN < Vref, Vout = -Vcc (device ON)

And as already mentioned by someone else. You don’t need to us only +V and 0V.
The standard application for a comparator is comparing an input voltage to a reference voltage,
so the reference is a a precision voltage reference or a pot connected between 0V and 5V, and the
input voltage is connected to the output of some circuit, like a light sensor or some other analog
sensor, although it could simply be a voltage divider across the power supply used to generate
a "Low Supply Voltage " error signal for a microcontroller.

then the output will be 0V when IN+ is floating,

You still don’t get it.

Nothing can be allowed to “float”. period.
"Floating " means “NOT CONNECTED”.

When you stop using the word “floating” , then we can move on, and not until then.

Please post the rest of your circuit , explaining why you are using a comparator, since
nothing you are saying is making any sense.

OK sorry, I was under the impression that it behaves a certain way when inputs are not connected. So how about this:

• Pulldown resistor on IN+ to GND, but IN+ could also be tied to 5V when it's there (say you had a USB that could be there or something)
• IN- to GND
• V- to GND, V+ to 12V
• Pull-up on the output

When 5V is absent the output will be 0V, and when 5V is present we get 12V, correct?

The reason I didn't think this was going to work at first is because the push pull comparator I tried before saturated at 12V instead of 0V when the inputs were tied together. I guess since this is open collector that makes all the difference?

Pulldown resistor on IN+ to GND, but IN+ could also be tied to 5V when it’s there (say you had a USB that could be there or something)
IN- to GND
V- to GND, V+ to 12V
Pull-up on the output

When 5V is absent the output will be 0V, and when 5V is present we get 12V, correct?

Keep in mind you do NOT want VIN+ AND VIN- BOTH connected to GND because then all you will have
is an oscillating output as the two inputs drift above and below each other.

Everything you have said so far will not work because of that.
You are NOT preventing VIN+ from being = to VIN-. That is a disaster waiting to happen.
Either VIN+ > VIN- (Vref)
or
VIN+ < VIN- (Vref)

UNDER NO CIRCUMSTANCES CAN YOU ALLOW THEM TO BE EQUAL ! (as in both 0v OR both +5V)
Do you understand that ?

You must modify your circuit such that it prevents that from occurring.

All of the hypotheticals you have presented thus far allow them to be equal at some point in time.
That will not work.
Either change your circuit or give up the idea of using a comparator , period.

Sorry, but what's the basis for saying that both inputs can't be tied together? Actually the offset voltage specified in the datasheet prevents it from oscillating, (hysteresis) so I don't think that's an issue.

Actually the offset voltage specified in the datasheet prevents it from oscillating,

The whole point is that one pin should have a voltage greater or less than the other pin, not equal to it. If you are only interested in 0 and 5V, why are you even using an analog comparator instead of TTL logic AND or NAND gates , which incidently just happened to be designed for equal voltages on both inputs ?

As explained in the following link, the meaning of input offset voltage , is that there is a tolerance for the pin such that if one pin is at 1.000 V and the other is at 1.0025 volts, it can not be known in advance
how the device will react to such a small deviation between the two inputs because the offset could be
positive or negative. When you read all the replies to this the question asked in this link, they all confirm
what I told you that when both input pins are close enough to equal, the two pins drift in both directions
resulting in oscillations.

What happens when both inputs of a comparator are equal ?

In short, you don't know what will happen within the input offset voltage
band, and need to design your circuit accordingly.

To prevent this output oscillation, a small hysteresis of a few millivolts is integrated into many modern comparators. For example, the LTC6702, MAX9021 and MAX9031 have internal hysteresis desensitizing them from input noise. In place of one switching point, hysteresis introduces two: one for rising voltages, and one for falling voltages. The difference between the higher-level trip value (VTRIP+) and the lower-level trip value (VTRIP-) equals the hysteresis voltage (VHYST).

While this is true, when you connect 0V (or +12V) to both inputs, it is not the same as actually shorting the two pins together with a wire, since small deviations in the input signals can lead one or the other input to exceed the hysteresis deadband, causing the device to switch, and then a millisecond later it might drift the other direction and switch the opposite way, resulting in oscillations.
If you're lucky it switches one way and stays that way but no formula is going to predict which way
it will switch when both inputs are equal. That's why I said you need to prevent that or abandon the
idea of using a comparator. You need to prevent the two inputs from being equal for more than a
millisecond.

androidfanboy:
(say you had a USB that could be there or something)

If that's your intended application, could you skip the comparator and just use a transistor or optocoupler to detect the 5V signal?

In short , this is what you still have not grasped:

The Op-amp comparator compares one analogue voltage level with another analogue voltage level, or some preset reference voltage, VREF and produces an output signal based on this voltage comparison. In other words, the op-amp voltage comparator compares the magnitudes of two voltage inputs and determines which is the largest of the two.

You are trying to use a comparator to determine when two signals are the SAME, which , obviously,
is EXACTLY opposite of what the device was designed for.

What I'm trying to do is switch between 5V and 12V sources but giving preference to the 5V source (so when both are present it picks 5V). When 5V is present, it powers the circuit through a Schottky diode, and when 12V comes into play the comparator and pullup resistor give a logic HIGH on a P-channel MOSFET to keep the 12V switched off. When 5V disappears, however, the comparator will output LOW to the MOSFET and switch the 12V into the circuit. The Schottky diode isolates the 5V and 12V sources and allows me to tap into the 5V only when it's there.

Anyway, after some testing with the comparator I finally came up with a circuit that will work and it's quite simple (2 resistors, 1 comparator, 1 MOSFET, 1 diode). Here's my comparator setup:

• IN+ has a pulldown resistor to GND
• IN- is tied to 3.3V (which is outputted whenever there's either 5V or 12V in the system)

When only 5V is present, the comparator compares 5V (IN+) with 3.3V (IN-) and sets the MOSFET to HIGH to shut off the 12V (not like it matters) and the same goes when 12V is present along with 5V. Then when only 12V is present, the comparator compares GND (IN+) with 3.3V (IN-) and voila, the MOSFET is switched LOW. The only thing about this is when the 12V hasn't even made it through to power the 3.3V regulator, but I tested when IN- is floating and IN+ is GND and it also produces 0V so we're good there, and we're probably talking micro-seconds anyway.

That being said, I'd still be interested in hearing about the logic gates if that could be any more robust or simple than what I have now. Post a truth table that shows possible inputs and desired output for said inputs.