PDA

View Full Version : LCDOUT issue



LCD_Rookie
02-21-2010, 02:28 AM
I am having trouble with my LCD. It is seeming to work fine, I can get it initialized and use LCDCMD is working great. I can't seem to get it to write using LCDOUT though.
For example if I write LCDOUT 0,0, ["Hello World"] it does not know what to do and goes back to alternate lines of black squares. Also, I tried sending LCDOUT 0,$C0, ["A"] and all that did was move the cursor to the 65th (A in ASCII is 65) position instead of printing A to the second line. The LCD I am using is a Powertip PC2004A (4x20 character) which is supposed to be HD77480 compatible and should work. The basic stamp I am using is a BS2pe.

I was able to however use and modify a sample code I found to get it to print 3 screens. This is shown below:



' LCDINIT.bpe
' This program demonstrates initialization and printing on a 4 x 20
' character LCD display. The set of "LCD constants", below, are provided
' as pre-defined and useful LCD commands, though not all are actually
' used in this program.
' {$STAMP BS2pe}
' {$PBASIC 2.5}
' {$PORT COM16}

#IF ($STAMP < BS2P) #THEN
#ERROR "Program requires BS2p, BS2pe or BS2px."
#ENDIF

E PIN 0
RW PIN 2 ' Read/Write\
RS PIN 3 ' Reg Select (1 = char)

LcdDirs VAR DIRB ' dirs for I/O redirection
LCDBus VAR OUTB
LcdBusIn VAR INB

LcdCls CON $01 ' clear the LCD
LcdHome CON $02 ' move cursor home
LcdCrsrL CON $10 ' move cursor left
LcdCrsrR CON $14 ' move cursor right
LcdDispL CON $18 ' shift chars left
LcdDispR CON $1C ' shift chars right

LcdDDRam CON $80 ' Display Data RAM control
LcdCGRam CON $40 ' Character Generator RAM
LcdLine1 CON $80 ' DDRAM address of line 1
LcdLine2 CON $C0 ' DDRAM address of line 2
LcdLine3 CON $80+20 ' DDRAM address of line 3
LcdLine4 CON $C0+20 ' DDRAM address of line 4


LcdScrollTm CON 250 ' LCD scroll timing (ms)

addr VAR Word ' address pointer

char VAR Byte ' character sent to LCD
idx VAR Byte ' loop counter

Initialize:
NAP 5 ' let LCD self-initialize
DIRL = %11111101 ' setup pins for LCD

LCD_Init:
PAUSE 1000 ' let the LCD settle
LCDbus = %0011 ' 8-bit mode
PULSOUT E, 1
PAUSE 5
PULSOUT E, 1
PULSOUT E, 1
LCDbus = %0010 ' 4-bit mode
PULSOUT E, 1
char = %00101100 ' select 5x10 font
GOSUB LCD_Command
char = %00001100 ' disp on, crsr off, blink off
GOSUB LCD_Command
char = %00000110 ' inc crsr, no disp shift
GOSUB LCD_Command

Main:
DO
DEBUG "Screen 1 "
GOSUB Screen_1
PAUSE 3000 'In place of transition button
DEBUG "Screen 2 "
GOSUB Screen_2
PAUSE 3000 'In place of transition button
DEBUG "Screen 3 "
GOSUB Screen_3
PAUSE 3000 'In place of transition button
LOOP
END

Screen_1:

S1L1 DATA " WELCOME TO ", 'line1
" PRESS ENTER ", 'line3
" THE SMART BBQ! ", 'line2
" TO BEGIN", 0 'line4

char = LcdCls ' clear the LCD
GOSUB LCD_Command
addr = S1L1
GOSUB Show_Message
PAUSE 1
RETURN

Screen_2:

S2L1 DATA " PLEASE LIGHT ", 'line1
" PRESS ENTER ", 'line3
" THE SMART BBQ ", 'line2
" TO CONTINUE", 0 'line4

char = LcdCls ' clear the LCD
GOSUB LCD_Command
addr = S2L1
GOSUB Show_Message
PAUSE 1
RETURN

Screen_3:

S3L1 DATA "PLEASE SELECT THE ", 'line1
"YOU ARE COOKING ON ", 'line3
"SIDE OF THE BARBECUE", 'line2
0 'line4
S3C1 DATA "LEFT", 0
S3C2 DATA "RIGHT", 0
S3C3 DATA "BOTH SIDES", 0
BACK DATA "GO BACK", 0

char = LcdCls ' clear the LCD
GOSUB LCD_Command
addr = S3L1
GOSUB Show_Message
char = LcdLine3 ' choose
GOSUB LCD_Command
addr = S3C2
GOSUB Show_Message
PAUSE 1
RETURN


LCD_Command:
LOW RS ' enter command mode

LCD_Write:
LCDbus = char.HIGHNIB ' output high nibble
PULSOUT E,1 ' strobe the Enable line
LCDbus = char.LOWNIB ' output low nibble
PULSOUT E,1
HIGH RS ' return to character mode
RETURN

Show_Message:
READ addr, char ' read a character from EEPROM
IF (char = 0) THEN Msg_Done ' if 0, message is complete
GOSUB LCD_Write ' write the character
addr = addr + 1 ' point to next character
GOTO Show_Message

Msg_Done:
RETURN







This would be fine and I might be able to make it work. The only problem I may run into is I am going to want to display variables, for example I am reading in a temperature with a thermocouple and want to display that. Is there a way to add variables to my DATA declarations? Or is there some other way I should look to get around this. Thanks for the help. Again, anything here will help
[code]