0
Offline
Newbie
Karma: 0
Posts: 49
|
 |
« on: May 14, 2008, 08:33:40 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Colombia
Offline
Full Member
Karma: 0
Posts: 130
|
 |
« Reply #1 on: May 14, 2008, 10:31:10 am » |
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Sr. Member
Karma: 3
Posts: 318
Arduino rocks
|
 |
« Reply #2 on: May 14, 2008, 01:45:58 pm » |
It appears to have the same pinout as any other parallel lcd. Should work?
!c
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 49
|
 |
« Reply #3 on: May 15, 2008, 08:52:19 am » |
Cool - I'm getting them tomorrow so I'll give it a try. Thanks Guys
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 49
|
 |
« Reply #4 on: May 16, 2008, 07:32:50 am » |
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 ??
|
|
|
|
|
Logged
|
|
|
|
|
London
Offline
Faraday Member
Karma: 6
Posts: 6226
Have fun!
|
 |
« Reply #5 on: May 16, 2008, 08:32:26 am » |
Make sure you are using a version of the library that has four line support. The constructor should look something like this: //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. 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.
|
|
|
|
« Last Edit: May 16, 2008, 08:33:11 am by mem »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 49
|
 |
« Reply #6 on: May 16, 2008, 09:20:23 am » |
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 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.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 49
|
 |
« Reply #7 on: May 18, 2008, 01:03:37 am » |
anybody ?
|
|
|
|
|
Logged
|
|
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 49
|
 |
« Reply #9 on: May 19, 2008, 08:56:05 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
London
Offline
Faraday Member
Karma: 6
Posts: 6226
Have fun!
|
 |
« Reply #10 on: May 19, 2008, 09:42:29 am » |
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 ?
|
|
|
|
« Last Edit: May 19, 2008, 09:42:52 am by mem »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 49
|
 |
« Reply #11 on: May 19, 2008, 03:31:31 pm » |
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
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 49
|
 |
« Reply #12 on: May 20, 2008, 03:00:39 pm » |
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 : 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  
|
|
|
|
« Last Edit: May 20, 2008, 03:19:26 pm by tvdbon »
|
Logged
|
|
|
|
|
London
Offline
Faraday Member
Karma: 6
Posts: 6226
Have fun!
|
 |
« Reply #13 on: May 20, 2008, 03:09:26 pm » |
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 
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 49
|
 |
« Reply #14 on: May 20, 2008, 03:20:50 pm » |
Thats what I thought too when I saw the 40 and 0x28, but like you say, the rest doesn't match ... very weird.
|
|
|
|
|
Logged
|
|
|
|
|
|