ADC with reference voltage


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2009
    Location
    USA
    Posts
    16

    Default ADC with reference voltage

    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)

    Code:
    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).
    Why is the email address verification case sensitive?

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default

    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.

  3. #3
    Join Date
    May 2009
    Location
    USA
    Posts
    16


    Did you find this post helpful? Yes | No

    Default

    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?
    Why is the email address verification case sensitive?

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default

    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.

  5. #5
    Join Date
    May 2009
    Location
    USA
    Posts
    16


    Did you find this post helpful? Yes | No

    Default

    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.
    Why is the email address verification case sensitive?

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts