LCD.pdf

(66 KB) Pobierz
Microsoft Word - Parallel LCD 2X16 1_3 .doc
599 Menlo Drive, Suite 100
Rocklin, California 95765, USA
Office: (916) 624-8333
Fax: (916) 624-8003
General: info@parallax.com
Technical: support@parallax.com
Web Site: www.parallax.com
Educational: www.StampsInClass.com
2 x16 Parallel LCD (#603-00006)
General Information
The 2 X16 Parallel LCD is an 8 bit or 4 bit parallel interfaced LCD.
This unit allows the user to display text, numerical data and custom
created characters.
The LCD uses the HD44780 series LCD driver from Hitachi, or
equivalent controller. The LCD is connected to a female 14-pin
connector for easy interface with the BS2p24/40 Demo Board
(#45187) and the Professional Development Board (#28138).
Though the device has the ribbon cable and 14-pin connector it may
also be hooked up manually using the diagram on the next page.
Technical Specifications
Cable length: 6” (152 mm)
Power requirements: 5.0 +VDC
2.95“ (75 mm)
.09“ (2.3 mm)
2-56 screw size
Dimensions may vary
Character size .12” x .2” (3 x 5 mm)
2.9“ (73.5 mm)
3.2“ (81 mm)
LCD Control from a BASIC Stamp
Parallax (www.parallax.com) publishes many circuits and examples to control LCDs. Most of these
examples are available for download from our web site. These examples are featured in StampWorks, the
Nuts and Volts of BASIC Stamps books, the free LCD Character Creator Software, and the BS2p Plus
Pack. Example codes are listed below for the BASIC Stamp 1 and 2 modules.
© Parallax, Inc. • 2X16 Parallel LCD ( #603-00006 ) 7/2005 Version 1.3 Page 1
16579444.009.png 16579444.010.png 16579444.011.png 16579444.012.png
Red
Red
Pin 1
Vdd
RS
E
DB1
DB3
DB5
DB6
Vss
P2
P1
Con.
P4
P3
P6
P5
R/W
DB0
DB2
DB4
DB6
P8
P7
P10
P9
P12
P11
To interface to the LCD in a 4-bit mode you will need set up the LCD in the following manner.
Stamp I/O pins
P4
11
DB4
12
P5
DB5
13
P6
DB6
P7
14
DB7
4
P3
RS
6
P0
E
5
P2
R/W
2317
8
9
10
4.7K
All
10k
+5
10 k
pot
Vss
BASIC Stamp 1 code
' =========================================================================
' File...... Parallel_LCD.bs1
' Purpose... Parallel LCD Display Demo
' Author.... Parallax, Inc.
' E-mail.... support@parallax.com
' {$STAMP BS1}
' {$PBASIC 1.0}
' -----[ Program Description ]---------------------------------------------
' This program demonstrates using a Hitachi-compatible Parallel LCD Display
' -----[ I/O Definitions ]-------------------------------------------------
SYMBOL E = 0 ' Enable Pin. 1 = Enabled
SYMBOL RS = 3 ' Register Select. 0 = Instruction
SYMBOL RW = 2 ' Read / Write control. 0 = Write
' -----[ Variables ]-------------------------------------------------------
SYMBOL char = B3 ' Character sent to LCD
SYMBOL temp = B4 ' Temp Variable
' -----[ EEPROM Data ]-----------------------------------------------------
EEPROM ("Hello, this is the LCD demo.")
' -----[ Initialization ]--------------------------------------------------
Begin:
LET PINS = 0 ' Clear The Output Lines
LET DIRS = %11111000 ' One Input, 7 Outputs
PAUSE 200 ' Wait 200 ms For LCD To Reset
© Parallax, Inc. • 2X16 Parallel LCD ( #603-00006 ) 7/2005 Version 1.3 Page 2
16579444.001.png 16579444.002.png 16579444.003.png 16579444.004.png 16579444.005.png
LOW RW ' Puts LCD Into Write Mode
Init_LCD:
LET PINS = %00110000 ' Wakes Up LCD
PULSOUT E,1 ' Send Data Three Times
PAUSE 10
PULSOUT E,1
PAUSE 10
PULSOUT E,1
PAUSE 10
LET PINS = %00100000 ' Function Set, 4-bit Operation
PULSOUT E,1
LET char = %00101000 ' Set 4-bit Operation
GOSUB Wr_LCD
LET char = 1 ' Clears The LCD Screen
GOSUB Wr_LCD
LET char = 6 ' Set Cursor Direction
GOSUB Wr_LCD
LET char = 14 ' Sets Cursor To Underline
GOSUB Wr_LCD
HIGH RS ' Prepare To Send Characters
' -----[ Program Code ]----------------------------------------------------
Main:
FOR B6 = 0 TO 27 ' Read Data From EEPROM To Display
READ B6, char
IF B6 = 15 THEN Next_Line
GOSUB Wr_LCD
Out:
NEXT
END ' End Of Code
' -----[ Subroutines ]-----------------------------------------------------
Wr_LCD: ' Write The Character In B3 To LCD
temp = char & %11110000 ' Logical AND Data Of High Byte Of
' I/O Pins
PINS = PINS & %00001000 | temp ' Logical OR The Data Leaving RS
' Pin In An Unchanged State
PULSOUT E,1 ' Clocks Out Data
PAUSE 10
temp = char & %00001111 * 16 ' Logical AND Data To Low Byte Of
' I/O Pins And Shifts To The Left
PINS = PINS & %00001000 | temp ' Logical ORs The Data Leaving RS
' Pin In An Unchanged State
PULSOUT E,1 ' Clocks Out Data
PAUSE 100
RETURN
Next_line:
LOW RS
LET char = 128 + 64 ' Places Cursor On Line 2
GOSUB Wr_LCD
HIGH RS ' Puts LCD Into Display Mode
READ B6, char
GOSUB Wr_LCD
GOTO Out
BASIC Stamp 2, 2e and 2sx code
' =========================================================================
' File...... Parallel_LCD_2X16.bs2
' Purpose... Parallel LCD Display Demo
' Author.... Parallax, Inc.
' E-mail.... support@parallax.com
' {$STAMP BS2}
' {$PBASIC 2.5}
' -----[ Program Description ]---------------------------------------------
' This program demonstrates using a Hitachi-compatible Parallel LCD Display
' This code works with the BS2, BS2e and BS2sx
' -----[ 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
' -----[ Variables ]-------------------------------------------------------
char VAR Byte ' Character To Send To LCD
inst VAR char ' Induction To Send To LCD
index VAR Word ' Character Pointer
temp VAR Byte ' Temp Variable
' -----[ EEPROM Data ]-----------------------------------------------------
DATA "Hello, this is the LCD demo." ' Message To Send To LCD
' -----[ Initialization ]--------------------------------------------------
© Parallax, Inc. • 2X16 Parallel LCD ( #603-00006 ) 7/2005 Version 1.3 Page 3
16579444.006.png
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
' -----[ Program Code ]----------------------------------------------------
Main:
FOR temp = 0 TO 27 ' 28 Characters
IF temp = 15 THEN ' Check For End Of Line
GOSUB Next_Line ' Jump To Next Line
ENDIF
READ temp, char ' Read Next Character From EEPROM
GOSUB Send_Text ' Send Character To LCD Display
NEXT
END
' -----[ Subroutines ]-----------------------------------------------------
Init_Lcd:
PAUSE 200
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
PAUSE 100
RETURN
Next_Line:
Inst = 128+64 ' Move Cursor To Line 2
GOSUB Send_Inst
RETURN
BASIC Stamp 2p24, 2p40 2pe and 2px24 code
' =========================================================================
' File...... Parallel_LCD_2X16.bsp
' Purpose... Parallel LCD Display Demo
' Author.... Parallax, Inc.
' E-mail.... support@parallax.com
' {$STAMP BS2p}
' {$PBASIC 2.5}
' -----[ Program Description ]---------------------------------------------
' This program demonstrates using a Hitachi-compatible Parallel LCD Display
' This code works with the BS2p24, BS2p40, BS2pe and BS2px24
' -----[ I/O Definitions ]-------------------------------------------------
Lcd PIN 0 ' LCD Enable Pin
' -----[ Variables ]-------------------------------------------------------
temp VAR Byte
char VAR Byte
' -----[ Initialization ]--------------------------------------------------
Init_Lcd:
© Parallax, Inc. • 2X16 Parallel LCD ( #603-00006 ) 7/2005 Version 1.3 Page 4
16579444.007.png
PAUSE 1000
FOR temp = 0 TO 2
LCDCMD Lcd, 48 ' Reset LCD (Send 3 times)
PAUSE 5 ' Delay Require By LCD Specs
NEXT
LCDCMD Lcd, 32 ' Set 4-bit Mode
LCDCMD Lcd, 40 ' Set 2-line Mode
LCDCMD Lcd, 12 ' Turn On Display With No Cursor
LCDCMD Lcd, 6 ' Set To Auto-Increment Cursor
LCDCMD Lcd, 1 ' Clear Display
' -----[ Main Routine ]----------------------------------------------------
Main:
DO
LCDOUT Lcd, 1, ["Hello, this is"] ' Clear LCD & Print Line 1 Text
LCDOUT Lcd, 192, ["the LCD demo."] ' Move To Line 2 & Print Text
PAUSE 3000 ' Wait A Few Seconds
LCDCMD Lcd, 1 ' Clear LCD
PAUSE 500 ' Wait 1/2 Second
LOOP ' Do It Again
END
© Parallax, Inc. • 2X16 Parallel LCD ( #603-00006 ) 7/2005 Version 1.3 Page 5
16579444.008.png
Zgłoś jeśli naruszono regulamin