I've received a board with the following circuit:


simulate this circuit – Schematic created using CircuitLab

The INPUT is a digital signal coming from a MCU, with HIGH value being 3.3V. Based on received INPUT, the circuit should operate in two states:

  • STATE 1 : When INPUT is HIGH, OUTPUT1 is HIGH and OUTPUT2 is LOW
  • STATE 2 : When INPUT is LOW, OUTPUT1 is LOW and OUTPUT2 is HIGH


The circuit was tested and controlled by a MCU, worked fine in both states. However, when we tested another MCU, we started with STATE 1, and then driven the INPUT LOW, but it didn't switch to STATE2. In fact, it kept holding in STATE 1. And it only goes to STATE 2 when we touched the input channel with Voltmeter. We tried to add a pulldown circuit but that didn't solve the case.

Q1 & Q2 are BC516-D27Z


  1. Updated with the correct circuit schematic.
  2. Added OUTPUT HIGH/LOW values.
  3. Both MCUs are the same.
  • 2
    \$\begingroup\$ Are your transistors meant to be upside down? \$\endgroup\$
    – Ian Bland
    Aug 29, 2022 at 21:40
  • 1
    \$\begingroup\$ Please confirm that you checked both outputs to make sure they were always LOW/HIGH or HIGH/LOW. Is the "board" a PC board where all the connections are soldered or a breadboard with push-in connections? Where did the board come from? +/- 7 volts is an unusual supply, and an output high of 7 volts, more so. When either op amp output is high, it's exceeding the Vbe AMR of the transistor it feeds. When either output is low, it's short-circuited. It should still work in both cases. All that's needed is a level shift from 3.4 V to 7 V. There are much simpler ways to do it. \$\endgroup\$
    – stretch
    Aug 29, 2022 at 21:44
  • 2
    \$\begingroup\$ Do you have a good ground connection between the mcu and the comparators circuit? \$\endgroup\$
    – user173271
    Aug 29, 2022 at 21:45
  • \$\begingroup\$ @IanBland a PNP in CE configuration. that's the symbol from LTspice \$\endgroup\$
    – Fmashehri
    Aug 29, 2022 at 22:14
  • \$\begingroup\$ @stretch I've corrected the circuit schematic. Answering your questions, It's a soldered board an old colleague designed. It has different functions, and one functions is this circuit, that a specific SPST switch that requires HIGH range from -5V to -7V. and yes the both OP-AMP states did not conflict. However, sometimes the HIGH output drops to -4.6V when loading on the SPST, but it still functioning. \$\endgroup\$
    – Fmashehri
    Aug 29, 2022 at 22:51

2 Answers 2


AD820 is an op-amp, not a comparator. It's a rather lousy comparator in terms of speed, and for this application a simple LM393 powered from +/-7V would work much better.

If the circuit is as you have drawn, then you're using the PNPs with collector and emitter swapped. They will operate with a very low current gain. That's not what you want. If that's how the circuit was assembled, then that's your problem. Flip the transistors upside down and things will start to work.

Like this:


simulate this circuit – Schematic created using CircuitLab

The output is indeed complementary:

The complementary outputs of the corrected circuit

But all this seems like a whole lot of work for little gain. This same circuit could be put together with a couple MOSFETs in place of the op-amp. To retain the spirit of the original circuit, I've decided to leave two BJTs there :)


simulate this circuit

The cost is 5x lower than that of an AD820. Instead of using 6 discrete MOSFETs, this could also be a single chip - CD4007, for the same cost, but higher level of integration.

The output switches in about 100ns, and is driven push-pull, i.e. without pull-ups. The static current consumption of this circuit is about 0.2mA.

The output waveform of a MOSFET-based circuit

For an even lower cost, an LM393 circuit will do the job:


simulate this circuit

The output switches reasonably quickly still:

The output waveform of a comparator-based circuit

  • \$\begingroup\$ Thank you for your answer. I've corrected the PNP placement, both of them are in CE configuration. As I mentioned, the circuit work perfectly when tested alone -input received from function generator and first MCU- , but fail to switch from state 1 to 2 when input is received from the the second MCU. Yes, it would be easier to change the circuit. but for an implemented PCB, it would be difficult. \$\endgroup\$
    – Fmashehri
    Aug 30, 2022 at 6:06
  • \$\begingroup\$ What concerns more is the capacitance-like behavior that happens in the input. \$\endgroup\$
    – Fmashehri
    Aug 30, 2022 at 6:24
  • \$\begingroup\$ @Fmashehri Well, how does that input from 1st MCU and 2nd MCU look on an oscilloscope? And also: you're literally throwing money away. It'll be cheaper to redesign the pcb and run it at PCBway or JCLPCB, than to use those op-amps. I'm still amazed that you'd pick such an expensive chip when there are so many low-cost alternatives that perform much better. As for PCB layouts for such circuits: treat them as disposable. It's so easy to make a new one, it's not worth worrying about. The hard part is always the actual design. \$\endgroup\$ Sep 7, 2022 at 18:12

I ran the simulation, and also added 1k resistors to the op-amps' outputs. Here is a plot of the DC sweep from 2V to 4V:

Dual Comparator

I see that I don't know how to do a DC sweep. I tried V(INPUT) but that gave me an error. And now CircuitLab has locked me out again.

And I see that I need to add a voltage source as @KubaHasntForgottenMonica has in their answer, but I can't use CircuitLab anymore.

  • \$\begingroup\$ Unfortunately, DC sweep in CircuitLab is somewhat broken - not the sweep part, but the solver reusing results from the previous operating point. So even when there are no errors, you can get very glitchy output curve. As for sweeping input voltage, you'd sweep INPUT.V, and this would have to be selected from a dropdown in the DC Sweep pane. \$\endgroup\$ Sep 7, 2022 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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