Paul Dietz Wrote: > There is a much better way! It is called a median filter. > Basically, this is just like a moving average (or more > generically, an FIR) filter, except that you take the median of > the data instead of the average. You do this by sorting the > data in the window by value, and then outputing the value which > ends up in the middle. > Alas! I have spent a couple days messing around with median filters. The first one I wrote pushed large values off the end of the sort stack, into lala land. It would never climb up. The next one pushed them off the bottom of the sort stack. Would never climb down. Finally I got one that read in 32 analog values, sorted them, and took the median as the setpoint. Code works. BUT the Relay fires whenever I hit the lamp on my bench. Noise immunity is still out of reach after a lot of hard work. Oh well, I know how to sort now. I fear the noise immunity is harder to buy than this. I see three avenues: 1. Go postal. 2. Try a longer time delay between measurements, until I get around the noise. 3. give up on median filters as being too complex, and going back to averaging. Another day, another $0.50 US. Best Regards, Lawrence Lile