Thursday, May 26, 2016

L 16x2 interface with 8051

today our task ishow to interface L(16x2) with we are using tow good software keil and proteus which will given on same blog.

The L Module can sily be used with an 8051 microcontroller . The L Module comes with a 16 pin connector. This can be plugged into connector 16 pin. The pins on the 16 pin connector of the L Module are defined below.

The L Character standard requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. The user may select whether the L is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit data bus is used the L will require a total of 7 data lines (3 control lines plus the 4 lines for the data bus). If an 8-bit data bus is used the L will require a total of 11 data lines (3 control lines plus the 8 lines for the data bus).
The three control lines are referred to as EN, RS, and RW.
The EN line is called "Enable." This control line is used to tell the L that you are sending it data. To send data to the L, your program should make sure this line is low (0) and then set the other two control lines and/or put data on the data bus. When the other lines are completely rdy, bring EN high (1) and wait for the minimum amount of time required by the L datasheet (this varies from L to L), and end by bringing it low (0) again.
The RS line is the "Register Select" line. When RS is low (0), the data is to be trted as a command or special instruction (such as clr screen, position cursor, etc.). When RS is high (1), the data being sent is text data which sould be displayed on the screen. For example, to display the letter "T" on the screen you would set RS high.
The RW line is the "Rd/Write" control line. When RW is low (0), the information on the data bus is being written to the L. When RW is high (1), the program is effectively querying (or rding) the L. Only one instruction ("Get L status") is a rd command. All others are write commands--so RW will almost always be low.
Finally, the data bus consists of 4 or 8 lines (depending on the mode of operation selected by the user). In the case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2, DB3, DB4, DB5, DB6, and DB7.
An Example Hardware ConfigurationAs we've mentioned, the L requires either 8 or 11 I/O lines to communie with. For the sake of this tutorial, we are going to use an 8-bit data bus--so we'll be using 11 of the 8051's I/O pins to interface with the L.

L command coad:

nowsimple program for L :
#include <reg51.h>#include <l.h>
void main(){
linit();ldatas(1,"ramoliyabiren");ldelay(50);lrotade(1,'r',"");lblink(5,"Computer Zone");while(1) {}
Hi I am Ramoliya Biren.this program is open use.for using this hader file.u need to add this l.h in you are source group in keil.for using fxn
ldatas(row no,"DATA which u need to desplay"); for desplay string on l
ldata("data(only single char) which u need to desplay on l")
lblink(no of time u wont to blink data,"data which u wont to blink"); hr data desplay on row 1 only
lrotade (row no,'direction of rotaed l or r',"data which u wont to rotaed");
visit :
#ifndef _leddatas_H#define _leddatas_H
#include <reg51.h> sfr ldata = 0xA0;sbit rs = P3^2;sbit rw = P3^3;sbit en = P3^4;
void ldelay (unsigned int itime){ unsigned int i,j; for(i=0;i<itime;i++) for(j=0;j<1275;j++);}
void lcmd(unsigned char value){ ldata = value; rs = 0; rw = 0; en = 1; ldelay(1); en = 0;}
void ldata (unsigned char value){ ldata = value; rs = 1; rw = 0; en = 1; ldelay(1); en = 0;}
void linit(){ lcmd(0x0e); lcmd(0x01); lcmd(0x80); ldelay(50);}
void lrow(unsigned char no){ if (no == 1) { lcmd(0x80); } if (no ==2) { lcmd(0xC0); }}
void ldatas (unsigned char row,unsigned char *lstring){ lrow(row); while (*lstring) { ldata(*lstring++); }}
void lblink(unsigned char no,unsigned char *lstring){ unsigned char j; for(j=0;j<no;j++) { lcmd(0x01); ldelay(50); ldatas(1,lstring); ldelay(50); }}
void lrotade(unsigned char no,unsigned char dir,unsigned char *lstring){ unsigned char i; ldatas(no,lstring); if (dir == 'l') { for (i=0;i<16;i++) { ldelay(100); lcmd(0x18); } } if (dir == 'r') { for (i=0;i<16;i++) { ldelay(100); lcmd(0x1C); } } }

U can also download all sourcodaand alsoemulationfile from hr.
so keep exploring 8051.....
see of emulation

No comments:

Post a Comment