Home - Search - Members
Full Version: 20X4 JHD 204A LCD..
KT
Jan 4 2009, 6:01 AM
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


Arun Kumar V
Jan 4 2009, 6:30 AM


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

Ajay
Jan 4 2009, 2:47 PM
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

KT
Jan 5 2009, 4:38 AM
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.
Ajay
Jan 5 2009, 8:19 AM
so is it working fine now?
KT
Jan 5 2009, 12:38 PM
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
Ajay
Jan 6 2009, 8:29 AM
can you paste the code here?
KT
Jan 6 2009, 9:53 AM
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

}





Ajay
Jan 6 2009, 10:08 AM
you forgot the main function
KT
Jan 7 2009, 5:29 AM
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
Arun Kumar V
Jan 7 2009, 10:57 AM


i think your 20x4 lcd is not initialized properly, this is a common mistake many newbies do, send 0x30 (30h) three times consecutively with a delay of 4.1 mS in between each send, then send 0x38 and rest of other regular commands( cursor, clear,direction etc).

reduce the init delay from 500msec to 15msec also check your busy flag checking routine.



Arun
KT
Jan 7 2009, 12:44 PM
Hey guys,

Finally got it working. Yup wot arun had pointed out about connections was right. Yes the culprit was the microcontroller socket, when i pushed the controller properly it started working properly. But still not able to understand how the 16x2 display worked :mad. And thank u guys.
Ajay
Jan 7 2009, 2:28 PM
congrats!

[Topic moved to 8051 discussion forum]
Arun Kumar V
Jan 8 2009, 4:17 AM

Yup wot arun had pointed out about connections was right




well, you owe me a "thanks button press" - buddy he he he



Arun
maverus
Jun 4 2009, 1:06 AM
Hey guys, Im using the same LCD however I keep getting a blinking cursor, that resets the value that was entered and it keeps going back to initial position then to position entered.
Please take a look at my code and give any pointers that would help, thanks in advance:
#include "headers.h"
#define RS PORTEbits.RE0
#define RW PORTEbits.RE1
#define EN PORTEbits.RE2

void init_1(void){
ADCON1=0x0F;
TRISE=0x00;
TRISC=0x00;
PORTE=0x00;
}
void LCD_busy(void)
{
unsigned char i,j;
for(i=0;i!=50;i++)
for(j=0;j!=255;j++);
}
void LCD_init(void){
PORTC=0x38;
RS=0;
RW=0;
EN=1;
EN=0;
LCD_busy();
PORTC=0x0D;
RS=0;
RW=0;
EN=1;
EN=1;
EN=0;
LCD_busy();
PORTC=0x01;
RS=0;
RW=0;
EN=1;
EN=1;
EN=0;
LCD_busy();
PORTC=0x07;
RS=0;
RW=0;
EN=1;
EN=1;
EN=0;
LCD_busy();
}
void LCD_command(unsigned char var){
PORTC=var;
RS=0;
RW=0;
EN=1;
EN=0;
LCD_busy();
}
void LCD_data(unsigned char data){
PORTC=data;
RS=1;
RW=0;
EN=1;
Delay10KTCYx(3);
EN=0;
LCD_busy();
}
void LCD_string( unsigned char *var){
while(*var)
LCD_data(*var++);
}

void main(void){
init_1();
LCD_init();
LCD_command(0x84);
LCD_data('L');
}
Ajay a
Jun 5 2009, 5:23 AM
in LCD_init function, try to send
PORTC=0x0C;

instead of
PORTC=0x0D;

and check again.
Chinmay Das
May 17 2011, 3:57 AM


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

Ajay Bhargav


it works
here is my AVR code for Atm16.

#include 
#define F_CPU 12000000
#define USART_BAUDRATE 9600 
#include
#include 
#include

#define comport PORTB
#define dataport PORTA

void LCD_intlz(void)
{
	wrcomm(0x0C);					// Display on Cursor off //

	wrcomm(0x01);					// clear  previous DDRAM content//	

	wrcomm(0x38);					// Function Set for 8-bit, 2 Line, 5x7 Dots //

	wrcomm(0x80);					//Force cursor to the beginning of 1st line//

	wrcomm(0x06);					//Right entry Mode//

	wrcomm(0x0f);					// Cursor Blinking On //

}



void wrcomm(unsigned char command)
{
dataport=command;
comport=0x04;
_delay_ms(10);
comport=0x00;
}

void wrdata(unsigned char data)
{
dataport = data;
comport =0x05; 
_delay_ms(20);
comport =0x01; 
 }

void LCD_Display(unsigned char *string)
{

	while(*string)
	wrdata(*string++);

}



void main()
{
DDRA=0xff;
DDRB=0xff;
LCD_intlz();
wrcomm(0x80);
LCD_Display(" Hello World 1");
wrcomm(0xC0);
LCD_Display(" Hello World 2");
wrcomm(0x94);
LCD_Display(" Hello World 3");
wrcomm(0xD4);
LCD_Display(" Hello World 4");
}




Chinmay Das
May 17 2011, 4:53 AM
here d img

In case u r intrest , that how m i interface d LCD lik micor commputer looks...




Chinmay Das
May 17 2011, 5:17 AM
here d disply

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Rickey's World © 2003 - 2007