LCD wont work :(


Closed Thread
Results 1 to 17 of 17
  1. #1
    Join Date
    Aug 2009
    Posts
    7

    Default LCD wont work :(

    I cant get my LCD (Sharp LM16A211 HD44780) working with PIC16F628 :/

    The connections look like this:

    PortA.0 > DB4
    PortA.1 > DB5
    PortA.2 > DB6
    PortA.3 > DB7
    PortA.4 > RS (with pull-up resistor)
    PortB.3 > E
    PortB.5 > LED (to check if the program is running)
    Ground > R/W


    I'm using the internal Osc (4MHz)

    The code:

    loop:
    Pause 1000
    High PORTB.5
    Pause 1000
    Low PORTB.5
    LCDOut $FE,1
    LCDOut $FE,$80,"Hello"
    GoTo loop




    The LCD isnt showing anything at all! Its just a empty screen. I have checked all the connections and they are OK.
    If I put the RS wire to GND, I will get the first row on the screen showing ###### (Not the #-char itself, more like black squares).

    Datasheets:
    http://www.kjell.com/filarkiv/SUPPOR...0574/90574.pdf
    http://www.evilghozt.se/download/LM16A211.pdf


    (Note: my english isnt that good :P )

    Regards Micke

  2. #2
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    How are the pin 3 (Contrast adjustment) connected?

    Have you tried to change the LCD defines?

    Code:
    ‘ Set command delay time in us
    DEFINE LCD_COMMANDUS 1500
    ‘ Set data delay time in us
    DEFINE LCD_DATAUS 44

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


    Did you find this post helpful? Yes | No

    Default

    The 628A has comparators on portA. Not sure about the 628. If it does look at this.
    http://www.picbasic.co.uk/forum/showthread.php?t=561
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Jan 2005
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    hoi,

    this works with 628 and Sharp LM16A211 at 4Mhz
    2 rows of black squares if disp is not initialised ( at power up)
    init the display first at startup

    rgds
    tb

    pause 2000

    DEFINE LCD_DREG PORTD 'dataport select'
    DEFINE LCD_DBIT 0 'first databit
    DEFINE LCD_RSREG PORTA 'lcd register port
    DEFINE LCD_RSBIT 3 'register select bit'
    DEFINE LCD_EREG PORTA 'enable poort'
    DEFINE LCD_EBIT 1 'enable bit'
    DEFINE LCD_BITS 4 'lcd bus size'
    DEFINE LCD_LINES 2 'lcd lines'
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50 'data delay in µs'

    'init display
    LCDOUT $FE,1 ' clear LCD
    pause 100 ' pauze 0,1s
    LCDOUT $FE,2 ' cursor home
    LCDOUT $FE,$0C ' cursor off
    pause 1000 ' pauze 0,1s


    ' message

    LCDOUT $FE, $80, " hello "
    LCDOUT $FE, $C0, " ready "
    pause 1000 ' pauze 0,1s

    go on

  5. #5
    Join Date
    Aug 2009
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by tiger_bel View Post
    hoi,

    this works with 628 and Sharp LM16A211 at 4Mhz
    2 rows of black squares if disp is not initialised ( at power up)
    init the display first at startup

    rgds
    tb

    pause 2000

    DEFINE LCD_DREG PORTD 'dataport select'
    DEFINE LCD_DBIT 0 'first databit
    DEFINE LCD_RSREG PORTA 'lcd register port
    DEFINE LCD_RSBIT 3 'register select bit'
    DEFINE LCD_EREG PORTA 'enable poort'
    DEFINE LCD_EBIT 1 'enable bit'
    DEFINE LCD_BITS 4 'lcd bus size'
    DEFINE LCD_LINES 2 'lcd lines'
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50 'data delay in µs'

    'init display
    LCDOUT $FE,1 ' clear LCD
    pause 100 ' pauze 0,1s
    LCDOUT $FE,2 ' cursor home
    LCDOUT $FE,$0C ' cursor off
    pause 1000 ' pauze 0,1s


    ' message

    LCDOUT $FE, $80, " hello "
    LCDOUT $FE, $C0, " ready "
    pause 1000 ' pauze 0,1s

    go on

    I have try that code, and I cant get it work.
    I have try to switch to a new LCD display, and still same problem.
    Now i have try with PIC16F676, almost the same problem there, but this time the first row is showing black squares on initializing and then clear screen 1 sec later...

    Here is the code for pic16f676:

    @ device INTRC_OSC_NOCLKOUT
    DEFINE LCD_DREG PORTC 'dataport select'
    DEFINE LCD_DBIT 0 'first databit
    DEFINE LCD_RSREG PORTC 'lcd register port
    DEFINE LCD_RSBIT 4 'register select bit'
    DEFINE LCD_EREG PORTC 'enable poort'
    DEFINE LCD_EBIT 5 'enable bit'
    DEFINE LCD_BITS 4 'lcd bus size'
    DEFINE LCD_LINES 2 'lcd lines'
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50 'data delay in µs'

    CMCON = 7
    VRCON = 0

    Pause 1000
    'init display
    LCDOut $FE,1 ' clear LCD
    Pause 100 ' pauze 0,1s
    flags = 0
    LCDOut $FE,2 ' cursor home
    LCDOut $FE,$0C ' cursor off
    Pause 1000 ' pauze 0,1s


    ' message

    LCDOut $FE, $80, " hello "
    LCDOut $FE, $C0, " ready "
    Pause 1000 ' pauze 0,1s


    loopme:
    Pause 1000
    High PORTA.0
    Pause 1000
    Low PORTA.0
    GoTo loopme

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


    Did you find this post helpful? Yes | No

    Default

    The 676 has ADC on port C. Might help to turn that off.
    How do you have the LCD contrast pin connected?
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Jan 2005
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    you are using 4bit datatransfer to display.
    are the 4 bits connected to DB4 to DB7 on display side ???

    rgds
    tiger_bel

  8. #8
    Join Date
    Aug 2009
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Wiring diagram:


    This is how the LCD display looks like for about 1sek before the screen goes blank again..


    Thanks for all help so far

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


    Did you find this post helpful? Yes | No

    Default

    Normally the contrast likes things on the "-" side. If you have a pot wire it like the example in the PBP manual. If not just try it going to the zero rail (-).

    And PORTC 0-3 needs to be digital.

    ANSEL = %00000000
    That should turn all ADC off.
    I think...
    Dave
    Always wear safety glasses while programming.

  10. #10
    Join Date
    Aug 2009
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Normally the contrast likes things on the "-" side. If you have a pot wire it like the example in the PBP manual. If not just try it going to the zero rail (-).

    And PORTC 0-3 needs to be digital.

    ANSEL = %00000000
    That should turn all ADC off.
    I think...
    If I set Vo (contrast) to GND, I wont even get the black squares at start.

    ANSEL = %00000000 <- I try that, no change.

    If I use a voltmeter on PortC 0-3 all are logic low (0volt) idle. In start before the LCD initailized portC 0-3 are logic high (5volt), is that right?

  11. #11
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Your diagram in post #8 has the contrast pot wrongly wired. Correct the wiring as per the attached snap. Then adjust the pot till you have clean characters on LCD.

    Al.
    Attached Images Attached Images  
    All progress began with an idea

  12. #12
    Join Date
    Aug 2009
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by aratti View Post
    Your diagram in post #8 has the contrast pot wrongly wired. Correct the wiring as per the attached snap. Then adjust the pot till you have clean characters on LCD.

    Al.
    im not using any pot at all. I have just put the Vo to +5volt with resistor between, if thats wrong I wouldnt seen those black squares, right?

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


    Did you find this post helpful? Yes | No

    Default

    Having the contrast wired wrong is the reason you see the black squares.

    Having the contrast going to 5+ is wrong. Sometimes going to (-) will work but the best bet is to use a pot like the manual and Al said. Then it is adjustable.
    Dave
    Always wear safety glasses while programming.

  14. #14
    Join Date
    Aug 2009
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    I have just put a pot there, and now I either get black squares or nothing

  15. #15
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Lightbulb

    Hi,

    For a quick contrast setting ... just use the forward voltage of a Si diode ( .5 to .6 v @ 1 mA ) to set Vo ... ( do not work with OLED displays !!! )

    simple and efficient ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  16. #16
    Join Date
    Aug 2009
    Location
    Upstate New York
    Posts
    8


    Did you find this post helpful? Yes | No

    Post Oilmex board LCD for Comparason

    I recently got my PIC-MT-USB up and running, with help from this forum. I got the switches to work and the lights to blink. The LCD was the next headache. I was hoping that your thread may give me some ideas. But I managed to get it to work with the help from an article: http://www.epemag.wimborne.co.uk/lcd1.pdf
    I am an old TTL guy, so the wiring diagram made lots of sense to me, and finally got it working. My code is attached with comments. It may offer some ideas. Hope it helps.
    Comments about my code are welcome from the community. I am a nophyte.

    '************************************************* ***************
    '* Name : OILMEX TEST *
    '* Author : [select VIEW...EDITOR OPTIONS] *
    '* Notice : Copyright (c) 2009 [select VIEW...EDITOR OPTIONS] *
    '* : All Rights Reserved *
    '* Date : 8/24/2009 *
    '* Version : 1.0 *
    '* Notes : FOR THIS TO WORK ON THE OLMEX BOARD *
    '* : the INC file had to be changed to *
    '* : change the config to HS from XT *
    '* : *
    '************************************************* ***************
    '************************************************* **************
    '* This block of code sets up switches to drive LEDs

    LED1 VAR PORTB.2
    LED2 VAR PORTB.1
    SWITCH1 VAR PORTB.4
    SWITCH2 VAR PORTB.5

    TRISB = %11111001 'sets bit 1, 2 to output. all else to input

    LOW LED1 'inatilized leds
    LOW LED2 'LED initalizain probabbly not needed

    '********** END PUSH BUTTON / LED CODE*********************

    '************* LCD DRIVER TEST CODE **********************
    '****** PINS BASED ON SCHEMATIC ***************************
    '* LCD Connections
    '* _RS PORTD0 -DATA when LOW, Commands when HIGH
    '* .R/W PORTD1 - LOW to WRITE Date, HIGH to READ data from LCD
    '* E PORTD2 - Data transferred on Transition High to Low
    '* Light PORTD3
    '* DB4 PORTD4
    '* DB5 PORTD5
    '* DB6 PORTD6
    '* DB7 PORTD7

    '**************


    define LCD_DREG PORTD 'Display connected to PORTD
    DEFINE LCD_DBIT 4 'Data Starting Bit (0, or 4)
    'When set to 0, Backlight Display Blinks, no Data
    DEFINE LCD_RSREG PORTD 'Reset register is on PortD
    DEFINE LCD_RSBIT 0 'Reset Bit is D0
    Define LCD_EREG PORTD 'Enable on PORTD
    DEFINE LCD_EBIT 2 'enable bit D2
    '*********** These LCD DEFINES not needed (presumably) *******
    'DEFINE RW_REG PORTD
    'DEFINE LCD_RWBIT 1
    'DEFINE LCD_BITS 4
    DEFINE OSC 20 'The display was jumpp, This took care of it
    'DEFINE LCD_COMMANDUS 2000
    'DEFINE LCD_DATAUS 50 'data delay in µs'
    'Define LOIADER_USED 1
    'define NO_CLRWDT 1
    '*************** End of UNUSED LCD DEFINES ******************
    TRISD = %00001111 'Set D4-8 as output. D0-4 as Input

    low PORTD.1 'Set NOT R/W to LOW (Write Data TO LCD)
    High PORTD.3 'Turn on Back LIght (Tested - Works)



    Pause 500 ' Wait for LCD to startup


    mainloop:
    Lcdout $fe, 1 ' Clear LCD screen
    PAUSE 500
    Lcdout "Hello" ' Display Hello
    Pause 500 ' Wait .5 second

    Lcdout $fe, 1 ' Clear LCD screen
    Lcdout "World"
    Pause 500 ' Wait .5 second

    '************* PUSHBUTTON / LET TEST RUTINE *************
    IF SWITCH1 = 0 Then 'NOTE Button Goes to 0 When pressed
    HIGH LED1
    else
    low LED1

    ENDif

    IF SWITCH2 = 0 then
    HIGH LED2
    else
    low LED2
    endif
    '***************** End Of Pushbutton Routine **********

    Goto mainloop ' Do it forever

  17. #17
    Join Date
    Aug 2009
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    YES! Its alive!

    It was a really simple problem, the R/W wire was not 100% connected LOL hehe, I feel quite silly :P

Similar Threads

  1. first project, and yes, doesn`t work
    By bogdan in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 28th April 2009, 06:13
  2. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  3. cant get my Lcd to work using Pic18f452
    By civicgundam in forum General
    Replies: 13
    Last Post: - 7th October 2007, 00:13
  4. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07
  5. Why doesn't my code for 18f452 work on 18f252?
    By senojlr in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 23rd December 2005, 02:42

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