Interfacing of LCD with AT89S52(8051)

This tutorial explains one of   the real world application of 8051. Here we are going to  explain how a 16×2 LCD is interfaced with AT89S52.

1)  LCD:

16×2 LCD is used as output by the controller to show any data or any information to user .The name 16×2 LCD  means 16 number of data can be can be written on two lines. The data can be numbers(0-9) or letters(A-Z) of any symbol like “$” ,”#”…… or a space ”  “.

 In recent years the LCD is replacing LEDs or seven segment display due to many factors:

  • The ability of LCDs to display numbers, characters and graphics. Where other displaying unit like seven segments are limited only to numbers and few characters
  • Due to presence of a controller in the LCD the displaying task gets much more easier for the micro-controller(8051)
  • To show a number or alphabet on LCD screen we need to just send the ASCII value to the data pin. Hence its pretty easy to display characters and graphics
  • The low price of  LCDs.

LCD Pin descriptions:

LCD-pinout

THE LCD PINOUT

THE PIN DESCRIPTION FOR LCD:

pin_description

In the above two figures the pin positions and pin description are discussed.The function of each pin is discussed briefly down here:

  • Vss,Vdd,Vee/Vo
         +5V is provided to Vdd(pin2) and ground is provided to Vss(pin1) to provide power to LCD and its controller. Vee is used to control the contrast of the LCD .If ground is connected directly to this pin the contrast will be so low that the each pixel would get  so dark  that nothing could be read. If Vcc(+5V) is directly provided to it the contrast will be so high that  the pixel wouldn’t glow at all. So connect a resistance  to ground in series with the pin.
  •     RS, Register select
         Two  important registers are present in the LCD. One is data register and other is instruction command code       register. If data is sent at data register the data is considered as data to be displayed on the LCD. If data is sent at  instruction command code register the data is considered as command from user like to clear the screen or blink the cursor,etc.
    To let the LCD know whether the data on data line is command or a databyte to be displayed, RS is used.
    ->If  RS=0 the instruction code command register is selected and the data on data line is a command.
    ->If RS=1  the data register is selected and the data on data line is to be displayed on screen.

Lcd command codes

                          SOME OF THE COMMAND CODES WHICH ARE ISSUED TO LCD

  • R/W, Read/Write
    It is an input pin which allows the user to read data from the LCD registers or write data into the LCD registers
    ->To write data to LCD Register pull down the R/W pin  to 0(GND)
    ->To read data from LCD register provide 1(+5v) to R/W pin
  • E,enable

The enable pin  is used to latch/hold information presented to its data pins. When is supplied to the data pins,a high to low pulse must be provided to enable pin in order  for the LCD to latch in th data present on the data pins.

  • DB0_DB7
     These 8 data pins are used to read or write data to LCD.To display number,letter we send ASCII codes of that letters or numbers to these data pin.
  • LED+,LED
     +5V is provided to LED+ and 0V is applied to LED- to on the green backlight of the LCD.

2) CIRCUIT DIAGRAM:

lcd_CIRCUIT

                                      THE ABOVE PICTURE IS THE CIRCUIT DIAGRAM OF LCD INTERFACING

CIRCUIT DISSCUSION

  1. Here
    P3.0=RS
    P3.1=R/W
    p3.2=Enable  is taken
  2. Port 2 is used as data port.
    P2.0=DB0
    P2.1=DB1
    .
    .
    .
    P2.7=DB7*PROVIDE A PULL RESISTOR TO THIS PORT IF POSSIBLE
  3. Power on reset circuit is provided by using 10k ohm and 10uF resistor on RST pin.
  4. 11.0592Mhz crystal is used alongwith two 33pF capacitors which are grounded.

3) COMPONENTS REQUIRED

  1. AT89S52-8051 based low cost  microcontroller with  8k memory
  2. 16×2 LCD
  3. 11.0592 Mhz crystal
  4. Capacitors: 1 –  10uF   ,  2 – 33pF
  5. Resistors: 1 – 10k ohm  ,    1-1k ohm

 

 


THE AVR

