Arduino Projects    |   Raspberry Pi  |     Electronic Circuits    |    AVR    |    PIC    |    8051    |    Electronic Projects   |   Free TI Design & Simulation Tools 

How to create custom characters on 16x2 LCD using 8051 microcontroller (AT89C51)

Summary

Developed By: 
Himanshu Choudhary

The commonly used 16x2 LCD can also display custom made characters besides numbers, alphabets & special characters. Any character can be made to appear on a 5x8 pixel matrix element without knowledge of its ASCII value. The idea explained here demonstrates the principle and operation of a simple LCD custom character display using 8051 microcontroller (AT89C51).

Custom character display on LCD using 8051 microcontroller

Description


When the ASCII code for any character, say ‘A’, is sent to be displayed on LCD module, the module's controller looks up the appropriate 5x8-pixel pattern in ROM (read-only memory) and displays that pattern on the LCD. There are 8 symbol locations where a custom character can be stored as shown in the following right table. These locations will have a particular bitmap layout corresponding to the custom character. To display an arrow sign, the bitmap values are mapped to a base address location, say 64 (ASCII code 0).


The symbol locations with their base addresses are given below:

 

ASCII Code
Base Address
0
64
1
72
2
80
3
88
4
96
5
104
6
112
7
120
 
This is achieved by first sending the address location (64) to LCD command register. Next, the bitmap values (0, 4, 2, 31, 2, 4, 0, 0) are sent to the LCD data register. Now the arrow sign gets stored at the first address. Now whenever this symbol is to be displayed, its location needs to be sent to the command register of LCD.
 
 
There's a 64-byte hunk of RAM (random-access memory) that the LCD controller uses in the same way as character-generator (CG) ROM. When the controller receives an ASCII code in the range that's mapped to the CG RAM, it uses the bit patterns stored there to display a pattern on the LCD. The concept here lies in the fact one can write to the CG RAM, thereby defining one’s own graphic symbols. Each byte of CG RAM is mapped to a five-bit horizontal row of pixels, and LCD characters are typically eight rows high, so 64 bytes of CG RAM is enough to define eight custom characters. These characters correspond to ASCII codes 0 through 7. When an LCD is first powered up, CG RAM contains random garbage bits. If necessary, CG RAM may be cleared by writing 00 into each CG RAM cell.
 
Writing to CG RAM
Writing to CG RAM is a lot like moving the cursor to a particular position on the display and displaying characters at that new location. The steps involved are:
  • Set RS (Register Select) and R/W (Read/Write) pins of the LCD to initialize the LCD to accept instructions
  • Set the CG RAM address by sending an instruction byte from 64 to 127 (locations 0-63 in CG RAM).
  • Switch to Data Mode by changing the setting of RS pin
  • Send bytes with the bit patterns for your symbol(s). The LCD controller automatically increments CG RAM addresses, in the same way as it increments cursor positions on the display.
  • To leave CG RAM, switch to Command Mode to set address counter to a valid display address (e.g. 128, 1st character of 1st line); the clear-screen instruction (byte 1); or the home instruction (byte 2). Now bytes are once again being written to the visible portion of the display.
  • To display the defined custom character print ASCII codes 0 through 7.
In the circuit, output of microcontroller AT89C51 (from port P2) goes to data pins of LCD numbered 7-14. The control pins RS (pin4), R/W (pin5) and EN (pin6) are connected to the pins 0, 1 and 6 of port P3 of the controller (P3^0, P3^1 & P3^6, respectively).
 
 

 

Circuit Diagram


Video

Code

This Code is only visible to Registered users. Please Login/Register

Code2

This Code is only visible to Registered users. Please Login/Register

Components

Presets | Variable Resistors
Preset
 
A preset is a three legged electronic component which can be made to offer varying resistance in a circuit. The resistance is varied by adjusting the rotary control over it. The adjustment can be done by using a small screw driver or...
AT89C51 Microcontroller, Atmel 89C51 Controller Image
AT89C51 Microcontroller

AT89C51 is an 8-bit microcontroller and belongs to Atmel's 8051 family. ATMEL 89C51 has 4KB of Flash programmable and erasable read only memory (...

16 x 2 LCD | 16x2 Character LCD Module
LCD

 

LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of applications. A 16x2 LCD display is very basic module and is very commonly used in various devices and circuits. These modules are preferred over seven segments...

Free Circuit Design & Simulation Tool by TI

Free Powerful Circuit Design & Simulation Tool by Texas Instruments

TINA-TI is a powerful circuit design and simulation tool. TINA-TI is ideal for designing, testing, and troubleshooting a broad variety of basic and advanced circuits, including complex architectures, without any node or number of device limitations.

Download It Here

Features:

Tina TI

TINA is an easy-to-use, powerful circuit simulation tool based on a SPICE engine. TINA-TI is a fully functional version of TINA, loaded with a library of TI macromodels plus passive and active models.

TINA-TI's new version 9 has changes from Version 7.0 in the following areas:

  • Schematic Symbol Editor (useable with the Macro Wizard) is included, so you can create your own symbols for imported SPICE macromodels.
  • Macros do not have to be from TI - you can import anyone's SPICE model now!
  • Does not require active or non-linear components for analysis (so you can now run a circuit using just passives).
  • TINA-TI includes Initial Condition and Nodeset components
  • TINA-TI includes Linear and nonlinear controlled sources (VCVS, CCVS, VCCS, CCCS), and the Controlled Source Wizard.
  • TINA-TI now allows WAV files to be used as stimulus (signal sources). You can play calculated waveforms on PC's multimedia system, and export calculated waveforms as a *.wav file.
  • TINA-TI has Multi-core processor support; this along with other optimizations makes simulations run 2-20 times faster.
  • Schematic file import/export in XML format
  • Block Wizard included for making block diagrams
  • TINA-TI has more SPICE models and example circuits included.
  • Circuits developed in TINA-TI 9 will work with TINA Industrial version 9.
  • TINA-TI Version 7.0 is forward compatible with Version 9, and version 9 supports saving schematics in version 7.0 format.
  • Available in English, Traditional and Simplified Chinese, Japanese, and Russian versions.

Download The Tool Here Free

You are here