Discussion in "8051 Discussion Forum" started by    KT    Jan 4, 2009.
Sun Jan 04 2009, 04:31 pm
#1
Hi there,

I am trying to display data on 20x4 LCD, i bought this JHD 204A LCD. I used the library in the download section to write the program. I am using Atmel 89C51. I have uploaded the datasheet of JHD 204A, and the data sheet of the controller on this display as well, KS0070B. Now my problem start with the program working fine with 16x2 display which again is JHD's product only. But when i connect 20x4 display, the characters are mixed up,

eg: I put ABCDEFGHIJK
it displays - @BBCCDDEE

But the same thing works fine with 16x2, it displays it properly. Infact anything I display on the 20x4 shows garbage values

Another issue is that the data sheet tell DDRAM address as starting from 00H, but if use this it does not display on the screen properly. But if i use 80H as in the library it works fine.

I dont understand where I have gone wrong with 20x4. Please help me out with this.

Attachment
Sun Jan 04 2009, 05:00 pm
#2


Infact anything I display on the 20x4 shows garbage values




To begin, you can carefully see if there is any "short" between data bus, it may happen that the solder is very close to neighbouring pads. wipe the excess solder flux /paste between the data pins.


from addressing point, the 3rd line is a continuation of 1st line and 4th line is that of 2nd line, thats all, no big deal !



Arun
Mon Jan 05 2009, 01:17 am
#3
First Line : 0x80
Second Line: 0xC0
Third Line: 0x94
Fourth Line: 0xD4

more information about this, read Basics of LCD.
http://www.8051projects.net/lcd-interfacing/basics.php
Mon Jan 05 2009, 03:08 pm
#4
Hi Arun,

Well I did check it up, but that was not the problem coz I have another 20x4 LC display and the same thing is happening with it. But if i switch it with 16x2 it works fine

Ajay, that data sheet got me confused. In fact the LCD controller data sheet also mentions that.
Mon Jan 05 2009, 06:49 pm
#5
so is it working fine now?
Mon Jan 05 2009, 11:08 pm
#6
No Ajay, its not working properly. The 20x4 LCD is driving me crazy. There was no problem with the soldering or the connections. The same program and connections are working fine with a 16x2 display but not with 20x4
Tue Jan 06 2009, 06:59 pm
#7
can you paste the code here?
Tue Jan 06 2009, 08:23 pm
#8
here is the code. its the same code which u had written. I have Pictures put which shows the 20x4 LCD and the 16x2 LCD. the 16x2 displays properly and the 20x4 does not. I have just changed the x & y in set cursor function

void lcd_init()
{
delayms(500);

LCD_PORT=0x38;
rs=0;
rw=0;
en=1;
en=0;
delayms(50);
LCD_PORT=0x0C;
rs=0;
rw=0;
en=1;
en=1;
en=0;
delayms(50);
LCD_PORT=0x06;
rs=0;
rw=0;
en=1;
en=1;
en=0;
delayms(50);
LCD_PORT=0x01;
rs=0;
rw=0;
en=1;
en=1;
en=0;
delayms(50);


}

void busy()
{
flag=1;
rs=0;
rw=1;
while(flag!=0)
{
en=0;
en=1;
}
}

void wrt_cmd(bit_8 val)
{
busy();
LCD_PORT=val;
rs=0;
rw=0;
en=1;
en=1;
en=0;
delayms(10);
}


void wrt_string(bit_8 *string)
{
busy();
while(*string)
wrt_data(*string++);
}


void wrt_data(bit_8 ch)
{
busy();
LCD_PORT = ch;
rs=1;
rw=0;
en=1;
en=1;
en=0;
delayms(100);
}


void wrt_value(bit_8 x)
{
wrt_data(x+0x30);
}


/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Bringing Cursor to (X,Y) location of LCD
X -> 1 to 20
Y -> 1,2,3,4
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

void cursorxy(bit_8 x, bit_8 y)
{
if((x<1||x>20)&&(y<1||y>4))
{
x=1;
y=1;
}
if(y == 1)
wrt_cmd(0x7F+x); //0x7F+x
else if(y == 2)
wrt_cmd(0xBF+x); //0xBF+x

else if(y == 3)
wrt_cmd(0x93+x); //0x93+x

else if (y == 4)
wrt_cmd(0xD3+x); //0xD3+x

}





Tue Jan 06 2009, 08:38 pm
#9
you forgot the main function
Wed Jan 07 2009, 03:59 pm
#10
Hey Ajay, thats just apart of my program all the functions, in the main i call the init first and write "ABCDEFGHIJK" on the screen. U can c it displaying, the 20x4 LCD does not do it properly but the same circuit and same program 16x2 does. I checked in 4bit mode as well same thing is happening

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

DonaldJAX
Fri Apr 19 2024, 01:08 pm
Lewisuhakeply
Thu Apr 18 2024, 06:00 pm
Darrellciz
Thu Apr 18 2024, 11:07 am
Charlessber
Thu Apr 18 2024, 09:29 am
BartonSem
Thu Apr 18 2024, 04:56 am
DonaldKnown
Thu Apr 18 2024, 12:24 am
utaletxcyw
Wed Apr 17 2024, 10:21 am
Anthonyvab
Wed Apr 17 2024, 08:48 am