GLCD: Interfacing 128×64 Pixel GLCD (KS0108) with PIC16F876

Filed in Articles , PIC , Projects , Uncategorized , glcd 14 comments

Now you know all necessary things about GLCD from introduction post, lets start working on it. As described earlier  GLCD requires 14 IO connections named as follows;

DB0-DB7: Data Pins
CS1 – CS2: Chip Select
E: Enable
R/W: Read-Write Selection
RS: Register Select

These are the data and control pins which are connected to the processing device such as microcontroller. Other than these are;

VCC: Power Input
GND: Ground
VO: Contrast Input
-Vout: -ve Voltage for Contrast
LED+: Backlight +ve Power Input
LED-: Ground

Step 1
This step included the hardware interfacing of GLCD with PIC16F876. We will follow the connections as given below;

DB0 -> RB0


DB7 -> RB7
CS1 -> RA0
CS2 -> RA1
RS -> RA2
RW-> RA3
E -> RA4
RST -> RA5

Schematic - Click to enlarge

Schematic - Click to enlarge

Pin RA4 is an open-collector output in PIC16F876, which means it will not output Logic high but instead will go to high-z state. So as to utilize the pic, we will use a pull-up resistor for its connection with GLCD.

Pull-up at RA4 - Click to enlarge

Pull-up at RA4 - Click to enlarge

You must have noticed that 4 connections are still left which are LED+, LED-, VO and -Vout.

LED+ and LED- are the Anode and Cathode of backlight led. A series resistor fo 10 Ohms to 22 Ohms is usually used.

-Vout is used for contrast setting and it outputs -ve voltage.  VO (or Vee) is the input for contrast voltage. A potentiometer is used here to vary contrast.

All the connections are shown below. Note that VO is referred as Vee
Other Connections - Click to enlarge

The hardware interfacing is complete and now move on to coding.

Step 2

The following program will display Creative Electron in the extreme left corner of the display.

The code is as follows;

#include <16F876A.h>
#include <CE_GLCD.c>
#include <graphics.c>

#use delay(clock=20000000)

char text[]=”Creative Electron“;

void main ()


glcd_text57(0, 0, text, 1, ON);


// End of Program

There are two new files included in the program. The file “CE_GLCD.c” contains the pin configuration information of the GLCD along with the timings and data output functions. The “Graphics.c” includes the functions used for making fonts, characters and graphics to be used in GLCD.

“glcd_init(ON)”  initializes the GLCD and clears the screen. After  initializing we need to output the string with the  “glcd_text57″ function. Its syntax is glcd_text57(x,y,string,size,color). The x and y are the start coordinates for text. “string” is the data you want to display. “size” is the fontsize while color means whether you need to ON the pixels or OFF.

A detailed help of the GLCD functions will be posted later. In the meantime you can view list of functions and their usage in “CE_GLCD.c” file.

After running the program in Proteus the output will be as following ;

Proteus Simulation - Click to enlarge

Step 4

Download the ZIP file which contains ;

Source Code: GLCD01.C (CCS C Compiler)
GLCD Driver: CE_GLCD.C (CCS C Compiler)
Hex File: GLCD01.HEX
Proteus Simulation: GLCD01.DSN (Proteus ISIS)

Download: Source Files – Interfacing 128×64 Pixel GLCD with PIC16F876
Filesize: 20 kB

Step 5

Check other functions listed in CE_GLCD.C driver file, to draw graphics such as rectangles, lines and circles. It also has many other useful functions.

Step 6

Enjoy GLCD InterfacING =)

Posted by hamzaazeem   @   25 September 2009 14 comments
Tags : , , , , ,

Share This Post

RSS Digg Twitter StumbleUpon Delicious Technorati


  • defcon

    i will try this out !

  • Allanrocks05

    if i use a 240x128 glcd. can i still interface it?

  • Ironhide87

    We plan to interface the PIC18F4520 with a larger size Graphic LCD, probably the size similar to 5" or 7" that possible? What software do we need to use to interface it. Currently we are using MPLAB IDE version 8.10. Is there any other software required?

  • creativeelectron

    While interfacing the GLCD we do not consider the physical size rather the pixel quantity or resolution. So what is the resolution of your GLCD ? Usually resolution is 128x64.

  • Ironhide87

    Our resolution is 480x234

blog comments powered by Disqus
Previous Post
Next Post