Those how are building microcontroller based project for little long must have got bored with the good old character LCDs. Whether you are bored or your application require to present more data to the user in a better way, you need Graphic LCD. Character LCD Interfacing is quite easy so every one uses it, but when I comes to Graphic LCD you need a well written and powerful graphic library. Its not enough that you read the LCD datasheet and connect it your MCU and start sending data. Because the LCD just appears to be block of memory whose contents are directly visible on screen. The datasheet can only guide you how to access this memory. You just can’t do much by writing to the memory. The graphic library is a piece of software that has complex algorithms to render graphic primitives like line, rectangles, circles, images and more. It also helps load fonts and render text and numbers on screen. So it provide high level access to the LCD screen and applications can be written much more easily.

While I was researching for graphic library for the GLCDs, I found some but I was not fully satisfied by any of them. So I began to write a clean, powerful, portable and easy to use library that can handle sever different graphic LCDs and can be ported to many MCUs. In this article I will use a Graphic LCD which is based on common KS0108 type controller with AVR ATmega32 MCU. In future I will port the tutorial and library for PIC and ARM CPUs.

Introducing the JHD12864E Graphical LCD Module.

Their are several type of graphical LCD module in the market. In this tutorial I will introduce you to a common graphical lcd module that is easily available in most part of the globe. If you are in India I request you to buy one of these from our online store, in this way you can help us.

ks0108 based 128 x 64 Graphic LCD Module

KS0108 based 128 x 64 Graphic LCD Module

The specification of this LCD are as follows.

  • 128 horizontal pixel and 64 vertical pixel resolution.
  • Controlled based on KS0108B
  • Parallel 8bit interface
  • On board graphic memory.
  • Available in Green backlight with dark green pixels.
  • Also available in Blue backlight with light blue pixels.
  • LED backlight.
  • 20 PIN linear connection.

PIN Description

PIN
Name
Function
Connection with AVR PIN
1 Vss Ground  
2 Vcc +5v Supply in  
3 V0 Contrast Adjust  
4 RS Instruction/Data Register Select PD3
5 R/W READ/WRITE SELECTION PD6
6 E ENABLE SIGNAL PB4
7 DB0 DATA IN/OUT PC0
8 DB1 DATA IN/OUT PC1
9 DB2 DATA IN/OUT PC2
10 DB3 DATA IN/OUT PC3
11 DB4 DATA IN/OUT PC4
12 DB5 DATA IN/OUT PC5
13 DB6 DATA IN/OUT PC6
14 DB7 DATA IN/OUT PC7
15 CS1 Chip Select 1 PB0
16 CS2 Chip Select 2 PB1
17 RST RESET SIGNAL RESET
18 VEE NEGATIVE 10V OUT  
19 LED+ LED BACKLIGHT  
20 LED- LED BACKLIGHT  

Graphic LCD Testing Circuit with AVR ATmega32

I suggest you to make a small circuit with ATmega32, its life support environment and Graphic LCD to experiment with these LCD. I have clocked the Test circuit with 16MHz crystal for maximum speed. Make the circuit as follows.

schematic for avr atmega32 and graphic lcd

Schematic for AVR ATmega32 and Graphic LCD Connection.

The RV1 (which is a variable resistor of 10K) is used to adjust the contrast of the display. If no display is visible on screen use this to adjust the contrast until you see everything clearly. The AVR’s Fuse bits must be set as follows to disable JTAG and enable external crystal.This step is very important and things won’t work if you forget this.

  • HIGH Fuse = 0xC9
  • LOW Fuse = 0xFF

Graphic LCD Test Circuit Fabrication Tips.

I have used my Low Cost 40 PIN AVR Development Board for quick testing. I is a bare bone AVR board with AVR and its life support. The nice thing is that it has prototyping area surrounding the AVR. I used this area to mount the 20 PIN FRC Box header for connecting the GLCD.

avr development board with glcd

40 PIN AVR Devboard with Graphic LCD Connector.

In the above image you can see the 20 PIN FRC Box header is soldered. The red wires connect the PINS of header to the MCUs I/O lines. They also supply power to the module and its led backlight.

graphic lcd connector

Graphic LCD Connector.

Take a 20 PIN FRC Cable. It has female connectors at both ends. Cut it to half and solder the wires to 20 PINs on the LCD Module. The image below illustrate the point. Now you can easily connect and disconnect the graphic lcd module from board.

Graphic LCD with Wire Soldered.

wires soldered on graphic module

Graphic LCD with Wire Soldering.

graphic lcd connected

Graphic LCD Connected.

avr glcd setup is ready

AVR Graphic LCD setup is ready!

In the next tutorial we will get our hands wet by writing the "Hello World" App for the Graphic LCD. I will show you how to create a AVR Studio Project with Graphic LCD Support by Adding and Configuring our Solid Graphic Library for AVRs.

So don’t forget to subscribe to the RSS Feed or email delivery of new articles! See the sidebar for more info. You can also connect via Twitter.

I also wish all my Indian friends a very happy Independence Day! As I was writing this article on the eve of Independence day.

Other Parts of the Tutorial Series

By
Avinash Gupta
Facebook, Follow on Twitter.
www.AvinashGupta.com
me@avinashgupta.com