Académique Documents
Professionnel Documents
Culture Documents
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
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.
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
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.
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;
}
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
}
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
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.
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)));
Command
Description
0x00
null (ignored)
Ignored as a no operation
0x01
Cursor Home
0x02
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
0x09
Horizontal tab
(by tab set)
Moves the current position across by the tab (default tab space 4)
10
Moves the cursor down one line to the position beneath in the
same column
11
Moves the cursor up one line to the position above in the same
column
12
13
0x0D Carriage Return Moves the cursor to the start of the next line
14
15
0x0F
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
20
0x14
Backlight off
(default)
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
25
0x19
Change
Address
32-255
0x20ASCII chars
0xFF