Olin Lathrop ha scritto: > But how do you want to handle harmonics and spikes? Are you trying to > detect the spikes or want to filter them out? If you want more of a > smoothed RMS, what kind of response time? You can't start thinking about > the right filter until you know what you want it to accomplish. No, I need the Basic 220V, indeed filtered "somehow" - but my response time is in the range of 1-5 seconds i.e. less than an average multimeter. Basically, let's avoid spikes such as pumps starting etc. > If that's all you want, a simple peak detector followed by two low pass > filter will work nicely. You don't need to store 20 recent samples, only 1 > and a flag. As the samples come in, look for local minima and maxima. Each > go into separate low pass filters. You adjust the time constant and number > of poles of these filters to get the random noise reduction and reponse time > you want. Keep in mind that each filter will only be fed at the line > frequency of 50Hz. Every time you update the filters, the final filtered > maxima minus the final filtered minima times a fixed constant is the line > voltage. ok... I guess I get this too. Something like the "simple" (you showed it many times) new_value = (ADC_value+(old_value) ) / 2 done for both max and min. >> I also have to say that, after the IIR, overall sum of 20 samples does >> no longer yeld 0... ! > > Actually it should yield 20x whatever the representation of 0 line voltage > is in your system. If your input signal is offset by half Vdd and that is > not subtracted out then you will get 20x that offset. However, the AC > information you are looking for will be gone and only this "effective zero" > will be left. makes sense, and this is indeed a different application. Useful to know for the future :) -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist