PDA

View Full Version : Voltage Ref Problem



jcon777
- 2nd January 2012, 18:57
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!

HenrikOlsson
- 2nd January 2012, 19:25
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.

Charles Linquis
- 3rd January 2012, 03:05
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

jcon777
- 3rd January 2012, 09:37
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

Charles Linquis
- 4th January 2012, 02:12
Are VA and VA1 WORD variables?

jetpr
- 7th January 2012, 02:59
'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