1
\$\begingroup\$

I need to design a circuit that can measure and output pulses for a MCU at zero crossing of 220VAC waveforms. The application requires that that both square wave waveforms and sine-waves should work. The square waves are important due to circuits being powered off cheap UPSes here.

I am familiar with the simple 'AC input' opto-isolators + resistors approach. That has worked very well for sine waves but in a square wave, the waveform crosses the zero point much more quickly and my circuit has very little time to react, it seems. Here's the circuit:

enter image description here

Based on this circuit I thought that slowing down the square-wave might work. So I designed a low-pass filter in addiion to replacing R1 and R2 with some capacitors to reduce power loss. Resultant circuit:

enter image description here

I don't quite remember the values for the LPF so the values in the schematic are just a guess. Note that this circuit does work as the square-wave is basically slowed down. It does have some phase shift but as long as that's constant, I'll just program it out into the MCU. I hope capacitor tolerances won't bother that too much.

My question is: is there a better way? The circuit has a switch mode power supply so no traditional transformer where I could have done zero-cross detection with a comparator - I do require isolation here. I'm also OK with the idea of a dedicated transformer provided it's very small and is able to pass the sine and the square wave.

\$\endgroup\$
2
  • \$\begingroup\$ I am not very familiar with opto-isolators, but if R2 is grounded with input on R1, how are the LEDs turning on the transistor? And with your second configuration, when R2 is grounded and input on R1 again, how is R1 and C3 forming a LPF with R2 in series? And wouldn't C1 and C2 affect the filter characteristics? I need to become more familiar with different filter configurations but I just don't see how this is working to slow down the square wave. Do you know of any write-ups that may clarify? \$\endgroup\$
    – sherrellbc
    Aug 15, 2014 at 15:40
  • \$\begingroup\$ @sherrellbc: The capacitors will eventually settle at half-charge average (with respect to the waveform), which will remove the other side of the LEDs from ground. The filter becomes more complex with the addition of other elements, but doesn't neutralize entirely (unless you manage to break it very badly). \$\endgroup\$ Aug 15, 2014 at 15:46

2 Answers 2

4
\$\begingroup\$

How about using a dual opto-isolator and putting the input diodes in inverse parallel. No additional parts compared to your top diagram other than a second pull-up resistor.

You could then deal with the two crossing signals separately with two MCU input pins (it would be possible to reduce it back to one but in this day and age, probably not a worthwhile exercise).

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
7
  • \$\begingroup\$ I can't understand how using a dual optoisolator would be better where better means the ouput spike will be slow enough even when the input is a square wave. Isn't he using a sort of dual opto isolator in antiparallel already though? At least that's what I'd call so... I'm lost. \$\endgroup\$ Aug 15, 2014 at 16:14
  • \$\begingroup\$ Ok now I got it and that's smart. Have my upvote! Maybe a little diagram or something would help. \$\endgroup\$ Aug 15, 2014 at 16:15
  • \$\begingroup\$ Pardon the incomplete drawing, but is this what you mean? imgur.com/5oxqpEd \$\endgroup\$
    – Saad
    Aug 15, 2014 at 16:40
  • \$\begingroup\$ @Saad Yes, that would work, but see my edit above. \$\endgroup\$ Aug 15, 2014 at 17:06
  • \$\begingroup\$ Wouldn't the reverse voltage of the mains damage the LEDs or significantly degrade them? \$\endgroup\$
    – Saad
    Aug 15, 2014 at 17:15
0
\$\begingroup\$

How about using a higher order filter?

schematic

simulate this circuit – Schematic created using CircuitLab

Change the capacitor values to obtain the pulse shape you desire.

\$\endgroup\$

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.