Need help with LCD programming...
Archiver
Posts: 46,084
I really need help with LCD programming.I'm new at this and I've been
working for days to figure it out but still I couldn't solve it.I am
using a 2 X 16 serial LCD with a keypad interface from Matrix
Orbital. I am also using a BS 2 and Basic Stamp Editor for my
program. I use an example program for 2 X 16 serial LCD for BS2.
Below is the example program:
' {$STAMP BS2}
'
[noparse][[/noparse] Program Description ]
'
' This program demonstrates the use of the multi-line initialization
and
' the use of custom characters. When using the standard 5x7 font,
the LCD
' will hold up to eight customer characters.
'
' Refer to the Hitachi HD44780 documentation for details on LCD
control.
'
[noparse][[/noparse] I/O Definitions ]
'
E CON 0
RW CON 2
RS CON 3
LCDpins VAR OutB
'
[noparse][[/noparse] Constants ]
'
ClrLCD CON $01
CrsrHm CON $02
CrsrLf CON $10
CrsrRt CON $14
DispLf CON $18
DispRt CON $1C
DDRam CON $80
CGRam CON $40
Line1 CON $80
Line2 CON $C0
'
[noparse][[/noparse] Variables ]
'
char VAR Byte
newChr VAR Byte
addr VAR Byte
cNum VAR Byte
'
[noparse][[/noparse] EEPROM Data ]
'
Mouth0 DATA $0E,$1F,$1F,$1F,$1F,$1F,$0E,$00
Mouth1 DATA $0E,$1F,$1F,$18,$1F,$1F,$0E,$00
Mouth2 DATA $0E,$1F,$1C,$18,$1C,$1F,$0E,$00
Smile DATA $00,$0A,$0A,$00,$11,$0E,$06,$00
Msg1 DATA "THE BASIC STAMP",0
Msg2 DATA " IS VERY COOL! ",3,0
'
[noparse][[/noparse] Initialization ]
'
Initialize:
DirL = %11111101
PAUSE 500
LCDpins = %0011
PULSOUT E,1 : PAUSE 5
PULSOUT E,1
PULSOUT E,1
LCDpins = %0010
PULSOUT E,1
char = %00101000 : GOSUB LCDcommand
char = %00001100 : GOSUB LCDcommand
char = %00000110 : GOSUB LCDcommand
DLChars:
char = CGRam
GOSUB LCDcommand
FOR addr = Mouth0 TO (Smile + 7)
READ addr,char
GOSUB LCDwrite
NEXT
'
[noparse][[/noparse] Main Code ]
'
Main:
char = ClrLCD : GOSUB LCDcommand
PAUSE 250
addr = Msg1
GOSUB Put_Msg
PAUSE 2000
' Animation by character replacement
FOR addr = 0 TO 15
READ (Msg2 + addr),newChr
FOR cNum = 0 TO 4
char = Line2 + addr
GOSUB LCDcommand
LOOKUP cNum,[noparse][[/noparse]2,1,0,1,newChr],char
GOSUB LCDwrite
PAUSE 100
NEXT
NEXT
PAUSE 3000
GOTO Main
END
'
[noparse][[/noparse] Subroutines ]
'
LCDcommand:
LOW RS
LCDwrite:
LCDpins = char.HighNib
PULSOUT E,1
LCDpins = char.LowNib
PULSOUT E,1
HIGH RS
RETURN
Put_Msg:
READ addr,char
IF (char = 0) THEN Put_Msg_Done
GOSUB LCDwrite
addr = addr + 1
GOTO Put_Msg
Put_Msg_Done:
RETURN
I'm using this example just to get an output.Later,I'll modify this
program.My question here is:
1) I did not get any output from my LCD. Do I have to change
something in the program because I use Matrix Orbital LCD and not
Hitachi HD44780?
2)I'm using a different LCD from the example given.What are the
things to consider when using a different LCD?
3)If I don't have to change anything,how do I know whether my LCD
connection is right?I connect my LCD to the BS2 using the diagram
given and I think I'm right.
Hope to hear from u guys...Thanx...
mizi...
working for days to figure it out but still I couldn't solve it.I am
using a 2 X 16 serial LCD with a keypad interface from Matrix
Orbital. I am also using a BS 2 and Basic Stamp Editor for my
program. I use an example program for 2 X 16 serial LCD for BS2.
Below is the example program:
' {$STAMP BS2}
'
[noparse][[/noparse] Program Description ]
'
' This program demonstrates the use of the multi-line initialization
and
' the use of custom characters. When using the standard 5x7 font,
the LCD
' will hold up to eight customer characters.
'
' Refer to the Hitachi HD44780 documentation for details on LCD
control.
'
[noparse][[/noparse] I/O Definitions ]
'
E CON 0
RW CON 2
RS CON 3
LCDpins VAR OutB
'
[noparse][[/noparse] Constants ]
'
ClrLCD CON $01
CrsrHm CON $02
CrsrLf CON $10
CrsrRt CON $14
DispLf CON $18
DispRt CON $1C
DDRam CON $80
CGRam CON $40
Line1 CON $80
Line2 CON $C0
'
[noparse][[/noparse] Variables ]
'
char VAR Byte
newChr VAR Byte
addr VAR Byte
cNum VAR Byte
'
[noparse][[/noparse] EEPROM Data ]
'
Mouth0 DATA $0E,$1F,$1F,$1F,$1F,$1F,$0E,$00
Mouth1 DATA $0E,$1F,$1F,$18,$1F,$1F,$0E,$00
Mouth2 DATA $0E,$1F,$1C,$18,$1C,$1F,$0E,$00
Smile DATA $00,$0A,$0A,$00,$11,$0E,$06,$00
Msg1 DATA "THE BASIC STAMP",0
Msg2 DATA " IS VERY COOL! ",3,0
'
[noparse][[/noparse] Initialization ]
'
Initialize:
DirL = %11111101
PAUSE 500
LCDpins = %0011
PULSOUT E,1 : PAUSE 5
PULSOUT E,1
PULSOUT E,1
LCDpins = %0010
PULSOUT E,1
char = %00101000 : GOSUB LCDcommand
char = %00001100 : GOSUB LCDcommand
char = %00000110 : GOSUB LCDcommand
DLChars:
char = CGRam
GOSUB LCDcommand
FOR addr = Mouth0 TO (Smile + 7)
READ addr,char
GOSUB LCDwrite
NEXT
'
[noparse][[/noparse] Main Code ]
'
Main:
char = ClrLCD : GOSUB LCDcommand
PAUSE 250
addr = Msg1
GOSUB Put_Msg
PAUSE 2000
' Animation by character replacement
FOR addr = 0 TO 15
READ (Msg2 + addr),newChr
FOR cNum = 0 TO 4
char = Line2 + addr
GOSUB LCDcommand
LOOKUP cNum,[noparse][[/noparse]2,1,0,1,newChr],char
GOSUB LCDwrite
PAUSE 100
NEXT
NEXT
PAUSE 3000
GOTO Main
END
'
[noparse][[/noparse] Subroutines ]
'
LCDcommand:
LOW RS
LCDwrite:
LCDpins = char.HighNib
PULSOUT E,1
LCDpins = char.LowNib
PULSOUT E,1
HIGH RS
RETURN
Put_Msg:
READ addr,char
IF (char = 0) THEN Put_Msg_Done
GOSUB LCDwrite
addr = addr + 1
GOTO Put_Msg
Put_Msg_Done:
RETURN
I'm using this example just to get an output.Later,I'll modify this
program.My question here is:
1) I did not get any output from my LCD. Do I have to change
something in the program because I use Matrix Orbital LCD and not
Hitachi HD44780?
2)I'm using a different LCD from the example given.What are the
things to consider when using a different LCD?
3)If I don't have to change anything,how do I know whether my LCD
connection is right?I connect my LCD to the BS2 using the diagram
given and I think I'm right.
Hope to hear from u guys...Thanx...
mizi...
Comments
I have been having a big problem with LCD's and I'm so sick of mine
working and then not. Anyway when I first got mine, I couldn't get a
simple message to display at all, so finally I realized that there was a
message being displayed, just my contrast was too high using the
prescribed 10k resistor, I switched it with a 5k pot, hooking up the
contrast line to the wiper of the pot. Also you mentioned that you have
a serial LCD, I think this program is written for a parallel module,
unless I'm mistaken or your LCD really is a parallel one. Does it have a
14 pin header, if so it is a parallel module?
-Mike
Original Message
From: ismiezie [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=A3FXpeF1VDfCSMV6k1tkYLidWdHE9CwZ1i4MhtGFYxVhF7URnb-5q2RU-HprNoXA0ctsi_EYEByQLm2r5HIs]ismiezie@y...[/url
Sent: Sunday, April 06, 2003 1:48 PM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Need help with LCD programming...
I really need help with LCD programming.I'm new at this and I've been
working for days to figure it out but still I couldn't solve it.I am
using a 2 X 16 serial LCD with a keypad interface from Matrix
Orbital. I am also using a BS 2 and Basic Stamp Editor for my
program. I use an example program for 2 X 16 serial LCD for BS2.
Below is the example program:
' {$STAMP BS2}
'
[noparse][[/noparse] Program Description ]
'
' This program demonstrates the use of the multi-line initialization
and
' the use of custom characters. When using the standard 5x7 font,
the LCD
' will hold up to eight customer characters.
'
' Refer to the Hitachi HD44780 documentation for details on LCD
control.
'
[noparse][[/noparse] I/O Definitions ]
'
E CON 0
RW CON 2
RS CON 3
LCDpins VAR OutB
'
[noparse][[/noparse] Constants ]
'
ClrLCD CON $01
CrsrHm CON $02
CrsrLf CON $10
CrsrRt CON $14
DispLf CON $18
DispRt CON $1C
DDRam CON $80
CGRam CON $40
Line1 CON $80
Line2 CON $C0
'
[noparse][[/noparse] Variables ]
'
char VAR Byte
newChr VAR Byte
addr VAR Byte
cNum VAR Byte
'
[noparse][[/noparse] EEPROM Data ]
'
Mouth0 DATA $0E,$1F,$1F,$1F,$1F,$1F,$0E,$00
Mouth1 DATA $0E,$1F,$1F,$18,$1F,$1F,$0E,$00
Mouth2 DATA $0E,$1F,$1C,$18,$1C,$1F,$0E,$00
Smile DATA $00,$0A,$0A,$00,$11,$0E,$06,$00
Msg1 DATA "THE BASIC STAMP",0
Msg2 DATA " IS VERY COOL! ",3,0
'
[noparse][[/noparse] Initialization ]
'
Initialize:
DirL = %11111101
PAUSE 500
LCDpins = %0011
PULSOUT E,1 : PAUSE 5
PULSOUT E,1
PULSOUT E,1
LCDpins = %0010
PULSOUT E,1
char = %00101000 : GOSUB LCDcommand
char = %00001100 : GOSUB LCDcommand
char = %00000110 : GOSUB LCDcommand
DLChars:
char = CGRam
GOSUB LCDcommand
FOR addr = Mouth0 TO (Smile + 7)
READ addr,char
GOSUB LCDwrite
NEXT
'
[noparse][[/noparse] Main Code ]
'
Main:
char = ClrLCD : GOSUB LCDcommand
PAUSE 250
addr = Msg1
GOSUB Put_Msg
PAUSE 2000
' Animation by character replacement
FOR addr = 0 TO 15
READ (Msg2 + addr),newChr
FOR cNum = 0 TO 4
char = Line2 + addr
GOSUB LCDcommand
LOOKUP cNum,[noparse][[/noparse]2,1,0,1,newChr],char
GOSUB LCDwrite
PAUSE 100
NEXT
NEXT
PAUSE 3000
GOTO Main
END
'
[noparse][[/noparse] Subroutines ]
'
LCDcommand:
LOW RS
LCDwrite:
LCDpins = char.HighNib
PULSOUT E,1
LCDpins = char.LowNib
PULSOUT E,1
HIGH RS
RETURN
Put_Msg:
READ addr,char
IF (char = 0) THEN Put_Msg_Done
GOSUB LCDwrite
addr = addr + 1
GOTO Put_Msg
Put_Msg_Done:
RETURN
I'm using this example just to get an output.Later,I'll modify this
program.My question here is:
1) I did not get any output from my LCD. Do I have to change
something in the program because I use Matrix Orbital LCD and not
Hitachi HD44780?
2)I'm using a different LCD from the example given.What are the
things to consider when using a different LCD?
3)If I don't have to change anything,how do I know whether my LCD
connection is right?I connect my LCD to the BS2 using the diagram
given and I think I'm right.
Hope to hear from u guys...Thanx...
mizi...
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
> I really need help with LCD programming.I'm new at this and I've
been
> working for days to figure it out but still I couldn't solve it.I
am
> using a 2 X 16 serial LCD with a keypad interface from Matrix
> Orbital. I am also using a BS 2 and Basic Stamp Editor for my
> program. I use an example program for 2 X 16 serial LCD for BS2.
> Below is the example program:
>
> ' {$STAMP BS2}
> '
[noparse][[/noparse] Program Description
> {SNIP}
>
> I'm using this example just to get an output.Later,I'll modify this
> program.My question here is:
> 1) I did not get any output from my LCD. Do I have to change
> something in the program because I use Matrix Orbital LCD and not
> Hitachi HD44780?
> 2)I'm using a different LCD from the example given.What are the
> things to consider when using a different LCD?
> 3)If I don't have to change anything,how do I know whether my LCD
> connection is right?I connect my LCD to the BS2 using the diagram
> given and I think I'm right.
>
> Hope to hear from u guys...Thanx...
> mizi...
Hello, you are using parallel code to talk to our display, talking to
our display is much much easier!!!
First you have to either make the LK162-12 into TTL mode (if you have
rev 2.1+) or use a RS232 chip in your circuit. I would also suggest
slowing the display down to 9600bps (use a programmed called speed on
our CD or our website)
You will need to connect the LCD to the Basic Stamp. We used one of
our serial cables, cut the end off and then soldered connectors to
pin #2, #3 and #5.
Pin #2 is connected to P0
Pin #3 is connected to P1
Pin #5 is connectod to Vss, which is ground
Code Examples
Sending text to the screen:
code:
'{$STAMP BS2}
SEROUT 1, 84, [noparse][[/noparse]"HELLO WORLD"]
This will display HELLO WORLD on your display.
SEROUT : is the command to send serial information out
1 : is Serial Port #1
84 : is the speed at which the information is sent at, in our case
9600bps.