NPEDUCATIONS, Electronic circuits development, electronics tutorials, microcontroller tutorials and projects, advanced microcontroller (ARM) based tutorials and projects, Embedded c development, Embedded c for ARM cortex M, Intel IoT based projects, IoT projects, CC3200 launch pad projects, MSP430 Launchpad tutorials and projects, Tiva C launch pad tutorials and projects, 8051 tutorials and projects, sensor interfacing with microcontroller tutorials, data communications and networking tutorials, peripheral interfacing with microcontroller, led message scrolling display, arduino based tutorials and projects, intel galileo based tutorials and project, ADC interfacing tutorials, LED Blinking, LCD interfacing, Embedded System tutorials and projects, B.tech projects, M.tech projects, online Embedded C training

LCD INTERFACING WITH 8051 | PIC | AVR MICROCONTROLLER PART2


16X2 LCD interfacing with microcontroller tutorial part2

In this tutorial, we will see the pin diagram of LCD, description of each pin and the general block diagram of LCD interfacing with basic Microcontroller.

Pin Diagram of 16x2 LCD:

There are 16 pins are available on the 16x2 LCD display, out of these, two pins are used to control the LCD back light. There is no problem, if these backlight pins are left unconnected, but the data displayed on the screen not able to visible over a longer distance. Later we will see how the display will look when backlight is off. The remaining 14 pins are involved in the actual operation of the LCD, including power supply pins. All these pins come from the LCD display controller (HD44780) except LCD backlight pins. HD44780 IC is a dot matrix display controller from Hitachi and its job to refresh the LCD screen and also responsible to display the text in different ways.
 The below figure 1.1 shows JHD162A model number on LCD which has same pin configuration as that of the Standard HD44780. A single HD44780 IC can only address up to 80 characters with help of an extension driver. To address more than 80 characters LCD uses two HD44780 controllers.

                     Figure 1.1 LCD pins diagram identifying pin numbers

Pin Description of LCD:



PIN NUMBER
SYMBOL
FUNCTION
1
Vss
Supply Ground
2
Vcc
Power supply (+5v)
3
Vee
Contrast adjust
4
RS
0 = Instruction Reg
1 = Data Register
5
R/W
0 = Write to LCD
1 = Read From LCD
6
EN
Enable signal
7
DB0
Data Line0
8
DB1
Data Line1
9
DB2
Data Line2
10
DB3
Data Line3
11
DB4
Data Line4
12
DB5
Data Line5
13
DB6
Data Line6
14
DB7
Data Line7
15
LED+
Backlight supply (+V)
16
LED-
Backlight supply  ground(Gnd)
Table 1.1 List of LCD pins and its description

For better understanding and remembering, the LCD pins are categorized in to four types.
1.      Control pins
2.      Data pins
3.      Power supply pins
4.      LCD Backlight pins



1. LCD Control Pins: EN, RS and R/W pins are comes under control pins or control lines, there are used to perform operations on LCD controller like read, write, data transfer.

Register select (RS): This pin is used to select Instruction register or Data register. If RS = 0, the instruction register is selected and the user allowed to send commands to LCD such as clear display, cursor shift, etc. If RS = 0, the Data register is selected and the user allowed to send data to the LCD which is to be displayed.
Read/Write (R/W): This pin is used to perform read and write operations on the LCD. To read information from LCD, the R/W pin should be at logic high (R/W = 1). To write information on to the LCD, the R/W pin should be at logic zero (R/W = 0).
Enable (E): When this pin finds a high to low pulse on it, then whatever information present on the data pins that will be taken into the LCD. This enable pulse is used to just wake up external interface of the LCD display controller during data transfer only otherwise it will perform internal operations like clear display, cursor shift. The other two control pins (RS and R/W) works in collaborates with the enable pin as shown table 1.2. The pulse width of enable pin must be 450ns and above, this value is recommended as per datasheet.
Enable
RS
R/W
operation
H->L
0
       0
Instruction Register (IR) writes as an Internal operation
H->L
0
1
Read Busy flag (DB7)  and address counter (DB0-DB6)
H->L
1
0
Data Register (DR) writes as an internal operation (DR to DDRAM locations or CGRAM locations)
H->L
1
1
Data Register (DR) reads as an internal operation (DDRAM location or CGRAM  location to DR)
H/L
X
X
Same as RS = 0 and R/W = 0
Table 1.2 LCD display controller Register selection using control pins (E, RS, R/W)




