Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
440 views7 pages

Addresses of Cursor Position For 16x2 HD44780 LCD

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 7

PIC16F877A is used here to display message on the Hitachi HD44780-based character LCD module.

PIC16F877A is 8-bit microcontroller based on reduced instruction set computer (RISC) architecture. It has 8kx14-bits flash program memory, 368 bytes of RAM. Here PIC16F877A microcontroller is connected to HD44780 LCD in 4-bit interface data, only four bus lines (DB4 to DB7) are used for data transfer. Bus lines DB0 to DB3 are having no connection with microcontroller. The data transfer between the HD44780U and the PIC16F877A is completed after the 4-bit data has been transferred twice.As for the order of data transfer, the four high order bits (for 8-bit operation, DB4 to DB7) are transferred before the four low order bits (for 8-bit operation, DB0 to DB3).Any character on HD44780 LCD is displayed by sending its respective ASCII code. Hence to display 1 on LCD microcontroller has to send 31h as data. When RS pin =0 instruction register is selected and information on data bus is taken as commands. The IR stores instruction codes, such as display clear and cursor shift, and address information for display data RAM (DDRAM) and character generator RAM (CGRAM). The IR can only be written from the PIC16F877A. When RS pin=1 data register is selected and information on data bus is taken as ASCII value of respective character to be displayed on HD44780 LCD. The DR temporarily stores data to be written into DDRAM or CGRAM and temporarily stores data to be read from DDRAM or CGRAM. When address information is written into the IR, data is written and then stored into the DR from DDRAM or CGRAM by an internal operation RW pin is used to either read from LCD (RW=1) or write to LCD (RW=0). When a High to Low pulse is applied on the Enable pin the information present on the data bus is latched into the LCD register.

Addresses of cursor position for 16x2 HD44780 LCD


line 1 line 2 80 H C0 H 81 H C1 H 82 H C2 H 83 H C3 H 84 H C4 H 85 H C5 H 86 H C6 H 87 H C7 H 88 H C8 H 89 H C9 H 8A H CA H 8B H CB H 8C H CC H 8D H CD H 8E H CE H 8F H CF H

PIC16F877A microcontroller connection with HD44780 LCD


PORTD bits 0-3 are connected to the LCD data bits 4-7 (high nibble) of LCD PORTA bit 3 is connected to the LCD RS input (register select) PORTA bit 2 is connected to the LCD RW bit PORTA bit 1 is connected to the LCD EN bit (enable) Crystal used is 4MHz Set up the PORTA and PORTD as I/O (TRISA, TRISD)

Ciruit Diargram :PIC16F877A connected to LCD

C code for programming PIC16F877A to interface LCD


void lcd_init(char c) Initialise LCD in 4-bit mode RS=0 command mode RW=0 lcd in write mode wait 15mSec after power is applied send 0x3 and High to low pulse at Enable pin wait 5mSec and High to low pulse at Enable pin wait 200uSec and High to low pulse at Enable pin wait 200uSec send 0x2 Four bit mode and High to low pulse at Enable pin send 0x28 Set interface length send 0xf Display On, Cursor On, Cursor Blink send 0x1 Clear screen Send 0x6 Set entry Mode void lcd_write(unsigned char c) write a byte to the LCD in 4 bit mode send higher nibble of data byte High to low pulse at Enable pin

Send lower nibble of data byte High to low pulse at Enable pin void lcd_character(char c) write one character to the LCD using wait for 40 usecond Set RS =1 to send ASCII code of character to LCD Call lcd_write function

PIC16f877_LCD.c
#include<pic.h> #include "delay.h" #include "lcd.h" void main() { TRISD=0X00; PORTD=0; lcd_init(); //LCD initialized lcd_line1(0); //LCD address specified AT LINE 1 lcd_string("INTERFACING LCD"); //Displays message "LCD INTERFACING" lcd_line2(0); //LCD address specified AT LINE 2 lcd_string(" PIC 16F877A");//Displays message " PIC 16F877A" while(1); } study projects files given below for more details on Interfacing LCD to PIC16F877A microcontroller

