16x2 LCD AND STAMP2
Dave55
Posts: 2
I am working throgh a book "123 Robotics experimente for the elvil genius.
It calls for a 16x2 LCD to attached to the stamp. the LCD lights up, but
that's all.Here is the code I have used any help would be great.
' LCD Test - Display a simple messae ON an LCD module
' {$STAMP BS2}
' {$PBASIC 2.5}
' Variables
i VAR Byte
Character VAR Byte··········· ' Character to Display
LCDData VAR OUT1············· ' Define LCD Pins on BS2
LCDE PIN 8
LCDRW PIN 9
LCDRS PIN 10
' Initialization
DIRS = %11111111111
' Make Least Significant 11 Bits Output
LCDRW = 0: LCDRS = 0: LCDE = 0
' Initialize LCD interface
PAUSE 20
' Wait for LCD to reset itself
LCDData = $0C: PULSOUT LCDE, 300: PAUSE 5
' Initialize LCD Module
PULSOUT LCDE, 300: PULSOUT LCDE, 300
' Forse reset in LCD
LCDData = $1C: PULSOUT LCDE, 300: PAUSE 5
' Initialize/Set 8 Bit
LCDData = $08: PULSOUT LCDE, 300
' No Shifting
LCDData = $80: PULSOUT LCDE, 300: PAUSE 5
' Clear LCD
LCDData = $60: PULSOUT LCDE, 300
' Specify Cursor Move
LCDData = $70: PULSOUT LCDE, 300
' Enable Display & Cursor
Character = 1: i = 0
LCDRS = 1··················· ' Print Character
DO WHILE (Character <> 0)
· LOOKUP i, [noparse][[/noparse]"Evil Genius", 0], Character
· IF (Character <> 0) THEN
··· LCDData = Character REV 8: PULSOUT LCDE, 300
··· i = i + 1
··· ENDIF
· LOOP
· END
It calls for a 16x2 LCD to attached to the stamp. the LCD lights up, but
that's all.Here is the code I have used any help would be great.
' LCD Test - Display a simple messae ON an LCD module
' {$STAMP BS2}
' {$PBASIC 2.5}
' Variables
i VAR Byte
Character VAR Byte··········· ' Character to Display
LCDData VAR OUT1············· ' Define LCD Pins on BS2
LCDE PIN 8
LCDRW PIN 9
LCDRS PIN 10
' Initialization
DIRS = %11111111111
' Make Least Significant 11 Bits Output
LCDRW = 0: LCDRS = 0: LCDE = 0
' Initialize LCD interface
PAUSE 20
' Wait for LCD to reset itself
LCDData = $0C: PULSOUT LCDE, 300: PAUSE 5
' Initialize LCD Module
PULSOUT LCDE, 300: PULSOUT LCDE, 300
' Forse reset in LCD
LCDData = $1C: PULSOUT LCDE, 300: PAUSE 5
' Initialize/Set 8 Bit
LCDData = $08: PULSOUT LCDE, 300
' No Shifting
LCDData = $80: PULSOUT LCDE, 300: PAUSE 5
' Clear LCD
LCDData = $60: PULSOUT LCDE, 300
' Specify Cursor Move
LCDData = $70: PULSOUT LCDE, 300
' Enable Display & Cursor
Character = 1: i = 0
LCDRS = 1··················· ' Print Character
DO WHILE (Character <> 0)
· LOOKUP i, [noparse][[/noparse]"Evil Genius", 0], Character
· IF (Character <> 0) THEN
··· LCDData = Character REV 8: PULSOUT LCDE, 300
··· i = i + 1
··· ENDIF
· LOOP
· END
Comments
I checked your program for typing accuracy and didn't see any mistakes - but that doesn't mean there wasn't a problem with the original program.
There are many ways to connect a parallel LCD to a BS2 - and I don't really like the method Myke Predko uses in his book because it uses 8-bit mode and wastes a lot of pins in my opinion.
For instructions on how to connect in 4-bit mode along with a BS2 program, check out Nuts & Volts #31 which you can get here www.parallax.com/html_pages/downloads/nvcolumns/Nuts_Volts_Download_V1.asp
(Sorry I do not have the link handy - just Google it).
The LDC controller needs proper initialization if not used in 8 bit mode.
You said·you are· using it in "parallel" mode and I am assuming that means 8 bit mode in controller terminology.
Anyway, check the app note - especially the "extrernal initialization" ( I think fig 21 / 23).
Pay attention to timing and switching from data to control mode.
I have a working 4 bit code I could send you if you are interested.
·
You need to send either 8 bits OUTL / OUTH or 4 OUTA - OUTC