2
\$\begingroup\$

I was designing a PCB and had to include some kind of analogue signal peak detector, so I used comparator to get +3.3V when signal is above 2V and 0 when signal is bellow 2 V. I chose AP331AWG comparator (https://www.diodes.com/assets/Datasheets/AP331A.pdf). This is the schematic I used: enter image description here

And after assemble, I tested this part of PCB and comparator output was never changing the voltage level no matter what signal came to IN+, I have tried shorting it to GND, very low signal and nothing triggered it, it always had same voltage level, but after inspecting datasheet some more I have found this reference design:

enter image description here

It suggests using pullup, but I don't understand why, maybe can someone help me to understand why it is required? I will add block diagram of this IC, maybe someone can tell me how the circuit works :

enter image description here

After soldiering additional pullup it worked normally, signal was high all the time, but it fell to 0 when IN+ was bellow 2 V. Before designing PCB I saw that reference design uses pullup, but I thought it was unnecessary and skipped it, because I simulated this circuit on LTspice using opamp and it worked without pullup, now I see that it is crucial for correct operation.

\$\endgroup\$

3 Answers 3

5
\$\begingroup\$

In the block diagram of the internal circuit, notice that when transistor Q5 conducts, OUTPUT is connected to ground. But if Q5 does not conduct, then OUTPUT is not connected to anything, leaving its voltage level indeterminate.

By connecting OUTPUT via a resistor to a voltage source, it now always is connected to something, and the only question is which connection determines OUTPUT's voltage. With the addition of the pull-up resistor, when Q5 does not conduct there is a zero-current connection between OUTPUT and the connected voltage source, causing OUTPUT to have the same voltage as the source. When Q5 does conduct, OUTPUT once again is connected to ground, even though some current flows through the pull-up resistor. (To keep the heat dissipation in the resistor low, you would pick a high resistance. 1 kΩ or 10 kΩ are common choices for a pull-up resistor.)

It is very common for integrated circuits to be designed to require the use of a pull-up resistor. Doing this permits multiple devices of this kind to be connected to the same signal (OUTPUT in this case) while using just a single pull-up resistor. The effect is that any one of the integrated circuits can pull OUTPUT low. The only way for OUTPUT to be high then is for all the integrated circuits to agree that it should be high. This is often called a wired-AND: the output is high only if all inputs are high.

In computers, a common use of this approach is to permit any one of a number of devices to pull a line low to signal an interrupt. Of course, then the computer still has to determine which device did so by some other means. Seeing that the signal is low does not suffice to identify the device that made it so.

The other approach to the output stage of an integrated circuit is generally referred to as a totem-pole output. In such a circuit, one internal transistor can be activated to pull the output low—as in the circuit you presented—and another one can be activated to pull it high. If neither output transistor conducts, then the output is not controlled. It is said to present a high-impedance or high-Z output, a fancy way of saying it is not connected. With such an output stage, you might omit a pull-up resistor altogether, if it is acceptable for the line to have an indeterminate value. (If it is not acceptable, you might as well use an open-collector-output or open-drain-output integrated circuit, like the one you present.) Such integrated circuits can be used to control a single line if you can guarantee that one and only one integrated circuit ever will control the signal at one time. If you violate this restriction, you will create short circuits that might damage devices.

\$\endgroup\$
4
\$\begingroup\$

This is a comparator with open drain/collector output. Please see the block diagram below.

For open drain to work properly it requires a pull up.

You can refer this document to see how to design using open drain comparators.

enter image description here

\$\endgroup\$
4
\$\begingroup\$

Whenever you use a comparator you have to check if it uses an open-collector output. If it does you'll need a pull-up resistor. Most do but some don't.

On the other hand, op-amps always have some kind of push-pull output that never requires a pull-up.

However, there's another problem with your design; the comparator's input common mode voltage range isn't sufficient for 2 volts with a supply voltage of 3.3 volts: -

enter image description here

In other words; with a supply voltage of 3.3 volts, the maximum input voltage that guarantees proper operation to specification is 1.8 volts.

There's another problem too: -

enter image description here

You should be using maybe 200 Ω and 330 Ω resistors as a minimum to avoid wasting power. 53 Ω across a 3.3 volt supply is taking nearly 63 mA and that is just a waste of 200 mW into heat.

\$\endgroup\$
4
  • \$\begingroup\$ so what will happen if I provide 2 V to IN- and 3.3 V to IN+ ? Because my signal is 1.3V-3V so I can adjust voltage divider to meet this criteria. \$\endgroup\$
    – Dominykas
    Commented Sep 22, 2023 at 10:28
  • \$\begingroup\$ @Dominykas the comparator isn't specified in that region of operation so, it cannot be determined what will happen with any certainty at all. It won't burn but it may fail to perform accurately in some respects and it may produce an output that just fails to work. If I were you I'd look for a rail-to-rail op-amp with the same pin-out and replace it (thus solving both problems). The good news is that you'll be very unlikely to make this mistake again = learning. \$\endgroup\$
    – Andy aka
    Commented Sep 22, 2023 at 10:35
  • \$\begingroup\$ I like the fact that you picked up on the divider network issue. \$\endgroup\$
    – SteveSh
    Commented Sep 22, 2023 at 15:06
  • 1
    \$\begingroup\$ @Dominykas: Some comparators and op amps are specified to work correctly if either input is within the common-mode range, treating an overly high input as though it were pegged a the upper limit, or an overly low input as though it were pegged at the lower limit. Some, however, may exhibit weird "phase reversal" behavior which will behave as though an out-of-range input was pegged to the other limit. \$\endgroup\$
    – supercat
    Commented Sep 22, 2023 at 18:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.