hello
i wrote this program below. I am putting the Vref- on the lead of a fourth diode in series . There are 4 diode connected in series so that there is always 1.6v . I assume the Vref+ and Vref- is always 2.6 differnce. It is doingan A/D convertion on a voltage divider with a max voltage of 2.5.
The problem is that My lcd always shows me 373 (10 bit a/d) no matter what the voltage input is. Any idea what is wrong.
SO , I have a voltage divider on the battery to bring the voltage down. Right now I am reading 1.03v with a supply at 4.57 and on the 4th diode I am reading 2.98v.
My voltage divider I have Vdd -51Kohm -15Kohm- Vss
'Battery test for transmit pic
INCLUDE "modedefs.bas"
@ DEVICE PIC16F88 , HS_OSC , WDT_OFF , PWRT_ON , BOD_ON , LVP_OFF , PROTECT_OFF
DEFINE OSC 20 'use external 20mhz crystal
DEFINE LCD_DREG PORTB ' Set LCD Data port
DEFINE LCD_DBIT 4 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
DEFINE LCD_COMMANDUS 2500
DEFINE LCD_DATAUS 250
DEFINE CHAR_PACING 2000
' Define ADCIN parameters
Define ADC_BITS 10 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
ADCON1 = %10100010
TRISA = %11111111 ' Set PORTA to all input
TRISB = %00000000
input1 var word
loop:
ADCIN 0, input1
'pause 30
Lcdout $fe, 1 'Clear screen
Lcdout "Left: ", Dec input1
Pause 100
Goto loop ' Go back to loop and blink LED forever
End
Bookmarks