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


Closed Thread
Results 1 to 10 of 10
  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,383


    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.

  7. #7
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

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

    kuba230,
    If I may jump in here now that your problem is solved...
    but not working properly, value on LCD display is not correct.
    So just curious... Was the 'bad' LCD displaying garbage characters or was it displaying a somewhat valid number??
    Please be more specific as to what the 'bad' LCD was displaying.

    Being more specific on describing the problem is more likely to help solve future problems

    dwight
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  8. #8
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

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

    To clarify... the reason I asked the above question(s) is because it seems to me that if the LCD was displaying any reasonable characters then the LCD was working.
    Was it an LCD contrast issue or were the characters complete garbage??

    Is it possible that you also fixed something else in your code that was suggested by the other reply's to your questions and that was the real problem??

    That is why I asked about what exactly you were seeing on the LCD.

    dwight
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  9. #9
    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 atached photo of my wrong LCD. I do not know, what is the problem with LCD.
    Display is marked as MC10621E8-SYL, *W 4034
    But after changing, everything is OK.

    Name:  Wrong LCD.jpg
Views: 649
Size:  367.8 KB
    Last edited by Kuba230; - 29th April 2016 at 06:54.

  10. #10
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

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

    Hey Kuba230,

    Thanks for posting the picture. So to me the picture says a lot... It definitely shows a problem with the LCD but it also shows that your code is working, more or less.
    I would submit that if others that posted comments about checking your register settings and AD setup would have known your display looked like that they would have suggested a problem with the LCD before talking about your code setup.

    It's obvious that you were smart enough to recognize that there was an issue with the LCD and you replaced the defective display.

    The reason I am focusing in on the idea of accurately describing your problem is because I have spent the last several days working with a new electronic technician and trying to teach troubleshooting techniques. It has become clear to me that it is very important for one (anyone) to really think about what the symptoms in a given circuit are telling you, and if you are inviting others to make suggestions then the more accurate you can describe the problem then the more accurate will be the feedback.

    Really just an academic point of learning to better communicate both with others and with ourselves.

    cheers
    dwight
    Last edited by Heckler; - 1st May 2016 at 06:17.
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

Similar Threads

  1. 16 bit conversion - AM2302
    By Scampy in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 12th April 2015, 01:34
  2. Replies: 1
    Last Post: - 13th March 2012, 00:34
  3. Conversion Problem
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 18th March 2007, 13:09
  4. Bit conversion
    By lerameur in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 5th November 2006, 12: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, 15: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