Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp

Interfacing GLCD with PIC16F877A

Today I discuss on interfacing GLCD with PIC16F877A. To overcome the limitation of LCD display we use GLCD (Graphical LCD). By using GLCD, now we can display image. We can draw line and shapes page by page which are not possible in normal LCD. So to know the process of interfacing GLCD with PIC16F877A, we need to know the hardware connection. And as well as the some special instruction which is used in Mikroc Pro for Pic.  In bellow you can see the circuit diagram of hardware Interfacing GLCD with PIC16F877A in Proteous 7.

glcd

As shown in above circuit diagram, We can easily connect our hardware. Now come with programming portion. For interfacing GLCD with PIC16F877A , we need to now some special library instruction of GLCD in MikroC Pro for pic. Those are discuss bellow.

Initializes the Glcd module :

    • GLCD_CS1 : Chip select 1 signal pin
    • GLCD_CS2 : Chip select 2 signal pin
    • GLCD_RS : Register select signal pin
    • GLCD_RW : Read/Write Signal pin
  • GLCD_EN : Enable signal pin
  • GLCD_RST : Reset signal pin
  • GLCD_DataPort : Data port
  • GLCD_CS1_Direction : Direction of the Chip select 1 pin
  • GLCD_CS2_Direction : Direction of the Chip select 2 pin
  • GLCD_RS_Direction : Direction of the Register select signal pin
  • GLCD_RW_Direction : Direction of the Read/Write signal pin
  • GLCD_EN_Direction : Direction of the Enable signal pin
  • GLCD_RST_Direction : Direction of the Reset signal pin
Must be defined before using this function.
And command for initialization is  Glcd_Init();
 

Selects Glcd side:                           

This command is basically used for selects the side of Glcd and command for that is Glcd_Select_Side(0);

Sets x-axis position:                    

This command is basically used for Sets x-axis position of Glcd and command for that is Glcd_Set_X(25);

Selects page of the Glcd:

This command is basically used for Selects page of the Glcd and command for that is Glcd_Set_Page(5);

Reads data from the current location:

This command is basically used for Reads data from the current location of the Glcd and command for that is

unsigned short data;

data = Glcd_Read_Data();

Writes one byte to the current location:

This command is basically used for Writes one byte to the current location of the Glcd and command for that is

unsigned short data_;

Glcd_Write_Data(data_);

 Clear screen:

This command is basically used for Clear screen or fill the screen with 0/1 of the Glcd and command for is Glcd_Fill(0);

 Draws a dot:

This command is basically used for Draws a dot at particular position of the Glcd and command forthat is Glcd_Dot(0, 0, 2); . The parameter color determines a dot state: 0 clears dot, 1 puts a dot, and 2 inverts dot state and first tow digit is used for x_pos and y_pos where you need the dot.

 Draws a line:

This command is basically used for draw a line between dots (0,0) means (x=0,y=0) and (20,30) means (x=20,y=30) and command for that is

Glcd_Line(0, 0, 20, 30, 1);

The last digit in command is used for color of the line 0 white, 1 black, and 2 inverts each dot.

Draws a vertical line:

This command is basically used for draw a vertical line between dots (10,5) means (x=10,y=5) and (10,25) means (x=10,y=25) and command for that is

Glcd_V_Line(5, 25, 10, 1);

 Draws a horizontal line:

This command is basically used for draw a horizontal line between dots (10,20) and (50,20) and command for that is

Glcd_H_Line(10, 50, 20, 1);

Draws a rectangle:

This command is basically used for draw a rectangle between dots (5,5) and (40,40) and command for that is

Glcd_Rectangle(5, 5, 40, 40, 1);

The last digit in command is used for color of the line 0 white, 1 black, and 2 inverts each dot.

 Draws a box:

This command is basically used for Draw a box between dots (5,15) and (20,40) and command for that is

Glcd_Box(5, 15, 20, 40, 1);

The last digit in command is used for color of the line 0 white, 1 black, and 2 inverts each dot.

 Draws a circle:

This command is basically used for Draw a circle with center in (50,50) and radius=10 and command for that is

Glcd_Circle(50, 50, 10, 1);

The last digit in command is used for color of the line 0 white, 1 black, and 2 inverts each dot.

 Sets font Use :

This command is basically used for The custom 5×7 font “myfont” which starts with space (32): and command for that is

Glcd_Set_Font(&myfont, 5, 7, 32);

Prints character :

This command is basically used for Write character ‘C’ on the position 10 inside the page 2:

Glcd_Write_Char(‘C’, 10, 2, 1);

The last digit in command is used for color of the line 0 white, 1 black, and 2 inverts each dot.

Prints text:

