Hello Friends
PIC16f690 @ 4mhz internal clock
Reading voltage at AN9 0vdc ~ vdc 4.46
Vdd as ref @ 4.46vdc
AN9 input via 5k pot with vdd as 4.46 and Vss as 0.00
The voltage on the DMM at pin AN9 and the result is off a few milli volts
any ideas ?
Thanx
Mastero
PIC16f690 @ 4mhz internal clock
Reading voltage at AN9 0vdc ~ vdc 4.46
Vdd as ref @ 4.46vdc
AN9 input via 5k pot with vdd as 4.46 and Vss as 0.00
Code:
'PIC16F690
Define CONFIG = 0x30f4
Define CLOCK_FREQUENCY = 4
AllDigital
Define SIMULATION_WAITMS_VALUE = 1
'------------------------------------
Dim digi3 As Byte
Dim digi2 As Byte
Dim digi1 As Byte
Dim digi0 As Byte
Dim temp As Word
Dim binval As Word
Dim volt As Word
'------------------------------------
ADCON0.ADON = 1
ADCON0.VCFG = 0
ADCON0.ADFM = 0
ADCON1 = 0x00
ADCON1 = %01010000
ANSELH.ANS9 = 1
TRISA = %00000000
TRISB = %00000000
TRISC = %10000000
'------------------------------------
Define LCD_BITS = 4
Define LCD_DREG = PORTC
Define LCD_DBIT = 0
Define LCD_RSREG = PORTA
Define LCD_RSBIT = 0
Define LCD_RWREG = 0
Define LCD_RWBIT = 0
Define LCD_EREG = PORTA
Define LCD_EBIT = 2
Define LCD_READ_BUSY_FLAG = 1
Lcdinit
Lcdcmdout LcdClear
main: 'main loop
Gosub readadc
Gosub bin2asc
Lcdcmdout LcdClear
Lcdout "Volt: ", digi3, digi2, ".", digi1, digi0
Goto main
End
readadc:
Adcin 9, volt
If volt > 0 Then
volt = volt / 2
binval = volt
Endif
Return
bin2asc:
digi3 = binval / 1000
temp = binval Mod 1000
digi2 = temp / 100
temp = temp Mod 100
digi1 = temp / 10
digi0 = temp Mod 10
digi3 = digi3 Or 0x30
digi2 = digi2 Or 0x30
digi1 = digi1 Or 0x30
digi0 = digi0 Or 0x30
Return
The voltage on the DMM at pin AN9 and the result is off a few milli volts
any ideas ?
Thanx
Mastero