??? 10/21/07 18:07 Read: times |
#145975 - Averaging/DSP/FIR filters Responding to: ???'s previous message |
Christoph Franck said:
There are many ways to implement a digital low-pass filter, and trying to imitate a RC lowpass might not even be the best idea. The simplest way to "stabilize" the last digit would be to use a simple moving average filter, i.e. take the last X ADC outputs, add them together, divide by X, and that's your "stabilized" filter output. Of course, using a power of 2 as X has quite a few advantages, such as making the division by X a simple bit-shift instead of an actual division. Yes, the above method does stabilise the reading but there are two problems with it. 1) you need to take at least 20 or 50 samples in succession 2) In order to perform(1) only high speed SAR_ADC's are applicable, what about a 200 000 count dual slope converter which I'm using, typically 50 samples equates to at least 20 seconds! Christoph Franck said:
All other filters will quite quickly start diving into the realm of digital signal processing. DSP, huh!, well the Fluke 45 uses the 6303 MCU, the Fluke 8840/42 uses the Z86-Zilog MCU, hardly DSP class processors? and yet readings from these meters are encredibily stable. I am using an AT89S52 and the TC500A D/slope ADC(200 000 counts(overclocked)) each reading (including precharge and auto_zero) takes approx. 400mSec, so my MCU twiddles its fingers inbetween,eh! Christoph Franck said:
If you want to imitate an actual analog filter (such as RC), you'll have to use an IIR digital filter (infinite impulse response). Unless you're aware of the can of worms that you're opening by using this type of filter (it's recursive, so it may be unstable, depending on the parameters, and it has some additional pitfalls as far as numerics go), you might want to stick with the very simplest of IIR filters, like Y(n) = X(n) + a * Y(n-1) or Y(n) = 0.5 * (X(n) + X(n-1)) + a * Y(n-1). (Y is the filter output, X is the filter input. a affects the time constant and the gain of the filter, and needs to satisfy -1 < a < 1 for the filter to be stable, and 0 Wow!, how about we start with a first order differential equation, you know, the one that actually governs the CR circuit universally? Cheers Jason |