PDA

View Full Version : Atod Digital Filter



GeoJoe
- 29th March 2008, 16:48
Hi all,
I'm trying to digitally filter a noisy adcin value.
Here is what I've tried.
adcin 4, current ' INITIALIZE CURRENT MEASUREMENT FILTER
CURRENT1 = CURRENT1 - CURRENT1 >> 6
CURRENT1 = CURRENT1 + CURRENT
CURRENT = CURRENT1 + CURRENT

I expect this to give me an RC filter equivalent measurement with a time constant based on the clock and measurement frequency. I already have RC filter hardware in the circuit that works pretty good, but the measurement is still not very stable. I am measuring an amplified current sense ic output for a buck converter. The current measured with a current probe on a o-scope shows about 1 amp ripple.

Without the filter code the reading jumps about +/- 25 points (Decimal ATOD value displayed on an LCD.) With the filter and no current running to measure at all the value is decimal 400!


Any suggestions on a better filter algorythm?

mackrackit
- 29th March 2008, 17:02
Have you tried putting a capacitor from the ADC in pin to ground? 22uf or larger. Might be easier than doing it in software.

Then after that do an average routine.

ADC_AVG = ADC_AVG + ADCIN
maybe five times in a for/next loop. Then divide ADC_AVG by five.

mister_e
- 29th March 2008, 17:36
Schematic and the WHOLE code would help.

and this one...

CURRENT1 = CURRENT1 - CURRENT1 >> 6
not sure how it will be processed...

CURRENT1 = CURRENT1 - (CURRENT1 >> 6)
could be better.

What's the initial value of CURRENT1?

Darrel did some nice average routine, maybe you want to have a look at it?
http://www.pbpgroup.com/modules/wfsection/article.php?articleid=7

GeoJoe
- 2nd April 2008, 17:04
CURRENT1 = CURRENT1 - CURRENT1 >> 6
Works great. Seems so clear now.