A to D on the PIC16F687


Results 1 to 16 of 16

Threaded View

  1. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default Missing ...

    4 Errors found before compiling : ( between star lines ...)



    DEFINE ADC_BITS 8 ' set number of bits in result
    DEFINE ADC_CLOCK 3 ' set clock source
    DEFINE ADC_SAMPLEUS 50 ' set sampling time for microseconds
    ADCON0 = %10000000 'I think this formats the result
    ADCON1 = %00000000 'I think this defines if ports are A or D. The first 0 may need to be a 1
    trisa = %11111111 'Port A is input
    AD_AN3 VAR PORTA.4
    '************************************************* *********************
    FUNCTION_BUTTON VAR PORTB.X ' TO BE DECLARED AS YOUR REQUIREMENTS !!!
    '************************************************* ********************
    AD_AN3_VALUE VAR byte
    '************************************************* *********************
    C2 VAR Byte 'TO BE DECLARED "
    '************************************************* *********************
    pause 500 'LCD's need to initialise before sending data
    LCDOUT $FE, 1 ' Clear LCD screen

    A_D_AN3:
    PAUSEUS 50 ' wait 50 microsec
    ADCIN 3, AD_AN3_VALUE ' read channel 3 to AD_AN3_VALUE
    LCDOUT $FE, 1 ' Clear LCD screen
    LCDOUT "A to D Value"
    LCDOUT $FE, $C0, #AD_AN3_VALUE
    PAUSe 100
    '************************************************* ********************
    C2 = 0 ' TO BE INITIALISED HERE !!!
    '************************************************* ********************
    BUTTON FUNCTION_BUTTON, 1, 255, 0, C2, 1, ON_TIME_FUNC
    GOTO A_D_AN3

    '************************************************* ********************
    ON_TIME_FUNC: ' TO BE SOMEWHERE to be called !!!

    ' What is it supposed to do ???????????????????
    '************************************************* *********************

    END




    NOW still hardware mix ... We continue : your LCD is "standard connected" ... so you MUST pass its RS pin to PORTB ( see defines list) to get RA4 free, as you want it an analog input. You also must declare ALL other PORTA pins as DIGITAL ( see ADCON bytes)

    Sorry, I did not verify if defaults LCD connexions are the same for F687 or F84 ... but there's no reason for a difference in the pin names !!!


    Now ... we will know if real ADC problems still exist ...

    Alain
    Last edited by Acetronics2; - 2nd July 2006 at 17:46.
    ************************************************** ***********************
    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. LCD with PIC16F687
    By jblackann in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 27th June 2006, 00:16
  2. PIC16F687 - supported?
    By badcock in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 6th August 2005, 11:33

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