This is a multi-part message in MIME format. --bound1058415873 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit Cool! I appreciate the code. I will give it a try. Very elegant and simple. Regards, Bob Andrew Warren wrote .. > Bob Japundza wrote: > > > I have been thinking about the tanks sloshing around as being > > noisy signal, and that is one of the reasons why I've been > > contemplating the median filter. Do you have a better suggestion? > > Seems to me that a straight low-pass filter would work well. > > > I tried an analog low-pass RC filter, and didn't have good luck > > with it, because of the low resistance of the senders (30-240 ohm > > Stewart-Warner float types) and not to mention it made me nervous > > to have large caps tied to the fuel senders, in an airplane, no > > less. > > Try a digital low-pass filter. Given a series of input samples > in the range 0-255, this code (all 7 words of it) should perform > a 256-sample moving-window average and give you the filtered > result in AVEHI. > > ; Run this on every input sample. Enter with the new input > ; sample in NEW. Exits with filtered result in AVEHI, and > ; NEW unchanged. > ; > ; Might want to initialize AVEHI to something reasonable at > ; program start; if it were me, I'd probably just initialize > ; AVEHI to the first input sample. > ; > ; (WIDTH-1)*AVE + NEW > ; AVE = ------------------- > ; WIDTH > > AVEHI EQU [ANY FILE REGISTER] ;Holds the average [0-255]. > AVELO EQU [ANY FILE REGISTER] ;Holds the fractional part > ;of the average. > NEW EQU [ANY FILE REGISTER] ;Holds the new sample. > > FILTER256: > > MOVF AVEHI,W > SUBWF NEW,W > SKPC > DECF AVEHI > ADDWF AVELO > SKPNC > INCF AVEHI > > -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: PICList Posts must start with ONE topic: > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads -- 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 --bound1058415873--