16F88 reading Analog Input


Closed Thread
Results 1 to 3 of 3
  1. #1
    thunderstrike44's Avatar
    thunderstrike44 Guest

    Default 16F88 reading Analog Input

    Hi,

    I have used the 16F877 PIC Processor for about a year and I have a little project I wanted to use the 16F88 for. I am having problems reading the analog inputs, I think. I have setup for only AN0 and AN1 to be analog in and am setting Port b 0-3 as indicators to see voltage level vdd-vss. Here is my testing code but I can't see to get it to work.

    DEFINE LOADER_USED 1

    OSCCON = %01100111

    TRISA = %00000011
    TRISB = %00000000
    PORTB = %00000000

    ANSEL = %00000011
    ADCON1 = %10000000
    CMCON = 7

    DEFINE ADC_BITS 8
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50


    CTA VAR BYTE

    main:

    ADCIN 0, CTA

    ledtst1:
    IF CTA > 50 Then tst2
    PORTB = %00000001
    GoTo cont

    tst2:
    IF CTA > 125 Then tst3
    PORTB = %00000011
    GoTo cont

    tst3:
    IF CTA > 200 Then tst4
    PORTB = %00000111
    GoTo cont

    tst4:
    PORTB = %00001111

    cont:

    Pause 10

    GoTo main
    End

    It does not give me any errors nor does it work. I am using MELabs Pro Basic compiler version 2.44. I have ordered the 2.45 but have not gotten it yet.

    Any sugguestions?

    Thanks,
    Brian

  2. #2
    paul farrugia's Avatar
    paul farrugia Guest


    Did you find this post helpful? Yes | No

    Default 16F88 Analogue inputs

    Hi,
    I,ve not used it either but a quick scan of the datasheet seems to show that ADCON0 must also be set?
    Cheers
    Paul
    Last edited by paul farrugia; - 30th August 2004 at 11:01.

  3. #3
    thunderstrike44's Avatar
    thunderstrike44 Guest


    Did you find this post helpful? Yes | No

    Default 16F88 Analog Reading Problem

    Tried that also to no avail. I don't know why they have to change the structure so much for one chip. I have been using the analog inputs on the 16F877A with out a problem, but the bugger is really different. There must be a answer.

    Brian R.

Similar Threads

  1. pic18f analog comparator problem
    By david.silaghi in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 6th May 2009, 09:38
  2. Analog Input on PIC16F88
    By penelopepug in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 6th May 2008, 22:49
  3. 16F88 Analog In
    By Mugelpower in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 25th March 2008, 08:30
  4. 16f88 - pin RA4 as analog input
    By savnik in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 15th December 2006, 13:55
  5. Analog pins for digital input
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 9th September 2005, 00:32

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