Part 4 – Getting started with a 128×64 Graphics LCD Display – Pin configuration

In the previous part, we saw how to instruction set works and how the different pins fit together to make the GLCD work. In this part, we’ll pick a particular microcontroller and try to work out how to configure the pins.

The JHD12864E works in a parallel mode. By parallel, I mean that the data is passed in one shot which is by the data pins D0-D7 on the display. There are other GLCDs which pass data in serial i.e. one instruction at a time. In this case, we don’t need so many pins but there will be other considerations that we will need to … uh … consider.

In this case, let’s see how many pins we’ll need to control. Looking at the diagram again:

clip_image005

The pins which will be controlled by the microcontroller are:

RS, R/W, E, CS1, CS2, RST – A total of 6 pins

DB0 – DB7 – A total of 8 pins

which brings it to about 14 pins. If you’d like the LED backlight to be controlled by the microcontroller as well, that’ll make it about 15 pins.

Given this condition, my suggestions would be to go for a 40-pin Microcontroller (ATMEGA1284 or PIC18F4550) or at least a 28 pin microcontroller (ATMEGA328 or PIC16F886) to make things easy. One thing that definitely helps is if you can ensure all the data pins are connected to a particular port in the same order. This makes it easier to write data and reduces programming effort significantly. By that, I mean if you’re connecting the data pins to PORT B on the microcontroller, connect them as follows:

DB0 –> PB0

DB1 –> PB1

DB7 –> PB7

For the remaining pins, VSS, VDD, LED+ and LED- are fairly straightforward and just need to be connected to +5V and GND as specified. Make sure you put a resistor between LED+ and +5V just in case. I use a 1K resistor and it works very well.

The next tricky part about the GLCD is the trimpot. You need to connect a 10K trimpot to the GLCD to adjust the contrast. The documentation is not very clear on this, so I’ll try to explain this in detail.

10K is an absolute necessity. Not 5K, not 1K. It’s just not worth the grief if you’re setting this up for the first time. Just go with a 10K trimpot. Of the three pins in the trimpot, here’s how you need to connect them:

Pin1 on trimpot –> +5V

Pin 2 on trimpot –> Pin V0 on GLCD

Pin 3 on trimpot –> Pin VEE (-10V) on GLCD

That’s all there is to it. You’ll need to adjust the trimpot till you see the contrast showing up on the LCD. Twist the screw on top as far as it will go on each side to until you see the stark contrast showing up.

Another thing that isn’t widely explained is about the Reset pin. What does it do? The reset allows you to clear everything on the display and make sure it starts putting things in the first line of the display. In the case of the JHD12864E, we need to pull it down to LOW and then bring it back to HIGH. For all further operations, the Reset will need to remain at HIGH and anytime we need to reset the display, we need to bring it to LOW and bring it back to HIGH.

That’s it about the pin configurations!

Next:

Prev: Part 3 – Getting started with a 128×64 Graphics LCD Display – Passing instructions

Table of Contents

21 thoughts on “Part 4 – Getting started with a 128×64 Graphics LCD Display – Pin configuration

  1. Pingback: Intro – Getting started with a 128×64 Graphics LCD Display | Emptiness in void

  2. Pingback: Part 3 – Getting started with a 128×64 Graphics LCD Display – Passing instructions | Emptiness in void

      • Sir plss do complete the parts …i really need ur help….only dis link was working with jhd128*64e….plsss…i need to start wid d glcd part and submit it by jan first week sir….atleast upload part5 sir..thank u

  3. Hi George – I don’t think I’ll be able to get it up by January. And also, it might not be easy for you to put together and submit by first week of Jan. If you need a quick solution, why don’t you use the Arduino library for the same? I tried it 2 years ago and it works with the Uno and they have complete libraries for everything. Here are a couple of links:

    http://playground.arduino.cc/Code/GLCDks0108

    http://playground.arduino.cc/uploads/Code/GLCD_Documentation.pdf

    The JHD12864E uses a KS0108 chip, so this solution works very well.

  4. Im working with arm 7 lpc2148 …i am able to print different bit patterns on the screen…im very thankful to ur tutorials…if possible provide me links for jhd12864e with arm7 to display a pixel….a circle…i got few links but they were not working well

    • Glad to hear that George! I haven’t used an ARM so can’t really help there. But in terms of displaying useful stuff, MikroC has an in-built font generator and image generator for 128×64 display which I used for my project. For displaying a pixel, you just need to send a single bit in the byte to the screen i.e. 0b00000001. Once you are able to output a single pixel on the screen, you should be able to use standard line and circle graphics algos to draw shapes and animations. To display full images, just use MikroC’s image generator and display it.

  5. hey i had one more doubt…i cud display a pixel….now i wanted to print the response of at commands from sim908 on my glcd like(OK,AT,MESSAGE SENT)…so basically how do we print alphabets here…i got an array of ascii values…den wat shud i do with it?

  6. and also while setting a pixel…
    1)v shud first read the byte at that position and den OR it with the new data ryt?
    2)but while reading value im getting eror…i just have to set the y,x address ryt and den the normal steps ryt?

  7. To answer your first question – to write characters, if you’re using MikroC’s tool, the first byte in the array is the width of the letter and the subsequent bytes need to be put in horizontally one after another. So you can think of writing it out as vertical lines one after the other. If the font is bigger than 8 bits or 1 byte, then you have to write it down vertically first and then move horizontally

    You are on the right track with having to read the value and OR it with the byte. But what I did was instead of reading from the GLCD, I just maintain a 1024 byte array (128 times 64 bits or 128 times 8 bytes) which keeps a realtime track of everything I write to the screen. I then just read from this array and OR the value I want to write and push it through.

    I thought it would be easier for you to understand this if you took a look at my latest code. I have been working on this for the last 2-3 months. You can take a look here:

    https://github.com/plastygrove/PIC-Graphics-LCD

    Uploaded just for you :), it’s a WIP and I wanted to wait a bit more before uploading it, but I think it might help with your requirements

    Do note that I’m using a 74HC595 shift register for the data bus to the GLCD. That saves me a few pins on the microcontroller to do other things, but it also slows down the refresh rate. I recommend at least a 20MHz clock cycle otherwise you might notice a slight flicker

  8. i can now print strings on glcd…im luvg it :) but still not able to set a pixel properly bcoz of the read function…..
    1)before calling the read function i hv to set the x,y address ryt?
    2)d read function is exactly like the write_data function apart from R/W =1 ryt?

    sorry to irritate u wid so many questions…its just dat u seem to be very helpful :)

  9. Glad to see you’re progressing so well, I’d love to see a video or photo of your project if possible.

    For setting the pixel, like I said earlier, I don’t read from the screen. I just store the screen data in an internal array which is updated every time I write to the screen. It’s faster than reading from the LCD and it only takes 1K of memory.

    You can see it in glcd.c, it’s called mmap.

    However, if you want to read from the LCD, I haven’t tried it myself since I never needed it. But a quick search showed the following link which explains how to go about reading from the LCD:

    http://www.edaboard.com/thread115197.html

  10. finally did it!!!decided to choose ur method of hvg mmap itself….thank u so much…il definitely upload my video once i also interface gsm,gps with it…thanku very much!!

  11. my code to plot a circle is not getting proper response…..not the entire circle gets plotted….will it be okay if i share my code so thatu cud help me out…or else cud u share wid me ur email id?

    • Hey George – apologies for the late reply. Sorry, I won’t be able to go through your code, I have written code for plotting a circle in the code I posted on github, so please feel free to use that as a reference. Hope your project comes out well!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s