PIC18F2423, ADC problem


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2009
    Location
    Florida USA
    Posts
    22

    Unhappy PIC18F2423, ADC problem

    Hi Group
    I have purchased a PIC18F2423 to make a pressure meter with 12 bit resolution.
    To test the circuit I hooked up a 1k pot to +5 and ground and the wiper to the ADC input AN1. I noticed that the result of the ADC does not output a bit with an input voltage under 11.5mV. Here is the code:


    'PIC18F2423, 4MHz Resonator, 4x20 LCD, Input AN1, Vref 4096mV

    'Defines ADC
    DEFINE ADC_BITS 12
    DEFINE ADC_SAMPLEUS 50

    Define OSC 4

    'Defines LCD
    Define LCD_DREG PORTB 'set lcd data port to PORTB
    Define LCD_DBIT 0 'set data starting bit to 0 (RC0 to RC3)
    Define LCD_RSREG PORTB 'set rs register port to PORTB
    Define LCD_RSBIT 4 'set rs register bit to 4 (RC4)
    Define LCD_EREG PORTB 'set E register port (PORTB)
    Define LCD_EBIT 5 'set E register bit to 5 (RC5)
    Define LCD_BITS 4 'set to 4-bit operation
    Define LCD_LINES 4 'set to 4-line lcd
    Define LCD_COMMANDUS 500 'delay 500us

    'Variable
    Press Var Word

    TrisA =%00111111

    'reset lcd display
    Lcdout $FE,1


    'Start to measure Pressure---------------------------------------
    Let Press=0

    Adcon1=%00011010 'Analog AN0 to AN4, Ref Gnd, Ext Ref 4096mV
    ADCON0=%00000101 'ADC enabled, ADC idle, AN1 on,
    Adcon2=%10010100 'Fosc/4, 4Tad, Right justified

    Adcon0.1=1 'start conversion
    notdon:
    IF ADCON0.1 = 1 THEN notdon 'wait for conversion to finish

    Press.highbyte=ADRESH 'move result of highbyte to Press
    Press.lowbyte=ADRESL 'move result of lowbyte to Press
    Pause 100
    LCDOUT $FE,$80, "Press " , DEC Press 'to see value of "Press"
    Pause 1000
    Let Press=Press*5
    Pause 50
    Lcdout $FE,$94, "Pressure: ",DEC Press/10, ".", DEC1 Press, " mb"
    Pause 3000

    Goto Start
    End

    Does anyone know why there is no ADC output with <11.5mV input? Help is appreciated.

  2. #2
    diy.jack's Avatar
    diy.jack Guest


    Did you find this post helpful? Yes | No

    Default

    Hi . I don't kown PIC18F2423.But when I use PIC18F2523,I make a mistack beacuse of not read it's datasheet carefully .Maybe you need alos read PIC18F2423 's datasheet .good luck.

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Take a look at this example
    http://www.rentron.com/PICX2.htm
    Or use the ADCIN command built into PBP, looks like you are mixing both ways.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Smile

    Change ADCON2 to use more Acquisition time,
    Wait after switching the ADC on (ADCON0) 1
    delete this ADC-defines !
    maybe ... ad a 1nF C to AN1 against ground
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  5. #5
    Join Date
    Mar 2009
    Location
    Florida USA
    Posts
    22


    Did you find this post helpful? Yes | No

    Default

    Found the problem: when I use " ADCIN 1, Press " instead of

    Press.highbyte=ADRESH 'move result of highbyte to Press
    Press.lowbyte=ADRESL 'move result of lowbyte to Press

    the ADC works correctly. I have used this code many times with other pic's and it always worked. Have to find out why it gave me a headache with this chip.
    Thanks everyone for the help, it was a pleasure.

Similar Threads

  1. PIC18f2423 two 12bit adc input problems
    By Brandon in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 16th December 2007, 09:47
  2. Mutliple ADC problem with PIC16F877
    By andyto in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd October 2007, 17:47
  3. PIC18F2423 ADC Need Help
    By Lockerbee1 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 23rd July 2007, 22:00
  4. ADC problem with PIC16F917
    By eetech in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th March 2007, 21:22
  5. Problem reading multiple ADC ports
    By jswayze in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 4th November 2004, 16:46

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