Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Broken 4x20 LCD (hitachi 44780)?

Status
Not open for further replies.

johankj

New Member
Hi all.

I've recently bought a 4x20 LCD panel based on H44780.

It took me a while to get it up and running (I use a 16F627 and didn't realise that RA5 is input only, and that init procedure is wack!).

I now can write text to the display, and I wrote a small test-program that spews data to the panel. When I start it, line 1 gets filled, and the line 3, but nothing ever appears on line 2 and 4? Eventually, line 1&3 wraps.

Any ideas? Phrphrphrphrphreeeease?!?
 
Hi,
Did you get it working before?
I've used 2x16 type, when it is supplied, no program or connection improperly, one line filled and not for another.
 
You need to check what type of module you have - a common type is basically just two 2 line panels in one - you have to select which pair you want to use, there's normally an extra pin for doing this. Check the datasheet for your module.
 
bananasiong said:
Hi,
Did you get it working before?
I've used 2x16 type, when it is supplied, no program or connection improperly, one line filled and not for another.

No, it's brand new. I'm not sure if I understand what you're saying on the second line.
 
Hi,
If the program is not working or the connection between the LCD and the microcontroller is not properly, I see one line filled and not for another line.
 
Nigel Goodwin said:
You need to check what type of module you have - a common type is basically just two 2 line panels in one - you have to select which pair you want to use, there's normally an extra pin for doing this. Check the datasheet for your module.

Looking at the datasheet, I note the following for the pin-out, there are 16:
DB0..DB7 Data in
E, R/W, RS Control Lines
V0 Contrast control
Vdd, Vss Power
A, K Power for LED

The panel is based on HD44780

I've also seen in the Hitachi that you can change the lines that you are writing to, but this has not done anything. I will take a closer look at this.

I've also noted that when I've maxed up the contrast, that lines 1 and 3 are the typical saturated LCD-matrix, but lines 2 and 4 are not.
 
Nigel Goodwin said:
You need to check what type of module you have - a common type is basically just two 2 line panels in one - you have to select which pair you want to use, there's normally an extra pin for doing this. Check the datasheet for your module.
Nope, no extra pin needed...

Check pages 10 & 11 of attached datasheet for number of lines.
One line: Startaddress line 1 is 00h to .... whatever characters you have (maximum is 27h = 40 characters)
Two lines: Startaddress line 2 is 40h to ...

A four lines display is actually a two line display with
Line 1: Address 00h to 13h
Line 2: Address 40h to 53h
Line 3: Address 14h to 27h continuation of line 1
Line 4: Address 54h to 67h continuation of line 2

That's why you always write to lines 1 and 3 on the LCD, for the HD44780 that's one and the same line.
You probably never write to address 40h, so nothing appears on lines 2 and 4 of the LCD.

The init procedure is also important since you use both lines. You have to execute the "Function Set" correctly N=1 (pages 24 & 25) or the display will assume one line and still nothing will appear on lines 2 and 4 :(:(

Too bad you use PIC, I have a LCD library for 8051 systems that calculates the correct address for any position on the LCD. Just tell line, position, text and there it is on the LCD :):):)
 

Attachments

  • HD44780.pdf
    322.1 KB · Views: 543
Do you have the exact datasheet for your specific module?, rather than a generic one.

Obviously the correct datasheet will tell you how to address the other lines.
 
johankj said:
I've also noted that when I've maxed up the contrast, that lines 1 and 3 are the typical saturated LCD-matrix, but lines 2 and 4 are not.
Thanks for that info, now I'm sure your init routine is bad, the HD44780 is configured for only one line (lines 1 and 3 and the LCD) default state :(
Fix you init routine first, you need to see blocs on all four lines, then you know it's ok :)
 
Nigel Goodwin said:
Do you have the exact datasheet for your specific module?, rather than a generic one.

Obviously the correct datasheet will tell you how to address the other lines.
Sorry Nigel but you don't need the datasheet for a specific LCD module, they are all the same as long as they are controlled by a HD44780.
I have several types of modules, different brands also but only one datasheet, the one I posted above, and all my modules works fine :):)

Only once I needed the datasheet of a specific module but that module has 2 HD44780 controllers on it!!
It's a 4*40 characters display, basicly 2 LCD's in one ... ...
 
Last edited:
mcs51mc is correct, If all 4 lines are not visible, the initialization is not correct, or better said not configured for 4 lines.

Now mcs51mc, I also have a "library" (hate that word with every fiber of my being) for PIC do to the same. Mind you I designed it and like any "library" its not part of the native language of the microcontroller therefore no one micro falls into the TOO BAD category. :)
 
mcs51mc said:
Sorry Nigel but you don't need the datasheet for a specific LCD module, they are all the same as long as they are controlled by a HD44780.

So if your datasheet only covers 2x16 displays how do you know what to do for a 4x20 display? - the generic HD44780 is the same interface and commands, but the actual implementation can vary from manufacturer.

