I need help designing a circuit that outputs Signal A high when AC sine wave is positive and Signal B high when the sine wave is negative. It's part of a larger project that cycles power in a transformer.

I have the below circuit working but it's not accurate enough. Signal A and B don't start/stop exactly at the zero-cross of the input sine wave. Any help appreciated!

enter image description here

  • 2
    \$\begingroup\$ This sounds like an XY question. What are you trying to do with this signal and "cycling power in a transformer"? \$\endgroup\$
    – vir
    Commented Nov 28, 2023 at 6:42
  • \$\begingroup\$ Have you considered an OPAmp? \$\endgroup\$
    – S_G
    Commented Nov 28, 2023 at 7:37
  • \$\begingroup\$ Is a 4N25 Opto an OPAmp? (I'm new to electronics) \$\endgroup\$ Commented Nov 30, 2023 at 6:06
  • \$\begingroup\$ bridge rectifier? \$\endgroup\$
    – tobalt
    Commented Nov 30, 2023 at 6:08
  • \$\begingroup\$ The two signals each start a timer that is controlling other switches downstream that switch power on the 1/4 cycle of a sine wave. It is meant to rapidly load and unload a transformer. This question only referred to the front end of the circuit. \$\endgroup\$ Commented Nov 30, 2023 at 6:09

2 Answers 2


Op-amp precision rectifiers are the likely turn-to solution. Here's an example circuit: -

enter image description here

When the input is positive, the op-amp is prevented from creating an inverted (negative) output by D1 but, when the input is negative, the natural situation is for a positive output to be produced and, of course, D1 allows this. D2 prevents output saturation of the op-amp when the input is positive i.e. keeps it in the linear region.

The circuit produces a positive half wave rectified output.

If the diodes are reversed then you get a half-wave rectified output when the input is positive and 0 volts when the input is negative. You can then add another inverting stage after this so that you get the polarity you require.

So, two precision op-amp circuits are needed and both are fed from \$V_{IN}\$. If you need to have a decent square wave output, add comparators to both output channels.


Thank you for the tips. I eventually got a 4N25 opto to work with two outputs, one positive sine high and one negative sine high. The Duty cycle is not quite 50% but when voltage gets up close to 110v it's about 52% and 48%. That's the only area still needing some tweaks.

Here is the circuit (v 4) and the scope shots. The resistor feeding the Opto is a 2k.

Version 4 circuit Positive Sine High Negative Sine High


Your Answer

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

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