Vous êtes sur la page 1sur 9

Serial LCD Module

20x4 Character Serial LCD

NEX Robotics Pvt. Ltd.


www.nex-robotics.com

Serial LCD Module

Notice:
The contents of this manual are subject to change without notice. All efforts have been made
to ensure the accuracy of contents in this manual. However, should any errors be detected,
NEX Robotics welcomes your corrections. You can send us your queries / suggestions at
info@nex-robotics.com

Content of this manual is released under the Creative Commence cc by-nc-sa license. For
legal information refer to: http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode

Products electronics is static sensitive. Use the product in static free


environment.
Read the user manuals completely before using this product

Recycling:
Almost all the parts of this product are recyclable. Please send this product to the recycling
plant after its operational life. By recycling we can contribute to cleaner and healthier
environment for the future generations.

NEX Robotics Pvt. Ltd.


www.nex-robotics.com

Serial LCD Module

INDEX
1.0 Introduction..........................................................................................................................4
1.1 Features................................................................................................................................4
1.2 Hardware Connection...........................................................................................................4
2.0 Command's for 20x4 Serial LCD.........................................................................................5
2.1 Set cursor (1-80)...................................................................................................................5
2.2 Set cursor (line,column).......................................................................................................5
2.3 Text on LCD Display............................................................................................................6
2.4 Custom character generator..................................................................................................6
3.0 Command Table for Serial LCD module..............................................................................8
4.0 Controlling 20x4 serial LCD from PC.................................................................................9
4.1 Software................................................................................................................................9
4.2 Set cursor..............................................................................................................................9
4.3 Text on LCD Display............................................................................................................9
4.4 Custom character generator..................................................................................................9

NEX Robotics Pvt. Ltd.


www.nex-robotics.com

Serial LCD Module

1.0 Introduction:
The serial 20x4 LCD module from nex robotics can be controlled over I2C or standard serial
port with TTL 5V level signals. This dramatically reduces the number of pins consumed by
LCD while interfacing with a microcontroller. It uses only two lines (TX and RX) for
communication with any device. A well defined and easy to use protocol ensures smooth and
error free operation.

1.1 Features:
1.
2.
3.
4.
5.
6.
7.
8.
9.

TTL 5V interface
Up to 8 custom characters can be defined
5 8 dot matrix
80 X 8-bit display RAM (80 characters max.) for 20X4 LCD
Low power consumption
Serial Interface: Baud Rate 9600,8-N-1,No Flow control
Operational Backspace
Back light ON/OFF
Inbuilt 560 character buffer is available

Note:Do NOT connect RS232 level interface directly to the module. It will destroy the
module and will make it non-operational.

1.2 Hardware Connection:

NEX Robotics Pvt. Ltd.


www.nex-robotics.com

Serial LCD Module

2.0 Command's for 20x4 Serial LCD:


2.1 Set cursor (1-80):
Set cursor to a position specified by one byte after command, where 01(0x01) is
the top left and 80(0x50) is the bottom right position.

AVR Example:
// move the cursor to the specific position
void cursor_set(unsigned char cursorPosition)
{
while(!(UCSRA & (1<<UDRE))); //Wait for empty
//transmit buffer
UDR = 0x02;
//command for set
//cursor
while(!(UCSRA & (1<<UDRE)));
UDR = cursorPosition;
}

2.2 Set cursor (line, column):


Sets cursor using two bytes, where first byte is the line and the second byte is the
column

AVR Example:
// move the cursor to the specific position(line,Column)
void cursor_set_row_column(int xpos, int ypos)
{
while(!(UCSRA & (1<<UDRE)));//Wait for empty transmit
//buffer
UDR = 0x03;
//command for set cursor(row ,column)
while(!(UCSRA & (1<<UDRE)));
UDR = xpos;
//Cursor position of line
while(!(UCSRA & (1<<UDRE)));
UDR = ypos;
//Cursor position of column
}

2.3 Text on LCD display:


Writes ASCII chars straight to the LCD display

AVR Example:
// Write text on LCD display
void write_on_LCD(void)
{
cursor_set_row_column(0x02,0x05);//cursor at 2nd row 5th
//column
char buffer[]={Nex-Robotics};
for(int i=0;i<=12;i++)
{
NEX Robotics Pvt. Ltd.
www.nex-robotics.com

Serial LCD Module

while(!(UCSRA & (1<<UDRE)));//Wait for empty


//transmit buffer
UDR = buffer[i];
//send character on LCD
}
}

2.4 Custom character generator:


The custom character generator allows 8 custom characters to be defined. Custom
characters can be generated by sending 8 byte map after the command. The first
step is to send command 23(0x17) to indicate that you intend to define a custom
character. Next, specify the position of one of the 8 available custom characters
you intend to build. The 8 chars are mapped at positions 1(0x01)-08(0x08).
Finally the 8 byte character pattern that defines the character is sent. The method
to calculate a character pattern is shown in Table 1 below:
Bit4 Bit3 Bit2 Bit1

Bit0 sent byte

Byte 0

1xx00000(128)

Byte 1

1xx00100(132)

Byte 2

1xx01110(142)

Byte 3

1xx10101(149)

Byte 4

1xx00100(132)

Byte 5

1xx00100(132)

Byte 6

1xx00100(132)

Byte 7

1xx00000(128)

