piclist 1998\10\03\151920a >
Thread: A/D filter
www.piclist.com/techref/logic/dsps.htm?key=filter
picon face BY : Steve Smith email (remove spam text)



In a message dated 02/10/98  05:16:55, you write:

<<
Hi !
In my application with a PIC16C84 I have to filter a continuos data stream
from an A/D converter.
The following algorythm         FILTRO = (a_d+(Kf-1)*FILTRO)) / Kf

        where         a_d = value supplied by A/D converter (range 0 - 255)
                        Kf  = filtering coefficient  ( 4 - 16 )

It doesn't supplies exact results, because of the rounding introduced by
integer math.  In fact the maximum value that FILTRO reaches is (255-Kf-1).
I use the AN526 unsigned 16 bit math routines .
Some suggestion to fix this problem ?
Or someone has a good solution for my aim ?
 >>
a possable soulition which uses two consecutive reads and rounding this could
be expanded to 4  8 16 bits easy its for a '74 but will port across easy

CALL    GET_VOLTAGE     ; GET THE ANALOGUE VOLTAGE REPRESENTING VOLTAGE
       MOVFW   ADRES           ; MOVE ADC RESULT INTO W REG
       MOVWF   VOLTAGE_0       ; SAVE RESULT IN VOLTAGE REG

       BCF     STATUS,C        ; CLEAR THE CARRY FLAG
       CALL    GET_VOLTAGE     ; GET THE ANALOGUE VOLTAGE REPRESENTING
VOLTAGE
       MOVFW   ADRES           ; MOVE ADC RESULT INTO W REG
       ADDWF   VOLTAGE_0,F     ; ADD NEW VALUE TO LAST READING IN VOLTAGE REG
       RRF     VOLTAGE_0,F     ; DIVIDE VOLTAGE BY 2 TO AVERAGE
       BTFSC   STATUS,C        ; CHECK THE CARRY BIT
       INCF    VOLTAGE_0,F     ; IF THE CARRY IS SET, INC THE VOLTAGE REG

Cheers Steve..........

<46409b8e.36167832@aol.com> 7bit

See also: www.piclist.com/techref/logic/dsps.htm?key=filter
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) A/D filter

month overview.

new search...