ADCIN setup help need


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2008
    Posts
    4

    Unhappy ADCIN setup help need

    Here's the problem I have.

    I have used ADCIN using port a.0/ AN0 many times on many different projects with no problems, but I recently tried using a different port on the MCU for the ADCIN channel with no results. I'm using a 16f690 chip and portc.1/AN5. Can someone please help me with the proper setup for the ansel, adcon and adcon1 registers, as well as any setup for the TRISC settings to get the AD to work using the above channel or any other other channel besides the an0 channel. I usually don't have these problems, but this is driving me crazy. By the way, I'm also using a 5k pot connected to the portc.1 pin which reads 0-5v with my meter , so I know the electrical is good. I know I have to be doing something stupid in the setup.

    Thanks for the help,

    Dan

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Post the code you are using that works for the channel you normally use and then we can show you what needs changed.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Aug 2007
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Hi, I have just browsed through the datasheet, and if I were doing it, I would set the following registers:

    INTCON.7 = 0 'Disable interrupts
    TRISC.1 = 1 'Set PORTC.1 to be an input
    CM1CON0.7 = 0 'Disable Comparator module
    CM2CON0.7 = 0 'Disable Comparator module
    VRCON = 0 'Disable Voltage Reference module
    ADCON0.7 = 0 'Right justify result. Assumes 10 bit AD conversion
    ADCON0.0 = 1 'Enable ADC module
    ANSEL.5 = 1 'Set high impedance buffer on ANS5 (PORTC.1)


    Andy

  4. #4
    Join Date
    Feb 2008
    Posts
    4


    Did you find this post helpful? Yes | No

    Default ADCIN problem fixed

    Thanks Andy,

    While I was waiting for someone to reply, I broused the site and found what I was doing wrong. I always use all the stuff you said, but when I was using the ADCIN command, I was trying to read the port# not the AD channel number. Once I changed from the port# over to the channel number, everything worked perfectly. By the way, can anyone tell me why the ADCIN was working using the portA.0 address and not the channel # all the other times I used ADCIN. Just curious...PortA.0 is the only port that works this way. No other port does it. I can't find out why anywhere.

    Thanks,

    Dan

  5. #5
    Join Date
    Aug 2007
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Hi Dan,

    It may have been because PORTA.0 was currently at logic low, or as far as PBP is concerned, 0.

    Effectively, you were writing:

    ADCIN 0, Var

    Which would have read from PORTA.0 anyway...

    You could do the same to PORTA.1 if you pulled it high.

    Andy

Similar Threads

  1. ADCIN and PIC18F4331 Arghhhhh !
    By GrandPa in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th December 2010, 21:27
  2. ADCIN - setup of ADCON2
    By Lowell314 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 7th December 2009, 19:41
  3. ADCIN setup for PIC16F688
    By PixController in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 29th February 2008, 19:38
  4. Use Button For setup
    By tump in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 21st November 2007, 20:43
  5. help using adcin
    By harryweb in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 31st January 2006, 08:46

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