Shop OBEX P1 Docs P2 Docs Learn Events
4x20 huge LCD problem — Parallax Forums

4x20 huge LCD problem

ScarecrowScarecrow Posts: 38
edited 2005-07-27 20:06 in BASIC Stamp
hi guys,

i just bought a 4x20 lcd and i made it work but i get some very strange results and ive tried everything and i think im going to hang myself now...hehe BUT before i do i tought that maybe you guys had the same problem so maybe theres hope in my life so here it is:

ive programed the lcd to display a character and display in the debug terminal the adress where that character is

the problem comes when in the first line at the 13·position it has a duplicate in line 2 at the first position, and then when line 1 is finished that duplicate(which is now in pos 9·of line 2)continues to finish line 2

same for line 3 and 4

i dont know what could be the problem and i really would like to make this work, ive read other posts with the same problem but no solution, thanks in advance =P

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-21 10:48
    There are a lot of cheap displays out there that don't use "standard mapping" of display addresses (DDRAM). Before you hang yourself, write a simple program that slowly walks through the DDRAM addresses and prints a "*" or other character; use DEBUGIN to control the loop so that you can monitor the addresses. It will take a few minutes, but you may discover the logic of the display mapping.

    One must assume you think that your code is at no fault here since you declined to post it....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • YanroyYanroy Posts: 96
    edited 2005-07-21 14:20
    Without knowing what kind of LCD you have, I could be way off base with this suggestion, but it seems to me that you could be experiencing a problem related to initialization.· Parallel LCD's with the HD44780 (or equivalent) controller need to be initialized with their size.· If you set the size wrong (say, 2x12, if that's even a valid size), it might cause this weird ghosting/wrapping you're experiencing.· I got a problem where it wouldn't let me write to the end of a line on my LCD, which is sorta similar to your problem.· Just a guess...
  • Philip GamblinPhilip Gamblin Posts: 202
    edited 2005-07-21 15:15
    I just went through the headache your are experiencing. I ended up doing exactly what Jon has described and finally managed to get a functional but not perfect display. If you want to solve this problem quickly, Purchase a 2 X 20 SERIAL display from Parallax. Then you have a known hardware quantity( which is a good chunk of the problem you now have) , and plenty of ready written software. I had mine working about 20 min after getting it to the bench. Much better than the 6 or 8 hours of hardship and frustration trying to get my $4.95 " bargain " display to work. Just my humble opinion.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-21 15:31
    Philip,

    ·· While I am inclined to agree with you for many reasons, there are those that will buy the bargain or surplus LCDs, and for those circumstances Jon has a good point.· Assuming the connections are the same as other LCDs (Most are) and at least a Hitachi-Comaptible controller, then you can at least map the display by slowly printing to all the addresses (Displaying the address in DEBUG) and determine mapping.· And of course, it always helps to obtain the datasheet for any LCD.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • ScarecrowScarecrow Posts: 38
    edited 2005-07-21 15:37
    well this is a blue backlit lcd with serial,4 and 8 bit interface posibilities from "electronic assembly" the controller is a KS0073 wich is 100% hitachi HD44780 compatible and it seems like a extremely nice product: its small, ready to mount over a circuit, good contrast......BUT as you see...theres a problem.....hehehehe i have already the adresses of the lines, i agree that this might be an initialization problem but i have absolutely no clue =S ill keep trying to find asolution but ill loose my sanity hehehe, also im sure its not a code error because even if i use it to write only the first line the problem appears, i have seen the same problem in other forums but no solution =(

    Post Edited (Scarecrow) : 7/21/2005 3:40:29 PM GMT
  • Buck RogersBuck Rogers Posts: 2,175
    edited 2005-07-21 19:53
    Hello from Buck Rogers
    Folks in my supply space are four LCD displays. One is a large format a 4x16 one from Optrex, the others are all 2x16 devices. One is a new one, the others are surplus.

    The heck of it is that they are all using the Hitachi controller, and have the same pinouts. Also the same "instruction sequences". All are parallel controlled by the way.

    So unless we see either the code, or screenshots of the device at work, we can't assume anything.

    Personal for both Chris, and Jon, your both right.jumpin.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Buck Rogers

    www.gregg.levine.name
  • GRCGRC Posts: 22
    edited 2005-07-22 01:47
    Hi Scarecrow
    From experience, usally the pinout connections cause the most trouble.
    Find the data sheet and double check the connections, then check them
    again.

    Good Luck
    Gordon
  • ScarecrowScarecrow Posts: 38
    edited 2005-07-22 12:49
    ok, ill try to be as detailed as i can, i took some pictures of the lcd in action and i posted the bs2 code for the adress test and normal characters test(its john williams code, thanks for that :P), i hope it helps =S, the address when the characters clone for line 1 starts at address $8C maybe that helps........from the internet i got that line1 address was $00, line2 $14, line3 $40, and line4 $54......
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-22 14:55
    ·· Just out of curiosity, when you manually set the address to a specific line as per Hitachi compatible displays, where does the character land?

    addr = $80 + $00· (Line 1 position 0)
    addr = $80 + $40· (Line 2 position 0)
    addr = $80 + $20· (Line 3 position 0)
    addr = $80 + $60· (Line 4 position 0)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • ScarecrowScarecrow Posts: 38
    edited 2005-07-22 15:08
    if i do "01234567890123456789" to these addresses:
    addr = $80 + $00 (Line 1 position 0)
    addr = $80 + $40 (Line 2 position 0)
    then you get the result you see in lcdtest.bmp

    if i do the whole 4, the same problem in line 1 and line 3 copying to line 2 and 4 after character 13

    Post Edited (Scarecrow) : 7/22/2005 3:11:16 PM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-22 15:16
    Wow,

    ·· That is weird.· I think I finally grasp what you're saying is happening.· After character 13 you're saying data prints to two locations at the same time?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • OakGraphicsOakGraphics Posts: 202
    edited 2005-07-22 16:02
    Have you tried removing the lcd from your circuit and attaching it to your computer in parallal mode - and use a program like lcdc to generate a test display? I am trying to suggest a method to determine if the circuit you built is mis-wired versus the lcd actually having a hardware problem.

    Nice display actually. Where did you get it? smile.gif (I might not want to buy one until your problem is solved, but it's still very small and cute!)
  • ScarecrowScarecrow Posts: 38
    edited 2005-07-22 18:42
    YES! CHRIS!, im going to try to use it in 8 bit mode to see what happens and maybe ill try serial mode but i have no idea how to do it serial mode, i got it from www.distrelec.com·its an european electronics dealer...=P

    Post Edited (Scarecrow) : 7/22/2005 6:45:07 PM GMT
  • ScarecrowScarecrow Posts: 38
    edited 2005-07-22 21:20
    hehe, i dont have a parallel port in my pc and i cant get the lcd to work in 8 bit mode, could you guys spare me some code to control it 8 bit mode? =S sorry....
  • ScarecrowScarecrow Posts: 38
    edited 2005-07-23 11:58
    i think i got kinda of an idea of the problem, in 4x20 lcds theres an extension register or something like that and im failing to initialize it in 4 line mode anyways its a very vague idea i dont understand th datasheet if you guys wanna help here it is(i would really appretiate it, im giving up on the lcd =(...)
  • ScarecrowScarecrow Posts: 38
    edited 2005-07-23 12:45
    OK I GOT THE SOLUTION!!! (Weeeeehhaaaa!!!), it was all in the initialization procedure, you have to enter extended function set, then say 4 lines, then exit, then do the other normal initializations, like this:

    char = %00101100 'enter extended function set
    GOSUB LCDcmd
    char = %00001001 '4 lines
    GOSUB LCDcmd
    char = %00101000 'exit extended function set
    GOSUB LCDcmd
    char = %00001100 ' display on, cursor off, blink off
    GOSUB LCDcmd
    char = %00000110 ' inc crsr, no disp shift
    GOSUB LCDcmd
  • pBASICpBASIC Posts: 25
    edited 2005-07-24 02:32
    Here is some help in serial if you do use serial
    ==================================================================================================
    PAUSE 4000························· 'Pause (4sec) Wait for LCD Bootup to Clear
    SEROUT 9,BAUD,[noparse][[/noparse]003]················ 'Hide display
    SEROUT 9,BAUD,[noparse][[/noparse]014,100]············ 'Turn Backlight to 100% (On)
    SEROUT 9,BAUD,[noparse][[/noparse]020]················ 'Turn Scroll Off
    SEROUT 9,BAUD,[noparse][[/noparse]024]················ 'Turn Wrap Off
    SEROUT 9,BAUD,[noparse][[/noparse]004]················ 'Turn Cursor Off
    SEROUT 9,BAUD,[noparse][[/noparse]CLR]················ 'Clear Screen
    SEROUT 9,BAUD,[noparse][[/noparse]LINE1]·············· 'Goto Home Position
    SEROUT 9,BAUD,[noparse][[/noparse]"Hello World!"]····· 'Display Text
    SEROUT 9,BAUD,[noparse][[/noparse]017,000,001]········ 'Position Cursor at Col 1 of Line 2 on LCD
    SEROUT 9,BAUD,[noparse][[/noparse]"Text Sent by BS2"]· 'Display Text
    PAUSE 4000························· 'Pause
    SEROUT 9,BAUD,[noparse][[/noparse]CLR]················ 'Clear Screen
    ·
  • ShortShort Posts: 26
    edited 2005-07-25 16:47
    Try this sample code its for non LCD support, It should work for you.




    '{$STAMP BS2}
    '{$PORT COM2} ' Dont forget here



    E CON 7 ' CHANGE HERE for YOUR pins to LCD
    RS CON 8

    Char VAR BYTE
    DA VAR BYTE

    MAIN:
    pause 1000
    GOSUB LCD_ini

    DIS:
    Char = 12
    GOSUB LCDcmd
    Char = 133 ' CHANGE VALUE HERE FOR diferent CURSER SPACES
    GOSUB LCDcmd
    Char = 69 ' VALUE for E
    GOSUB LCDda
    Char = 77 ' VALUE for M
    GOSUB LCDda
    Char = 73 ' VALUE for I
    GOSUB LCDda
    Char = 84 ' VALUE for T
    GOSUB LCDda

    STOP



    LCD_ini:
    LOW 9
    'PAUSE 1000
    Char = 48 ' 8-bit mode
    GOSUB LCDcmd
    PULSOUT E, 1
    PAUSE 10
    Char = 48 ' 8-bit mode
    GOSUB LCDcmd
    PULSOUT E, 1
    PAUSE 1
    Char = 48 ' 8-bit mode
    GOSUB LCDcmd
    PULSOUT E, 1
    PAUSE 1

    PAUSE 5
    PULSOUT E, 1
    PULSOUT E, 1
    Char = 32 ' 4-bit mode
    GOSUB LCDcmd
    PULSOUT E, 1
    Char = 40 ' Set for 2 line operation
    GOSUB LCDcmd
    Char = 12 ' Shift cursor right
    GOSUB LCDcmd
    Char = 6 ' Increment DDRAM after write
    GOSUB LCDcmd
    Char = 1 ' Clear LCD screen
    GOSUB LCDcmd
    Char = 4
    GOSUB LCDcmd
    RETURN



    LCDcmd:
    LOW RS



    LCDwr:
    DA = Char.HIGHNIB
    GOSUB CONV
    PULSOUT E, 1
    DA = Char.LOWNIB
    GOSUB CONV
    PULSOUT E, 1
    HIGH RS
    RETURN


    LCDda:
    HIGH RS


    LCDwrD:
    DA = Char.HIGHNIB
    GOSUB CONV
    PULSOUT E, 1
    DA = Char.LOWNIB
    GOSUB CONV
    PULSOUT E, 1
    LOW RS
    RETURN


    CONV:
    OUTPUT 3
    OUT3 = DA.BIT3 ' CHANGE HERE for the pins you have connected to LCD 4 bit mode
    OUTPUT 4
    OUT4 = DA.BIT2
    OUTPUT 5
    OUT5 = DA.BIT1
    OUTPUT 6
    OUT6 = DA.BIT0
    RETURN
  • ShortShort Posts: 26
    edited 2005-07-25 16:51
    Dont forget to TAKE LOW 9 OUT of program!
  • OakGraphicsOakGraphics Posts: 202
    edited 2005-07-26 09:47
    scarecrow - I was flipping through the pbasic manual today and noted most lcds do take a bit of time to initialize. You might need some wait statements in there to give it a break. It suggested at least 700ms then sending 3 sets of wake commands. Also - some commands need a delay before doing anything else. :-/

    Either way I am glad you got it working! It's a very cute display to say the least!
  • OakGraphicsOakGraphics Posts: 202
    edited 2005-07-26 09:50
    Speaking on serial control of these lcds- I am starting to see futaba and the like VFD that can do serial control. Has anybody tried them yet?
    I would think I would prefer serial any day. smile.gif I see Pbasic having some code on this in this thread. Pbasic - what model(s) did you use with that?
    Just trying to find a 4x20 lcd/vfd that is small and can be controlled serial wise without tossing out more then 30$ for the deal.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-26 14:49
    OakGraphics said...
    scarecrow - I was flipping through the pbasic manual today and noted most lcds do take a bit of time to initialize. You might need some wait statements in there to give it a break. It suggested at least 700ms then sending 3 sets of wake commands. Also - some commands need a delay before doing anything else. :-/
    Either way I am glad you got it working! It's a very cute display to say the least!
    ·· Here's a little bit of information that can help you avoid putting pauses in your code for LCDs when using them in Parallel mode...The Hitachi/Compatible displays have what's called a BUSY flag that is set when the display is ready for a new character or command.· This is easily read by the BASIC Stamp or SX, and allows you to start sending data as soon as the LCD is ready.

    ·· Basically you read in the command register (Which will read in the current address pointer) and check the state of BIT7.· If BIT7 is set, you re-read the register until it's cleared then send your next character/command.· This is more useful to the SX, but the faster BASIC Stamps, such as the BS2px24 could find themselves wasting time pausing when it might be quicker to simply check the busy flag at the entry point into your LCD write routine.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • pBASICpBASIC Posts: 25
    edited 2005-07-27 20:06
    I know this is kind of dumb but I think that program I found was in the help file for the basic stamp editor search in it for SEROUT.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    =============================================================================================================================================
    Name=Chris Ault

    =============

    Age

    12

    ======
    grade

    7

    Webpage
    Email=miniwarrior@cox.net
Sign In or Register to comment.