-
Voltage Ref Problem
Marry Christmas and Happy New Year everyone!
I am using pic12F675, picbasic pro compiler.
I use ADCON0.6=1 uses GPIO.1 as Vref then ADCIN 0, VA it works ok
then I use ADCON0.6=0 to use the Vdd as Vref then ADCIN 3, VA1 it will not work...no readings
Adin 0 uses external Vref and Adin 3 uses the VDD
how can I read both 0 and 3 with different Vref
I use the following:
ADCON0.6=1
ADCIN 0, VA
ADCON0.6=0
ADCIN 3,VA1
what is the problem? can't I use different Vref in the same program?!
Please help!
-
Re: Voltage Ref Problem
Does it give you a reading if you don't switch VRef?
I'm guessing you have the TRIS and/or ANSEL set wrong for the particular pin (GP4) but you don't show that part of your code so it's hard to say.
/Henrik.
-
Re: Voltage Ref Problem
Do you have ANSEL set to %00011011 ?
ANCON0.7 = 1 ?
TRISIO.0 = 1
TRISIO.1 = 1
TRISIO.4 = 1
My guess is that you have the Vref pin configured as digital, or as an output
-
Re: Voltage Ref Problem
This is what I have set:
trisio = %00011011
ANSEL = %00001011
CMCON = %01010111
ADCON0.7 = 1 ' Set PORTA analog and right justify result
ADCON0.6=1
ADCIN 0, VA
ADCON0.6=0
ADCIN 3,VA1
Thanks for help
-
Re: Voltage Ref Problem
Are VA and VA1 WORD variables?
-
Re: Voltage Ref Problem
'For global reference to system voltage, use the Voltage variable, which is based on a
'scale of 1 to 1000, with 775 = 7.75 volts. Remember that the resistors on the board
'divide the actual battery voltage in half so the ADC can "digest" it without damage.
'ADCIN voltages are limited to 5. Both EGT and Voltage are compared with the onboard
'precision voltage reference which delivers a perfect 5V.
'**Voltage**
LCDVLow=0
LCDVHigh=0
Voltage=0
ADCIN VoltChannel, Voltage 'Take just 1 voltage sample. 7.6V = 194
' SerOut LCDScreen, T9600, [LCDCmd, LCDLine1,"VoltsX=",#Voltage] 'RPM
' PAUSE 2000
Voltage = Voltage * 4 '194 * 4 = 776
LCDVHigh = Voltage / 100 '776 / 100 rounds to 7
LCDVLow = (Voltage // 100) / 10 '776 // 100 = 76, 76 / 10 = 7
LCDVLow = LCDVLow - 2
'Final Display = 7.7