having problems with Hantronix 20x4 lcd


Closed Thread
Results 1 to 17 of 17
  1. #1
    Rhatidbwoy's Avatar
    Rhatidbwoy Guest

    Default having problems with Hantronix 20x4 lcd

    I am having problems with my hantronix lcd screen. I can not get anything out of it. The unit is getting 5 volts of Vd. The ground is connected to ground with the R/W to ground also. The Vl, which is the contrast is connected as Hantronix prescribed and the voltage to that is .8 volts. Then last I am using the 4bit mode.

    I have tried PBP sample for LCD and I have modified the PBC and tried there sample also for the fact that I can manipulate the Init. seq. I still get nothing from everything and I can not find any information over the internet and none from Hantronix. There tech sup is really of no help finding the problem.

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


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Could be a timing problem. Write a program to verify your configuration settings.

    With the code below you should see the light of the LED 60 times in 1 minute.
    Just count and check your watch. (The LED is ON for 500 ms and OFF for 500 ms).

    Best regards,

    Luciano


    Code:
            Low PORTB.0    ' Turn off LED connected to PORTB.0
    
    
    loop:   Toggle PORTB.0  ' Toggle the LED connected to PORTB.0
            Pause 500       ' Delay for 500 milliseconds
            Goto loop       ' Go back to loop and blink LED forever
    
            End

    (Connection schematic, see the LED and the 470 ohm resistor)

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

  3. #3
    Rhatidbwoy's Avatar
    Rhatidbwoy Guest


    Did you find this post helpful? Yes | No

    Default

    I think that you are talking about a different project. What the problem that I was having is not seeing anything on a LCD.

    I got something to display, but the problem that I am having now is that the character lineup for the row and column isn't right. 00 for the hdm-20416h is row 1 column 1. I get nothing there when I write to it. from the home position I get something. If I write to line 2 which is 40 I get nothing. 40 meaning line 2 column 2.

  4. #4
    MikeTamu's Avatar
    MikeTamu Guest


    Did you find this post helpful? Yes | No

    Default

    How about you post your code?

  5. #5
    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.

  6. #6
    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.

  7. #7
    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

  8. #8
    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

  9. #9
    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

  10. #10
    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.

  11. #11
    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.

  12. #12
    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.

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


    Did you find this post helpful? Yes | No

    Default

    Hi,

    The compiler will take care for the right LCD timing, no
    need to insert pauses. The compiler can do that for you only if
    you specify the used oscillator. If you don't specify the oscillator
    frequency, PicBasic Pro assumes that you are using a 4MHz oscillator.
    If you are using a 20 MHz oscillator, DEFINE OSC 20 is mandatory.
    If you don't do that, LCDOUT will not work with the right timing.
    LCDOUT is not the only PicBasic command that needs correct timing.
    (See PicBasic Pro manual).

    DEFINE OSC xy tells the compiler the oscillator frequency and
    the compiler will output an HEX file with all the delays calculated
    for that oscillator frequency.

    Make sure your PIC is also using the same oscillator frequency.
    (Your harware is also using the same oscillator frequency).

    To test that, go back to my first post in this thread, and try
    to compile the flashing LED program and flash the PIC with it.
    (Make sure you use DEFINE OSC xy in the code).

    Examples:

    DEFINE OSC 4 'Oscillator speed 4 MHz
    DEFINE OSC 20 'Oscillator speed 20 MHz

    See PicBasic Pro manual for all the possible values of DEFINE OSC.

    There is a list of DEFINEs in the PicBasic Pro manual and some are for
    the LCD configuration. Some of these DEFINEs can help in case you are
    using an exotic LCD controller. (NOT the case for Hantronix).

    * * *

    The addresses you see in the Hantronix spec sheet are the
    display RAM Map addresses. The Hantronix spec sheet is correct, no
    errors in it.


    Best regards,

    Luciano

  14. #14
    Rhatidbwoy's Avatar
    Rhatidbwoy Guest


    Did you find this post helpful? Yes | No

    Default

    I get the timing issue that you are talking about. What i have done to correct the timing issue I had was to use the on board INTRC that the PIC16F6xx has to offer. Leaving me running the 4MHz is not a problem.

    The timing issue that I do have is that after I run a clear (LCDOUT $FE, 1), I have to pause after that so the LCD can see what I am writing and do it (The screen timing that the specs show is no different than the other screen I was using, but there with the actual screen). The thing that gets me also is that the maping of the LCD is not to what they have. it starts with 00 for line 1 and 40 for line 2 and so forth. I am using the 80 screen setup.

    A reason to why i was having these problems was because I needed a longer time after clearing the screen for the line problem I was having not to be a problem. Another thing to is that the contrast is not between 0 and 5 volts it needs something higher. Checking the voltage between Vdd and contrast it comes to being 7 volts where as the standard screen they recommend .3v and extended was something higher. Any how I got it to work.

    Thank you for your time in explaining how things are to go and other was of trouble shooting.

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


    Did you find this post helpful? Yes | No

    Default

    Hi,

    The picture below shows how to connect the 10k potentiometer to
    the LCD module. If you cannot adjust the contrast, your LCD module is broken.

    Best regards,

    Luciano



    http://img8.picsplace.to/img8/3/lcd_pot.jpg

  16. #16
    Rhatidbwoy's Avatar
    Rhatidbwoy Guest


    Did you find this post helpful? Yes | No

    Default

    i got that part. luciano I get what you are saying. we are just getting crossed with the explanation.


    ok get this. I am having problems with my program. I would like for the pointer that I have in my project (transmitter) to go to line four. I have the pointer start in column 2 on the LCD and go up and down. There are three screens that this pointer shows up on and the first screen it works on. The first screen it starts on the second line second column then goes down to line four. The problem that I am having is that I would like for this to happen on the second page also, go from line one to four then scroll to page three, but I can not get it to go down to line four. I have checked the program (transmitter) numerous amount of time and I can not seem to find what the problem is. Do you have any idea on that.


    Where it starts:

    CHANNELS:
    line = linet
    line = linet1
    screen = screent
    line = $81:val = $8E
    CHANNELSA:
    screen = 2
    lcdout $FE, 1
    pause 10
    lcdout $FE, $93, CS1
    lcdout $FE, $D3, CS2
    lcdout $FE, $83, "Channel 1:"
    lcdout $FE, $C3, "Channel 2:"
    lcdout $FE, $97, "Channel 3:"
    lcdout $FE, $D7, "Channel 4:"
    gosub subval
    gosub value
    gosub pointer
    pause 500
    CHANNELSB:
    goto channels1b

    CHANNELS1B:
    if PortB.7 = 1 or PortB.6 = 1 or PortB.5 = 1 or PortB.4 = 1 then pause 300
    if PortB.7 = 1 or PortB.6 = 1 or PortB.5 = 1 or PortB.4 = 1 then CHANNELS1C
    goto CHANNELS1B
    CHANNELS1C:
    if PortB.6 = 1 and PortB.7 = 1 then pause 300
    if PortB.6 = 1 and PortB.7 = 1 then enter
    if PortB.5 = 1 then meninc
    if PortB.4 = 1 then mendec
    if PortB.7 = 1 then chlinc
    if PortB.6 = 1 then chldec
    goto channels1b




    This is where I think the problem is:

    MENINC:
    if line = $81 and Screen = 2 or screen = 3 then Line2
    if line = $C1 and Screen = 1 or screen = 2 or screen = 3 then line3
    if line = $95 and screen = 1 or screen = 2 then line4
    if line = $D5 and screen = 2 then channels1 ' Scroll to page 3
    goto scren
    MENDEC:
    if line = $D5 and screen = 1 or screen = 2 then line3
    if line = $95 and screen = 1 or screen = 2 or screen = 3 then line2
    if line = $C1 and screen = 2 or screen = 3 then line1
    if line = $81 and screen = 3 then line4s ' Scroll to page 2
    goto scren
    LINE1: line = $81:val = $8E:goto scren
    LINE2: line = $C1:val = $CE:goto scren
    LINE3: line = $95:val = $A2:goto scren
    LINE4: Line = $D5:val = $E2:goto scren
    LINE4S: line = $D5:val = $E2:goto channelsa



    Program continues with the loop:

    SCREN:
    if screen = 1 then menua
    if screen = 2 then channelsa
    if screen = 3 then channels1a


    P.S. the program is posted earlier in the forum
    Last edited by Rhatidbwoy; - 21st December 2005 at 21:45.

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


    Did you find this post helpful? Yes | No

    Default

    Hi,


    Your code:

    MENINC:
    if line = $81 and Screen = 2 or screen = 3 then Line2
    if line = $C1 and Screen = 1 or screen = 2 or screen = 3 then line3
    if line = $95 and screen = 1 or screen = 2 then line4
    if line = $D5 and screen = 2 then channels1 ' Scroll to page 3
    goto scren


    =============================

    I don't work with PICBasic Pro, I just read this forum for ideas.
    Anyway, I will try to help you. Below is my version of your code.
    (You will have to fix also your code at label MENDEC).

    PicBasic does not disntigush between upper or lower case, but please
    be consistent when you write your code. Example, labels in upper case,
    variable names in lower case.

    Best regards,

    Luciano

    Code:
    MENINC:
     
    IF line = $81 THEN
        If screen = 2 OR screen = 3 THEN LINE2
    ENDIF
    
    
    IF line = $C1 THEN LINE3
    
    
    IF line = $95 THEN
        IF screen = 1 OR screen = 2 THEN LINE4
    ENDIF
    
    
    IF line = $D5 AND screen = 2 THEN CHANNELS1
    
    
    GOTO SCREN
    Last edited by Luciano; - 22nd December 2005 at 12:24.

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 : 1

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