>> Continuing on with the above idea.. >> If you need to convert your ADC value to engineering units, and are >> oversampling to do the low pass filtering, you can make the >> oversampling do the multiply portion of the scaling calculation. >> >> ie: suppose, Humidity = ADC_VALUE * 1.73 ( or whatever) then >> just accumulate 173 samples, saves doing the scaling calculation. > > Ray: > > Maybe I'm missing something, but it seems to me that summing 173 > samples and discarding the low byte will give you > > ADC_VALUE * 173/256, NOT ADC_VALUE * 1.73. > > If you really want to scale your input by 1.73, you'll need to > sum 443 samples (i.e., 256 * 1.73 samples) before discarding the > low byte. > > -Andy Correct, however, depending on signal characteristics it's probably not nessessary to discard all of the low byte. However much you right-shift by needs to be included in the scaling. A simple filter algorithm that provides "RC type" low pass filtering that is easy to implement. Totalizer + Input - Previous_Output Output = ------------------------------------ N Notes: 1. Choose a value for N = 2^X ( ie 128,256,512 etc) makes the division fast and simple. 2. Sample input at equal time intervals. (probably not critical) 3. Initialize Totalizer to Input*N, or Zero ( application dependant) Ray Gardiner (DSP Systems) ray@dsp-systems.com http://www.dsp-systems.com private email to:- ray@netspace.net.au