2. LCD Data pins: DB7-DB0 pins of LCD are referred as Data lines which are used to send data or commands to LCD by making R/W value to 1. The number of data lines required to interface is depending upon the LCD mode of operation (4-bit or 8-bit), discussed later. The DB7 pin is also referred as busy flag line or busy status pin thought which the MCU will get the status of the LCD when R/W = 1. During that time, DB0-DB6 will gives address counter value.
LCD Busy flag:  When BF = 1, means the LCD is busy with its internal operations and it is not going to accept any data or commands from external world (MCU, PC, etc.). After completion of internal operations the LCD will make BF = 0 indicating that it is ready to accept any command or data from external world. To read busy flag status, the R/W = 1, and RS =0.

3. LCD Power supply pins: The pins Vcc and Vss (Gnd) are called supply lines. A 5v supply is enough to drive the LCD more than that may damage the LCD. The Vee pin is used to control the contrast of the LCD.
Contrast of an LCD defines as it is a ratio of intensity of brightest pixel to the darker one. For example, if the contrast ratio is 20:1 means the brightness of a brightest pixel is twenty times greater than the darker one.
A preset of 4.7k – 10k is connected between Vcc, Vss and Vee to vary the contrast of the LCD. A current limiting resistor should be added to the preset, in order to protect the LCD from excess current flow when the preset pointed to its minimum value of resistance.
4. LCD backlight pins: the LED+ (15th pin) and LED- (16th pin) are referred as backlight pins of LCD. The pins are used to vary the brightness of the backlight by placing different values of resistance. Generally a 330ohms resistor is connected between LED+ and the power supply or directly connected to supply. LED- should be grounded.
One can vary the brightness of the backlight using software by generating and connecting PWM signal to LED+ pin, which is discussed later in this series of tutorials.



LCD interfacing with microcontroller:
There are two modes that we can operate the 16x2 LCD modules.
1.      8-bit data mode: uses all 8 data pins (I/O) for information transfer between microcontroller and LCD. Data transfer is fast compared to 4-bit mode.

2.      4-bit data mode: uses four I/O data lines instead of 8 data lines. It will send 1 byte of data or instruction to LCD in two 4-bit transfers. Generally this mode is used to save I/O lines. Data transfer requires twice the time when compared with 8-bit mode. This mode is not suitable in applications where the time is crucial. This mode is used when I/O line are less to interface an LCD. Generally Speaking, the 4-bit mode is not significantly slower than 8-bit mode, but it save four I/O lines.


                                 Figure 1.2 LCD interfacing with microcontroller block diagram
In the block diagram figure 1.2, the microcontroller refers to either 8051 or PIC or AVR or ARM processor or any other microprocessor but should maintain the enable pulse width greater than 450ns. The 1k resistor in series with the preset will protect the LCD from high current flow, when the preset wiper pin is at minimum value (nearly shorted). Today’s LCD backlight is generated by using LED’s, as per data sheet the LED forward voltage (VF) should be 4.2V-4.6V and maximum LED forward current (IF) is 260mA. If the IF crosses the maximum rated current may damage the backlight LED, it is one of my best experiences with LCD, and for that purpose a 330Ohms current limiting resistor is used.
V = I*R .
R = V/I (Let us assume 150mA current flowing through backlight LED).
R = 5/15mA = 330Ohms.
If the LED+ is directly connected to supply voltage, it may draw 130mA – 260mA.
The 1k resistor in the figure 1.2 is taken randomly, no calculations are performed. This resistor is used to protect the LCD from excess current flow when the preset is at its minimum. You can also connect 330ohms, 560ohms, etc., do not take larger values which makes your preset useless and the display contrast will be fixed to single value.

The data lines (DB0-DB7) can be connected to GPIO lines of any microcontroller. The LCD data lines (DB0-DB7) current sinking capability is 1.2mA (Iol) and current sourcing capability is 0.205mA (Ioh). The minimum output high voltage is 2.4V (Voh) and the maximum output low voltage is 0.4V (Vol). You should first check that these specifications are suitable with particular microcontroller or not, then start interfacing LCD with microcontroller. For example, the Texas instrument MSP430 launch pad board is operated at 3.5V, but the LCD display is operates at 5V. Therefore we should introduce a voltage converter circuit between LCD and MSP430 launch pad.

Related links for LCD interfacing:
1. 8051 BASED 16X2 LCD INTERFACING IN 8-BIT MODE WITHOUT USING BUSY STATUS FLAG
2. 8051 BASED 16X2 LCD INTERFACING IN 4-BIT MODE WITHOUT USING BUSY STATUS FLAG

0 comments :

Post a Comment

Thanks for visiting NPEDUCATIONS. We will contact you soon

0 comments :

Post a Comment

Thanks for visiting NPEDUCATIONS. We will contact you soon

If you really like this tutorial, Don't forget to give the comment or please subscribe to the RSS feed by submitting your E-mail or like our Facebook page.
Related Posts Plugin for WordPress, Blogger...

 
Powered by Blogger