A/D versus Digital I/O


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    dallennn's Avatar
    dallennn Guest

    Question A/D versus Digital I/O

    I am using PBPro programming the 16F876 for both analog and digital use. I see that the command ADCON1 needs to be set for these purposes. I need 1 A/D channel and as much digital I/O as I can get. Is there a way - or how do I set up the ADCON1 command to enable A01 as the analog input and A02-A05 as digital?
    Do I also have to set up any other command?

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Take a look at this post first.
    http://www.picbasic.co.uk/forum/showthread.php?t=4880

    And try to come up with a register setting and then post it here.

    We can then check if you made it right or wrong.

    So you can understand how to make it.





    ---------------------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Hi Dallennn & Sayzer. I use the ADC's on 16F872 frequently. I just make them all digital, then declare the input. When you use the adcin command, it automatically converts it to a byte size analog input. Example using ra0 as ADC input:

    trisa = %00000001 'ra0 input
    adcon1 = 7 'all inputs digital
    x var byte 'place to put the ADC reading

    start:
    ADCIN 0,X 'read adc value & put into x

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Hi peterdeco1,

    Never tried that before.

    Sounds a quick jump to actual reading procedure.

    Since you say you have done it and it works, I now learn something new.

    Thanks for the info.


    ----------------------
    Last edited by sayzer; - 31st October 2006 at 14:49.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  5. #5
    dallennn's Avatar
    dallennn Guest


    Did you find this post helpful? Yes | No

    Smile It works!

    Hi peterdoco1 and Sayzer,

    Peterdoco1, I first tried your solution and it worked! And that is:
    trisa = %00000001
    adcon1 = %00000111

    Sayzer, I then looked at and tried your solution and it worked! Your solution was to look at the register table for adcon1 and find the the values for that which I wished to do which is: ra0 = analog and ra1-5 as digital. This gave me a value of:
    trisa = %00000001
    adcon1 = %00001110
    Is that what you would have used?
    I did have one small problem getting ra4 led to turn on until I remembered that ra4 is open drain.

    dallennn

  6. #6


    Did you find this post helpful? Yes | No

    Default

    Hi Dallennn. You said ...ra0 = analog and ra1-5 as digital. This gave me a value of:
    trisa = %00000001
    adcon1 = %00001110

    As I mentioned previously, I always let the software do the work for me and will work for word variables too. But one thing I see in your post above is the trisa register is set for ra0 input, the rest all outputs.

Similar Threads

  1. Digital Out on an A/D pin safe ?
    By mr.sneezy in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st January 2009, 23:48
  2. 12f675 A/d Miseries
    By MARAD75 in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 16th December 2008, 03:16
  3. 12F675 A/D and GPIO sleep interrupt
    By macinug in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 8th September 2008, 15:39
  4. A/D converter fails?
    By egberttheone in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 13th February 2006, 19:57
  5. digital I/O
    By igeorge in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 28th December 2005, 01:56

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