LCD or Liquid Crystal Display is fast becoming a preferred choice for use as interface device for displaying over 7-Segment.
Every LCD needs a driver to interface between the microcontroller and LCD module. This driver is included on the LCD module.
The LCD we are using here is a 16x2 LCD. That means it has 16 columns and 2 rows.
Pin number 1 and 16 will be written behind the LCD.
The Pin Configuration of the LCD is given below
(open image in separate tab to expand)
The LCD uses three control lines, EN, RS and RW.
The EN line is called 'Enable'. This control line is used to tell the LCD that you are sending it data. To send the data to the LCD, your program should make sure this line is low (0) and then set the other two control lines and/or put data on the data bus. When the other lines are completely ready, bring EN high (1) and wait for the minimum amount of time required ( about 200ns), and end by bringing it low(0) again.
The RS line is the 'Register Select' line. When RS is low(0), the data is to be treated as a command or special instruction (such as clear screen, position cursor, etc.). When RS is high (1), the data being sent is text data which should be displayed on the screen. For example, to display the letter 'T' on the screen you would set RS high(1).
The RW line is the 'Read/Write' control line. When RW is low (0), the information on the data bus is being written to the LCD. When RW is high (1), the program is effectively querying (or reading) the LCD. All commands are write commands except for 1 ('Get LCD status'), which is a read command. Thus, RW will almost always be low.
4 bit Mode / 8 Bit mode:
The LCD can work in either 8 bit parallel mode, i.e, then entire 8 bit data can be sent at once, or it can be used in 4 bit mode. In 4 bit mode the 8 bit data is broken into packets of 4 bit data and sent (higher 4 bits first, then lower 4 bits). 4 bit mode simplifies the circuit.
Upon power on, the LCD is automatically in 8 bit mode.
Here, we are using the LCD in 4-bit mode.
Initializing the LCD
Before you may really use the LCD, you must initialize and configure it. This is accomplished by sending a number of initialization instructions to the LCD.
Every LCD needs a driver to interface between the microcontroller and LCD module. This driver is included on the LCD module.
The LCD we are using here is a 16x2 LCD. That means it has 16 columns and 2 rows.
Pin number 1 and 16 will be written behind the LCD.
The Pin Configuration of the LCD is given below
The LCD uses three control lines, EN, RS and RW.
The EN line is called 'Enable'. This control line is used to tell the LCD that you are sending it data. To send the data to the LCD, your program should make sure this line is low (0) and then set the other two control lines and/or put data on the data bus. When the other lines are completely ready, bring EN high (1) and wait for the minimum amount of time required ( about 200ns), and end by bringing it low(0) again.
The RS line is the 'Register Select' line. When RS is low(0), the data is to be treated as a command or special instruction (such as clear screen, position cursor, etc.). When RS is high (1), the data being sent is text data which should be displayed on the screen. For example, to display the letter 'T' on the screen you would set RS high(1).
The RW line is the 'Read/Write' control line. When RW is low (0), the information on the data bus is being written to the LCD. When RW is high (1), the program is effectively querying (or reading) the LCD. All commands are write commands except for 1 ('Get LCD status'), which is a read command. Thus, RW will almost always be low.
4 bit Mode / 8 Bit mode:
The LCD can work in either 8 bit parallel mode, i.e, then entire 8 bit data can be sent at once, or it can be used in 4 bit mode. In 4 bit mode the 8 bit data is broken into packets of 4 bit data and sent (higher 4 bits first, then lower 4 bits). 4 bit mode simplifies the circuit.
Upon power on, the LCD is automatically in 8 bit mode.
Here, we are using the LCD in 4-bit mode.
Initializing the LCD
Before you may really use the LCD, you must initialize and configure it. This is accomplished by sending a number of initialization instructions to the LCD.
- The first instruction we send must tell the LCD we'll be communicating with it with a 4-bit data bus (4-bit mode). We also need to select a 5x8 dot character font. These two options are selected by sending the command 20h ( 'h' denotes hexadecimal format) to the LCD as a command.
- We've now sent the first byte of the initialization sequence. The second byte of the initialization sequence is the instruction 0Fh. This commmand is sent to instruct the the LCD to, 'Display on, Cursor Blinking'.
- Other commands are also available. Send higher nibble first, then lower nibble.
This circuit diagram can be used as a reference.
You can download a header file for your use from here. The pin connections are mentioned in the header file.
You can download a header file for your use from here. The pin connections are mentioned in the header file.
For any further clarification please leave a comment below or mail us at blogger.engg@gmail.com
No comments:
Post a Comment