> The Neutral terminal of the Mains is connected to a PIC input through a > 4.7M resistor for detecting zero crossings. (Some may consider this > dangerous, but since the power supply itself makes the whole circuit > "live", this doesn't make any big difference.) You should put some low pass filtering in there. You circuit will detect the zero crossings of the power line just fine, but it is very susceptible to noise near the zero crossing. A 5V spike near 0 will cause additional edges, and 5V is a very small noise spike as power line standards go. I would use two successive R/C filters to reduce the high frequencies, then measure the zero crossings. Of course now there will be some phase shift. I don't know if this is acceptable in your application. If the filters aggresively attenuate the line voltage (you've got plenty to start with), then the phase shift will be very predictable and quite independent of part value variations. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics