Вы находитесь на странице: 1из 9

Experiment No.

6
Interfacing of Displays with 8051
-------------------------------------------------------------------------------------------------------------------Name of Student:
-------------------------------------------------------------------------------------------------------------------Day & Date of Submission:
Checked and verified by:
--------------------------------------------------------------------------------------------------------------------

Department of Instrumentation & Control


College of Engineering Pune

Experiment No. 6

Aim:To study, design and implement interfacing of displays such as LCD and 7
Segment LED to 8051 microcontroller.
Objectives:

To study LCD displays and understand various command associated for


interfacing it to Microcontroller

To study 7 Segment LED displays, it types, and interfacing perspective to


microcontroller

To write algorithms, flowchart (sequence of steps) and program for interfacing


displays to microcontroller.

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:

The declining prices of LCD

The ability to display numbers, characters, and graphics

Incorporation of a refreshing controller into the LCD, thereby relieving the CPU
of the task of refreshing the LCD

Ease of programming for characters and graphics

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

STN-Super twisted nematic

FSTN-Film compensated super twisted nematic

CSTN-Color super twisted nematic

DSTN- Double layer super twisted nematic

TFT-Thin film transistor

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

Force cursor to beginning to 1st line

C0

Force cursor to beginning to 2nd line

1C

2 lines and 5x7 matrix

18

Shift the entire display to the right

14

Shift the entire display to the left

10

Shift cursor position to right

Shift cursor position to left

Display on, cursor blinking

Display on, cursor blinking

Display on, cursor off

Display off, cursor on

Display off, cursor off

Shift display left

Shift display right

Increment cursor (shift cursor to right)

Decrement cursor (shift cursor to left)

Return home

Clear display screen

(Please attach the program printouts at the end of the write-up)


Solution: (Design, Algorithm, Program and result)

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;
}

void lcddata(unsigned char value)


{
ldata=value;
rs=1;
rw=0;

en=1;
MSDelay(1);
en=0;
return;
}

void MSDelay(unsigned int itime)


{
unsigned int i,j;
for(i=0;i<itime;i++) ;
for(j=0;j<1000;j++) ;
}

Simulation:

Conclusion:

What did you learn?

Вам также может понравиться