This could easily ignite the Average vs Median debate that took up so = much bandwidth about two years ago. I am convinced that median filter = techniques are superior to averaging, for this reason: Say I have some = pulse noise, with a nasty 60 hz hum superimposed on it (that's probably = what I'm dealing with): 3.0, 3.1, 2.9, 3.0, 3.1, 2.9, 1.0, 3.0, 2.9, 3.1 What is the average? 2.8 by my calculation=20 What if you eliminate the last data point? the average is 2.76 = hmmmmm....=20 What is the best representation of the data? 3.0, the median, no matter = how many data points we have. Also accurate averaging requires at least 16 bit math - with 8 bit math = rounding errors add up to gitcha. I'm trying to avoid hogging memory = with yet another 16 bit divide routine. Median is very code efficient. I think I am convincing myself that this would not work well anywhere = close to 60 or 120 hz X2 Nyquist sample rate - you are better off with = 4 or 5 or 8 samples during each cycle, and sampling over a few cycles. = Nyquist was an optimist, just like Murphy! So far I have figured on having a low pass RC filter on the input tuned = to attentuate 60 hz severely. =20 I am curious about a "software low pass filter" technique mentioned in = another post.... ----- Original Message -----=20 From: David VanHorn=20 To: Lawrence Lile ; PICLIST@MITVMA.MIT.EDU=20 Sent: Tuesday, November 07, 2000 9:38 AM Subject: Re: [PIC]: The tintinnabulation of the noise >Let's see: 120 hz =3D 8.33 milliseconds per oscillation. If I sample = at twice this, that's 4.33 milliseconds. sampling at exactly twice is = cutting it fine, so say we sample at four times that's ~2 milliseconds. =20 > >I've got enough memory to increase the number of samples, maybe that = will help as well? =20 This only helps you pick up the noise.. If you want it to go away, you need to narrow your bandwidth, by = averaging. If you take one sample per second, and the sample is an average over = the 1S period, then you won't see any 60 Hz noise. If you just take a 1uS = sample once a second, then you will get the full value of the 60 hz noise, wherever in it's waveform you happen to snag it. An input RC with a = long time constant will work, but you'll have to adjust the time constant depending on any other requirements in the system. You could also take multiple samples at some rate that is an integer multiple of 60 Hz, and mathematically average them. It's important = that you take an integer multiple of samples though, because otherwise you'll = be left with a "stub" of a cycle that won't average out.=20 It gets stickier if the noise can be amplitude modulated. Then the cleanest technique is to average in hardware. -- Where's dave? http://www.findu.com/cgi-bin/find.cgi?kc6ete-9 -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu