LCD DISPLAY |
|||||||||||||||||||||||||||||||||||||||||||||||||
| . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | |||||||||||||||||||||||||||||||||||||||||||||||||
| display scrolling text on a Hitachi HD44780 LCD display (still under construction, check back soon) | |||||||||||||||||||||||||||||||||||||||||||||||||
Overview Character LCDs (as well as graphic LCDs) are very useful in electronics projects. They can provide instant/dynamic display and interface for the user or be used for debugging purposes. Typically the LCD display comes on its controller board that you can connect to computer or microcontroller. A very common type of LCD controller is the Hitatchi 44780. This is an easy to use and easy to program controller provided that the appropriate spec sheets and diagrams are at hand. In this tutorial, I use a 2 line 16 character Hitachi HD44780 character display. If you're serious about using it, get acquainted with the datasheet: Hitachi HD44780 Datasheet (PDF) This LCD has 14 pins, an optional backlight and a simple parallel bus interface for easy communication. The signal send to the LCD can be 4 or 8 bits ASCII depending on the mode you initialize. If using 8 bit mode, 8 data pins from the LCD are used, for a total of 10 pins on your driver board. If you want to save on I/O pins on your microcontroller, you can use 4 bit mode. In this case, a total of 6 bits is required, (only 4 data pins). The lower and upper nibble are sent consecutively to make the 8 bits of data for every transfer. The Enable (E) pin is used to initiate the data transfer within the LCD. The Register Select pin (R/S) determines whether data or an instruction is being transferred between the microcontroller and the LCD. The Read/Write pin (R/W) selects whether we are performing a read or write operation to the LCD. See below for more information. Without getting into much detail, the different instructions available for use with the 44780 are:
Using an LCD library (Procyon's avrlib) will enable us to perform these instructions in C code without worrying about bit level programming. 1. 14 pin Hitachi HD44780 pinout The hitachi HD44780 has 14 pins. The pinout is as follows.
If you are using a potentiometer with 3 pins, connect the wiper to pin 3 of the LCD, and the other two pins to Vcc and ground. Connect pins 4, 5 and 6 to 3 I/O pins on your microcontroller and pins 7-14 to 8 pins on another I/O port on your microcontroller. I use the a compact microcontroller board: the chalkroach. This is a developer's board for the ATMega32 40 pin AVR from Atmel. To make, stuff and program a chalkroach microcontroller board, go to the chalkroach tutorial. 2. Connect the LCD display The following is the way I have connected chalkroach to the Hitachi HD44780.
These pin assignments need to be set up in the microcontroller code, as we will see below. 3. Write the LCD program After connecting up the LCD, we need to program a microcontroller to send text to the display. Instead of doing bit level programming, we will use an LCD module from avrlib to communicate with the LCD. This library provides the follwing easy to use C functions:
Using these functions, we can set the bit mode of the LCD, the pin assignment the cursor movement options as well as print characters easily to the LCD. |
|||||||||||||||||||||||||||||||||||||||||||||||||