As an Amazon Associate we earn from qualifying purchases.
A zero crossing detector tells a circuit the exact moment an AC waveform passes through 0 V. It is the timing reference behind dimmers, phase-angle power control, solid-state relays and mains frequency measurement. This article shows a simple, low-cost, transformerless zero crossing detector for 230V AC. It uses a bridge rectifier and an MCT2E optocoupler, so the output side is electrically isolated from the mains.
Circuit
The circuit needs only a few parts:
- A bridge rectifier (four diodes or a bridge module) rated for the mains peak voltage with a good margin.
- A high-value series resistor (180 kΩ in this design) that limits the LED current.
- An MCT2E optocoupler.
- A pull-up resistor on the transistor side, connected to the 5 V logic supply.
The mains goes into the bridge rectifier. The rectified output passes through the 180 kΩ resistor to the LED inside the optocoupler. On the isolated side, the output transistor’s collector is pulled up to 5 V and the emitter goes to ground. The collector is your output.
Working
Fig – INPUT AC(230V RMS) , BRIDGE RECTIFIER OUTPUT( DC) AND OUTPUT OF OPTO COUPLER
- The bridge rectifier converts the AC into pulsating DC. Both half cycles are now positive.
- The output of the bridge rectifier is fed to the opto-coupler (see how optocouplers and photocouplers work).
- The LED inside the optocoupler needs a minimum of about 1 V to turn on.
- When the wave gets close to the zero crossing line, below about 1 V, the LED turns off.
- As a result the output transistor turns off and the collector is pulled up to 5 V.
For most of each half cycle the LED is on, so the transistor conducts and the output stays low. Only near 0 V does the LED switch off and the output jump high. You get one short positive pulse at every zero crossing. On a 50 Hz supply that is 100 pulses per second, because the rectifier turns both half cycles into positive ones. On a 60 Hz supply it is 120 pulses per second.
The pulse is not exactly centred on 0 V. The LED needs a small current to stay on, so it switches off slightly before the crossing and back on slightly after. With a 230V, 50 Hz supply this gives a pulse in the range of a few hundred microseconds. This is usually fine for dimmers and relay timing. If you need more precise timing, measure the pulse and subtract the offset in software.
Design
Resistor design (High voltage side)
The series resistor sets the LED current. The general formula is R = (peak mains voltage − LED voltage) ÷ LED current.
- From the V-I characteristic of the opto coupler LED (datasheet of MCT2E), the LED needs 2 mA at about 2 V.
- INPUT AC = 230 V (RMS voltage)
- Peak voltage of AC = √2 × RMS voltage ≈ 325 V
- Voltage across the current limiting resistor = 325 − 2 = 323 V (the LED takes 2 V)
- R = V ÷ I = 323 ÷ 2 mA = 161.5 kΩ
Take the nearest standard value of 180 kΩ. This gives a peak LED current of about 1.8 mA, which is enough to keep the transistor conducting.
Check the resistor’s power rating too. With 230 V across 180 kΩ, the dissipation is about V² ÷ R = 0.29 W. A 1/2 W resistor is the bare minimum. A 1 W part, or two 90 kΩ resistors in series, runs cooler and shares the voltage stress.
For a 120 V supply the peak is about 170 V, so the same calculation gives roughly 84 kΩ. You can use the same method for any other mains voltage. If you do this often, a set of electronics circuit calculators saves time on this kind of arithmetic.
Collector resistor
This resistor pulls the output up to 5 V when the transistor is off. It only needs a small current of about 0.3 mA.
R = V ÷ I = 5 V ÷ 0.3 mA ≈ 16.7 kΩ
The nearest standard values are 15 kΩ or 18 kΩ. The original version of this design used 25 V in the calculation, which gave 83 kΩ and then 100 kΩ. That was a mistake, because the pull-up goes to 5 V. A 100 kΩ resistor still produces a logic high, but the rising edge becomes slow and the output is more sensitive to noise. A value around 15 kΩ to 18 kΩ gives a cleaner pulse. If the output stays high when the LED is on, the pull-up is too small for the current transfer ratio, so increase it a little.
Using it with a microcontroller or Arduino
The output is a 5 V logic signal, so it can go straight to a microcontroller input. For an Arduino, connect it to an external interrupt pin (pin 2 or 3 on an Uno) and trigger on the rising edge. Each interrupt marks a zero crossing, and from there you can:
- Measure the time between pulses to get the mains frequency.
- Start a delay timer to fire a triac later in each half cycle for dimming or phase control.
- Switch a load on only at the zero crossing to reduce switching noise.
On a 3.3 V board, connect the pull-up to 3.3 V instead of 5 V and recheck the value. Keep the interrupt routine short, and do the real work in the main loop.
The pulse from this circuit can time a triac on the load side. See the triac gate driver circuit for how to fire it with an opto-isolated driver.
Advantages
- Low cost
- Transformerless
- Isolated (the zero-cross pulse can time a MOC3021 opto-triac driver on the load side)
Limitations and safety
- Mains voltage is lethal. The bridge rectifier and the 180 kΩ resistor sit directly on the live line. Build the circuit on a proper board in an insulated enclosure and never touch it while powered.
- Isolation only exists between the LED and the transistor inside the optocoupler. Keep clear spacing between the mains tracks and the low-voltage side of the board.
- The high resistor wastes a small amount of power continuously, and the pulse is slightly offset from the true crossing.
- Use diodes with a reverse voltage rating well above 325 V, such as 1N4007 types.
- Add a fuse on the mains input.
Before building it, draw the schematic and check the values in a tool like Circuit Wizard. This helps you catch mistakes before any mains wiring is involved.
FAQ
Why use a bridge rectifier in a zero crossing detector?
An optocoupler LED conducts in one direction only. The bridge rectifier lets the LED conduct on both half cycles, so you get a pulse at every zero crossing instead of every other one.
Can I use a different optocoupler instead of the MCT2E?
Yes. Many general-purpose transistor optocouplers work, as long as you recalculate the LED resistor from the datasheet current. There are also AC-input optocouplers with two back-to-back LEDs. These can remove the need for the bridge rectifier, though the output then pulses at a different pattern.
Why is the output a pulse and not a square wave?
The LED is off only when the rectified voltage is close to 0 V. The output therefore goes high briefly at each crossing and stays low the rest of the time. Edge detection on the rising edge is the usual way to use it.
Does this circuit work for 120 V or 60 Hz mains?
Yes. Recalculate the series resistor for the lower peak voltage, about 84 kΩ for 120 V. The pulses then come at 120 per second for 60 Hz, so adjust any timing code in your microcontroller.