Table 1
In order to build the above arrow into location 1(0x01) send the following sequence to the
command register:
23 (0x17) (command)
1
(0x01) (character location 1-8)
128 (byte 0) (0x80)
132 (byte1) (0x84)
142 (byte2) (0x8E)
149 (byte3) (0x95)
132 (byte 4) (0x84)
132 (byte 5) (0x84)
132 (byte 6) (0x84)
128 (byte 7) (0x80)
Now that the character is built into a memory location, it can be called at any time as long as
the module remains powered by simply sending the address between 1(0x01) and 8(0x08) as
shown in Table 2 below.

NEX Robotics Pvt. Ltd.


www.nex-robotics.com

Serial LCD Module

Address to write
custom character

Address to read
custom character

0x80

0x81

0x82

0x83

0x84

0x85

0x86

0x87
Table 2

AVR Example:
// Generate custom character
void custom_char_generate()
{
custom_bit_pattern[]={0x80,0x84,0x8E,0x95,0x84,0x84,0x84,0x80}
;
while(!(UCSRA & (1<<UDRE)));

//Wait for empty


//transmit buffer
UDR = 0x17;
//command
while(!(UCSRA & (1<<UDRE)));
UDR = 0x01;
//character location
for(int i=0;i<=7;i++)
{
while(!(UCSRA & (1<<UDRE))); //Wait for empty
//transmit buffer
UDR = custom_bit_pattern[i]; //send bit pattern byte
//by byte
}
}
// To Display the custom character
void custom_char()
{
while(!(UCSRA & (1<<UDRE))); //Wait for empty
//transmit buffer
UDR = 0x80;
// to read custom char Refer
//Table 2
}

NEX Robotics Pvt. Ltd.


www.nex-robotics.com

Serial LCD Module

3.0 Command Table for Serial LCD Module:


Decimal Hex

Command

Description

0x00

null (ignored)

Ignored as a no operation

0x01

Cursor Home

Sets the cursor to the home position (top left)

0x02

Set cursor (180)

Cursor to a position specified by the next byte, where 1 is the top


left and 80(0x50) is the bottom right

0x03

set cursor (line, Sets cursor using two bytes, where first byte is the line and the
column)
second byte is the column

0x04

Hide cursor

0x05

Show underline
Changes the cursor to the underline type
cursor

0x06

Show blinking
Changes the cursor to the blinking type
cursor

0x08

Backspace

deletes the preceding character from the current position on the


display

0x09

Horizontal tab
(by tab set)

Moves the current position across by the tab (default tab space 4)

10

0x0A Smart line feed

Moves the cursor down one line to the position beneath in the
same column

11

0x0B Vertical tab

Moves the cursor up one line to the position above in the same
column

12

0x0C Clear screen

Clears the screen and sets cursor to the home position

13

0x0D Carriage Return Moves the cursor to the start of the next line

14

0x0E Display Off

15

0x0F

Software
Version

Module returns a single byte software version

17

0x11

Clear Column

Clears the contents of the current column and moves cursor right
by one column

18

0x12

Tab set

Sets the required tab size, the following byte can be a size of
between 1 and 10

19

0x13

Backlight on

Turns the backlight of the LCD on

20

0x14

Backlight off
(default)

Turns the backlight of the LCD off

21

0x15

Disable startup
Disables the display of setup information at power up
message

22

0x16

Enable startup
Enables the display of setup information at power up
message

23

0x17

Custom
character

First byte CGRAM addr(1-8) and next 8 byte of custom bit


pattern. To read custom char. send 0x80(addr(1)) - 0x87(addr(8))

25

0x19

Change
Address

First byte of sequence to change LCD address

32-255

0x20ASCII chars
0xFF

NEX Robotics Pvt. Ltd.


www.nex-robotics.com

stops the position cursor from appearing on the display

No character display on LCD

Writes ASCII chars straight to the display


8

Serial LCD Module

4.0 Controlling Nex Robotics 20x4 Serial LCD from PC:


Note: Please use RS232 to TTL level converter to connect this module to
PC. Do not connect it directly to PC.
4.1 Software:
Please use any serial terminal software such as Hyperterminal, minicom or Bray's
terminal on PC.

4.2 Set cursor:


To set cursor to a specified position, where 01(0x01) is the top left and 80(0x50) is
the bottom right position:
Configure serial terminal as follows:
1) Select proper COM Port from device manager
2) Select Baud Rate: 9600
3) Data bits: 8
4) Parity: NONE
5) Stop bits: 1
6) Flow Control: NONE
Set cursor position using Set cursor (1-80) command:
To set the cursor on 10th position on LCD send 0x02 followed by 0x0A
Set cursor position using set cursor (line, column) command:
In this command we have to send three bytes. 1st byte is command, 2nd byte is row
number and 3rd byte is column number in hex.
To set cursor on 1st row and 10th column on LCD send 0x03,0x01,0x0A

4.3 Text on LCD display:


To write on LCD directly from PC. We have to write character without command.

4.4 Custom character generator:


To generate custom character we have to send custom character generator command
followed by address of custom character and 8 bytes of custom bit pattern as shown in
Table 1.
Ex.0x17,0x01,0x80,0x84,0x8E,0x95,0x84,0x84,0x84,0x80
0x17: Custom character generator command (Refer table 2)
0x01: Address (between 01-08) for custom character.
Next 8 bytes are custom character bit pattern bytes.
To display the custom character on 2nd row 8th column following command we have to send
0x03,0x02,0x08 for cursor set and 0x80 for custom character display.
Note: The custom character will stay in LCD memory till the LCD is ON. It must be
defined again every time the LCD is powered ON.

NEX Robotics Pvt. Ltd.


www.nex-robotics.com

Vous aimerez peut-être aussi