Marechiare wrote: > Detecting peaks is not a good idea in my opinion. Much better advice > was: > >> Trying to detect the peak value and scale that is IMO a bad idea >> because a single brief spike could throw the reading way off. True, but you can filter first and then detect the peaks. Each peak is then the result of a bunch of input samples, and therefore random noise is attenuated. I the simulation I posted here some days ago, I passed the raw samples thru two poles of low pass filtering, each with a filter fraction of 1/4. That means random noise is attenuated by 16. >> Taking the average of the magnitude and scaling it would probablly >> be a reasonable option. True RMS is also pretty easy to calculate >> (square the individual values, average them and take the square root >> at the end) True RMS requires much more computation. It all depends on how much harmonic content you expect the input to have, and how much you care if it does. Since he is measuring the power line, the harmonic content should be quite low such that little is gained from true RMS. ******************************************************************** 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