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:
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!