having problems with Hantronix 20x4 lcd


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    I was talking about your problem with the LCD.

    Yesterday, before posting, I went through your previous threads
    and I saw amongst other threads "problem with LCD" and "xtal problem".

    The timing is important for a HD44780-based LCD, especially during its initialization.

    The purpose of my test was to check the oscillator frequency. (SW & HW).
    After all, your post was saying "I can not get anything out of it".

    Post your code.

    Best regards,

    Luciano
    Last edited by Luciano; - 18th December 2005 at 08:13.

  2. #2
    Rhatidbwoy's Avatar
    Rhatidbwoy Guest


    Did you find this post helpful? Yes | No

    Default

    luciano.
    thanks for the concern for everything that i have posted on this forum. I got many things to work since I started to write to this forum. xtal problem i fixed with INTRC. The first lcd problem I got to work with the contrast setting. The seond lcd is a hantronix and that is were I am having problems.

    The hantronix screen that I have is the hdm-20416h. The contrast should be controlled with either a single or dual power source. I tried the single and that did not work. I am now working with a dual power source for the contrast and that works. It is not much that it needs dual power source but that it need to have more than 5volt to work. The second problem that I have with the hantronix screen is that the line address is not correct. Line 1 starts with $00 but to go any further into the line i can not do. Line 2 threw 4 is not to what the hantronix reccomend, but it is $C0, $94, $D4 . Those are the line addresses that I have figured out and what I have gotten to work so far. I am having a time trying to figure out what is happenning with line 1, but that is nothing more than the other problems that I had. Time will tell in getting it to work.

    Thank you again for suggestion that I could use for figuring out timing issues.

    The code that I am using is as follows:

    ' PicBasic program to demonstrate operation of an LCD in 4-bit mode
    ' PIC16F628
    ' LCD should be connected as follows:
    ' LCD PIC
    ' DB4 PortA.0
    ' DB5 PortA.1
    ' DB6 PortA.2
    ' DB7 PortA.3
    ' RS PortA.4 (add 4.7K pullup resistor to 5 volts)
    ' E PortB.3
    ' RW Ground
    ' Vdd 5 volts
    ' Vss Ground
    ' Vo 20K potentiometer (or ground)
    ' DB0-3 No connect

    Pause 1000 ' Wait for LCD to startup
    CMCON = 7

    loop: Lcdout $fe, 1 ' Clear LCD screen

    lcdout $FE, $00 + 0, "LINE 1"
    lcdout $FE, $C0 + 0, "LINE 2"
    lcdout $FE, $94 + 0, "LINE 3"
    lcdout $FE, $D4 + 0, "LINE 4"

    pause 2000
    Lcdout $fe, 1 ' Clear LCD screen
    lcdout $FE, $00 + 1, "LINE 1"
    lcdout $FE, $C0 + 1, "LINE 2"
    lcdout $FE, $94 + 1, "LINE 3"
    lcdout $FE, $D4 + 1, "LINE 4"

    pause 2000
    Lcdout $fe, 1 ' Clear LCD screen
    lcdout $FE, $00 + 2, "LINE 1"
    lcdout $FE, $C0 + 2, "LINE 2"
    lcdout $FE, $94 + 2, "LINE 3"
    lcdout $FE, $D4 + 2, "LINE 4"

    pause 2000
    Lcdout $fe, 1 ' Clear LCD screen
    lcdout $FE, $00 + 3, "LINE 1"
    lcdout $FE, $C0 + 3, "LINE 2"
    lcdout $FE, $94 + 3, "LINE 3"
    lcdout $FE, $D4 + 3, "LINE 4"

    pause 2000
    Lcdout $fe, 1 ' Clear LCD screen
    lcdout $FE, $00 + 4, "LINE 1"
    lcdout $FE, $C0 + 4, "LINE 2"
    lcdout $FE, $94 + 4, "LINE 3"
    lcdout $FE, $D4 + 4, "LINE 4"

    pause 2000
    Lcdout $fe, 1 ' Clear LCD screen
    'lcdout $FE, $00 + 5, "LINE 1"
    lcdout $FE, $C0 + 5, "LINE 2"
    lcdout $FE, $94 + 5, "LINE 3"
    lcdout $FE, $D4 + 5, "LINE 4"

    pause 2000
    Lcdout $fe, 1 ' Clear LCD screen
    'lcdout $FE, $00 + 6, "LINE 1"
    lcdout $FE, $C0 + 6, "LINE 2"
    lcdout $FE, $94 + 6, "LINE 3"
    lcdout $FE, $D4 + 6, "LINE 4"

    pause 2000
    Lcdout $fe, 1 ' Clear LCD screen
    'lcdout $FE, $00 + 7, "LINE 1"
    lcdout $FE, $C0 + 7, "LINE 2"
    lcdout $FE, $94 + 7, "LINE 3"
    lcdout $FE, $D4 + 7, "LINE 4"

    pause 2000
    Lcdout $fe, 1 ' Clear LCD screen
    'lcdout $FE, $00 + 8, "LINE 1"
    lcdout $FE, $C0 + 8, "LINE 2"
    lcdout $FE, $94 + 8, "LINE 3"
    lcdout $FE, $D4 + 8, "LINE 4"

    pause 2000
    Lcdout $fe, 1 ' Clear LCD screen
    'lcdout $FE, $00 + 9, "LINE 1"
    lcdout $FE, $C0 + 9, "LINE 2"
    lcdout $FE, $94 + 9, "LINE 3"
    lcdout $FE, $D4 + 9, "LINE 4"

    pause 2000
    Lcdout $fe, 1 ' Clear LCD screen
    'lcdout $FE, $00 + 10, "LINE 1"
    lcdout $FE, $C0 + 10, "LINE 2"
    lcdout $FE, $94 + 10, "LINE 3"
    lcdout $FE, $D4 + 10, "LINE 4"

    pause 2000
    Lcdout $fe, 1 ' Clear LCD screen
    'lcdout $FE, $00 + 11, "LINE 1"
    lcdout $FE, $C0 + 11, "LINE 2"
    lcdout $FE, $94 + 11, "LINE 3"
    lcdout $FE, $D4 + 11, "LINE 4"

    pause 2000
    Lcdout $fe, 1 ' Clear LCD screen
    'lcdout $FE, $00 + 12, "LINE 1"
    lcdout $FE, $C0 + 12, "LINE 2"
    lcdout $FE, $94 + 12, "LINE 3"
    lcdout $FE, $D4 + 12, "LINE 4"

    pause 2000
    Lcdout $fe, 1 ' Clear LCD screen
    'lcdout $FE, $00 + 13, "LINE 1"
    lcdout $FE, $C0 + 13, "LINE 2"
    lcdout $FE, $94 + 13, "LINE 3"
    lcdout $FE, $D4 + 13, "LINE 4"

    pause 2000
    Lcdout $fe, 1 ' Clear LCD screen
    'lcdout $FE, $00 + 14, "LINE 1"
    lcdout $FE, $C0 + 14, "LINE 2"
    lcdout $FE, $94 + 14, "LINE 3"
    lcdout $FE, $D4 + 14, "LINE 4"

    pause 2000
    Lcdout $fe, 1 ' Clear LCD screen
    'lcdout $FE, $00 + 15, "LINE "
    lcdout $FE, $C0 + 15, "LINE "
    lcdout $FE, $94 + 15, "LINE "
    lcdout $FE, $D4 + 15, "LINE "

    pause 2000
    Lcdout $fe, 1 ' Clear LCD screen
    'lcdout $FE, $00 + 16, "LINE"
    lcdout $FE, $C0 + 16, "LINE"
    lcdout $FE, $94 + 16, "LINE"
    lcdout $FE, $D4 + 16, "LINE"

    pause 2000
    Lcdout $fe, 1 ' Clear LCD screen
    'lcdout $FE, $00 + 17, "LIN"
    lcdout $FE, $C0 + 17, "LIN"
    lcdout $FE, $94 + 17, "LIN"
    lcdout $FE, $D4 + 17, "LIN"

    pause 2000
    Lcdout $fe, 1 ' Clear LCD screen
    'lcdout $FE, $00 + 18, "LI"
    lcdout $FE, $C0 + 18, "LI"
    lcdout $FE, $94 + 18, "LI"
    lcdout $FE, $D4 + 18, "LI"

    pause 2000
    Lcdout $fe, 1 ' Clear LCD screen
    'lcdout $FE, $00 + 19, "L"
    lcdout $FE, $C0 + 19, "L"
    lcdout $FE, $94 + 19, "L"
    lcdout $FE, $D4 + 19, "L"
    PAUSE 250

    GOTO LOOP
    Last edited by Rhatidbwoy; - 18th December 2005 at 22:08.

  3. #3
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Add 80h to the character address (set bit 7) to make
    the Display Data RAM Address Set command.

    $80 -> 1st line
    $c0 -> 2nd line
    $94 -> 3rd line
    $d4 -> 4th line

    Best regards,

    Luciano

  4. #4
    Rhatidbwoy's Avatar
    Rhatidbwoy Guest


    Did you find this post helpful? Yes | No

    Default

    the thing about $80 for the first line is that it does not even register on the screen. I have it at 00 right now and that is the only thing that has anything registered on the screen

    $80 does nothing. The funny part to me is that the spec sheet for this screen says that:

    line1 $00
    line2 $40
    line3 $14
    line4 $54

    nothing is even close

  5. #5
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    $00 + $80 = $80
    $40 + $80 = $c0
    $14 + $80 = $94
    $54 + $80 = $d4

    Luciano

  6. #6
    Rhatidbwoy's Avatar
    Rhatidbwoy Guest


    Did you find this post helpful? Yes | No

    Default

    tell me if this is not funny.

    For the hantronix hdm-20416h row1 column1 is $00. Row1 column2 is $80. Then anything to follow row1 column2 is $80 + what ever column that I want it to fall under. I found this out at 5:47pm central time on 18 dec 05. took me one week to figure out all my problems.

  7. #7
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi

    When you power-up the LCD, its cursor position is on line 1 position 1.
    The LCD does that automatically. Also when you clear the LCD the
    cursor will go back to line 1 position 1.

    So if just after LCD power-up or after a LCD clear you write the PicBasic code ....

    Lcdout "test"

    ... the word "test" will be displayed one line 1 and will use the first 4 locations on line 1.

    * * *

    To input instructions to the LCD module, such as clear screen, go to line 2, etc., you
    must prefix the instruction with 254 (0xFE). The byte following prefix is seen and
    treated as a instruction code. After the instruction code, the LCD automatically returns
    to text mode. Every instruction code must be sent with its own 254 prefix (0xFE).

    Cursor position on a four lines LCD:

    To move the cursor to the beginning of the first line and display a text you will need
    to send the prefix $FE, the instruction code $80 and the text to be displayed.

    Example:
    LCDOUT $FE,$80, "Hello on line 1"

    To move the cursor to the beginning of the second line and display a text you will need
    to send the prefix $FE, the instruction code $C0 and the text to be displayed.

    Example:
    LCDOUT $FE,$C0, "Hello on line 2"

    To move the cursor to the beginning of the third line and display a text you will need
    to send the prefix $FE, the instruction code $94 and the text to be displayed.

    Example:
    LCDOUT $FE,$94, "Hello on line 3"

    To move the cursor to the beginning of the fourth line and display a text you will need
    to send the prefix $FE, the instruction code $D4 and the text to be displayed.

    Example:
    LCDOUT $FE,$D4, "Hello on line 4"

    * * *


    In your program, just after LCD power-up or just after a display clear you send:

    lcdout $FE, $00 + 0, "LINE 1"

    With the above code you just send a NOP instruction ($0) to the LCD controller.
    (NOP = Short for No OPeration). The LCD controller ignores your NOP instruction and
    will stay on line 1 position 1 and the output text "LINE 1" will go
    on line 1 position 1 because you don't have changed the LCD cursor position.

    Try to write a text on line 2 and then, without clearing line 2, go to line 1 and write a text on line 1.
    If you tray that you will understand the purpose of the PicBasic code
    LCDOUT $FE,$80, "Hello on line 1".

    Best regards,

    Luciano
    Last edited by Luciano; - 19th December 2005 at 11:39.

  8. #8
    Rhatidbwoy's Avatar
    Rhatidbwoy Guest


    Did you find this post helpful? Yes | No

    Default

    ok. I totally understand what you are talking about. It is just funny to me that the spec sheet talked about how line 1 column 1 is $00 and column 2 line 1 is $80.

    Another thing is that I am not getting anynthing of consistency for the screen. I am trying this whole thing out with my project and I am not getting what the screen mapping is portraying to be. Line 2 in the LCD program works, but with my project program it does not work. Just very frustrating.

    Alright. This should be the determining factor for getting this right. I was having problems with the line and column again (That is the following night). I tried everything that I did the night before and nothing worked, but coming to the conclusion that I needed a pause. I was writing too fast to the screen and the first LCDOUT that I had in it was taking care of the correct write sequence for the other lines. The LCD program that I have works fine because I have a pause in it and my project program I went back to make the corrections. Yes it works fine now.
    Attached Files Attached Files
    Last edited by Rhatidbwoy; - 20th December 2005 at 00:11.

Similar Threads

  1. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  2. Pic18f452 with 20x4 LCD Help
    By djmachine in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 6th November 2008, 22:43
  3. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  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. LCD 20X4 connect with DS1820
    By jojokatada in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 9th March 2005, 11:04

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