At 11:35 AM 5/12/2005 -0500, you wrote: >Finally got around to implementing/trying some proportional filtering [ >N=N+(N-L)*K ] in one of my pieces of PIC code (which is essentially a >frequency counter). This thing is sweet! I've experimented with K=1/4, 1/2, >and 3/4. For my app, 3/4 works well (but I still have a bit of averaging in >there still, since I'm experimenting with combinations of averaging and >proportional filtering). > >BTW, I chose these constants since they made for some simple assembly code. > >Curious about one thing though -- anyone have a correlation or calculation to >compare software proportional filtering to an RC filter? Or asked another >way -- how do I determine the equivalent hardware filter time-constant for a >proportional software filter? I'm sure the update rate of the calculations >will be a factor here. > >I don't really need this for anything specific, just think it will be an >interesting tidbit of info. > >Cheers, >-Neil. This simulates a single-pole RC low pass filter with time constant tau = Ts * (1/K - 1) (where Ts is sample period) So, if you want tau = 0.5 seconds and you are sampling 20 times a second (Ts = 0.05) then you'd use K = 1/9 . The output never quite reaches the input (with infinite precision math), so it's an IIR filter. With a step change the error after t time is % error = 100% * exp(-t/tau)). So with 0.5 second tau, after 5 tau (2.5 seconds) you'd have an error of about 0.7%. Best regards, Spehro Pefhany --"it's the network..." "The Journey is the reward" speff@interlog.com Info for manufacturers: http://www.trexon.com Embedded software/hardware/analog Info for designers: http://www.speff.com Inexpensive test equipment & parts http://search.ebay.com/_W0QQsassZspeff -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist