free 8051 Microcontroller Projects AVR PIC Microcontroller Projects Tutorials Ebooks Libraries, interfacing tutorials, lcd tutorial, stepper motor, dc motor 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems

 
8051 microcontroller 8051 microcontroller
Forums

Go to page  [1] 2
Moderators: Ajay, Junied , abbas1707, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph
Author Post
weijie
Wed Jul 09 2008, 07:25PM
 User Offline
Registered Member #8603
Joined: Tue Jun 24 2008, 11:22PM

Posts: 10
Thanked 0 times in 0 posts
i was trying to interface my at89c51ed2 with a LCD
however , i got some problem initialize it ..
there is a post on www.bipom.com teaching ppl
but i don understand why we nid to put 0x30 into data for 3 times before we can put in other command . can someone explain to me ?
anyone got simple c code for lcd ?
Thank you ~

Back to top


say2paul
Wed Jul 09 2008, 09:17PM
 User Offline
Registered Member #8461
Joined: Tue Jun 17 2008, 10:56AM

Posts: 123
Thanked 6 times in 6 posts
Go through this link:

http://www.8051projects.net/lcd-interfacing/

It will explain you each n everything about interfacing LCD with 8051.
Back to top


Colin Mac
Thu Jul 10 2008, 06:53AM
 User Offline
Registered Member #4338
Joined: Wed Oct 10 2007, 05:46AM

Posts: 62
Thanked 1 time in 1 posts
http://www.edsim51.com/examples.html#prog4

see this too
Back to top


weijie
Thu Jul 10 2008, 07:09AM
 User Offline
Registered Member #8603
Joined: Tue Jun 24 2008, 11:22PM

Posts: 10
Thanked 0 times in 0 posts
http://www.8051projects.net/lcd-interfacing/initialization.php
this page shows that we nid input a 30H as command into it before any other command . Why ?
Back to top


Ajay
Thu Jul 10 2008, 08:13AM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 4035
Thanked 751 times in 710 posts
30H is the init byte for LCD.

As i explained there are two types of resets in LCD
1. Power on reset
2. Software reset

1. Power on reset, as name says. LCD get reset during power up by itself (thats the reason you see blocks on LCD when you just power it up). During power on reset LCD get initialized in 8-bit mode.

2. Software reset, This kind of reset is to reset LCD with software instructions. 30H is sent 3 times as init byte sequence.

As you know during power on reset LCD initialized in 8-bit mode so no need to give software reset if you are using LCD in 8-bit mode, but if you want to use LCD in 4-bit mode then you have to give LCD a software reset and tell the LCD that you are going to use 4-bit mode.
reset sequence is explained in 4-bit initialization section. Please read it carefully.


www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top


weijie
Sat Jul 12 2008, 10:58AM
 User Offline
Registered Member #8603
Joined: Tue Jun 24 2008, 11:22PM

Posts: 10
Thanked 0 times in 0 posts
i had completed the c code for lcd . but i cant run it on my at89c51ed2 .
i choose to put 8 data lines at port 0 , and RS,RW,EN at port 2 .
do i nid to put a Vcc (5V) , through a resistor to those pins at port 2 ?
should i configure such like http://www.edsim51.com/examples.html using resistor value 10k ?

#include <at89c51ed2.h>

#define LCD_DATA P0
#define LCD_EN P2_0
#define LCD_RW P2_1
#define LCD_RS P2_2

void delay(int);
void WRT_COMM();
void WRT_DATA();

void main()
{
delay(18000);

LCD_DATA = 0x38; //Initialize LCD 2 Lines, 5 x 7 Matrix, 8 bit interface.
WRT_COMM();

LCD_DATA = 0x0E; //Display ON, Cursor ON,blink off
WRT_COMM();

LCD_DATA = 0x01; //Clear Display
WRT_COMM();
delay(18000);

LCD_DATA = 0x06; //Increment cursor position, No display shift.
WRT_COMM();

LCD_DATA = 'D';
WRT_DATA();

LCD_DATA = 'O';
WRT_DATA();

LCD_DATA = 'N';
WRT_DATA();

LCD_DATA = 'E';
WRT_DATA();
}

void delay(int time)
{
int t;
time = time * 2; //each machine cycle is 0.5u second
for(t=1; t<=time; t++)
{}
}

void WRT_COMM()
{
LCD_RS = 0;
LCD_RW = 0;
LCD_EN = 1;
LCD_EN = 0;
delay(180);
}

void WRT_DATA()
{
LCD_RS = 1;
LCD_RW = 0;
LCD_EN = 1;
LCD_EN = 0;
delay(180);
}


[ Edited Sat Jul 12 2008, 07:39PM ]
Back to top


Arun Kumar V
Sat Jul 12 2008, 11:45PM

 User Offline
Registered Member #426
Joined: Sun Jan 28 2007, 11:50PM

Posts: 521
Thanked 218 times in 185 posts
Hi friend,

Avoid using Port 0 and port 2 , instead use P1 for 8 bit data and P3 for control lines of LCD.

if you insist on using P0 then you need to have 10K pull up resistors, also try adjusting the Contrast on the LCD, i hope you have a 10K pot between Vss, Vdd, and Vee of LCD



Arun

[ Edited Sat Jul 12 2008, 11:46PM ]
Back to top


weijie
Sat Jul 12 2008, 11:49PM
 User Offline
Registered Member #8603
Joined: Tue Jun 24 2008, 11:22PM

Posts: 10
Thanked 0 times in 0 posts
but the controller that i using is at89c51ed2 pid40 .
it have special function on port 1 and 3 that i need to use it for other purpose later
Back to top


Arun Kumar V
Sat Jul 12 2008, 11:56PM

 User Offline
Registered Member #426
Joined: Sun Jan 28 2007, 11:50PM

Posts: 521
Thanked 218 times in 185 posts

the answer is in my last post

if you insist on using P0 then you need to have 10K pull up resistors,





Arun
Back to top


sashijoseph
Sun Jul 13 2008, 12:56AM

 User Online
Registered Member #5870
Joined: Mon Feb 04 2008, 06:26PM

Posts: 648
Thanked 137 times in 130 posts
@weijie

In your code try increasing the delay in the range of milliseconds.
sth like this.....

void delay(int time)
{
int t,i;
time = time * 2; //each machine cycle is 0.5u second
for(t=1; t<=time; t++)
for( i=0 ; i<750 ; i++) ;
}

Also insert a small (1 ms) delay between LCD_EN 1 and 0.

It would be better to use the 'busy-flag' method rather than fiddling with delay values.


Let there be music........
Back to top


Go to page  [1] 2  

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

8051 Microcontroller Projects 8051 AVR tutorials PIC microcontroller, 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems