A/D converter sample


Closed Thread
Results 1 to 6 of 6
  1. #1

    Question A/D converter sample

    want to view a code for a/d converter using a pic 16f877a with a pbpro compiler version 2.03 only....

  2. #2
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    2.03 does not support the 16F877a (added to PBP in version 2.42) ... looks like it is really time to upgrade.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  3. #3


    Did you find this post helpful? Yes | No

    Question a/d converter

    can have an alternative just to program it....what about pbasic only?

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by allan josephus View Post
    can have an alternative just to program it....what about pbasic only?
    Download MPLAB from www.microchip.com, learn some assembly language and program it for free. All it costs is time.

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Wink

    Found in PbP 2.21 examples ... ADC7x file ...

    Code:
    ' Access PIC16C7x A/D
    
            Include "modedefs.bas"          ' Include serial modes
    
    SO      con     0                       ' Define serial output pin
    
            ADCON1 = 0                      ' Set PortA 0-3 to analog inputs
            ADCON0 = $41                    ' Set A/D to Fosc/8, Channel 0, On
            Pause 1                         ' Wait for channel to setup
    
    loop:   ADCON0 = $45                    ' Start conversion
            Pause 1                         ' Wait for conversion
    
            Serout SO,N2400,[#ADRES,10]     ' Send variable to serial out
    
            Goto loop
    may be you've had it in your PbP Folder for the past ten years !!! ( LOL !!!! )

    no reason for such adc's use not to work ... once "trimmed" to your Pic's specifics !!! ( and of course supported by your version of the compiler !!! )

    Alain

    PS: IF you ONLY use the AN 5, AN 6, AN 7 adc inputs ( 0 > 4 shared by comparators ... are to let aside !!! ) ... I think a program compiled for 16F877 can work with a 16F877A ...
    Last edited by Acetronics2; - 21st February 2008 at 13:07.
    ************************************************** ***********************
    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 " !!!
    *****************************************

  6. #6
    Paolo.T's Avatar
    Paolo.T Guest


    Did you find this post helpful? Yes | No

    Smile Ad converter 12 Bit for Pic 18F4458

    'Code example for 18F4458 very important setting -HS oscillator-
    'Ad12.bas

    DEFINE OSC 20

    Define LCD_DREG PortB 'inizializza il display lcd sulla portaB'
    Define LCD_DBIT 0 'inizializza il display lcd'
    Define LCD_RSREG PORTB 'inizializza il display lcd'
    Define LCD_RSBIT 4 'inizializza il display lcd'
    Define LCD_EREG PORTB 'inizializza il display lcd'
    Define LCD_EBIT 5 'inizializza il display lcd'
    Define LCD_BITS 4 'modalità scrittura a 4 bit'
    Define LCD_LINES 2 'display a 2 linee'
    Define ADC_BITS 12

    TrisA = %111111 'definisci i pin di entrata/uscita porta A'
    TrisB = %00000000 'definisci i pin di entrata/uscita porta B'
    TrisC = %00000000 'definisci i pin di entrata/uscita porta
    TrisD = %00000000 'definisci i pin di entrata/uscita porta D'
    TrisE = %001

    B0 var word
    B1 var word
    B2 var word

    Clear

    ADCON0 = %00000011
    ADCON1 = %00001101
    ADCON2 = %10010100


    Start: ADCON0 = %00000011
    Pause 5
    ADCON0 = %00000010
    B0.HighByte = ADRESH
    B0.LowByte = ADRESL
    Lcdout $fe, 1
    Lcdout "Test AD pic 18f"
    Lcdout $fe,$c0
    Lcdout "Value 12bit ",#B0
    pause 25
    Goto Start:
    Last edited by Paolo.T; - 23rd February 2008 at 19:47. Reason: setting Hs oscillator

Similar Threads

  1. Replies: 9
    Last Post: - 31st July 2008, 08:56
  2. A/D converter sample
    By allan josephus in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th February 2008, 03:40
  3. A/D converter fails?
    By egberttheone in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 13th February 2006, 18:57
  4. A/D converter with pic16f84, i need a help
    By micro in forum General
    Replies: 0
    Last Post: - 13th December 2005, 21:17
  5. Re Cs5532 A/d Converter
    By massquip in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 29th April 2004, 16:31

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