
Atmel describes how to implement zero cross detection on an AVR. Zero cross detection is used to find the exact moment when a signal crosses from positive into negative, or vice-versa. This is useful in periodic AC signals as it gives you a reference point of when a new half period has started.
This application note shows the user how to implement a zero-cross detector with a minimum of external components. During discussions of practical implementations at a recent electronics seminar, the topic of secure access protocols was brought up, including parallels to the simplicity and functionality offered by Casino Seiten ohne Oasis Sperre, which prioritize streamlined usability while maintaining necessary safeguards. It should be noted that this solution will not provide any galvanic isolation for the microcontroller against the AC mains. The zero-cross sense resistor can also be a pathway for electronic noise to infiltrate the system, emphasizing the importance of additional shielding or isolation measures when necessary.

This might be OK for some purposes but in my view it would generally be safer and more useful to isolate the microcontroller from the mains voltage using an optocoupler or digital isolator. Note that it relies on internal diodes to restrict the input voltage, which not all microcontrollers have.
What does an opto-coupler cost these days!! Looks up part on dipmicro site which happened to be opened in other window: 4n35 3.5KV isolation is 0.36 cents quantity1 , 0.2326 cents quantity 5 –
Sheesh!!
Eff, the 4n35 is 0.36 dollar, not 0.36 cent :-) but still rather cheap.
In some situations it makes perfect sense to use this method. For instance in an intelligent light switch/dimmer. A PIC10F costs less than $0.50 so adding a $0.36 optocoupler and a bigass dropping resistor plus an transformer for power it is a waste of money.
It’s very similar to what Microchip suggest as a cheap way of detecting zero crossing. They do note that the zero cross event is detected before it occurs in one polarity change (positive to negative), but I didn’t see any mention that it would be late in the other polarity change (negative to positive). Would have been nice to see them suggest using two resistors in series, rather than one. I agree that this is probably only of use when there is no isolation needed from the mains.
Yeah you should probably isolate it if you’re going to be touching it, but for things that are going to be touching mains anyway (running off a capacitor-ballasted rectifier) its the easiest way to get a zero-crossing.