Jay.slovak
Active Member
I have one small problem with my PIC18LF4320's AD Converter. I have calculated all necessary conversion times, But its not working OK. The source of the voltage is a Power supply (That's my school Project) and the AD input is Buffered with OPamp (Datasheet says that source impedance SHOULD NOT be grater that 2.5K). When I AD convert for example 50 values in 1mS intervals of the same Pin, and make an average value of them, it gives me the value that should be there.
Here's the Code:
Is there any way I can improve acurancy or is there a Mathematical Routine to make any average of 16 Ad values?
Help appreceated...
Here's the Code:
Code:
AD1
MOVLW b'00000100' ;Channel 1
MOVWF ADCON0
GOTO INITAD
INITAD
MOVLW b'00010110' ;Tad=3.2Ms, Tacq=12.86Ms Fosc=20MHz
MOVWF ADCON2 ;Timeing requirements
BSF ADCON0,0 ;Turn on AD
NOP
BSF ADCON0,GO ;Begin AD Conv.
BTFSC ADCON0,GO ;Done?
GOTO $-2 ;No, Wait...
MOVF ADRESH,w ;Yes, Value is in W
RETURN
Is there any way I can improve acurancy or is there a Mathematical Routine to make any average of 16 Ad values?
Help appreceated...