1
\$\begingroup\$

I designed the following zero crossing detector using an FOD819S optocoupler (U5):

zero crossing schematic

The source of the optocoupler is connected to a MB6F full-bridge rectifier (D2) which is supplied by a 9V transformer connected to 220V AC/50Hz. The 3.3V regulator (U8) supplies power to an ESP32 microcontroller and a segment display (not shown in schematic).

I probed the circuit in T1 (in blue, relative to GND) and it works as expected most of the time. For reference, I connected another probe to T2 (in yellow) before the full-bridge rectifier.

zero crossing wave

However, when cutting and re-applying AC to the transformer, it sometimes shows some odd behavior:

zero crossing wave

Or it simply stays at 0V:

zero crossing wave

Another issue is that the detected frequency is ~10% above 100Hz (not stable) which is also what I detect from a microcontroller using an interrupt on falling edge. It might be a consequence of the slow rise time.

What is wrong with this circuit? Should I add a constant load before the regulator?

Solution

Here is the signal when using the first circuit from Dave Tweed (with a pull-down resistor):

zero crossing wave

\$\endgroup\$
  • 6
    \$\begingroup\$ That isn't a zero-crossing detector, it's a peak detector. And are you actually running all of the power supply current through the LED? That's insane! \$\endgroup\$ – Dave Tweed Apr 10 at 15:48
  • \$\begingroup\$ With the series capacitor you're getting a derivative of the mains voltage during the brief conduction peaks which accounts for the extra counts. I agree with Tim that this is probably abuse of the LED during turn-on (and I think it will probably kill the LED over time). \$\endgroup\$ – Spehro Pefhany Apr 10 at 15:49
  • \$\begingroup\$ I think you could figure this out if you showed a few plots on the scope of U5-pin1 and U5-pin2. \$\endgroup\$ – scorpdaddy Apr 10 at 15:56
4
\$\begingroup\$

If you want to monitor the output of the bridge rectifier, put your optoisolator in parallel with the power supply, not in series with it. Note that this requires an extra blocking diode (D6) in order to prevent the power supply input capacitor from driving the optoisolator LED.

schematic

simulate this circuit – Schematic created using CircuitLab

Better still, put the optoisolator upstream of the bridge rectifier. Then every rising and falling edge at its output represents a zero crossing of the AC voltage.

schematic

simulate this circuit

\$\endgroup\$
  • \$\begingroup\$ What is the purpose of D6 in your second schematic? Is it a symbol for another optoisolator? \$\endgroup\$ – Harry Svensson Apr 10 at 16:27
  • \$\begingroup\$ @HarrySvensson It protects the LED from reverse voltage. I tend to prefer a reverse shunt diode rather than a series diode for a number of reasons. \$\endgroup\$ – Dave Tweed Apr 10 at 16:32
  • \$\begingroup\$ I like this circuit, as long as you only need to know the line frequency and do not need to catch every half-cycle. \$\endgroup\$ – TimWescott Apr 10 at 17:26
  • 1
    \$\begingroup\$ @TimWescott: But a lot more accurate than the OP's original proposal, whose output pulses weren't anywhere near the zero crossings! Evidently, that isn't what he's actually interested in. \$\endgroup\$ – Dave Tweed Apr 10 at 19:13
  • 1
    \$\begingroup\$ In which case, you DO care about the actual zero crossings! You might have mentioned that up front, rather than just talking about frequency detection. \$\endgroup\$ – Dave Tweed Apr 11 at 11:19
1
\$\begingroup\$

First, I wouldn't call that a "zero crossing detector" per se, although in normal operation it does seem to be enough to measure line frequency.

In startup, the current into C1 will be much higher, and for a longer period of time. That's part of the reason you're seeing shorter high-going pulses out of the thing. I suspect that the rest of the reason is that in that period of time you're pushing way more than the 1.5mA that the thing is rated for through the diode, and saturating the transistor beyond what the manufacturer rates the device for.

With your circuit as given, I would be concerned about exceeding the LED's maximum-rated 50mA during startup. If you're absolutely married to using that circuit, you may want to consider a resistor in series with the coupler.

As for the higher-than-expected measured frequency -- you are probably correct that you are misreading the output. If your microcontroller has a way to implement filtering on its input pins (a few do) then do so. If not, then you need a Schmitt trigger on that signal before it goes into the microprocessor.

\$\endgroup\$
  • \$\begingroup\$ In a comment, as this is an opinion: if it were me, I'd put a positive-going and negative-going comparator on the lines coming from T2, using a suitable resistor network so as not to exceed the comparator supply voltage. A 74xx32 would be sufficient, and I see that TI has a one-gate version. Five or six resistors ought to do it, and give you a nice clean output. \$\endgroup\$ – TimWescott Apr 10 at 15:52
  • \$\begingroup\$ Good catch! My application is not cost sensitive and I can filter the input in software so I will put the optocoupler in parallel with the supply as a quick fix. I will however keep that mind for a future revision. \$\endgroup\$ – DurandA Apr 10 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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