____________________________________________________________________________________________________
[/wptab] Overview Text LCD (as we discussed 16×2 LCD earlier) has its own limitation, you can also create small graphics on Text LCD by generating custome character but somewhile it is limited. By using Graphical LCD(GLCD) we can present information in a better and user friendly way by using any patterns or shapes. Graphical LCDs are preferred where both character and graphical representation are required. GLCD is a bit complex and we need a powerful graphic library to work with it. MikroC PRO for PIC Microcontrollers provides powerful built in libraries for that What is Graphical LCD ? The graphical LCD is made up of a grid of pixels. Common resolution is 128×64. That means, their are 64 horizontal lines and each line has 128 pixels. These displays are monochrome that means each pixel can either be ON or OFF. ON pixels looks dark while OFF pixels are nearly invisible. The GLCD has a graphic RAM where each bit in RAM corresponds to one pixel on screen. You write to the graphic RAM to modify its contents and the screen will change accordingly. About & Types of GLCD There are various types of graphics LCD modules available in the market depending on pixel size such as 120×64, 128×128, 240×64,128×64 and 240×128. The graphics LCD used here has a pixel size of 128×64 and is based on AG12864EFIQB -H. Interfacing Overview of GLCD The graphical LCD used here is AMPIRE 128X64(AG12864EFIQB -H) module, which is a 128×64 pixel monochromatic display. It uses KS0108B (or KS0107B) display controller. The KS0108B is a dot matrix LCD segment driver with 64 channel output, and therefore, the GLCD module contains two sets of it to drive 128 segments. On the other hand, the KS0107B is a 64-channel common driver which generates the timing signal to control the two KS0108B segment drivers. The KS0108B and KS0107B are a very popular controllers and have made their way into many graphical LCDs. The internal block diagram of the AMPIRE 128X64 GLCD module is shown below. The KS0107 drives the 64 display lines, COM1 – COM64. The first KS0108 drives the left half segments (SEG1 to SEG64) and the second one drives the right half segments (SEG65 to SEG128) of the display. The two halves of the display can be individually accessed through the chip select pins (CS1 and CS2) of the two KS0108 drivers. Each half consists of 8 horizontal pages (0-7) which are 8 bits (1 byte) high. This is illustrated in the drawing below. Starting from page 0 on the left half (/CS1 = 0) if you transmit one data byte, it will appear on the first column of page 0. If you repeat this 64 times, then switch to the second half, and repeat until 128th position is reached, the first 8 display lines will be plotted. The next 8 lines can be plotted similarly by switching to page address 1. The total amount of bytes needed for a complete display frame (128×64 pixels) is, therefore, 2 x 64 pixels x 8 bits = 1024 bytes. The AMPIRE 128X64 module does have an internal negative voltage generator circuit which provides a negative voltage at VEE external pin. An external potentiometer (usually 10 K) is connected between VDD and VEE pins to set the LCD contrast. The pin diagrams of KS0108 based GLCDs is not standardized and it is therefore, important to read the manufacturer’s datasheet for correct wiring of a GLCD module. The following table shows the pin descriptions of AMPIRE 128X64 module. It has 20 pins with each different function shown below. The KS0107/KS0108 does not have a character generator so this must be implemented in the microcontroller firmware. The LCD controller supports a handful of instructions which are summarized in the table shown below. Note that the RS (D/I) pin is high only during data read and data write operations, and stays low when a transmitted byte is an instruction. Software Detail There are many software like Mikro C Pro, Mikroelectronica GLCD font creator, image2GLCD, etc Application Typical application of Graphical LCD is show below Content for the tab VIDEO Click Here : Understanding of GLCD Interfacing
1. Program of graphical lcd (128×64) interfacing with 8051
/******************************************************
www.firmcodes.com
DEVELOPED BY:- FIRMWARE DEVELOPER
WHAT PROGRAM DO:- Image is displayed on graphical lcd using 8051
******************************************************/
#include <reg51.h>
#include <stdio.h>
#define DATA P2
sbit RS = P1^0;
sbit RW = P1^1;
sbit lcd_e = P1^2;
sbit CS1 = P1^3;
sbit CS2 = P1^4;
sbit RST = P1^5;
void GLCD_PutPicture(const unsigned char *);
void Select_page(unsigned char);
int i;
/* image code to display on graphical lcd */
code unsigned char const S2_bmp[1024] ={
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 192, 224, 192, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 128, 192, 240, 252, 252, 254, 255, 255, 255, 255, 223, 239, 255, 127, 254, 252, 240, 224, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 192, 64, 64, 64, 64, 0, 0, 64, 192, 192, 0, 0, 0, 192, 192, 64, 64, 64, 192, 128, 0, 0, 0, 192, 192, 192, 0, 0, 0, 0, 128, 192, 192, 0, 0, 0, 0, 128, 192, 64, 64, 64, 64, 128, 0, 0, 0, 128, 64, 64, 0, 64, 192, 128, 0, 0, 0, 192, 192, 192, 64, 64, 192, 128, 0, 0, 0, 192, 192, 64, 64, 64, 64, 192, 0, 0, 128, 64, 64, 0, 64, 128, 0, 0, 0, 0,
0, 0, 0, 0, 128, 240, 248, 255, 255, 255, 255, 255, 255, 255, 255, 255, 253, 129, 255, 255, 255, 127, 190, 255, 193, 254, 239, 63, 60, 240, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 127, 4, 4, 14, 0, 0, 0, 0, 127, 127, 0, 0, 0, 127, 127, 0, 8, 28, 127, 103, 64, 0, 0, 127, 1, 7, 62, 120, 16, 0, 0, 127, 127, 0, 0, 0, 63, 127, 96, 128, 128, 128, 64, 0, 0, 12, 63, 127, 64, 128, 128, 0, 96, 127, 31, 0, 0, 127, 127, 127, 0, 0, 96, 63, 31, 0, 0, 127, 127, 77, 128, 12, 0, 64, 0, 0, 99, 71, 6, 140, 12, 120, 0, 0, 0, 0,
0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 127, 255, 255, 253, 249, 243, 0, 255, 253, 251, 127, 255, 255, 255, 239, 223, 63, 239, 255, 255, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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128, 129, 128, 128, 0, 0, 128, 128, 0, 0, 128, 128, 128, 128, 0, 0, 128, 128, 0, 0, 128, 128, 0, 0, 0, 0, 128, 128, 128, 128, 0, 128, 0, 0, 128, 128, 128, 128, 0, 0, 128, 128, 0, 0, 0, 0, 128, 128, 0, 0, 0, 128, 128, 128, 0, 0, 0, 128, 128, 128, 0, 0, 0, 128, 128, 128, 128, 0, 0, 0, 128, 128, 128, 128, 0, 128, 128, 128, 0, 0, 0, 0, 0, 0, 128, 128, 128, 0, 0, 0, 128, 128, 128, 0, 0, 0, 128, 128, 0, 0, 0, 0, 128, 128, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 143, 184, 184, 135, 135, 188, 176, 143, 128, 128, 143, 184, 184, 135, 135, 188, 176, 143, 128, 128, 143, 184, 184, 135, 135, 188, 176, 143, 128, 128, 176, 128, 128, 191, 132, 132, 128, 128, 191, 128, 128, 191, 132, 140, 187, 160, 128, 191, 129, 135, 184, 184, 134, 129, 191, 128, 128, 159, 161, 160, 160, 145, 132, 159, 160, 160, 160, 159, 132, 128, 191, 160, 160, 160, 159, 132, 128, 191, 164, 164, 160, 144, 167, 164, 188, 152, 128, 176, 128, 128, 159, 161, 160, 160, 145, 132, 159, 160, 160, 160, 159, 132, 128, 191, 129, 135, 184, 184, 134, 129, 191, 128, 0, 0, 0, 0
};
void GLCD_Init();
void GLCD_Data(unsigned char);
void GLCD_Comd(unsigned char);
void DelayMs(int);
//------------------------
// Main Program
//-----------------------
void main(void)
{
DelayMs(2);
RST = 1;
DelayMs(5);
RST = 0;
DelayMs(5);
RST = 1;
DelayMs(5);
GLCD_Init();
DelayMs(15);
GLCD_PutPicture(S2_bmp);
while(1);
}
void GLCD_Comd(unsigned char cmnd) // graphical lcd command
{
DATA = cmnd;
RS = 0;
RW = 0;
lcd_e = 1;
DelayMs(10);
lcd_e = 0;
}
void GLCD_Data(unsigned char dat) // graphical lcd data
{
DATA = dat;
RS = 1;
RW = 0;
lcd_e = 1;
DelayMs(10);
lcd_e = 0;
}
void DelayMs(int k) // delay in milli-second
{
unsigned int a;
for(a=0;a<=k;a++);
}
void GLCD_Init()
{
unsigned char Comd[5]={0xc0,0xb8,0x40,0x3f};
Select_page(1);
for(i=0;i<4;i++)
GLCD_Comd(Comd[i]);
Select_page(0);
for(i=0;i<4;i++)
GLCD_Comd(Comd[i]);
}
//----------------------------------
// Page Selection
//----------------------------------
void Select_page(unsigned char Page)
{
if(Page)
{
CS1=0;
CS2=1;
}
else
{
CS1=1;
CS2=0;
}
}
//-------------------------------------
// Display Picture for page0 & page1
//-------------------------------------
void GLCD_PutPicture(const unsigned char *ip)
{
int Page=0,i=0;
int Column=0;
for (Page = 0; Page < 8; Page++)
{
Select_page(1);
GLCD_Comd(0xb8 | Page);
GLCD_Comd(0x40);
for (Column = 0; Column < 128; Column++)
{
if (Column == 64)
{
Select_page(0);
GLCD_Comd(0xb8 | Page);
GLCD_Comd(0x40);
}
GLCD_Data(*ip++);
}
}
}
PROTEUS File for SIMULATION(Password Of RAR file is :-firmcodes.com)