RA7/CLKIN as analog input


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2005
    Posts
    72

    Default RA7/CLKIN as analog input

    hello

    in an existing environment i want replace a 16C58 with an 16F628A. originally at the CLKIN (RA7) there was an potentiometer. how can i read in analog this pin and must configure them?

    thanks for an idea and greetings

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Use POT or RCTIME statement. Must add an external capacitor prior to make it work. Input must be set to analog too. CMCON=7.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Jan 2005
    Posts
    72


    Did you find this post helpful? Yes | No

    Default

    thanks for the information, unfortunalety it doesn't run...
    can you tell my link where CNCOM is described online?can't find a good information

    POT and RCTIME are described in the PBP Compiler Manual, but im not sure if my code is arranged right
    could you tell me a short example in PBP?

    thank you very much

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    this one comes from Melabs code example
    Code:
    ' PicBasic Pro program to read pot and display on LCD
    
    ' Define LCD pins
    Define  LCD_DREG        PORTA
    Define  LCD_DBIT        0
    Define  LCD_RSREG       PORTA
    Define  LCD_RSBIT       4
    Define  LCD_EREG        PORTB
    Define  LCD_EBIT        3
    
    ' Allocate variables
    x       var     byte
    
    
            CMCON = 7               ' Set PORTA to digital
    
            Pause 100               ' Wait for LCD to start
    
    
    mainloop: Pot PORTB.0, 127, x
    
            Lcdout $fe, 1, "pot=", #x       ' Send value to LCD
    
            Pause   100             ' Do it about 10 times a second
    
            Goto    mainloop        ' Do it forever
    
            End
    in the PBP you have also one code example for POT and the according schematic. BTW if you don't have any book on hand, they provide one online

    pdf:
    http://www.melabs.com/downloads/pbpm304.pdf

    Html:
    http://microengineeringlabs.com/resources/pbpmanual


    CMCON is the register for analog comparator of the PIC16F628. You'll find it in the datasheet section 9.0
    datasheet:
    http://ww1.microchip.com/downloads/e...Doc/40300c.pdf
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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 18f252
    By kiteman in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th January 2009, 08:34
  3. Analog Input on PIC16F88
    By penelopepug in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 6th May 2008, 22:49
  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 : 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