Go Down

Topic: Will this LCD work ? (Read 1 time) previous topic - next topic

tvdbon

Hi There,



I'm planning a project with a 4 line LCD. These are the only ones that I can find locally. I've been looking through the datasheet and it seems hd44780 compatible, but I'm not sure. Can somebody check the datasheet and just verify for me that it will work.

Thanks,
Tom


drone

It appears to have the same pinout as any other parallel lcd. Should work?

!c

tvdbon

Cool - I'm getting them tomorrow so I'll give it a try. Thanks Guys

tvdbon

ok, so it works, but only the first line. The other lines won't display anything. And if I use the 4bit2x20 lcd library then it doesn't show anything ??

mem

#5
May 16, 2008, 03:32 pm Last Edit: May 16, 2008, 03:33 pm by mem Reason: 1
Make sure you are using a version of the library that has four line support.

The constructor should look something like this:
Code: [Select]
//constructor.  num_lines must be 1 or 2 or 4, currently.
LCD4Bit::LCD4Bit (int num_lines) {
 g_num_lines = num_lines;
 if (g_num_lines != 1 && g_num_lines != 2 && g_num_lines != 4)
 {
   g_num_lines = 1;
 }
}

And your cursorTo function should look something like this.

Code: [Select]

void LCD4Bit::cursorTo(int line_num, int x){

 //if we are on a 1-line display, set line_num to 1st line, regardless of given
 if (g_num_lines==1){
   line_num = 1;
 }
 //offset 40 chars in if second line requested
 //
 switch (line_num){
       case 2:
           x+= 0x40 ; break;;
     case 3:
           x+= 0x14 ; break;; // In fact, line 3 is an extension of the line 1 (beyond the 20 first characters)
     case 4:
           x+= 0x54 ; break;; // Line 4 is an extension of line 2
 }
 
 commandWrite(0x80+x);
}
]


There is four line specific code in a few other places in the library but if yours doesn't have lines like the above then you need to download one that says it supports 4 lines.


tvdbon

Quote
Make sure you are using a version of the library that has four line support.


I checked the library and it looks fine. But this is what I Figured out.

When I set it to a 1 line lcd, it works fine for line1. I can also write on line 3 using lcdlocate(1, 0x14), essentially forcing it to start writing at that address. But, as soon as I change the num lines to anything else then I can't do anything, not even write on line 1. The only other place where the numlines have any relevance (except for setting the location) is in the init part

Code: [Select]
int num_lines_ptn ;
 if (g_num_lines != 4) {
       num_lines_ptn = g_num_lines - 1 << 3;
 } else {
     num_lines_ptn = 2 - 1 << 3; // we are controlling the 4 lines display as an 2 lines.
 }
 int dot_format_ptn = 0x00;      //5x7 dots.  0x04 is 5x10

 commandWriteNibble(num_lines_ptn | dot_format_ptn);
 delayMicroseconds(60);


The datasheet on this lcd doesn't give much else apart from the pinouts. Any help would be greatly appreciated.

tvdbon


mem

The cursor positioning code in the library should do that 0x14 addressing for you. Have you tried this library: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1170601618/0#0
Its discussed in this thread: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1170601618/0#0

Most 4 line displays actually contain two driver chips and the panel manufacturers use subtly different ways of connecting them up. There are some suggestions in the discussion thread linked above that may help you get yours going.

tvdbon

Yep, I tried that library. Also the pinouts only show 1 enable so no go on that either. I'll try tonight in 8bit mode and see how that goes

mem

#10
May 19, 2008, 04:42 pm Last Edit: May 19, 2008, 04:42 pm by mem Reason: 1
Quote

When I set it to a 1 line lcd, it works fine for line1. I can also write on line 3 using lcdlocate(1, 0x14), essentially forcing it to start writing at that address. But, as soon as I change the num lines to anything else then I can't do anything ...


Am I correct in thinking that you can write to line 3 by doing
  cursorTo(1, 0x14);
but cursorTo(3, 0); does not work?

and that you tried this with the library linked in post 8  ?


tvdbon

Quote

Am I correct in thinking that you can write to line 3 by doing
  cursorTo(1, 0x14);
but cursorTo(3, 0); does not work?

and that you tried this with the library linked in post 8  ?



Correct, but cursorTo(3,0) won't work because I specify only 1 line when I init the LCD. If I use any other amount then nothing works. Yes, I tried that library.

Don't know if this helps but I think I found the datasheet for the controller for this lcd:

http://www.lcdproduct.com/Tech/Controller_Or_Driver/SPLC780D_DS.pdf

tvdbon

#12
May 20, 2008, 10:00 pm Last Edit: May 20, 2008, 10:19 pm by tvdbon Reason: 1
OK, so I got it to work. I the registers in the datasheet are either wrong or I have the wrong datasheet, but here is what I figured out:

(1) It's really a 2x40 lcd, but the lines are cut in two so you have a 4x20
(2)

According to my datasheet the registers for each line should start at :

Line 1 : 0x0
Line 2 : 0x40
Line 3 : 0x14
Line 4 : 0x54

but the registers actually are :

Line 1 : 0x0
Line 2 : 0x28
Line 3 : 0x14
Line 4 : 0x3C

Weird ??

So I initialized the lcd as a two line lcd and I changed the cursorTo function to the following :

Code: [Select]
void LCD4Bit::cursorTo(int line_num, int x){
 //first, put cursor home
 commandWrite(CMD_HOME);

 //if we are on a 1-line display, set line_num to 1st line, regardless of given
 if (g_num_lines==1){
   line_num = 1;
 }
 
 //offset 40 chars in if second line requested
 if (line_num == 2){
   x += 0x28;
 }
 
 if (line_num == 3){
   x += 0x14;
 }
 
 if (line_num == 4){
   x += 0x3C;
 }
 
 //advance the cursor to the right according to position. (second line starts at position 40).
 for (int i=0; i<x; i++) {
   commandWrite(0x14);
 }
}


Now it finally works :)


mem

good to hear you got it going!

0x28 is decimal 40, I was thinking that the documentation may have confused hex and decimal
but  x3c is decimal 60 not 54.

anyway, full marks for persistance  :)

tvdbon

Thats what I thought too when I saw the 40 and 0x28, but like you say, the rest doesn't match ... very weird.

Go Up