App note: Zero cross detector for AVRs

atmapp

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. It should be noted that this solution will not give any
galvanic isolation for the microcontroller against the AC mains. The zero cross sense resistor can be a way for electronic noise to get into the system.

Join the Conversation

5 Comments

  1. 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.

  2. 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!!

  3. 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.

  4. 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.

  5. 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.

Leave a comment

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.