The Special series of controllers launched by ATMEL.

  •  High-performance, Low-power AVR® 8-bit Microcontroller
  •  Advanced RISC Architecture
  • High Endurance Non-volatile Memory segments
  •    In-System Programming by On-chip Boot Program

 

  • JTAG (IEEE std. 1149.1 Compliant) Interface
  •  Extensive On-chip Debug Support
  • Programming of Flash, EEPROM, Fuses, and Lock Bits through the JTAG Interface
  •  Peripheral Features

–  8-bit Timer/Counters with Separate Prescalers and Compare Modes
– 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture
Mode
– Real Time Counter with Separate Oscillator
–  PWM Channels.ADC
– Byte-oriented Two-wire Serial Interface
– Programmable Serial USART
– Master/Slave SPI Serial Interface
– Programmable Watchdog Timer with Separate On-chip Oscillator
– On-chip Analog Comparator


Interfacing LEDs to 8051

The output of pins of the 8051 microcontroller automatically generate a HIGH value of voltage. Thus to make an LED glow, i.e, turn it ON, we have to generate a LOW value, to forward bias it.  We can use any of the ports P1, P2 or P3, and connect an Led to any pin of the above ports. The command used to turn on led is:   CLR <PORTNAME.PINNO>

E.g,   CLR P3.4        assuming led is connected to pin no. 4 of port 3.  (Pin no.  14, see diagram below)

Next, to turn OFF the Led, we use the command SETB P3.4.

These commands help access the pins of the microcontroller individually, which is a somewhat useful feature of the 8051, over other, even more advanced controllers.

8051 pin configuration

What are LEDs.

  • LEDs are like simple diode but they glow when they are forward biased,that is when positive voltage is applied to its anode (P-side) and negative or ground is provided to the cathode(N-side).
  • The main specification of LED are its current rating=20mA,cut in voltage=2V,life time=2lakh hours, max. potential difference between cathode and anode is around 4.5V. There are different color of LED’s depending on the semi-conducting material.                                                   
  • The LEDs has two pins -one cathode(-) and another anode(+).To forward Bias a LED we must connect anode(+)  to positive potential and cathode(-) to negative potential.The pin longer in length is the anode(+) and the pin shorter than the other one is cathode(+).In this way the anode and cathode are identified,by looking at their length.
    Led's cathode and anode
  • Don’t ever connect LED directly to Vcc . First of all there is a great chance that the LED could get burned or damaged .Secondly it causes serious voltage drop.That is if you connect the output of IC 7805 (5v voltage regulator,that is it give constant 5V from its output pin) directly to an LED then the voltage output of 7805 reduces to 3.85V from 5.02 V .So whenever you connect a LED to the output pin of any IC connect a series resistor with it.
    Resistor before Led
  • The brightness of LED can be controlled by changing the value of series resistance.
    If  good brightness is required use a resistance of lower value e.g R=100,150ohm.
    If medium light is needed use a series resistance of 330-470ohm
    If faded light is required use a high resistance in series.Maybe from 500ohm-1.5k ohm.

Interfacing of basic I/O devices to 8051

Examples are shown here on how to interface basic I/O devices to 8051

1)Interfacing of leds to 8051


8051: The slow and steady

This section is dedicated to entirely 8051 microcontroller . 8051 is a 8 bit controller manufactured by INTEL corp.

 

A microcontroller perfect for beginners to enter into robotics.

Interfacing to basic I/O devices


Whats STRAIG

Welcome to STRAIG’s homepage.

This page is intended to be a starting point for those who are new to the basics of robotics and are ready to explore.

STRAIG was started as an initiative of the students of  St. Thomas College and Technology,Calcutta,India, in order to help students pick up the elements of building autonomous robots, with the aim of subsequently providing them with a platform to develop their own projects. Starting from scratch is not easy, as we tend to make mistakes, and meet with failures more often than not!! We realized that students everywhere must be facing similar difficulties, so this site has been initiated to share whatever we learnt along the way, and also to generate interest and ideas for better understanding…both for ourselves, and for those who have landed up here!! 🙂

Hope you find this a useful and informative site, and do help to make it grow, by any suggestions or comments you may have!!


Continue reading


Create your own website, free on WordPress.com.Create your own website.
Start free