Bob Japundza wrote: > Andy, just one question. How would you change the code to handle > a 10-bit a/d sample? Probably not necessary in the case where I'm > determining fuel level (1/256 is plenty of resolution), but I'm > curious if it can be done yet kept simple. Bob: The code wouldn't be AS simple, but it certainly wouldn't be complicated; the fast that the moving window is 256 samples wide is the real key to making the implementation easy. > I suppose I could really make the fuel gauge rock-steady by using > this algorithm along with sampling around 250ms or so... Yes. A 256-sample window, with a sample taken 4 times per second, gives you a 64-second-wide window. If that's too wide, and you want to narrow the window without affecting the simplicity of the code, just call the filter routine multiple times per sample. -Andy === Andrew Warren -- aiw@cypress.com === Principal Design Engineer === Cypress Semiconductor Corporation === === Opinions expressed above do not === necessarily represent those of === Cypress Semiconductor Corporation -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics