Let's say you have a device which is fed by AC line voltage and features an isolated SMPS. The switcher outputs 5 VDC, and that powers a PIC micro. I'm curious how is the Microchip's ZCD (Zero cross detection) module supposed to work here? In the technical brief (TB3138), they give the following diagram:

Microchip's usage example from TB3138

However that assumes the AC and the PIC share the same ground, which is not the case. Probably they assume the PC will be on the non-isolated side, or that the isolation would be a 50/60 Hz transformer. I've searched Microchip's app notes on this topic, and I couldn't find any mention of this scenario.

Any ideas about how to interface the AC to the ZCD pin, is it even feasible?

(And yes, I know those opto-couplers cost pennies).

  • \$\begingroup\$ How much current does the input pull? \$\endgroup\$ Sep 15, 2017 at 18:19
  • \$\begingroup\$ The ZCD pin input current is 300 µA \$\endgroup\$
    – anrieff
    Sep 15, 2017 at 18:27

1 Answer 1


I'd use either a very small 50/60Hz step-down transformer (in the low single digit VA range) as a coupling transformer if space wasn't a major issue, or a Y1 capacitor in the few-nanofarad range as a coupling cap if I was tight on space. Either way, the relatively light load of the input shouldn't pose an issue, and the coupling device will act to limit the current so you won't need the resistors any longer.

  • \$\begingroup\$ Thank you for your answer! Before accepting it I'll want to simulate or test it on real HW though. Space is tight so I'll go with the Y cap, but I'm worried about the ballpark estimation you gave ("few nanofarad"). I believe it has to be more precise than that - I want to support both 110V/230V networks, and ensure max input current stays within the 50 - 300 µA range. \$\endgroup\$
    – anrieff
    Sep 16, 2017 at 13:47
  • \$\begingroup\$ @anrieff -- yeah, you'll probably have to figure out the right value (I'm not sure what all your parameters are) \$\endgroup\$ Sep 16, 2017 at 14:38
  • 1
    \$\begingroup\$ It is not a good idea to leave out the resistors if you want reliable service. Over time there may be leakage in the cap or spikes that have dVdT higher than you planned for and this will cause current in the input pin to exceed your design limits. Also for high voltage non isolated circuits it is good design practice to use more than one components in series to prevent fire in the case of single component failures. \$\endgroup\$
    – KalleMP
    Sep 11, 2019 at 6:25
  • 2
    \$\begingroup\$ @anrieff don't forget to account for isolation. If you don't use a transformer, the circuit gets dangerous because there is no galvanic isolation between the 230Vac and the logic level. Also, some filtering would help (you never know what comes from mains) and a series resistor can prevent burning. \$\endgroup\$ May 14, 2020 at 7:52

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.