- This topic has 8 replies, 3 voices, and was last updated 12 years, 11 months ago by
AJISH ALFRED.
-
AuthorPosts
-
April 19, 2012 at 4:48 pm #4918
bnbn qwe
ParticipantI am doing a project : digital room thermometer. So , I have to interface LCD with 8051 microcontroller at89s52. But whenever I power up the microcontroller , LCD is lit but only black boxes are showing. I have tried many different codes and many things, but display is same . onle black boxes. But i have simulated this circuit in proteus . here, that LCD is giving correct output. Plz help in determining the problem. Here are the attached code and circuit diagram. Here is the C Code….//Program to test LCD. Display single character "A"#include<reg51.h>#define cmdport P3#define dataport P2sbit rs = cmdport^0; //register select pinsbit rw = cmdport^1; // read write pinsbit e = cmdport^6; //enable pinvoid delay(unsigned int msec) // Function to provide time delay in msec.{int i,j ;for(i=0;i<msec;i++)for(j=0;j<1275;j++);}void lcdcmd(unsigned char item) //Function to send command to LCD{dataport = item;rs= 0;rw=0;e=1;delay(1);e=0;}void lcddata(unsigned char item) //Function to send data to LCD{dataport = item;rs= 1;rw=0;e=1;delay(1);e=0;}void lcd_ini() //Function to inisialize the LCD{lcdcmd(0x38);delay(50);lcdcmd(0x0E);delay(50);lcdcmd(0x80);delay(50);}void main(){lcd_ini();lcddata('A');}April 19, 2012 at 4:58 pm #7506Mehtab Ali
Participantyou havent cleared lcd. it has previous data stored in it sometimes. please clear it by sending it 01 like ” lcdcmd(0x01);” also use a command “lcdcmd(0x06);” to shift the cursor to right.
April 19, 2012 at 5:00 pm #7507Mehtab Ali
Participantincrease the delay from ” delay(50) to delay(250)”
April 19, 2012 at 5:01 pm #7508bnbn qwe
Participanti have simulated this in proteus. whenever i give that clear command (01h) , nothing is displayed on simulator. but without it, simulator display is fine. But practically, that LCD is giving black boxes in lab.
April 19, 2012 at 5:03 pm #7509Mehtab Ali
Participantyou try it using clear command and increase the delay as well. also you need to shift the cursor to right.
April 19, 2012 at 5:11 pm #7510bnbn qwe
Participanthere is my modified code but nothing shows in simulator.
void lcd_ini() //Function to inisialize the LCD{lcdcmd(0x38);delay(250);lcdcmd(0x0E);delay(250);lcdcmd(0x01);delay(250);lcdcmd(0x06);delay(250);lcdcmd(0x80);delay(250);}and can you please clarify the use of delay duration in LCD. our test microcontroller is at89s52 and we are using crystal oscillator of 11.59 Mhz. is that frequency is related to lcd delay? how can i change the delay accordingly?April 20, 2012 at 12:47 am #7513Mehtab Ali
Participantlcd requires some time to execute the commands so after a command we need to either give it a delay or we can check the busy flag.the crystal frequency is ok. in your program delay(250) is appropriate for lcd.
i have run the c code and assembly code for lcd, and both displays data on lcd. you also check your connections.
April 20, 2012 at 3:46 am #7514bnbn qwe
Participantwill try today and let u know after college
May 4, 2012 at 5:52 pm #7587AJISH ALFRED
ParticipantIf nothing could be seen on the lcd, sometimes it happens because of over brightness. put a variable resistor in series with pin15 of the lcd, not less than 1k. Do the changes mentioned by Mehtab ali in his post. Try changing the resistance after running the code.
-
AuthorPosts
- You must be logged in to reply to this topic.