Академический Документы
Профессиональный Документы
Культура Документы
6
Interfacing of Displays with 8051
-------------------------------------------------------------------------------------------------------------------Name of Student:
-------------------------------------------------------------------------------------------------------------------Day & Date of Submission:
Checked and verified by:
--------------------------------------------------------------------------------------------------------------------
Experiment No. 6
Aim:To study, design and implement interfacing of displays such as LCD and 7
Segment LED to 8051 microcontroller.
Objectives:
To explore various types, forms of LCD and LED displays and its interfacing
challenges.
Theory:
Displays are of two types-LEDs and LCDs. However LCDs are finding widespread use
replacing LEDs because of the following reasons:
Incorporation of a refreshing controller into the LCD, thereby relieving the CPU
of the task of refreshing the LCD
A liquid crystal displayis a flat panel display that uses light modulating properties of
liquid crystals.LCDs are available to display arbitrary images or fixed imageswhich can
be displayed or hidden, such as preset words, digits, and 7-segment displays as in a
digital clock. There are many different LCD modes such as
TN-twisted nematic
Some of the most common LCDs connected to the 8051 are 16*2 (16 characters per line
by 2 lines) with HD44780U controller. The standard LCD has 14 pins with 8 pins
reserved as data pins. The 8-bit data pins, D0-D7, are used to send information to the
LCD or read the contents of the LCDs internal registers. PinsVss and Vcc are reserved
for ground and +5V power supply respectively. VEE is used as powersupply to control
contrast. RS pin is used to select command register or data register. R/W pin is used to
read or write information to the LCD. The enable pin is used by the LCD to
latchinformation presented to its data pins. There are also instruction command codes
that can besent to the LCD to clear the display or force the cursor to the home position.It
is recommended to check the busy flag before writing any data to the LCD.When
D7=1(busy flag=1) the LCD isbusy taking of internal operations and will not accept any
new information.The LCD command codes are as follows:
Code (Hex) Command to LCD Instruction Register
80
C0
1C
18
14
10
Return home
7 segment interfacing
Program:
#include <REGX51.H>
unsigned int i,j;
unsigned char msb, lsb;
void delay(void)
{
for(i=0;i<25000;i++);
}
void main(void)
{
P1=0X00;
while(1)
{
for(j=0;j<=99;j++)
{
lsb=j%10;
msb=j/10;
msb=(msb<<4)+lsb;
P1=msb;
delay();
}
}
}
Simulation:
LCD Interfacing
Program:
#include<reg51.h>
void MSDelay(unsigned int);
void lcdcmd(unsigned char);
void lcddata(unsigned char);
sfr ldata=0x90;
sbit rs=P2^0;
sbit rw=P2^1;
sbit en=P2^2;
void main()
{
lcdcmd(0x38);
MSDelay(250);
lcdcmd(0x0E);
MSDelay(250);
lcdcmd(0x01);
MSDelay(250);
lcdcmd(0x06);
MSDelay(250);
lcdcmd(0x86);
MSDelay(250);
lcddata('C');
MSDelay(250);
lcddata('O');
MSDelay(250);
lcddata('E');
MSDelay(250);
lcddata('P');
MSDelay(250);
}
void lcdcmd(unsigned char value)
{
ldata=value;
rs=0;
rw=0;
en=1;
MSDelay(1);
en=0;
return;
}
en=1;
MSDelay(1);
en=0;
return;
}
Simulation:
Conclusion: