12 bit or higher ADC on a PIC that works with PBP?


Closed Thread
Results 1 to 9 of 9

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Sorry and welcome on the forum so far, but if you can't do a simple search for a part number, imagine how hard the coding will be... school work i guess?

    first hit
    PIC18F2423, PIC18F2523, PIC184423, PIC18F4523, datasheet : http://ww1.microchip.com/downloads/e...Doc/39755B.pdf

    it worked great
    Last edited by mister_e; - 11th November 2007 at 10:31.
    Steve

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

  2. #2
    Brandon's Avatar
    Brandon Guest


    Did you find this post helpful? Yes | No

    Default really not looking for an argument (really)

    I was looking for some first hand knowledge on Pic chips with 12bit ADCs.

    I have searched for them and its not that I haven't found any, it's that I found a lot.
    But at-least one of them, the 16f882 seems unclear about the ADCs. Some searchs come back stating it has 12bit ADCs but the datasheet doesn't clearly state 12bit, infact it states 10bit.

    I could buy some of the other Pic chips that claim to have 12bit ADCs but I was looking for a little advice from someone who may have used one before with PBP.

    Your link to the entire Microchip website wasn't really what I was looking for.

    But thanks and I hope I have not offended you.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    As far as I can tell the 16F882 is 10-bit. I wouldn't think the 882 had 12-bit when the rest
    of the same family like 883, 884, 886 and 887 were all 10-bit.

    I've used the 18F2553 and 18F2523 12-bit A/D. Here's a short code example;
    Code:
    'CONFIG settings in 18F2553.INC
    'CONFIG PLLDIV=5,CPUDIV=OSC1_PLL2,USBDIV=2,FOSC=HS,FCMEN=OFF,IESO=OFF
    'CONFIG VREGEN=OFF,CCP2MX=ON,WDT=OFF,WDTPS=32768,PBADEN=OFF,PWRT=OFF,MCLRE=OFF
    'CONFIG LPT1OSC=OFF,BOR=ON,BORV=2,STVREN=ON,LVP=OFF,XINST=OFF,DEBUG=OFF,WRTB=ON
        
        DEFINE OSC 20
        DEFINE DEBUG_REG PORTC
        DEFINE DEBUG_BIT 6    ' Hardware USART TX pin
        DEFINE DEBUG_BAUD 9600
        DEFINE DEBUG_MODE 0   ' Non-inverted mode through MAX233
        
        ADResult VAR WORD
        
        Q CON 3126         ' (5/4095)*256=0.312576313. rounded up to 3126
        
        ADCON0 = %00000001 ' A/D module enabled, channel 0
        ADCON1 = %00001110 ' Vref = Vdd & Vss, AN0 = analog
        ADCON2 = %10101011 ' Right justified, 12 Tad, Frc clock
        INTCON = %01000000 ' Global ints disabled, enable peripheral interrupts
        PIE1.6=1           ' A/D interrupt enabled (for wake from sleep)
        
        ' Note we don't use an interrupt routine since the A/D complete
        ' interrupt is only waking the PIC from sleep.
        
    Main:
        ADCON0.1=1           ' Start the A/D conversion
        @ SLEEP              ' Sleep until A/D conversion finished
        WHILE ADCON0.1       ' A/D complete?
        WEND                 ' 
        PIR1.6=0             ' Clear A/D int flag
        
        ASM
         MOVFF ADRESL,_ADResult   ; get low byte
         MOVFF ADRESH,_ADResult+1 ; get high byte
        ENDASM
        
        DEBUG "Raw A/D val = ",DEC ADResult,13,10
        ADResult = ADResult */ Q
        DEBUG "ADResult */ ",DEC Q," = ",DEC ADRESULT,13,10
        DEBUG "ADResult = ",DEC ADResult DIG 4,".",DEC ADResult DIG 3,_
        DEC ADResult DIG 2,DEC ADResult DIG 1,"V",13,10
        PAUSE 2000
        GOTO Main
        
        END
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    I have used the new 18F8723 with 12 bit A/D.

    To get the the full resolution, you have to use DEFINE

    "DEFINE ADC_BITS 10"

    Because PBP only "knows about" 8 and 10 bit converters.
    If the DEFINE is missing or not interpreted properly in the
    compiler, it will default to 8 bits.

    If you use the line above at the top of your program,
    and have a 12-bit converter in your chip, the result will
    indeed have a full 12 bits of resolution.
    Charles Linquist

Similar Threads

  1. decoding quadrature encoders
    By ice in forum mel PIC BASIC Pro
    Replies: 93
    Last Post: - 28th February 2017, 09:02
  2. AT/PS2 Keybord - PIC Interface?
    By Kamikaze47 in forum Code Examples
    Replies: 73
    Last Post: - 9th August 2009, 16:10
  3. Replies: 2
    Last Post: - 10th February 2006, 01:04
  4. PBP 16-bit ADC result math
    By sonic in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 13th March 2005, 14:21
  5. Using PBP Hex Files with FED Pic Programmer
    By jrudd in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th February 2005, 10:57

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