Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

can any one fix my adc problem ?

Status
Not open for further replies.

de_student2003

Newbie level 2
Joined
Jan 9, 2006
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,312
i am using pic16f877 and facing a problem of converting my analog signal to digital signal. when i was using RA0 AND RA1 as my analog input and doing sampling, the output for these two input were interferencing. that is, when one analog input is fixed on certain analog signal, and the other analog input is varied every now and then, by theoretically, the varied input will be changing it digital output and the other fixed one will remain unchange. but now the problem is, mine one will affect the both digital output although only one analog signal altered and the other one maintain unchanged.

can any one help me to fix it.

what is mean by rc clock for sampling?? if i set to that mode, am i need to change the device clock to rc type?

Added after 4 minutes:

op....i tried to add attachment of my code...but it seen i have met a failure to do so

Added after 39 seconds:

LIST P=16F877
#INCLUDE <P16F877.INC>
ORG .0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ANALOG TO DIGITAL CONVERTER:: ;;
;; ANALOG INPUT: RA0 CONNECT TO X AXIS ;;
;; RA1 CONNECT TO Y AXIS ;;
;; RA3 CONNECT TO +5V ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

BCF STATUS,RP0
CLRF PORTA
CLRF PORTB
CLRF PORTC
BSF STATUS,RP0
MOVLW B'00000011'
MOVWF TRISA ;RA0/RA1 AS INPUT
MOVLW B'00000000'
MOVWF TRISB ;PORTB AS OUTPUT OF X AXIS
MOVWF TRISC ;PORTC AS OUTPUT OF Y AXIS
MOVLW B'11000000'
MOVWF ADCON1 ;RA0/RA1 AS ANALOG INPUT

;;;;;;;;;MAIN;;;;;;;;;
REPEAT
CALL CHANNEL0
CALL ADC_X
CALL CHANNEL1
CALL ADC_Y
GOTO REPEAT

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CHANNEL0
BCF STATUS,RP0
MOVLW B'01000001' ;FOSC/8 [7-6], RA0 AS INPUT [5-3], A/D on [0]
MOVWF ADCON0
BSF INTCON,ADIE
BSF INTCON,GIE
RETURN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CHANNEL1
BCF STATUS,RP0
MOVLW B'01001001' ;FOSC/8 [7-6], RA1 AS INPUT [5-3], A/D on [0]
MOVWF ADCON0
BSF INTCON,ADIE
BSF INTCON,GIE
RETURN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ADC_X
BSF ADCON0,GO ;START A/D CONVERSION
BTFSC ADCON0,GO ;WAIT UNTIL CONVERSION COMPLETE
GOTO $-1 ;ELSE CONTINUE CONVERTING
BSF STATUS,RP0
MOVF ADRESL,W ;AFTER DONE, STORE IN REGISTER
BCF STATUS,RP0
MOVWF PORTB
RETURN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ADC_Y
BSF ADCON0,GO ;START A/D CONVERSION
BTFSC ADCON0,GO ;WAIT UNTIL CONVERSION COMPLETE
GOTO $-1 ;ELSE CONTINUE CONVERTING
BSF STATUS,RP0
MOVF ADRESL,W ;AFTER DONE, STORE IN REGISTER
BCF STATUS,RP0
MOVWF PORTC
RETURN
END
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top