Output on LCD using PIC16F877A microcontroller

Heart beat monitor PIC16f84 Microcontroller display on LCD


This is very simple project for heart beat monitoring using microcontroller PIC 16f84. A pair of LED and LDR is used as sensor for sensing the pulses of heart. The signal is generated when a finger is placed between LED and LDR. OP amp LM358 is used for the further processing of the signal generated from the LDR, if finger is placed and some obstacle for light is created, which it self is varying with the pressure of blood in the veins of finger. The output of two operational amplifiers is TTL pulses. For a healthy person, these pulses should be nearly equal to 70 to 80 BPM and if we convert it into frequency then we will get 1.2 to 1.4 Hz. The microcontroller PIC16f84 senses these TTL pulses generated from the analog circuit and count then using a very simple algorithm converts them into beats per minuets. The results of the beats are shown on LCD with unit BPM. For display of heart beat monitor , a general purpose LCD is used. Students can use any single line or two line LCD available in their local market. As, in the program, only first 16 characters and first line is used to display any message on LCD. If any student got 2 line and 20 characters LCD, it will also works good. Here is circuit diagram of the heart beat monitor using PIC microcontroller 16f84.

below is c language code for the heart rate monitor using PIC microcontroller 16f84, the c code is written Hi-Tech C. //# define # include < pic . h> #define rs RA2 #define e RA1 #define lcd_data PORTB #define _XTAL_FREQ 4000000 void delayms(unsigned int itime);

void pulse(void); void send_char(unsigned char data); void lcd_goto(unsigned char data); void lcd_clr(void); void send_string(const char *s); void init_lcd(void); void dis_num(unsigned int data,unsigned char digit); void prog1(void); unsigned long no=0; void main (void) { TRISA=0; TRISB=0; TRISA3=1; init_lcd(); delayms(10); lcd_clr(); delayms(10); send_string("Heart rate meter"); delayms(1000); lcd_clr(); delayms(10); while(1) { prog1(); } } void prog1(void) { unsigned int temp1=0,temp2=0; unsigned char i; unsigned int hb=1; while(RA3); while(!RA3){ hb++; delayms(1); } hb=30000/hb; lcd_goto(2); send_string("H.B.R: bpm"); lcd_goto(8); dis_num(hb,3); } void delayms(unsigned int itime) { unsigned int i;

for(;itime>0;itime--) { __delay_ms(1); } } void send_config(unsigned char data) //send lcd configuration { rs=0; //set lcd to configuration mode lcd_data=data&0xf0; //lcd data port = data pulse(); lcd_data=(data<<4)&0xf0; pulse(); } void pulse(void) { e=1; //pulse e to confirm the data delayms(1); e=0; delayms(1); } void lcd_goto(unsigned char data) //set the location of the lcd cursor { //if the given value is (0-15) the send_config(0x80+data); //cursor will be at the lower line } void lcd_clr(void) //clear the lcd { send_config(0x01); delayms(2); } void send_string(const char *s) //send a string to display in the lcd { rs = 1; while (*s)send_char (*s++); } void send_char(unsigned char data) //send lcd character { rs =1; delayms(1); //set lcd to display mode lcd_data=data&0xf0; //lcd data port = data pulse(); lcd_data=(data<<4)&0xf0; pulse(); } void init_lcd(void) { rs=0;e=0; //command mode

delayms(10); //delay 10ms lcd_data=0x30; //load initial nibble pulse(); //Latch initial code delayms(5); //delay 5ms pulse(); //Latch initial code delayms(1); //delay 1ms pulse(); //Latch initial code lcd_data=0x20; pulse(); //Latch initial code //configure lcd send_config(0x28); //Set 4-bit mode, 2 lines send_config(0xF); //Switch off display send_config(0x06); //Enable cursor auto increase } void dis_num(unsigned int data,unsigned char digit) { if(digit>3) send_char('0'+(data/1000)%10); if(digit>2) send_char('0'+(data/100)%10); if(digit>1) send_char('0'+(data/10)%10); if(digit>0) send_char('0'+(data/1)%10); }

You might also like