ADCON does not compile 16F628


Closed Thread
Results 1 to 4 of 4
  1. #1
    mslaney's Avatar
    mslaney Guest

    Default ADCON does not compile 16F628

    Hi there,
    Maybe you've [seen this/done this/fixed this...]

    PIC16F628
    If I try to compile with ADCON:
    symbol priviously undefined ADCON0 and GO_DONE

    If I try without ADCON: syntax error

    There is no reference to adcon in the datasheet.
    CMCON does nothing for me either.
    If the ANx pins are powered up as comparators, how do I set them to analog inputs to read a pot? Yes, I made an honest attempt at the datasheet.

    CODE:

    'Read a POT on AN0
    'Code converted from F876 to F628 to test ICD with realtime input

    'DEFINES
    Define ADC_BITS 8
    define ADC_CLOCK 30
    define ADC_SAMPLEUS 50
    define OSC 4
    define ADCON1
    cmcon = %00000001

    'VARIABLES
    adval var byte
    v_in var byte

    Init:
    portb = $00
    trisb =$0
    v_in = porta.1

    Main:
    trisa = %00000001
    trisb = %11111111


    loop:
    adcin v_in,adval 'Read channel 0 adval

    ledtst1:
    if adval > 5 then tst2
    portb = %00000001
    goto cont

    tst2:
    if adval > 10 then tst3
    portb = %00000011
    goto cont

    tst3:
    if adval > 20 then tst4
    portb = %00000111
    goto cont

    tst4:
    if adval > 40 then tst5
    portb = %00001111
    goto cont

    tst5:
    portb = %00011111

    cont:
    pause 100
    goto loop
    end

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Unhappy

    there's a simple answer to this. There's no analog to digital converter in the PIC16F628. You have only analog comparator. Wich is a big difference. This is also why you have those error message. If you want some PIC with analog to digital converter you may use the following
    PIC16F877,876...
    PIC12F675,683
    PIC16F819
    and many others.


    BTW if you want to have a POT reading, there's a function called POT or RCTIME that allow to do something like this in addition of one capacitor. Inputs must be set to digital to perform those statements. CMCON=7

    See PBP manual or Melabs website for some code examples.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default Re: ADCON does not compile 16F628

    Hi Mike,
    As far as I remember the 16F628 does not have an ADC.

    It does have comparators - there is a fine tutorial by Melanie either here or on the PicBasic list about using the comparators (search function available at www.melabs.com).

    Arch

  4. #4
    mslaney's Avatar
    mslaney Guest


    Did you find this post helpful? Yes | No

    Default

    Yes, you're right. I have mistaken pins RA0,1,2,3 / "AN0,1,2,3" for analog inputs rather than analog comparators. Doh!

    Thanks for the confirmation.

Similar Threads

  1. Unable to pass a variable to LCDOUT without getting compile errors
    By Ferroto Baggins in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th February 2010, 16:43
  2. Compile and Program help using PICKit2
    By ozarkshermit in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 10th March 2009, 14:51
  3. Replies: 2
    Last Post: - 9th February 2006, 22:03
  4. 16F628 problems
    By fowardbias in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 11th January 2006, 07:38
  5. SERIN2 not working with 16F628
    By d1camero in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 6th May 2004, 20:37

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