Shop OBEX P1 Docs P2 Docs Learn Events
16x2 Parallel LCD, Displays incorrect chars. — Parallax Forums

16x2 Parallel LCD, Displays incorrect chars.

GeorgeLGeorgeL Posts: 131
edited 2009-08-30 03:37 in BASIC Stamp
I just recieved my 16x2 LCD Parallel, and got the demo to show up correctly, but I am trying to display charecters I store in an array and they show asian charecters or something like that.

' =========================================================================
'   File...... Parallel_LCD_2X16.bs2
'   Purpose... Parallel LCD Display Demo
'   Author.... Parallax, Inc.
'   E-mail.... [url=mailto:support@parallax.com]support@parallax.com[/url]
'   {$STAMP BS2}
'   {$PBASIC 2.5}
' -----[noparse][[/noparse] Program Description ]---------------------------------------------
' This program demonstrates using a Hitachi-compatible Parallel LCD Display
' This code works with the BS2, BS2e and BS2sx
' -----[noparse][[/noparse] I/O Definitions ]-------------------------------------------------
E               PIN     0               ' Enable Pin For LCD
RW              PIN     2               ' R/W Pin For LCD
RS              PIN     3               ' LCD Register Select
                                        ' 0 = Instruction, 1 = Text
' -----[noparse][[/noparse] Variables ]-------------------------------------------------------
char            VAR     Word            ' Character To Send To LCD
time            VAR     Byte(5)
inst            VAR     char            ' Induction To Send To LCD
index           VAR     Word            ' Character Pointer
temp            VAR     Byte            ' Temp Variable
gpstime VAR Word
' -----[noparse][[/noparse] EEPROM Data ]-----------------------------------------------------
'DO
SERIN 15,16572,[noparse][[/noparse]WAIT("RMC,"),DEC gpstime]
gpstime = gpstime
FOR temp = 0 TO 4
time(temp)= gpstime DIG temp
NEXT
'GOSUB Main
'GOSUB Initialize
'LOOP
'DATA "Goodbye, this is the LCD demo."     ' Message To Send To LCD
' -----[noparse][[/noparse] Initialization ]--------------------------------------------------
Initialize:
  LOW RW                                ' Set LCD To Write Mode
  OUTS = %0000000000000000              ' Set All Output Low
  DIRS = %0000000011111111              ' Set I/O Direction
  GOSUB Init_Lcd                        ' Initialize The LCD Display
' -----[noparse][[/noparse] Program Code ]----------------------------------------------------
Main:
  FOR temp = 0 TO 4                   ' 28 Characters
    char= time(temp)
    DEBUG DEC time(temp)                        ' Read Next Character From EEPROM
    GOSUB Send_Text                     ' Send Character To LCD Display
  NEXT
  RETURN
END
' -----[noparse][[/noparse] Subroutines ]-----------------------------------------------------
Init_Lcd:
  OUTS = %00110000                      ' Reset The LCD
  PULSOUT E,1                           ' Send Command Three Times
  PAUSE 10
  PULSOUT E,1
  PAUSE 10
  PULSOUT E,1
  PAUSE 10
  OUTS = %00100000                      ' Set To 4-bit Operation
  PULSOUT E,1
  Inst = %00101000                      ' Function Set (2-Line Mode)
  GOSUB Send_Inst
  Inst = %00001110                      ' Turn On Cursor
  GOSUB Send_Inst
  Inst = %00000110                      ' Set Auto-Increment
  GOSUB Send_Inst
  Inst = %00000001                      ' Clears LCD
  GOSUB Send_Inst
  Inst = 14                             ' Set Cursor To Underline
  GOSUB Send_Inst
  RETURN
Send_Inst:
  LOW RS                                ' Set Instruction Mode
  OUTB = Inst.HIGHNIB                   ' Send High Nibble
  PULSOUT E,1
  OUTB = Inst.LOWNIB                    ' Send Low Nibble
  PULSOUT E,1
  HIGH RS                               ' Set LCD Back To Text Mode
  RETURN
Send_Text:
  OUTB = Char.HIGHNIB                   ' Send High Nibble
  PULSOUT E,1
  OUTB = char.LOWNIB                    ' Send Low Nibble
  PULSOUT E,1
  RETURN
Next_Line:
  Inst = 128+64                         ' Move Cursor To Line 2
  GOSUB Send_Inst
  RETURN

Comments

  • VaatiVaati Posts: 712
    edited 2009-08-29 19:03
    Try this code...· I think it's formatted to work with a 16x2.· What it does is display "Hello smile.gif "· You can look at the code to see how the smiley face is made.

    What type of custom character are you trying to make?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Quit buying all those fixed voltage regulators, and·get an Adjustable Power Supply·for your projects!· Includes an LED testing terminal!

    *-NEW-* SD Card Adapter·Now available!· Add extra memory to your next Propeller project with ease!
  • GeorgeLGeorgeL Posts: 131
    edited 2009-08-29 19:09
    Im just trying to display normal numbers like 23123 but not reading it from EEPROM, but from a GPS. When I send the same data to the DEBUG window, I have to do DEC but cant figure out if theres something similar for the LCD. The LCD just displays 5 random non-english characters.

    ·
  • VaatiVaati Posts: 712
    edited 2009-08-29 19:23
    Are you storing the value of the GPS reading in a variable--if so, which one? I've never used GPS, but I think you could use that code I posted and modify the DisplayMessage routine so Scratch = [noparse][[/noparse]your GPS variable here]

    So when you have it display the data on the debug terminal, there isn't a problem?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Quit buying all those fixed voltage regulators, and·get an Adjustable Power Supply·for your projects!· Includes an LED testing terminal!

    *-NEW-* SD Card Adapter·Now available!· Add extra memory to your next Propeller project with ease!
  • GeorgeLGeorgeL Posts: 131
    edited 2009-08-29 19:27
    On start, I just store a 5 digit number (for simplicity lets say 18516) and I split each number to a single digit and stored it in a 5 Byte Array called time.
    Then, I define char from the demo code to be time(counter) where counter is a for-next from 0 to 4.
  • vaclav_salvaclav_sal Posts: 451
    edited 2009-08-29 21:40
    The demo is using char defined as word and your data are in bytes.
    The result is pure Kingons.
    DEBUG is your friend.

    ·
  • GeorgeLGeorgeL Posts: 131
    edited 2009-08-29 22:48
    That didnt, really help achieve a solution, Mike Green where are you [noparse]:)[/noparse]
  • vaclav_salvaclav_sal Posts: 451
    edited 2009-08-30 03:37
    How about some debugging?

    SERIN 15,16572,[noparse][[/noparse]WAIT("RMC,"),DEC gpstime]
    DEBUG gpstime···· ' ???

    gpstime = gpstime ' ??

    FOR temp = 0 TO 4
    time(temp)= gpstime DIG temp '??
    debug time(temp)
    debug temp

    NEXT

    Or better yet lookup/·use ·STR qualifier to do the conversion bypassing the gpstime for loop
    which is the problem.
    SERIN 15,16572,[noparse]/noparse]WAIT("RMC,"),STR time\5[color=white]·[/color
    Keep in mind that the time array still needs to be defined as (concecutive ) array.


    Post Edited (vaclav_sal) : 8/30/2009 5:01:19 AM GMT
Sign In or Register to comment.