That is the question.

Most of the diagrams I have seen on the interwebs are of the opto-coupling school of thought:

enter image description here

enter image description here

But the AVR182: Zero Cross Detector application note just throws in the resistors like so:

enter image description here

I am headed for simplicity. Will this MCU directly plugged into mains stand any chance of surviving longer than a couple of uses in the real world ?

  • 3
    \$\begingroup\$ It is also a question of safety. The isolated circuits mean you can touch the low voltage sections, and not have any chance of getting zapped. \$\endgroup\$ – JRE Feb 27 at 11:51
  • \$\begingroup\$ The last one is good if you have a capacitive PSU, which is non-isolated mains powered application. With such application you have to be aware of shock hazzard. \$\endgroup\$ – Marko Buršič Feb 27 at 12:10

The 1 MΩ resistors are sufficient to reduce the voltage and current of the normal 110–240 VAC mains sine wave to a level that the AVR can handle.

However, the application note admits it's incomplete:

Any voltage higher than 1,000V would probably be spikes or surges. The clamping diodes are able to handle spikes for a short period of time but not surges. The application note will not go into how to protect against surges, but simply recommend implementing protection against surges in the design.

And, of course, the AVR chip is not isolated from mains, so you have to protect the entire circuit against touching. If you have something like a display or control panel, this will be much harder than just putting an optocoupler before the microcontroller.

  • \$\begingroup\$ there will be an LCD. Ok, I'll pick one from the first two. Is the first scheme any better than the second ? How ? \$\endgroup\$ – kellogs Feb 27 at 13:27

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.