A2D on PIC 16F685


Results 1 to 8 of 8

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Forkosh View Post
    It worked!
    But how would I change it to read AN0 and AN1

    How do I change the program to read multiple channels?
    Quote Originally Posted by Forkosh View Post
    which PICs work with the ADCIN command? WHich one that you used worked with that command?
    Code:
      ADCON0.1=1       ' Set GO/DONE bit to start A/D conversion
      WHILE ADCON0.1=1 ' Wait for it to complete
      WEND
      adcVar.HighByte = ADRESH ' Read high-byte of result
      adcVar.LowByte = ADRESL  ' Read low-byte of result
    Instead of the part above, you may try
    ADCIN 0, AdcVar

    and to continue with multiple channels, you may try
    ADCIN 1, AdcVar1
    ADCIN 2, AdcVar2

    etc.

    ADCIN command will take care of setting ADC registers etc.


    Edit:

    Here is another version of reading as many ADC channels as available on your PIC.

    Code:
    NumOfCh CON 7                   ' Number of Analog Channels we will read. 
                                    ' Change this number as desired.  
    
    AdcValue   VAR BYTE[NumOfCh+1]  ' Array to store ADC Values in a row.
    Channel    VAR BYTE             ' Loop variable to go through channels.
    
    Start:
    
        FOR Channel = 0 TO NumOfCh      ' Will read 7 analog cannnels and store  
            ADCIN Channel, AdcValue[Channel]    '..ADC values in AdcValue Array.
        Next Channel
        
    ' do something here.
    
    GOTO Start
    Last edited by sayzer; - 16th October 2007 at 15:08. Reason: Added Array.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. SMS via pic
    By kenandere in forum GSM
    Replies: 15
    Last Post: - 10th March 2010, 10:00
  2. Replies: 67
    Last Post: - 8th December 2009, 02:27
  3. HSERIN & Interupts (aka controlling PIC programs from a remote PC)
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 17th June 2009, 14:46
  4. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

Members who have read this thread : 0

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