Spread the love

LCD_Graphic ____________________________________________________________________________________________________

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.

internal block diagram of graphical lcd

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.

pAGE ACCESS NEW -

                        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.

pin detail GLCD

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.

DisplayControlInstructions

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 application of GLCD

Click Here : Understanding of GLCD Interfacing

1. circuit diagram of graphical lcd (128×64 ) with ARM7 ( LPC2148 )

interfacing graphical lcd arm lpc2148 microcontroller

1. Program of graphical lcd (128×64) interfacing with ARM7( LPC2148 )

/******************************************************
www.firmcodes.com
DEVELOPED BY:- FIRMWARE DEVELOPER
WHAT PROGRAM DO:- Image is displayed on graphical lcd using ARM7(LPC21XX)
******************************************************/
#include<lpc21xx.h>

#include"delay.h"  // delay header file

#include"graphical_lcd.h" // grafical lcd header file 

void pic(const unsigned char *ip);  // function to print data on lcd

/* 128x64 image into bit form*/
const unsigned char mnb[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,   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,  31, 127, 255, 255, 255, 255, 255, 255, 254, 253, 243, 231, 199,   0, 255, 255, 255,  10, 255, 255, 207, 207, 179, 126, 255, 122,  23,   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,   3,   7,  15,  62, 125, 123, 115, 231, 207, 159,   0, 255, 255, 255,   0, 127, 127,  63,  30,   5,   3,   2,   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, 128,   0,   1, 128, 128,   0,   1, 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
};




int main()
  {
	   PINSEL0=0X00000000;  // select as gpio
	   PINSEL1=0X00000000;  // select as gpio
	   IO0DIR=0XFFFFFFFF;   // make direction as output
     lcd_ini();  // initilization of grafical lcd
	   pic(mnb);	// loading picture on grafical lcd
	   while(1); // infinite loop
		 return 0;
  }


void pic(const unsigned char *ip) // function to display image on lcd
  {
     int Page=0;
     int Column=0;
     for (Page = 0; Page < 8; Page++)      
       {
         page_sel(1);                        
         cmd(0xb8 | Page);
         cmd(0x40);
         for (Column = 0; Column < 128; Column++)
           {
             if (Column == 64)
               { 
                 page_sel(0);                  
                 cmd(0xb8 | Page);
                 cmd(0x40); 
               }
             lcd_display(*ip++);                          
          }
      }
  }</span>

 GRAPHICAL_LCD.H  HEADER FILE

define LCD (0xff<<8)
#define RS (1<<16)
#define RW (1<<17)
#define EN (1<<18)
#define CS1 (1<<19)
#define CS2 (1<<20)
#define RST (1<<21)

void lcd_display(unsigned int x)
 {
    IO0CLR|=(RS|RW|EN|LCD);
    IO0SET|=(x<<8);
    IO0SET|=RS;
    IO0CLR|=RW;
    IO0SET|=EN;
    delay_fv(10,10);
    IO0CLR|=EN;
    delay_fv(10,10);
 }

void cmd(unsigned char m)
 {
    IO0CLR|=(RS|RW|EN|LCD);
    IO0SET|=(m<<8);
    IO0CLR|=RS;
    IO0CLR|=RW;
    IO0SET|=EN;
    delay_fv(10,10);
    IO0CLR|=EN;
    delay_fv(10,10);
 }

void page_sel(int a)
  {
	IO0CLR|=(CS1|CS2);
	if(a)   //PAGE 0
	 {
		IO0CLR|=CS1;
		IO0SET|=CS2;
         }
	else   // PAGE 1
	 {
		IO0CLR|=CS2;
		IO0SET|=CS1;
         }
   }

void lcd_ini()
  {
      IO0SET|=RST;
      page_sel(1);
      cmd(0Xb8);
      cmd(0X40);
      page_sel(0);
      cmd(0Xb8);
      cmd(0X40);
  }


void lcd_str(unsigned char *str)
   {
      while(*str!='\0')
        {
           lcd_display(*str);
           str++;
        }
   }

</span>

DELAY.H  HEADER FILE

void delay_ff()
{
    unsigned int b,v;
    for(b=0;b<600;b++)
    for(v=0;v<100;v++);
}

void delay_pf(unsigned int x)
 {
   unsigned int i,j;
   for(i=0;i<x;i++)
   for(j=0;j<153;j++);
 }

void delay_fv(unsigned int x,int y)
  {
     unsigned int i,j;
     for(i=0;i<x;i++)
        for(j=0;j<y;j++);
  }

 

PROTEUS File for SIMULATION(Password Of RAR file is :-firmcodes.com)

download (1)

Content for the tab VIDEO