# Recommended capacitor rating for this mains zero-crossing detector

I found this zero-crossing detecting circuit here

I want to recreate it, using the parts that I have on hand (or can get cheapest), but I'm not sure how to choose the correct 0.1uF capacitors.

Firstly, why are there two capacitor/resistor pairs instead of one? Won't the current be the same with 2k and 0.05uF? The additional capacitor only seems to isolate the optocoupler further, but shouldn't that be unnecessary?

Secondly, I am assuming these parts are class X, since they are connected directly between line and neutral. How do I choose the correct ac voltage rating, if I am using 230V mains? How much margin should I include? I want to use a 310VAC capacitor I have found.

• A quick sidenote on capacitor ratings -- AC mains capacitors (X and/or Y safety rated capacitors) are rated by their nominal mains working voltage, instead of by their insulation withstanding voltage -- so it's perfectly normal to see a 230 or 277V rated X capacitor on 230-240V mains supplies. Commented Dec 27, 2015 at 17:23

If you want to simplify the circuit further, I'd suggest you to use this circuit which uses just one resistor and dual channel optocoupler (K814P) on the line side:

This will give you peaks at each zero cross which you can use as a time reference for your dimming delay. This is a working and tested circuit.

Before using it, you need to keep something in mind, though. Zero cross detection will not be infinitely sharp peak. In reality it will be like this:

Blue is mains supply (220V 50 Hz) and yellow is circuit output (on a 3.3V system).

The peak will be observed at zero cross but your micro-controller (arduino) will detect Logic HIGH or Logic LOW a few ms before the peak and lowest output voltage respectively. Why? Because on a 3.3V system, any voltage above 2V will be interpreted as HIGH. Something similar will happen for a 5V system.

Besides this, any voltage above 0.8V can also be interpreted as HIGH sometimes. So, there is a region where you can't be sure about the logic levels that your micro-controller can see. To be on the safer side, you need to stay out of that zone. Consider this:

As seen here, 0.8 V is the max voltage which confirms a definite logic LOW signal. Any signal more than that might be recorded as HIGH. Taking worst case scenario of HIGH detection at 0.8V itself, if the triac is turned on within 1.3 ms period of HIGH detection, it might lead to an unreliable behavior. If a minimum delay of 2 ms is assured in the code, it will ensure a robust dimming of the device without any flicker.

For max delay, considering the worst case scenario of zero detection at 2V, max delay can be 9.5ms. However to be on the safer side, a max delay of 9ms should be used. For a 5V system and exact parts chosen, the timing might be a little off but you should be able to program by trial and error.

• yes this is the kind of circuit that i want to go with, but when i have seen it elsewhere, the led current was much more significant, on the order of 5 ~ 10 mA. here it is more like 1mA (at peak). i had assumed this was too low for accurate zero-cross, but the scope shots show otherwise. btw this answer is very useful to me, but i'm not sure I can really 'accept' it is a direct answer to the question about caps Commented Dec 27, 2015 at 8:31
• @user3125280 - You can accept this as an answer if it really helps. It will help other people who are searching for a similar zero crossing solution. However if you really want something with capacitor only, then you can probably wait for more answers. Furthermore you might have to change 200K if you are living in 110V region. Commented Dec 27, 2015 at 8:37

that circuit looks more like a peak detector than zero-crossing

It depends you could use ordinary film capactors if the resistors can be relied upon to fail in a safe way (you can get special fusible resistors) else you should use X2 (or X1) rated film capacitors

it seems to me that only one capacitor is needed (just use use 0.047) and replace the other with a wire link

for 230V you should reduce the capacitance to 0.047 (or 0.022 for a single)

The reccomended numbers were rounded to nearest "E6" to match commonly avaialble parts

if the 310VAC capacitor has an X1 or X2 marking it's good. else you'll need a fuse of some sort in-case the capacitor fails

• are you sure about the use of class x1 for 230v? i have found x2 capacitors with much higher voltage ratings like this one Commented Dec 27, 2015 at 7:31
• yeah the circuit is nearly pure capacitive at 50Hz, so you see the strongest signals at zero crossing - which seems less useful but i haven't had a chance to play with yet. the micro will have to extrapolate from the peaks, the main reason to use this circuits is to not use two several watt resistors Commented Dec 27, 2015 at 7:35
• X2 vs X1 not sure... I read it somewhere on the internet, and all the computer PSU's I've scrapped for parts had X1 capacitors so assumed it was true. Commented Dec 27, 2015 at 7:39
• that gave me an idea. i just looked at an old server psu - it had six class x2 275VAC 0.047uF capacitors! Hard to tell if they are directly across the mains though, and there is a fuse before them. Commented Dec 27, 2015 at 7:46
• edit - on that evidence X2 must be good enough. Commented Dec 27, 2015 at 7:53

Question title: -

Recommended capacitor rating for this mains zero-crossing detector

This is not a zero crossing detector. There are two 100nF caps. At 50Hz each has an impedance of $\dfrac{1}{2\pi\cdot 50\cdot 100E-9}$ = 31.8 kohms.

Together they have an impedance of about 64 kohms and swamp the impedance of the resitors so, the current flowing into the LEDs will be leading the voltage by 90 degrees: -

The peak impulse from the opto transistor is when the LEDs are not conducting and that is when voltage is at a maximum therefore it is not a zero-cross detector but a peak detector.

• yeah as mentioned in the comments it is purely capacitive (i copied the description 'zero-crossing detector' from the website, it can still be used for this purpose though) the motivation is that there are no resistors using several watts of power, but whiskeyjack showed that a bigger resistor still works. (i thought the current in led's would be unusably low) thanks anyway though Commented Dec 27, 2015 at 12:25