display lcd problem black square

Status
Not open for further replies.

Thread Starter

MED_TN

Joined Feb 21, 2013
15
Hi.
my program function well in ISIS proteus but in the real life it dosen't, the problem thats a have in the first line many black square.
i use a 4 bits configuration and 18f4550 pic.
thats my program please help me.
sorry for my bad level of english thats my first time in this forum.



sbit LCD_RS at LATB0_bit;
sbit LCD_EN at LATB1_bit;
sbit LCD_D4 at LATB2_bit;
sbit LCD_D5 at LATB3_bit;
sbit LCD_D6 at LATB4_bit;
sbit LCD_D7 at LATB5_bit;

// Pin direction
sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;


/****************************Programme Principal*********************/

void main()
{

TRISA=0x00;
TRISB=0x00;
PORTB.f0=0;
PORTA=0xFF;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);

delay_ms(500);
Lcd_Out(1,1,"bonjour");
delay_ms(500);
LCD_out(2,2,"Salut");
delay_ms(500);
}
 

tshuck

Joined Oct 18, 2012
3,534
1.) use code tags(click the '#' button while editing...) to put your code in a proper format.

2.). Add a while(1) to you code so the PC doesn't progress past your program memory usage....

Like:
Rich (BB code):
sbit LCD_RS at LATB0_bit;
sbit LCD_EN at LATB1_bit;
sbit LCD_D4 at LATB2_bit;
sbit LCD_D5 at LATB3_bit;
sbit LCD_D6 at LATB4_bit;
sbit LCD_D7 at LATB5_bit;

// Pin direction
sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;


/****************************Programme Principal*********************/

void main()
{

TRISA=0x00;
TRISB=0x00;
PORTB.f0=0;
PORTA=0xFF;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);

delay_ms(500);
Lcd_Out(1,1,"bonjour");
delay_ms(500);
LCD_out(2,2,"Salut");
delay_ms(500);
while(1);
}
 

ErnieM

Joined Apr 24, 2011
8,377
We can understand you well enough (and it's better then some native English speakers here).

Does your circuit do anything? There are things that stop a real PIC that ISIS proteus doesn't see, such as the oscillator or configuration bits. Can you get a pin to change state? Just turn it on high and leave it there, a voltmeter or even a LED can see if that worked.

Posting your whole schematic would help. Also if you post in the Embedded Systems and Microcontrollers forum here it gets better attention.

Welcome to the forums!
 

spinnaker

Joined Oct 29, 2009
7,830
Some will argue that this is always a symptom of an initialization problem which is a good argument but I have seen this issue caused by the contrast pin too.

So I would check twp things. First I would verify pin by pin that the LCD is wired the way you think it is wired. You can use a scope, logic analyzer, logic probe, voltmeter. Whatever you have. You can make a probe out of an led and resistor.

Next I would check that voltage on the contrast pin is changing as you change the potentiometer.
 

Thread Starter

MED_TN

Joined Feb 21, 2013
15
We can understand you well enough (and it's better then some native English speakers here).

Does your circuit do anything? There are things that stop a real PIC that ISIS proteus doesn't see, such as the oscillator or configuration bits. Can you get a pin to change state? Just turn it on high and leave it there, a voltmeter or even a LED can see if that worked.

Posting your whole schematic would help. Also if you post in the Embedded Systems and Microcontrollers forum here it gets better attention.

Welcome to the forums!
Thanks to youe answer i dont have the shematic now but i put the third pin (3) of the LCD in the GND i didn't use a pot and (do you think thats not wrong ??) and in my program i did'nt put a delay_ms before lcd_inti() i will changed and i will see what happened.
I use a led and it function very well so i thnik the pic dont have problem with my code.
please if you have any other solutions or idea give it to me and monday i will try all the solution in the university.
thx for all memeber i like this forum it is full with ideas.
 

Thread Starter

MED_TN

Joined Feb 21, 2013
15
also i I connected RW pin to Ground because i use the lcd only to write things and i see in others forum that it is wrong and i must connect R/W to a pin of the pic. thats true ????
and if i must do it what i must change in my program
Thx
 

tshuck

Joined Oct 18, 2012
3,534
Thanks to youe answer i dont have the shematic now but i put the third pin (3) of the LCD in the GND i didn't use a pot and (do you think thats not wrong ??) and in my program i did'nt put a delay_ms before lcd_inti() i will changed and i will see what happened.
I use a led and it function very well so i thnik the pic dont have problem with my code.
please if you have any other solutions or idea give it to me and monday i will try all the solution in the university.
thx for all memeber i like this forum it is full with ideas.
You need a potentiometer to adjust the contrast...otherwise you'll just see either nothing, or a bunch of black rectangles....

Follow this:
http://embedded-lab.com/blog/?p=203

reference:
http://www.bipom.com/documents/appnotes/LCD%20Interfacing%20using%20HD44780%20Hitachi%20chipset%20compatible%20LCD.pdf
 

ErnieM

Joined Apr 24, 2011
8,377
also i I connected RW pin to Ground because i use the lcd only to write things and i see in others forum that it is wrong and i must connect R/W to a pin of the pic. thats true ????
and if i must do it what i must change in my program
Thx
"Black squares" is either a contrast pot problem, or a bad initialization.

The LCD is capable of working just fine with the R/W pin grounded. However, you need to insert a delay to insure the LCD has completed what you just told it to do. I don't know what that delay is offhand but 1 mS may be good.

You DO need a "delay_ms before lcd_inti()" as you mentioned. In fact, sprinkle in all the delays you can think of, and even make them ridiculously long... 100 mS everywhere. Once it works you can experiment with shorter delays. Do add extra delays until you know your thing works.

Lastly, most every LCD needs that pot to set the contrast. No pot and the display can go "black squares."

I say "most" need the pot as I happen to own one that doesn't need the pot, ignores the pot, but works just fine if it is there or not. So once your works you can try removing the pot and see what happens.
 
Status
Not open for further replies.
Top