This article describe the hardware setup required for interfacing HD44780 based alphanumeric LCD modules with a PIC16F877A microcontroller. The software part consisting of the LCD library for PIC, its setup and use with MPLAB X IDE and XC8 compiler are described in a separate article.
A common controller chip used in many alphanumeric LCD module is the HD44780. The purpose of the controller is to generate pixel patterns and drive individual pixels of the LCD to show characters and symbols. In this method the main microcontroller running your application code does NOT need to generate the pixel patterns, it just need to tell the controller chip which character or symbol to show the rest is done by the controller, i.e. the HD44780.
The same controller chip is used in many differently sized alphanumeric LCDs. Thus the connection schematic and driving code is same.
Pin Details of LCD Module
All HD44780 based LCD modules have 16 pin connecters. The detail about these pins is given below.
Interface pins of LCD Module
|Pin Type||Connected with PIC16F877A’s pin|
Common modules works with 5v supply. Pin 1 is connected to GND and pin 2 is connected to +5v supply. The pin 3 is the contrast adjust pin and proper wiring of this pin is very important to get anything visible on the screen. Even if you have done everything perfectly, but an improper wiring of this line can lead to a complete blank display !
A 10K preset is used as a voltage divider to get any voltage between 0v and 5v. This voltage is feed to the VEE pin. So after everything is ready and you have programmed your PIC Micro to show something on the LCD, you have to adjust this preset before you can see anything on the LCD.
Then their are three control line, namely the RS, R/W, E. these are connected to microcontrollers general purpose input output line.
After that comes the data lines DB0 to DB7 (8 bit wide). These are also connected to microcontrollers general purpose input output line. The HD44780 controller also has a 4 bit data transfer mode. This mode is very useful as it uses only 4 bit lines to transfer the whole 8 bit data. The data is transferred in two transfers each of 4 bit. Thus this technique requires only four i/o line of microcontroller in place of eight. This smart saving of i/o lines is very useful as you are free to use the saved i/o lines for other purpose in your design.
In four bit transfer mode, data bits DB0-DB3 are left unconnected only DB4 to DB7 are connected with microcontroller.
Finally comes the backlight power lines. As you may be knowing the backlight helps viewing the contents of the LCD module in dark situations. Making the backlight lit is simple, as it is just a set of LEDs. You need to supply +5v and a GND connection to make it glow. But as with any LED it is suggested to use a current limiting resistor in series with the backlight. The resistor we prefer is a 100ohm resistor (a 1/4th watt resistor is enough but you may use 1/2 watt also).
Complete schematic of the LCD subsystem is shown below.
LCD Module Subsystem
16×2 LCD Board
The 16×2 LCD Board makes it easy to interface a 16×2 LCD module with low cost microcontroller development board which do not have built in support for lcd modules. This board has the following
- 16×2 lcd module (you can choose either a green or a blue backlight lcd)
- The contrast adjust resistor.
- Backlight current limiting resister.
so you can see that it has all the things required by the lcd subsystem in a nice pcb.
In addition to the above, it also has the ability to turn on or off the lcd backlight and also control its brightness using pwm technique.
LCD Board Description
Backlight Control Jumper
Connecting with PIC16F877A Development Board
The PIC16F877A development board as the PIC16F877A microcontroller chip and its supporting basic circuitry all in a nice high quality PCB. The development board comes fully assembled and tested, thus makes it ideal for doing experiments for learning by beginners.
40 PIN PIC Development Board
In the bottom portion of the pic development board you can see a row of male headers. Most of these pins are the microcontrollers general purpose input/output lines and the rest are 5v and GND supply lines. Using these pins you can connect external peripherals (like the LCD board or something else) to do your experiment. The pins are clearly labeled on the PCB surface.
Since other peripheral boards also have male headers for interconnection, you need a female to female burg wires like these to make connections.
LCD Board Connection
Connect LCD Board with the development board using the above mentioned burg wires according to the table given below.
40 PIN PIC Dev Board
|3 LED PWM||Not Connected|
5v and GND connection points are labeled in the development board as Extra 5v OUT. Please refer to the image below for their positions. 5v and GND are also available in the 40 pin row of male headers. In the image below Yellow wire is 5v and Green wire is GND.
Close up of Connection.
Schematic of the whole setup
PIC16F877A Interfaced with LCD Module Schematic (Click to Enlarge …)
- LCD Library for PIC – Setup on MPLAB X IDE This article describes the setup and use of the C library for hd44780 based alphanumeric lcd modules. Here we describe how to setup a MPLAB X project with support for lcd related functions. The library is designed for compilation and use with Microchip’s XC8 C Compiler.
By Avinash Gupta
eXtreme Electronics highly recommends EasyEDA for circuit and PCB design.
Facing problem with your embedded, electronics or robotics project? We are here to help!
Post a help request.