ADC reading simple circuit?

Status
Not open for further replies.

Oinquer

Newbie
Joined
Mar 22, 2013
Messages
5
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Visit site
Activity points
1,312
Hello,

im doing an ADC reading of an 4.2 lithium battery, and i have a doubt about the circuit...
since my pic is 5V and im using a 4.2 max input im just connecting a small resistor to between VDD and AN2 from PIC to read it.
Im doing it right since i can read it... but the reading seems to slowly go up...should be oposite....do i need to put a weak pulldown to prevent voltage from "building up" or what?

someone with some experience migh help??

thank you.
 

Care to explain why adc needs protection? The cell is 4.2v, micro is 5v tolerant.
 

, made a fast circuit in eagle...

Code:
program LED

' Declarations section 
  dim tmp as word
  dim sas as string[10]
main:
    OSCCON= 0x7f
    ansela = 0x00
    anselc = 0x00
    FVRCON = 0xc1
    ADCON1 = 0xe3
    ADCON0 = 0x09
'   Main program 
    TRISC = 0x00
    TRISA = 0x00
    PORTC.2 = 0
    delay_ms(1000)
    PORTC.2= 1
    UART1_init(9600)
    UART1_Write(0xff)
while true

      ADCON0.1 = 1
      while (ADCON0.1)
      delay_ms(500)
      wend
      tmp =  ADRESH  << 8
      tmp = tmp +  ADRESL

      WordToStr(tmp, sas)
      UART1_Write_Text(sas)
      delay_ms(500)
wend
end.

Also...for about 5 hours i had the battery draining, and found that the readings are going up....
maybe im doing something wrong with the reading....
microcontroller datasheet **broken link removed**


Probably found error...
ANSELA.2 = 1
...testing now.
 
Last edited:

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…