??? 10/24/07 23:16 Read: times |
#146160 - And moving forward Responding to: ???'s previous message |
Christoph Franck said:
Jason, you wrote that you could not use a moving average (or other FIR) filter because you cannot wait for four samples to arrive, and that you think that an IIR filter would do a "better" job. You would also like to adjust the time constant of that IIR filter in a range that easily spans several orders of magnitude. Yes, it's working perfectly, the only downside is that my ADC reading is slow, but then, of course it is, it's going through a cr low pass filter. Christoph Franck said:
Are you aware that an IIR filter with a large time constant will also take several input samples in order to reach a stable output ? And that it may output values that are wildly different from the actual ADC input during its startup period (unless you mess with the filter internals and set the output value to the first sample at the start of the measurement, instead of starting from zero) ? Yes, I can switch out the cr low pass filter until E=Vc approx. and then switch it back in. I already have a push button/code whereby the end user can select whether the cr low pass is either 'in' or 'out'. Christoph Franck said:
Are you aware that filter time constants that are below ~5 times your sampling period will lead to numeric problems during the calculation ? (Simulation rule of thumb -> simulation step size should be at least 1/5 of the smallest time constant of the system) Yes, the end user can select 1..100 secs of integration. So the end user will not be allowed to venture below 1 sec, other than switching the cr filter out. Christoph Franck said:
These two points will already place some limits on sensible values for the time constant. Actually, a time constant of 3 to 8 secs works nicely. Christoph Franck said:
I still believe that a variable-length moving average filter would be the better choice for your purpose. Average up to X of the last available ADC output samples (less than X if not that many samples have been taken since the start of the measurement). This filter will give results that are close to the ADC output even during its settling time. Well, you might be happy to note that I'm going to build in a min/max/avg feature and from the average point of view at least, this will be a rolling average. Christoph Franck said:
You could also combine the moving average filter with a median filter (e.g. regard the last 6 samples, throw away the highest and the lowest value, and average the remaining 4). Well, given that the adc is a dual slope and therefore very slow, approx. 2 samples every second, I need to make every available sample count. My next step, in my development is work on how the '51 is going to generate the correct calibration. Cheers for now Jason |