'Subroutine to get pot x value
getposval:
ADCON0 = 41h 'Set A/D to Fosc/8, AN0, On
Gosub getad
posval = adval
Return
'Subroutine to get pot negval value
getnegval:
ADCON0 = 49h 'Set A/D to Fosc/8, AN1, On
Gosub getad
negval = adval
Return
'Subroutine to get 5v current value
getfive:
ADCON0 = 51h 'Set A/D to Fosc/8, AN2, On
Gosub getad
five = adval
Return
'Subroutine to get variable amps value
getvaramp:
ADCON0 = 59h ''61h 'Set A/D to Fosc/8, AN3, On
Gosub getad
varamp = adval
Return
'Subroutine to get temperature value
gettherm:
ADCON0 = 61h 'Set A/D to Fosc/8, AN4, On
Gosub getad
therm = adval
Return
getad:
WaitUs 50 ''pauseus 50 ' Wait for A/D channel acquisition time
ADCON0.2 = 1 'Start conversion
While ADCON0.2
Wend 'Wait for it to complete
adval.HB = ADRESH 'Write conversion result
adval.LB = ADRESL
'''adval = adval * 2
WaitMs 2 ''pause 2
Return