> In my case I have to lock a PIC generated PWM 50Hz/60Hz sinewave > to the mains for power backfeed into the mains. > Do you think a software PLL is overkill? I was told a PLL > method is more immune to mains noise like spikes than a > zero crossing detector controlling the interrupt input. > > Also I can life with the ADC conversion latency in this > application, since a small phase error is allowable. > > Thanks! > > Daniel... You are right, zero cross detection will pick up all the noise on the line, but better detection relies on averaging detection (with deliberately poor filtering) followed by differentiation. This detects the peaks and should give you less troubles than a PLL. A PLL can be used too but a digital PLL must run on a 'high' harmonic of the input. This depends on the processor speed. If you manage to make a PLL with 100usec basic resolution in a PIC that also does something else meanwhile the phase error due to this should be 1% ish at 50Hz (assuming the PLL uses both semiperiods for input) (note that 1% is a relatively large error for mains phase. It represents the normal conduction angle of a peak rectifier and almost 2 degrees of phase). Depending on how much power you feed back this may be enough (remember that the phase error associated energy almost entirely turns into heat in your switching elements due to 'misunderstandings' between them and the mains). Will you publish your circuit ? Peter -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.