Shop OBEX P1 Docs P2 Docs Learn Events
LCD Displays only 8 of 16 chars — Parallax Forums

LCD Displays only 8 of 16 chars

Philip GamblinPhilip Gamblin Posts: 202
edited 2005-07-12 06:20 in BASIC Stamp
I am using the code from Stamp Works 1.2.(StampWorks Manual Version 1.2 • Page 75) See attached
·My displays are 1 X 16 and 2 X 8 Char displays and are connected as in the StampWorks Manual.· I am going on the assumption that the wiring is correct since I am able to display " The Basi ". What I believe should be displayed is "The Basic·Stamp!"·In fiddling with the code I can change the message, but still display only 8 chars. Same result with either display,·the 1 X16 or·2 X 8.· Interestingly though all of the funtions of the program operate. It scrolls,and flashes etc. but the character count is wrong. ·I have tried to·diddle what I believe to be·one of the confiuration bytes and have seen 2323232323232323 displayed so I know all the digits are available·I have rechecked my wiring and rechecked it again. I know that doesn't mean it's right, I just didn't see any glaring errors.

I have debugged the index value for the read command which reads the message form eeprom, and it seems to be incrementing properly but the chars simply stop displaying.· My guess is that I need to tell the program that I have 1 X 16 not a 2 X 16 display. At this point, I am completely cluleless.

In the LCD_Init routine, there are two consecutive Pulseout comands. Just looking at the routine, it appears there is a line missing.

