> I have an a/d tied to a fuel level sender, and am > trying to smooth the resultant value so that any quick > fluctuations in fuel level are dampened out (tilting > the tank, bumps, etc.) I've thought of a push/pop > stack scheme to average but am afraid that would > consume too much memory. I've also thought of > sampling the a/d once a second and taking an average > over ten seconds... I like to sample the A/D as fast as possible and filter in software. I've mentioned this many times, so see the archives for details. An easy software single pole filter is: FILT <-- FILT + (NEW - FILT) * FP Where FILT is the filtered value, NEW the new measured input value, and FP the filter pass parameter from 0 to 1. Note that you can cascade these to create multi-pole filters. I like to use two, assuming the cycles and memory are available. In your case, the input is changing very slowly from the PIC's point of view. The easiest FP to implement is 1/256, which means the mutliply is just picking off the high byte. Two filters with FP of 1/256 have a 50% step in 429 iterations. If you want the 50% step response time to be 10 seconds, then you need to do an iteration in 10sec / 429 = 23mS. The 90% step response time will be 23 seconds, and the 99% step response time 40 seconds. Sounds plenty fast enough to measure the level in a gas tank and should smooth out the sloshes nicely. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads