Help needed with 16F870 ADC


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2004
    Posts
    24

    Unhappy Help needed with 16F870 ADC

    I am trying to measure a voltage between 2.90V and 4.12V (from a RTD via a differential amplifier[MCP602]), and display this as a number between 0 and 1023.

    My circuit has this voltage on AN0, and 2.9V on -Vref(AN2) and 4.12V on +Vref(AN3)

    The programme is:

    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 1
    DEFINE ADC_SAMPLEUS 100

    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 4
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 5
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2

    ADCON1=%10001000 '+Vref, -Vref, right justified
    TRISA=255 'PortA analogue input

    PT100 var porta.0
    avg var word
    temp var word
    temp1 var byte
    sign var byte
    cnt var byte

    cnt=0
    avg=0

    PAUSE 500
    LCDout $FE,1 'clear LCD
    LCDout "Temperature ="

    main: ADCin PT100,temp
    avg=avg+temp
    cnt=cnt+1
    pause 100
    if cnt>3 then main

    cnt=0
    temp=avg/3
    avg=0

    LCDout $FE,$C0,DEC temp," "
    goto main

    Doesn't seem to work though, ADC reads 0! Looked though 16F870 datasheet, but can't see what I'm missing?

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Lightbulb

    Hi,

    Instead of " PT100 var PORTA.0" ...

    just write

    PT100 CON 0 ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Stable Adc Reading Routine
    By gebillpap in forum General
    Replies: 27
    Last Post: - 13th May 2015, 02:18
  2. Can't get ADC to loop
    By TravisM in forum mel PIC BASIC
    Replies: 2
    Last Post: - 11th October 2009, 15:33
  3. Servo control / UART / SPI help needed
    By Blackhawk in forum mel PIC BASIC
    Replies: 10
    Last Post: - 10th November 2006, 03:40
  4. ADC value with 2 decimals on an LCD
    By Squibcakes in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2005, 15:54
  5. 12F675 ADC 'Issues'
    By harrisondp in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2005, 01:55

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