I want to build a digital dimmer for resistive Loads. I have found this circuit for that:


  • The input voltage is 220VAC 50Hz.
  • The red box in the picture is for Zero Crossing Detection.

When the AC voltage crosses the zero, the Microcontroller will be interrupted an therefore detects the zero crossing. so you can reach to the required voltage by triggering the Triac after a specific Delay.Do you recommend this circuit? if so, please let me know if there is any IC to replace with the Red Box (shown in the picture) to detect the zero points of AC voltage (as my circuit should be as small as possible)?

P.S. As I need this circuit to reduce the consumed energy of Loads, the circuit itself must dissipate at most 5 watts.


In the answers to this question is explained how you can do that complete zero-crossing detection circuit with just U1, R12 and 2 series resistors on the 220 V side. One solution uses a common optocoupler, the other one a Darlington optocoupler, which needs less current to drive the optocoupler's LED, so that's less power in the series resistors (less than 200 mW for the complete zero-crossing detector).

enter image description here

This replaces the red box plus the rectifier at the left.

edit dd. 2012-07-14
If an AC input optocoupler is too expensive, then you can use a common optocoupler with a 1N4148 in anti-parallel:


You'll have the advantage of lower cost and wider offering. The LTV-817 costs only 10 cent in 1000 quantity, yet has a respectable 50 % CTR. For only 2 cent more you get the LTV-815, which has a Darlington output. Instead of 1 positive pulse every half period you'll have a positive pulse a bit longer than half a period.

enter image description here

If the mains frequency is 50 Hz then one period is 20 ms. If then the positive pulse is 12 ms long you know that it covers two zero-crossings symmetrically. Since the zero-crossings are 10 ms apart there was one 1 ms after the start of the 12 ms pulse, and one 1 ms before the end. So you know that the next zero-crossing will be 9 ms after the end of the pulse.
This is very easy in software and keeps BOM cost low.
(end of edit)

But watch out with the triac driver. The input is isolated from the mains through the optocoupler, but apparently they forgot that on the driver side, so the circuit is directly connected to the mains after all, and therefore possibly lethal!

You need an optocoupler on that side as well. Typical application from the MOC3051 datasheet:

enter image description here

Make sure to use a random phase optocoupler (like the MOC3051).

  • \$\begingroup\$ This other answer of yours also explains it very well. \$\endgroup\$ – m.Alin Jul 13 '12 at 15:23
  • \$\begingroup\$ Of course. I was just pointing to an additional source of information. \$\endgroup\$ – m.Alin Jul 13 '12 at 15:29
  • \$\begingroup\$ Steven I am really sorry but I am not very professional. will you help me figure this out?? where shall I put my Microcontroller? and as you said the first Image can be replaced by the Red Box plus rectifier. So can I connect the R1 and R2 directly to the 220VAC???? If yes what should be the Values of R1 and R2?? I am confused. :( \$\endgroup\$ – Mehrdad Kamelzadeh Jul 13 '12 at 16:48
  • 1
    \$\begingroup\$ @Mehrdad - For mass production you'll want as few components as possible. Instead of needing several components to provide the perfect signal I rely on software to detect the actual zero-crossing in the middle of the pulse. For mass production software is virtually free. If the SFH620A is too expensive there are alternatives. Digikey lists 650 AC input optocouplers. The EL814 costs only half the price of the SFH620A. \$\endgroup\$ – stevenvh Jul 14 '12 at 10:02
  • 1
    \$\begingroup\$ @Mehrdad - the actual zero-crossing is in the middle of a pulse, so you can only determine it after the pulse. If you wanted to fire the triac exactly at the zero-crossing you're a ms or so too late. So you set a timer for when the next zero-crossing is expected, and when that timer gives you an interrupt you know that's a zero-crossing. At the same time you're processing the input pulse to define the moment of the next zero-crossing. So you always use the input pulses for the next zero-crossing. \$\endgroup\$ – stevenvh Jul 14 '12 at 13:55

I'm not aware of any IC that can replace a full zero-cross-detector, but I have been using this circuit and it works quite well and it has a very low power consumption.

Zero cross detector

You can find more information here.

  • \$\begingroup\$ I have to use Microcontroller. Where should it be in this circuit? \$\endgroup\$ – Mehrdad Kamelzadeh Jul 13 '12 at 19:32
  • \$\begingroup\$ You should connect the signal marked as OUT to your interrupt pin. \$\endgroup\$ – Bruno Ferreira Jul 13 '12 at 19:34
  • \$\begingroup\$ Do you agree with the Load part of my circuit? have you got any suggestion or recommendation or it's just fine? \$\endgroup\$ – Mehrdad Kamelzadeh Jul 13 '12 at 19:41
  • \$\begingroup\$ For the load I would follow stevenvh advice. If you want isolation from mains for zero cross detection, you should also isolate the load control. Depending on the output current of your microcontroller and the characteristics of the opto-triac you use you may not nedd the transistor to drive the opto-triac. \$\endgroup\$ – Bruno Ferreira Jul 13 '12 at 19:46

This application note (AVR182: Zero Cross Detector) from Atmel describes how you can do zero-crossing detection with two 1MΩ resistors. This involved connecting the mains signal directly to the MCU which may or may not be a good idea, but it is very efficient in terms of components. If you're only going to drive the TRIAC it might not be a bad idea.

Just remember to insulate stuff when if you're debugging etc.

Edit: Updating URL to relocated application note.

  • \$\begingroup\$ I have seen that but I think this is not energy efficient. Is it? \$\endgroup\$ – Mehrdad Kamelzadeh Jul 26 '12 at 10:07
  • \$\begingroup\$ How would it not be? The current through 2MΩ resistors at 220V is ~24mW. \$\endgroup\$ – Trygve Laugstøl Jul 26 '12 at 22:53
  • \$\begingroup\$ so would please tell me what are the pros and cons between this method and the other which @Stevenvh has provided here (I am sorry If I raise very fundamental questions as I am not very professional) ? \$\endgroup\$ – Mehrdad Kamelzadeh Jul 27 '12 at 10:20

These are fine examples of nice working single/multichannel zero cross dimmers with IR/UART/DMX512.


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.