LCD Interfacing with 8051 microcontroller

///LCD Interfacing with 8051 microcontroller

LCD Interfacing with 8051 microcontroller

AT89S51 is an electronic device falling under the category of the microcomputer. It is basically an 8-bit CMOS device capable of performing high at low-power and comes with flash programmable and erasable read only memory (PEROM) of 4K byte size. AT89S51 is compatible with the industry-standard MCS-51 instruction set as well as pinout and the device are manufactured using Atmel’s high-density nonvolatile memory technology. Being a highly powerful microcomputer, AT89S51 provides effective solutions to numerous embedded control applications. In this chapter, the process of LCD interfacing with AT89S51 is being discussed.

Character LCD (Liquid Crystal Display)

A 16×2 character LCD module is the most basic electronic display device. The module will consist of 2 rows each with 16 columns which can display 16 characters. Several other LCD modules are also available like 20×4 dimension LCD which can display 20 characters per line and 4 such lines would be available. The choice for the module depends on the requirement.

The main advantage of using a character LCD instead of a seven segment display and other multi-segment LEDs is that there is no limitation in displaying special & custom character animations and so on. All character LCDs will have 16 pins among which 8 are data pins through which data or commands are passed into the LCD registers. A character LCD can be configured in 8 bit or 4-bit mode in which 8 data pins and 4 data pins are used respectively. This feature allows efficient use of the digital I/0 pins of the microcontroller.

Charactor-lcd

Features

The features of a character LCD module make it more suitable for an electronic display than 7 segment displays and other multi-segment display modules. Most importantly the module can be interfaced much easily unlike other modules with no complexity in both hardware and software. The 4-bit mode interfacing of the LCD module enables an efficient method of saving the number of general-purpose I/O pins which is a major criteria for an embedded system designer. There is no limitation in characters which can be displayed using the module. The contrast of the module can be adjusted using the VEE pin of the module and LED backlight which makes the display more bright can be enabled with LED+ and LED- pin.

Registers

A character LCD consists of two registers

1. Command register
2. Data register

The RS (register select) pin of the LCD module is used to select the specific register. When RS is low, command register is selected and when RS is high, data register is selected. State of R/W pin determines the operation to be performed whether to read or write data.

All instructions to be executed by the LCD are latched into the command register of the LCD. LCD commands include a clear display, a cursor on/off, display shift and so on.

Character to be displayed on the LCD is stored in the data register. The data is stored temporarily in the data register.

Commands

Commands are instructions given to the LCD module to perform a predefined task. The task to be performed is defined by the manufacturer. Some of the LCD commands are listed below.

1. Clear display – 0x01
2. Display on, cursor off – 0x0C
3. Increment cursor – 0x04

The rest of the commands can be obtained from the device datasheet.

Example Firmware

The firmware should include the general header file for 8051 microcontrollers which is reg51.h. The header file also contains a delay library.

Sending the Commands

The register select pin of the LCD module should be connected to a general-purpose I/O pin and the corresponding pin should be made low. R/W pin should be grounded to select the write operation. The command register will not be accessed. Enabling the LCD would latch in the value of the data port into the command register of the module. Enabling the module involves applying a high to low pulse to the Enable pin of LCD.

RS, R/W, Data_PORT, and Enable_pin should be macro defined in the firmware.

Example:

Sending Data

Data write operation involves the similar steps as that of a command write operation except data register should be selected by setting the RS pin and grounding the R/W pin. Enabling the module would then latch in the value in the data port to the data register of the module and corresponding character will be displayed on the LCD module.

LCD data sending

Example firmware:

RS, R/W, Data_PORT, Enable_pin should be macro defined in the firmware.

Initialising the LCD

Prior to writing data into the character LCD, it needs to be initialized. Initialisation is done to configure the module for the specific use. It involves writing some initialization commands into the command register. Some of the initialization commands include a command to turn the display on and cursor off, the command to set cursor at the preferred position and the command to set the option for cursor increment or decrement and so on.

Ex:

DON’T MISS OUT UPDATES!
Be the first to get latest updates and exclusive content straight to your email inbox.
Stay Updated
Subscribe, it is quick.
We hate spam too. Give it a try, you can unsubscribe anytime.
Spread the love, share this

Leave A Comment

DON’T MISS OUT UPDATES!
Be the first to get latest updates and exclusive content straight to your email inbox.
Stay Updated
Subscribe, it is quick.
We hate spam too. Give it a try, you can unsubscribe anytime.
close-link
25% OFF - OpenLabPro Course
Use Coupon: CRS25UL

 
8051 Microcontroller Primer
Want to learn indepth programming, peripheral interfacing and driver development?
close-link
Launched: IoT online Course - 25% Off when you complete your order today.
Checkout Now
close-image

Subscribe To our Email Newsletter

Be the first to get latest updates and exclusive content straight to your email inbox.
Send me Tutorials and Guides
close-link