PDA

View Full Version : ADC with reference voltage



GoldStar
- 20th May 2010, 19:45
Hello I am trying to get ADC working on the 16f684 for the first time. I actually have it working for VDD reference but I can't get the Vref working right. For my project I want two analog inputs plus the analog Vref input (AN0 - AN2) I am using PWM output as well on RC5 (CCP1)



PortA = %00000000
TRISA = %00000111
PortC = %00000000
TRISC = %00000000
'ADC Registers
ADCON0 = %11000001
ADCON1 = %00000000
ANSEL = %00000111


It looks like everything is correct, (right justify, external vref, Fosc/2, ADon) and my three analog channels. The problem is that when I do a conversion from AN0 any voltage above 1.5 maxes out the ADRESH and ADRESL (all set to ones). My reference voltage is 12 volts and I'm using internal RC oscillator (4MHZ) which limits my ADC resolution to 7 bits.

I have changed my ADCS to FOSC/16 as recommended in the PDF and still have the same problem. It also seems that for AN0 when I apply a voltage above VDD the pic limits the voltage to VDD (using a 10K pot to set the voltage).

HenrikOlsson
- 20th May 2010, 20:05
My reference voltage is 12 volts
Come again.... 12V, that's way to high. Maximum voltage on the Vref pin is whatever the supply voltage for the chip is currently. If there's a "." missing in there and it shoudl read 1.2V then that won't work either as the low limit for Vref is 2.2V. See table 15-9 in the datasheet.


It also seems that for AN0 when I apply a voltage above VDD the pic limits the voltage to VDD
Yes, naturally because the inputs have protection diode from the input to both Vss and Vdd so they'll clamp the voltage to one diode-drop above or below Vdd and Vss respectively.

/Henrik.

GoldStar
- 20th May 2010, 20:18
You know I was just reading the absolute maximum ratings for each pin and it says 0.3+Vdd for any pin other than VPP/MCLR. So the mystery is solved then? The pic ADC doesnt work for voltages higher than VDD?

HenrikOlsson
- 20th May 2010, 20:44
Correct, you'll need to scale down the voltage so it gets within the specs of the chip in general as well as the ADC.

And those 0.3V is the voltage drop across the protection diodes on the pins. As soon as the voltage on the pin goes above Vdd+0.3V the diode gets forward biased and "shorts" the input to Vdd - basically.

/Henrik.

GoldStar
- 20th May 2010, 21:01
More and more I work with the PIC I am having more respect for it. They are designed very well especially for newcomers and people who don't read the manual unless it doesnt work. I will redesign my analog inputs then to spec then.