Dario Greggio wrote: > Basically I need to measure 220V mains, Measure the actual voltage? Peak? RMS? What? > by mean of a 220->6 tiny > transformer and a partitor and a protection diode, staight into a > PIC's ADC. So the 0 value is Vdd/2 and the peaks are within the A/D range? > I'm sampling the sine every 1mS and was wondering of a FFT or average > or else... I need some 5% accuracy. It sounds like you are trying to measure the mains voltage, so it being close to a sine wave is a good assumption. I don't see anything useful a FFT is going to do for you, although it's still not clear exactly what you want out. If you have the memory, you could keep the last 20 samples, which will always contain the most recent top and bottom peaks. Each sample is spaced 18deg apart, so there is always a sample within 9deg of each peak. COS(9deg) = 0.988, which is well within your 5% error tolerance. In other words, peak detection of your samples yields at most 1.2% error due to missing the peaks a little. The max minus min of the stored samples gives you the peak to peak voltage. That divided by 2*sqrt(2) yields the RMS voltage, assuming sine wave. There are a lot more details depending on what you want to do about short term spikes, harmnoic content, etc. If memory is a issue, there are ways to get the peaks without storing a whole cycle worth of data. ******************************************************************** Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products (978) 742-9014. Gold level PIC consultants since 2000. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist