I'm working on a circuit powered by a capacitive transformerless power supply, that is a microcontroller based triac-switching project for resistive loads.

I've taken the basic design of the power supply from Microchip's Application Note AN954:

Capacitive PSU

I'm using 1uF for C1 and 5.6V for D1, as they allow for a slightly increased load. I'm also in the UK so it's powered by 240v @ 50Hz.

I've attached an interrupt pin on the microcontroller to the point circled in red on the schematic via a 100K resistor, to give me the ability to detect the zero crossing. However, as this is a capacitive power supply, the zero crossing point detected is out of phase with the real zero crossing.

If I simulate the circuit, I can see that it's approximately 270° out of phase, however I'm not sure if this is just by chance based on the component values I've chosen, or if this circuit would always produce a zero cross exactly 270° out.

Is there a way to calculate mathematically (not too advanced!!) exactly what the offset is, so that I can accurately compensate for it in the firmware?

  • 1
    \$\begingroup\$ Zero crossing is highly depending on exact values of the various components (including the Vout load) and the mains frequency. 270 degrees sounds like an ideal capacitor, I doubt you'll manage to get that in practice. I think it all depends on your exact application. I think you should use your microcontroller to measure, predict and improve prediction the zero crossings, not trying to calculate them as exact times. \$\endgroup\$
    – jippie
    Aug 16, 2012 at 20:20

1 Answer 1


The calculated angle is accidental, it is not a reliable value. To demonstrate how unreliable is it, imagine that capacitor is 1 pF. The angle will be close to zero, << much less << than 270.

I'd suggest to add optocoupler with high voltage diode and resistor, read zero crossing with accurate estimate of current transfer ratio of optocoupler, known part's delays, and known software delays. Though with high voltages (above 300V) the coupler should be super low current kind, say with LED requiring less than 1 mA to be detectable.


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.