This is the data sheet such as it is..... It Smile really; Poor spelling is never good and it seems to have contradictions especially on the Function set instruction
Spiral, you seem to be pretty close to a solution.
You can send the display a command to tell it where in the display memory to write the next character. This is the address for the character (from position 0 to 79) and then set the high bit of the character. Perhaps an example:
char=%10000000 + 5 ' set Display RAM address to 5
GOSUB LCDCM
(BTW, I don't know if that addition is valid syntax, but you should get the idea.)
You have commented out the following:
' char=%10101000 ' Set DDRAM address to 0
' GOSUB LCDCM
This will set the next address to $28, or 40 decimal, which should be the first character of the right half of the display.
One approach would be to keep track of what column you have reached, and when you think you should be in column 8, you force the display to column 40:
Start: FOR index = 0 TO 14
READ Msg + index, char ' get character from memory
GOSUB LCDwr ' write it to the LCD
PAUSE 500
IF index == 7
char=%10101000 ' goto position 40
GOSUB LCDCM
PAUSE 2 ' only need about 45 us delay, worst case.
ENDIF
NEXT
Again, I don't know if that is the right bpx code for an IF statement, but I expect you can figure it out.
Oh, one other thing -- I found that the Clear function on the display takes a long time, so the next command you send might not be seen, which may be why the code you commented out didn't seem to work -- it may have arrived before the display was ready for it.
You also don't need to worry about setting the CGRAM address (character generator), unless you are going to write some character bit maps to the display.
First, here's the corrected program and correctly setup LCD code (as far as I'm concerned). I tediously confirmed each bit of the setup and give an explanation for each. Many of the original comments were wrong....... used about 100 of my 100k EEPROM writes in the meantime
DingBatty:
Yea?? Thank you. For some reason setting the DD RAM address didn't work for me..... and I tried a lot!
I didn't however set the high bit of the character. I'll try though. I didn't know anything about that.
I'll study your post! Thank you again
DingBatty said: Oh, one other thing -- I found that the Clear function on the display takes a long time, so the next command you send might not be seen, which may be why the code you commented out didn't seem to work -- it may have arrived before the display was ready for it.
Uh, you know..... I think you nailed it! I never though about that and it would explain a lot!
This is the data sheet such as it is..... It Smile really; Poor spelling is never good and it seems to have contradictions especially on the Function set instruction
but, being a LCD newbee, maybe I'm reading it wrong.
I collected the datasheets for the controller chips that are used typically in these LCD displays (or clones of them). You might find these a little easier to read:
DingBatty said: Oh, one other thing -- I found that the Clear function on the display takes a long time, so the next command you send might not be seen, which may be why the code you commented out didn't seem to work -- it may have arrived before the display was ready for it.
Uh, you know..... I think you nailed it! I never though about that and it would explain a lot!
DingBatty, just wanted to let you know that a PAUSE 2 after the clear screen worked like a charm!
IT WORKS!!!!! YEEEEAAAAAAAAA!!!!!!!!
Good grief that was painful!!!
Alright, the PAUSE 2 after the clear screen, then I had to set the display to TWO LINE MODE. I found out about the two line mode because setting DD RAM to 40 did nothing. So I set it to ONE. The message moved over one block. COOL! Then set DD RAM to TWO, then THREE, then SEVEN and all worked. 40 did not. I tried $40, nope..... then the two line mode thing.
Alright, here's the real, honest to goodness, working code. I'll clean it up a little more and make some checks.... but for the moment, use it and have fun!
DingBatty, thank you sir. You pointed out the very obvious to me and give me the final pieces to this.
DingBatty, just wanted to let you know that a PAUSE 2 after the clear screen worked like a charm!
Good for you! If you look in the controller datasheet(s), you will see that the Clear function takes up to 1.52 ms at the nominal clock frequency of 270 KHz. So a 2 ms delay should be sufficient after a Clear operation.
Hey guys, a little late but I thought I'd join the revolution. It's sad it took so long since I still have nearly a hundred of them (probably more, but some are scratched) but over the past couple days I got one working with the msp430 from TI. The hope is this chip can at some point enable me to use only 1 pin of a Propeller or BS2, but I haven't gotten as far as to figure out how to do serial communication.
I have also included a picture of my lcd which I used some hot glue and tin foil to set up a backlight on.
I will post my code soon as I have time to clean it up and comment on it. It's not too hard to understand considering I didn't know how to program C until this week.
Comments
http://www.alldatasheet.net/datasheet-pdf/pdf/277445/ZETTLER/AC161B.html
but, being a LCD newbee, maybe I'm reading it wrong.
You can send the display a command to tell it where in the display memory to write the next character. This is the address for the character (from position 0 to 79) and then set the high bit of the character. Perhaps an example:
(BTW, I don't know if that addition is valid syntax, but you should get the idea.)
You have commented out the following: This will set the next address to $28, or 40 decimal, which should be the first character of the right half of the display.
One approach would be to keep track of what column you have reached, and when you think you should be in column 8, you force the display to column 40:
Again, I don't know if that is the right bpx code for an IF statement, but I expect you can figure it out.
Oh, one other thing -- I found that the Clear function on the display takes a long time, so the next command you send might not be seen, which may be why the code you commented out didn't seem to work -- it may have arrived before the display was ready for it.
You also don't need to worry about setting the CGRAM address (character generator), unless you are going to write some character bit maps to the display.
DingBatty:
Yea?? Thank you. For some reason setting the DD RAM address didn't work for me..... and I tried a lot!
I didn't however set the high bit of the character. I'll try though. I didn't know anything about that.
I'll study your post! Thank you again
Uh, you know..... I think you nailed it! I never though about that and it would explain a lot!
Lemme try that too. If it works, you are the man!
I collected the datasheets for the controller chips that are used typically in these LCD displays (or clones of them). You might find these a little easier to read:
Hitachi HC44780U datasheet: http://www.sparkfun.com/datasheets/LCD/HD44780.pdf
Samsung KS0066U datasheet: http://www.datasheetcatalog.org/datasheet/SamsungElectronic/mXuuzvr.pdf
Samsung S6A0069 datasheet (successor to KS0066U): http://www.datasheetcatalog.org/datasheet/SamsungElectronic/mXruzuq.pdf
That last one has lots of additional commands and additional signalling that I don't think any of these cheap LCDs support.
Uh, you know..... I think you nailed it! I never though about that and it would explain a lot!
Lemme try that too. If it works, you are the man!
IT WORKS!!!!! YEEEEAAAAAAAAA!!!!!!!!
Good grief that was painful!!!
Alright, the PAUSE 2 after the clear screen, then I had to set the display to TWO LINE MODE. I found out about the two line mode because setting DD RAM to 40 did nothing. So I set it to ONE. The message moved over one block. COOL! Then set DD RAM to TWO, then THREE, then SEVEN and all worked. 40 did not. I tried $40, nope..... then the two line mode thing.
Alright, here's the real, honest to goodness, working code. I'll clean it up a little more and make some checks.... but for the moment, use it and have fun!
DingBatty, thank you sir. You pointed out the very obvious to me and give me the final pieces to this.
Good night. I'm late for bed.
Hitachi HC44780U datasheet: http://www.sparkfun.com/datasheets/LCD/HD44780.pdf
[/QUOTE]
Thank you sir. Now that's a proper data sheet! And best of all, it seems applicable to this LCD. I'll be referencing this from this point forward.
Good for you! If you look in the controller datasheet(s), you will see that the Clear function takes up to 1.52 ms at the nominal clock frequency of 270 KHz. So a 2 ms delay should be sufficient after a Clear operation.
Congratulations, and I'm glad to be helpful.
(Yippee! Post # 100!)
I have also included a picture of my lcd which I used some hot glue and tin foil to set up a backlight on.
I will post my code soon as I have time to clean it up and comment on it. It's not too hard to understand considering I didn't know how to program C until this week.