18F1320 ADC multiple channel select


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305

    Default 18F1320 ADC multiple channel select

    According to the datasheet you have to select each channel as you want to read it using ADCON0. I want to be able to display 3 values at the same time an a 4x20 VFD. I presume I have to set it up where I change ADCON0 for each channel I want to read, then send to the VFD, go back, set ADCON for the next ADC channel and send that to the next line on the VFD etc etc.

    Is there a simpler way to do this?

    Here is a simple piece of code I wrote that reads a value and displays volts, the ADC count and junk to fill the other 2 lines.
    ADCON1 selects which channels are set to analog inputs, and ADCON2 sets clock source and justification.
    I want the value of ADCIN 4 on line 1, ADCIN 5 on line 2 and ADCIN 6 on line 3 with two words on the 4th line which will be above buttons on the front panel - kind of like a menu system.

    OSCCON = $60 '4mhz
    DEFINE LCD_DREG PORTA
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 2
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 3
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 4
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50
    Define ADC_BITS 10
    Define ADC_CLOCK 3
    Define ADC_SAMPLEUS 50
    Value VAR WORD
    RAW VAR WORD
    ADCON0 = %00011001
    ADCON1 = %00001111
    ADCON2 = %10111111
    TRISA = %00000000
    TRISB = %00010000

    Pause 2000

    loop: Lcdout $FE, 1
    ADCIN 6, value
    Raw = value
    value = (value */ 500)>>2
    Lcdout $FE, 2, "DC Volts= ",DEC (value/100),".",DEC2 value
    Lcdout $FE, $C0, "ADC count= ",DEC RAW
    LCDOUT $FE, $94, "Testing 3rd line"
    LCDOUT $FE, $D4, "Testing 4th line"
    Pause 250
    Goto loop

  2. #2
    BertMan's Avatar
    BertMan Guest


    Did you find this post helpful? Yes | No

    Default

    You do not need to set ADCON0. PBP controls this register via use of the ADCIN command.

Similar Threads

  1. Multiple "AND"'s in select case?
    By polymer52 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st January 2010, 19:10
  2. multiple switches~one ADC
    By naga in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 18th August 2009, 10:20
  3. multiple ADC using DSpic 30f3010
    By angeline in forum mel PIC BASIC
    Replies: 6
    Last Post: - 22nd February 2008, 10:03
  4. 16F819 ADCIN Channel Select?
    By modifyit in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 27th April 2005, 18:31
  5. Reading multiple ADC channels FAST
    By lwindridge in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st April 2004, 22:37

Members who have read this thread : 2

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