This command is basically used for Write text “Hello world!” on the position 10 inside the page 2:

Glcd_Write_Text(“Hello world!”, 10, 2, 1);

The last digit in command is used for color of the line 0 white, 1 black, and 2 inverts each dot.

 Displays bitmap:

This command is basically used for Draw image my_image on Glcd and command for that is

Glcd_Image(my_image);

 Displays a partial area of the image:

  • x_left: x coordinate of the desired location (upper left coordinate).
  • y_top: y coordinate of the desired location (upper left coordinate).
  • width: desired image width.
  • height: desired image height.
  • picture_width: width of the original image.
  • picture_height: height of the original image.
  • image: image to be displayed. Bitmap array is located in code memory.

Draws a 10×15 part of the image starting from the upper left corner on the coordinate (10,12). Original image size is 16×32.

Glcd_PartialImage(10, 12, 10, 15, 16, 32, image);

And Here I give you a example program to make you understand better way . in my program I display My website logo and my site name. see the C Code for that.

See embedded Code

Embedded C Code
// Name : Interfacing GLCD with PIC16F877A
// Purpose : To display image and text on GLCD
// Author : Subham Dutta
// Date : 13-12-13
// Website : www.nbcafe.in
// ——————————————————
// GLCD Picture name: amie nbcafe.bmp
// GLCD Model: KS0108 128×64
// ——————————————————
const code char amienbcafe[350] = {
0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127, 127, 255, 255, 255, 191, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 207, 191, 127, 143, 143, 255, 15, 255, 255, 255, 255, 255, 254, 227, 207, 120, 56, 223, 199, 252, 255, 255, 255, 255, 255, 255, 15, 255, 31, 159, 255, 63, 223, 255, 255, 255, 255, 255, 255,
0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 252, 7, 226, 206, 31, 127, 255, 255, 255, 127, 15, 195, 240, 252, 193, 15, 63, 255, 255, 255, 255, 127, 31, 204, 3, 63, 249, 252, 255, 255, 255, 255, 255, 255, 255, 255,
0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 191, 159, 223, 207, 192, 196, 199, 231, 231, 162, 0, 3, 1, 96, 99, 99, 227, 227, 227, 131, 0, 33, 99, 225, 228, 198, 199, 207, 207, 192, 159, 191, 191, 255, 255, 255, 255, 255, 255, 255,
0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127, 127, 255, 191, 190, 190, 158, 222, 220, 236, 225, 243, 255, 255, 62, 156, 129, 195, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
0, 255, 255, 255, 255, 255, 255, 239, 227, 207, 231, 231, 231, 199, 239, 247, 255, 255, 247, 239, 199, 231, 207, 231, 199, 195, 231, 247, 199, 231, 231, 199, 255, 231, 255, 239, 215, 239, 231, 247, 207, 231, 199, 231, 231, 255, 255, 255, 255, 255,
0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
};char GLCD_DataPort at PORTD;
sbit GLCD_CS1 at RB0_bit;
sbit GLCD_CS2 at RB1_bit;
sbit GLCD_RS at RB2_bit;
sbit GLCD_RW at RB3_bit;
sbit GLCD_EN at RB4_bit;
sbit GLCD_RST at RB5_bit;
sbit GLCD_CS1_Direction at TRISB0_bit;
sbit GLCD_CS2_Direction at TRISB1_bit;
sbit GLCD_RS_Direction at TRISB2_bit;
sbit GLCD_RW_Direction at TRISB3_bit;
sbit GLCD_EN_Direction at TRISB4_bit;
sbit GLCD_RST_Direction at TRISB5_bit;
void main() {
Glcd_Init();
Glcd_PartialImage(0, 0, 50, 50, 50, 50, amienbcafe);Glcd_Write_Text(“NBCAFE”, 55, 1, 0);Glcd_Write_Text(“AMIE NBCAFE”, 55, 4, 0);
Glcd_Write_Text(“Engineering platform”, 0, 6, 0);
}

Must See the simulation to understand the project interfacing GLCD with PIC16F877A.

Not Enough, Need More

E-Mail Subscription





3 thoughts on “Interfacing GLCD with PIC16F877A”

  1. Sincerely Yours,I checked your blog named “Interfacing GLCD with PIC16F877A | NBCAFE” daily. Your humoristic style is spectacular, keep it up! And you can check our website about ??.

Comments are closed.

E-Mail Subscription





Table of Contents
Subham Dutta

Subham Dutta

Hi myself Subham Dutta, having 15+ years experience in filed of Engineering. I love to teach and try to build foundation of students. Try to make them imagine what they learn.

Need more this type of content in your E-Mail?



NBCAFE