8x2 Lcd


Closed Thread
Results 1 to 7 of 7

Thread: 8x2 Lcd

  1. #1
    Join Date
    Jun 2007
    Posts
    11

    Default 8x2 Lcd

    Hi
    I am new to PIC's and Picbasic and am trying to get an 8x2 LCD working in 4 bit mode. I am using the following code and it works with a 16x2. The controllers are the same and the starting address of each line are the same. Is there something else I need to do or just start check the wiring again. All that shows are 8 blocks on the first line. I am not reading a pot at this time just trying to get it to display, pot= . I forget where the code came from so sorry to who ever wrote it for not getting your name in here.


    ' For PIC16F88 and melabs PICBASIC PRO Compiler
    '
    ' Read pot and display on LCD

    ' Define LCD pins
    Define LCD_DREG PORTA
    Define LCD_DBIT 4
    Define LCD_RSREG PORTB
    Define LCD_RSBIT 6
    Define LCD_EREG PORTB
    Define LCD_EBIT 3

    ' Allocate variables
    x Var Byte


    ANSEL = %00010000 ' Make the pot analog and rest digital
    CMCON = 7 ' Set PORTA to digital

    Pause 100 ' Wait for LCD to start


    mainloop: Adcin 4, x ' Read the pot

    Lcdout $fe, 1, "pot=", #x ' Send value to LCD

    Pause 100 ' Do it about 10 times a second

    Goto mainloop ' Do it forever

    End




    Thanks
    Ron

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    The first thing to do is make sure that the display uses an HD44780 controller.
    You should see the number on one of the chips if it does.

    If it does, then the problem may be due to timing differences.

    Try this ...
    Code:
    DEFINE  LCD_LINES  2
    DEFINE  LCD_COMMANDUS  5000
    DEFINE  LCD_DATAUS   500
    
    PAUSE 3000
    LCDOUT $FE,1
    PAUSE 2000
    
    LCDOUT $FE,1,"HELLO:",$FE,$C0,"WORLD!"
    
    STOP
    And if by chance it works, start reducing the numbers until it stops working, then add a little back in for safety.
    Last edited by Darrel Taylor; - 10th July 2007 at 05:00. Reason: Added LCD_LINES 2
    DT

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


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by rshaver View Post
    Define LCD_DREG PORTA
    Define LCD_DBIT 4
    ...
    ANSEL = %00010000 ' Make the pot analog and rest digital
    ...
    mainloop: Adcin 4, x ' Read the pot
    Looks to me you are using RA4 as both a data line digital output for the LCD and an analog input for the pot - pick one and move the other. Your ANSEL has it as the analog input now ... makes sense the LCD is not working.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

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


    Did you find this post helpful? Yes | No

    Smile

    Looking into my crystal ball a bit more ... you do not have many defines for the LCD (see manual). Are you relying on the default values for those you have not shown? (not the best of practices if you are)

    I am predicting that
    Code:
    Define LCD_DBIT 4
    should be
    Code:
    Define LCD_DBIT 0
    (only if you have the four data lines on RA0-RA3). If not, RA5 is input only and also will be causing you grief.

    Let us know....
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  5. #5
    Join Date
    Jun 2007
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Darrel

    I will give that a try when I get home this afternoon.

    Paul

    I have tried Define LCD_DBIT 0 with the same results. But will set it back to this when I try it again.

    Thanks to both of you for the suggestions. I'll let you know how it goes.

    Ron

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


    Did you find this post helpful? Yes | No

    Smile

    Use 0 if your four data lines are RA0-RA3
    Use 4 if your four data lines are RA4-RA7 (but this will not work as noted above)

    If you still have issues, you might want to post a schematic and the rest of your code (if there is more) - more and better info usually means more and better help

    Good Luck
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  7. #7
    Join Date
    Jun 2007
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Thanks for the help.. It is up and working. Don't really know what happened. The code looks the same except for:

    DEFINE LCD_LINES 2
    ANSEL = %00000000

    and:

    Define LCD_DBIT 0

    I had tried the LCD_DBIT 0 before but no help.. And ANSEL =%00000000. So maybe the LCD_LINES 2... I did not think that made a difference. But I greatly appreciate the help. It made me look at things and I did learn some more.

    Ron

Similar Threads

  1. Is this code not initialising the LCD properly?
    By Platypus in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 30th January 2010, 19:14
  2. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  3. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  4. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  5. Dedicated LCD Controller question
    By chuckles in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th February 2006, 14:44

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