Problem with 10-bit A/D conversion - PIC18F2455 - LCD


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Apr 2008
    Posts
    25

    Default Problem with 10-bit A/D conversion - PIC18F2455 - LCD

    Hello,
    I have written code for 10-bit A/D conversion with PIC18F2455, but not working properly, value on LCD display is not correct.
    I used sample code from melbas written for 10-bit A/D conversion on LCD for PIC18F4550.
    I only changed values for define LCD registers and bits.
    http://melabs.com/samples/LABXUSB-18F4550/adci10xu.htm
    I using 20MHz external oscillator.

    What is problem?


    Thank you


    Here is my code:

    Define LOADER_USED 1
    DEFINE OSC 48

    ' Define LCD registers and bits
    Define LCD_DREG PORTB
    Define LCD_DBIT 4
    Define LCD_RSREG PORTC
    Define LCD_RSBIT 7
    Define LCD_EREG PORTC
    Define LCD_EBIT 6
    DEFINE LCD_BITS 4 ' 4-bit data bus
    DEFINE LCD_LINES 2 ' LCD - 2 lines


    ' Define ADCIN parameters

    Define ADC_BITS 10 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS


    adval var word ' Create adval to store result

    TRISA = %11111111 ' Set PORTA to all input
    ADCON1 = %00001010 ' Set PORTA analog...
    ADCON2 = %10000000 ' ...and right justify result

    Pause 500 ' Wait .5 second

    loop: ADCIN 0, adval ' Read channel 0 to adval
    Lcdout $fe, 1 ' Clear LCD
    Lcdout "Value: ", DEC adval ' Display the decimal value
    Pause 100 ' Wait .1 second
    Goto loop ' Do it forever
    End

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,389


    Did you find this post helpful? Yes | No

    Default Re: Problem with 10-bit A/D conversion - PIC18F2455 - LCD

    ADCON2 = %10000000 ' ...and right justify result
    and set the conversion clock to fosc/2
    way out of specs


    ADCON2 = %10000011 ' ...and right justify result and use frc

  3. #3
    Join Date
    Apr 2008
    Posts
    25


    Did you find this post helpful? Yes | No

    Default Re: Problem with 10-bit A/D conversion - PIC18F2455 - LCD

    I changed
    ADCON2 = %10000000

    to

    ADCON2 = %10000011

    it is still the same

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


    Did you find this post helpful? Yes | No

    Default Re: Problem with 10-bit A/D conversion - PIC18F2455 - LCD

    What is your ADC source and how is it connected?
    What are the current readings and what are the expected readings?
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Apr 2008
    Posts
    25


    Did you find this post helpful? Yes | No

    Default Re: Problem with 10-bit A/D conversion - PIC18F2455 - LCD

    Source is pressure sensor (output 0 - 1V), wchich is normaly working with 10-bit A/D - PIC16F877 conection.
    I built conection with PIC18F2455, but not working properly.

  6. #6
    Join Date
    Apr 2008
    Posts
    25


    Did you find this post helpful? Yes | No

    Default Re: Problem with 10-bit A/D conversion - PIC18F2455 - LCD

    Problem is solved, I changed LCD display, it is OK.

    Thanks for your help.

Similar Threads

  1. 16 bit conversion - AM2302
    By Scampy in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 12th April 2015, 00:34
  2. Replies: 1
    Last Post: - 12th March 2012, 23:34
  3. Conversion Problem
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 18th March 2007, 12:09
  4. Bit conversion
    By lerameur in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 5th November 2006, 11:11
  5. Conversion of 10-bit word into ASCII
    By Barry Johnson in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 16th January 2005, 14:26

Members who have read this thread : 2

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