I have several types of modules, different brands also but only one datasheet, the one I posted above, and all my modules works fine :):)

Only once I needed the datasheet of a specific module but that module has 2 HD44780 controllers on it!!
It's a 4*40 characters display, basicly 2 LCD's in one ... ...

Exactly, which is what I've been asking all along - with four line LCD's you need to know the details, with two line ones it's pretty universal.

BTW, I would agree that he's probably not initialising it correctly, presuming he's using the single controller type of four line display?.
 
mcs51mc said:
Thanks for that info, now I'm sure your init routine is bad, the HD44780 is configured for only one line (lines 1 and 3 and the LCD) default state :(
Fix you init routine first, you need to see blocs on all four lines, then you know it's ok :)
I didn't give the clear command, which I have added now.

I rewrote the program, changing the DDRAM address the the corresponding lines (writing '123' on each line), as you outlined. I now get text on line 1,3,4, but not 2? I can see the cursor moving across it, however.
 
Nigel Goodwin said:
Do you have the exact datasheet for your specific module?, rather than a generic one.

Obviously the correct datasheet will tell you how to address the other lines.
No, sorry, only that it is a 20x4 HD44780 based panel.
 
Nigel Goodwin said:
Try posting your initialisation code.

Ok, I'll post it, but it's not very pretty.. :eek:

; RA0..RA4, RB5, RA6..RA7 Are LCD Data outputs 1..8
; DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
; RA7 RA6 RB5 RA4 RA3 RA2 RA1 RA0
;
; RB7 is RS (Register Select) & RB6 is E (Enable)
; RS=0 Instruction, RS=1 Character, E=0 Inputs HiImp, E=1 Write Enabled


; Initialize the LCD
BCF PORTB,7 ; Set LCD for Inst.

MOVLW b'00000001' ; Clear Display
MOVWF PORTA ; Push instruction
BCF PORTB,5 ; Set bit 5
BSF PORTB,6 ; Set Enable
CALL DELAY ; General Delay
BCF PORTB,6 ; Clear Enable

MOVLW b'00111000' ; Function Set. 8-bit transfer and address type
MOVWF PORTA ; Push instruction
BSF PORTB,5 ; Set bit 5
BSF PORTB,6 ; Set Enable
CALL DELAY ; General Delay
BCF PORTB,6 ; Clear Enable

MOVLW b'00001110' ; Turn on the display and cursor
MOVWF PORTA ; Push instruction
BCF PORTB,5 ; Clear bit 5
BSF PORTB,6 ; Set Enable
CALL DELAY ; General Delay
BCF PORTB,6 ; Clear Enable

MOVLW b'00000110' ; Set entry mode
MOVWF PORTA ; Push instruction
BCF PORTB,5 ; Clear bit 5
BSF PORTB,6 ; Set Enable
CALL DELAY ; General Delay
BCF PORTB,6 ; Clear Enable
 
johankj said:
MOVLW b'00111000' ; Function Set. 8-bit transfer and address type
MOVWF PORTA ; Push instruction
BSF PORTB,5 ; Set bit 5
BSF PORTB,6 ; Set Enable
CALL DELAY ; General Delay
BCF PORTB,6 ; Clear Enable

OK, so you're setting it to 2 line mode then!.

However, instead of writing each command seperately, it makes much more sense to do it in a subroutine, like this example from my tutorials:

Code:
;Initialise LCD
LCD_Init	movlw	0x20			;Set 4 bit mode
		call	LCD_Cmd

		movlw	0x28			;Set display shift
		call	LCD_Cmd

		movlw	0x06			;Set display character mode
		call	LCD_Cmd

		movlw	0x0d			;Set display on/off and cursor command
		call	LCD_Cmd

		call	LCD_Clr			;clear display

		retlw	0x00
 
johankj said:
I can see the cursor moving across it, however.
Do you send a "Display On/Off Control" command with D=1, C=1 and B=0 (Display: On ; Cursor: On ; Blink: Off) see page 24 of datasheet?
If not, what you see isn't the cursor but some spookie thing because of I don't know what (yet) :D.
 
mcs51mc said:
Do you send a "Display On/Off Control" command with D=1, C=1 and B=0 (Display: On ; Cursor: On ; Blink: Off) see page 24 of datasheet?

He's posted his code, which clearly shows he does that - you don't need to understand PIC code to read his nicely commented binary command data (whereas my is hexadecimal - buy I speak hexadecimal better than binary).
 
Nigel Goodwin said:
He's posted his code, which clearly shows he does that - you don't need to understand PIC code to read his nicely commented binary command data (whereas my is hexadecimal - buy I speak hexadecimal better than binary).
Yes, it took me a little longer than you to analyse the code :eek:

I wonder why you never mentioned that it's completely against the sequence described on page 45 of the datasheet. Sorry to mention it again :D.

So johankj, please modify the sequence of commands according to page 45, respect the mentioned timings and everything would be ok. At least I hope.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top