Thanks for the help.

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-10 21:12
    Philip,

    ·· The display is most likely configured as if it were a 2 X 8 even though it's a 1 X 16.· Treat it as a 2 X 8 and it should work.· In other words, use 2 line mode, and change the address to $40 (Send an value of $C0, which is the address plus setting bit 7 high) to begin the second half of the line.· I have two display that are the same configuration.· They are OPTREX PWB16187.· This configuration is actually quite common.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com


    Post Edited (Chris Savage (Parallax)) : 7/10/2005 9:19:58 PM GMT
  • Philip GamblinPhilip Gamblin Posts: 202
    edited 2005-07-11 03:50
    So its a matter of where the data is written into the DDRAM?... I think understand what you said, but I'm not sure how to implement it. Specifically I'm not sure where to set 2 line mode, or where to alter the address. But I'm going to look now.

    Thanks.
    ·I did make an attempt to implement your suggestion, but failed. Looks like it is an issue with the DDRAM addressing. I think i need to cozy up with a copy of the hd44780 data sheet and have a nice read. Hopefully I'll have a better grip on this tomorrow.
    Thanks again.

    Post Edited (Philip Gamblin) : 7/11/2005 4:28:33 AM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-11 04:03
    Philip,

    ·· Check your data sheet.· My addressing might look a little off to you because normally BIT7 of the address command is set adding 128 to it, but normally the addresses in a 1 X 16 display would be:

    00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15

    But in many 1 X 16 displays it's actually:

    00 01 02 03 04 05 06 07 64 65 66 67 68 69 70 71

    Because the display is treated as if it were a 2 line display with 8 characters each.· Even then it gets tricky, because all the addresses in between 07 and 64 are there, and you can store text in them.· They are typically used in display scrolling and other neat tricks, but if you were to keep printing text past the end the way you were, when you got to 64 you would see text again in the second half of the display.· I hope this helps.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Philip GamblinPhilip Gamblin Posts: 202
    edited 2005-07-11 04:55
    Ok , I understand what you're saying but in the code the only reference I can find to the DDRAM addr is

    DDRam CON $80 ' Display Data RAM control.

    I believe you're telling me to write the first 7 chars to addr 0-7 and the next 8 chars to addrs 64 to 71 .... Cool . My confusion is how to change where the chars are being written. The write routine simply dumps the two nibbles of the of the char 1 at a time onto the data bus an strobes the enable.
    Again, it looks like i need to become MUCH more familiar with the data sheet. Thanks.

    LCD_Command:

    LOW RS ' enter command mode '*********************************************************************

    LCD_Write: ' I don't see where the LCD Write uses the DDRAM address

    LCDbus = char.HIGHNIB ' output high nibble ' it just puts the 2 nibbles on the data bus and strobes the enable

    PULSOUT E, 1 ' strobe the Enable line

    LCDbus = char.LOWNIB ' output low nibble

    PULSOUT E, 1

    HIGH RS ' return to character mode

    RETURN
  • NateNate Posts: 154
    edited 2005-07-11 11:52
    Phillip,

    When using a LCD, one sends the start address of where in the DRAM to store data to be displayed, and then one sends the actual data one char at a time - you·set·your start DRAM address·in your posted code in the main program section:

    FOR index = 14 TO 0············· ' go backward by moving cursor

    ·· ··· char = DDRam + index···· ' to a specific address

    ······ GOSUB LCD_Command

    ······ PAUSE 150

    NEXT

    In this section you are actually moving the curser around, but it has the effect of setting the DRAM address as well.· (It looks to me as though your program sends your text to some undefined location the first time through the main loop, but the next time through the DRAM start location has been set to 0 [noparse][[/noparse]$80 = %1000_0000, where the '1' tells the LCD this is start address, the '0's are the address, see HD44780U data sheet]).· To write to a specific DRAM location, do this:

    "char = ('1'·prepended to·seven bit desired DRAM address)"

    and then

    "GOSUB LCD_Command"

    this sets DRAM start address, and the LCD is smart enough to increment the address after each write (your "GOSUB LCD_write" lines).· As Chris has expalined, you will need to experiment to find out which DRAM addresses you actually need to send your text to the right place.· You may have to send the DRAM address twice, once before sending any text (beginning of Main program?), and again after sending the first 8 chars.

    If the line in your code that reads "LCD_Write:" was left justified (subroutine), I think you would understand your program better.

    Nate


    Post Edited (Nate) : 7/11/2005 1:21:41 PM GMT
  • Philip GamblinPhilip Gamblin Posts: 202
    edited 2005-07-11 14:19
    Thanks so much for the help. Part of the problem is I just copied this program from th estamp works manual.... I didn't have any realy undestanding of the program....But I'm getting closer.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-11 15:49
    Philip,

    As Chris pointed out, you probably have a display that does not use a contiguous display map in the physical display as the module provided with StampWorks does.· What this means is that you have to program around this.· You'll need to keep track of the cursor position and when you're going to cross that boundary you need to update the cursor location manually (the "standard" initialization in the StampWorks manual causes the cursor to advance on every write).

    Part of the problem you're having understanding what is really as simple program is that you're using the wrong LCD.···The code was written for a contiguous display device.· I'm currently writing an update to StampWorks, so I will go re-open the LCD chapter and emphasize that point.

    The best thing to do is find the driver documentation for the display you've got -- that will help you make sense of the code (StampWorks has never been presented as a stand-alone document, and the reader is directed to gather and study appropriate technical documentation on all the parts used).· With the HD44780 bit 7 tells the display to deal with the DDRAM; bit 6 indicates the destination is the CGRAM.· I simplified (I thought) program design through the use of constants.

    In one of you point out two consecutive PULSOUT instructions and ask about a missing instruction.· That's not the case; what's happening is that the program takes advantage of the BS2's instruction load timing and the delay is appropriate.· On fast Stamp modules (e.g., BS2p and BS2px) you can insert a very short delay with:

    · PAUSE 0

    which is indeed a valid instruction.

    Finally, "diddling" with code that you don't fully understand is probably not the best way to "fix" it....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Philip GamblinPhilip Gamblin Posts: 202
    edited 2005-07-11 16:35
    No doubt you're exactly right. This is a very clear example of using the wrong hardware and a little knowlege being a dangerous thing. The display is surplus, and it seems rather obvious now that you guys have generously donated your time to explain it to me, to be an issue with the DDRAM being non-contigous.

    Thanks to you guys, I should be able to get there from here.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-11 16:46
    You should be able to use the code you have to "map" the display, then control it (albeit manually) to get what you need. I really hate those non-contiguous displays, and toss them into the trash if I discover them in my parts bins. Good luck with your projects.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Philip GamblinPhilip Gamblin Posts: 202
    edited 2005-07-11 23:55
    Yeah I'm working on that now. I was just trying to kill time while waiting for my Parallax serial display to arrive. But I am learing a lot. Thanks again for all the help. I'll be fairly familiar with the HD44780 once this is over. That serial LCD display is becoming more of a bargain by the minute!
  • Philip GamblinPhilip Gamblin Posts: 202
    edited 2005-07-12 06:20
    Finally thanks to you guys, its woking. It was simply a DDRAM mapping issue. A lot easier to say than it is to understand. Mine wasn't a particularly elegant solution, but functional. I'll at least have a way test and avoid these style displays in the future. I am learning a lot about the controller though.
    Many Many thanks again and Happy Stamping!
Sign In or Register to comment.