help setting up 16F886 for ADC


Results 1 to 17 of 17

Threaded View

  1. #1

    Default help setting up 16F886 for ADC

    I'm trying to use adcin to read two different pots to get 8 bit results and I'm having trouble. I'm using the internal oscillator (there is no external oscillator). The pots are connected to AN0 and AN1

    ' Define ADCIN parameters ********************************
    Define ADC_BITS 8 ' Set number of bits in result
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS
    'Define ADC_CLOCK 3 ' This define is inoperative on 16F88x
    ADCON0 = %11000000 ' Set ADC_CLOCK to RC (DEFINE ACD_CLOCK inoperative on the 16F88x)
    ADCON1 = %00000000 ' Left-Justify result in ADRESH:ADRESL registers
    ANSEL = %00000011 ' Set AN0, AN1 to analog, others digital
    ANSELH = %00000000 ' Set AN8 and higher channels to digital operation
    '************************************************* *********

    I just copied the code from the LAB-X1 "adcin3x" sample program for the 16F887. I figured it would work the same for the 16F886 since it's basically a 28 pin version of the 16F887, but it doesn't seem to be working. I figured the problem was that the LAB-X1 uses a 4MHz external oscillator, but I've tried different setting on ADCON0 and it doesn't seem to change anything.
    Last edited by keithv; - 11th July 2016 at 21:40.

Similar Threads

  1. 16f886
    By Larry in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 4th November 2008, 17:57
  2. 16f886
    By hvacrtech in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 27th May 2008, 06:06
  3. Setting Address via ADC
    By breesy in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th October 2007, 15:33
  4. Setting up ADC....
    By robertmark68 in forum General
    Replies: 1
    Last Post: - 11th August 2006, 19:08
  5. Setting Up Adc Ports
    By GEEZER in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 22nd August 2005, 04:04

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