Page 1 of 1

LCD does not show up the characters

PostPosted: Sat Sep 28, 2013 11:58 pm
by mohdismiaswaly
Hello,

I am planning to display a string of characters using 16x2 LCD module.
Please see the photo below. I put the compiled code (hex file) into Proteus simulation. It does running normal.

But when I put the code inside my PIC18F4550 connected to all 16 pins of the LCD (TGK model bought from Cytron), there was just a block of black display appeared. I have check all the solder points, there are no short circuit between all 16 pins.

Simulation OK, but real hardware NOT OK.

How????

Re: LCD does not show up the characters

PostPosted: Sat Sep 28, 2013 11:59 pm
by mohdismiaswaly
Here is what I got from simulation in Proteus...

Re: LCD does not show up the characters

PostPosted: Sun Sep 29, 2013 12:12 am
by mohdismiaswaly
This is my code,
CODE: SELECT_ALL_CODE
#include<htc.h>

#define   RS         RB4
#define   E            RB5
#define     lcd         PORTD
         
void init_lcd(void);
void MSDelay(unsigned int itime);
void lcdcmd(unsigned char value);
void lcddata(unsigned char data);

void e_pulse(void);
void delay(unsigned short i);
void send_char(unsigned char data);
void send_char_end(unsigned char data);
void send_config(unsigned char data);
void lcd_goto(unsigned char data);
void lcd_clr(void);


void main(void)
{

   while(1)               
   {
      TRISB=0;
      TRISD=0;

      send_config(0b00000001);      //clear display at lcd
      send_config(0b00000010);      //Lcd Return to home
      send_config(0b00000110);      //entry mode-cursor increase 1
      send_config(0b00001100);      //diplay on, cursor off and cursor blink off
      send_config(0b00111000);      //function set
      
      lcd_goto(0);               //cursor start from beginning

      send_char('T');
      send_char('O');
      send_char('T');
      send_char('A');
      send_char('L');
      send_char(' ');
      send_char('P');
      send_char('A');
      send_char('R');
      send_char('K');
      send_char('I');
      send_char('N');
      send_char('G');
      send_char('=');
      send_char('6');
      
      lcd_goto(20);               //cursor go to 2nd line of the LCD
   
      send_char('E');
      send_char('M');
      send_char('P');
      send_char('T');
      send_char('Y');
      send_char('=');
      send_char('?');
      send_char(' ');
      send_char('H');
      send_char('O');
      send_char('V');
      send_char('E');
      send_char('R');
      send_char('=');
      send_char_end('?');      
      }
}

//==================subroutine LCD setting ==========================

void send_config(unsigned char data)
{
    RS=0;
   lcd=data;
   delay(500);
   e_pulse();
}

void e_pulse(void)
{
   E=1;
   delay(500);
   E=0;
   delay(500);
}

void send_char(unsigned char data)
{
    RS=1;
   lcd=data;
   delay(4000);
   e_pulse();
}

void send_char_end(unsigned char data)
{
    RS=1;
   lcd=data;
   delay(10000);
   e_pulse();
}


void lcd_goto(unsigned char data)
{
    if(data<16)
    {
        send_config(0x80+data);
   }
        else
        {
    data=data-20;
   send_config(0xc0+data);
        }
}


void lcd_clr(void)
{
    RS=0;
      send_config(0x01);
    delay(600);   
}


//==================subroutine DELAY==========================
void delay(unsigned short i)
{   
    for(;i>0;i--);
}

Re: LCD does not show up the characters

PostPosted: Sun Sep 29, 2013 9:55 pm
by robosang
I think the contrast is not adjusted correct, looking at 2 rows of black box on LCD.

Re: LCD does not show up the characters

PostPosted: Thu Oct 03, 2013 12:18 am
by mohdismiaswaly
You mean the connection of pin 15 and 16 on the lcd?

So I need to connect variable resistor in series to that pin?

Re: LCD does not show up the characters

PostPosted: Fri Oct 04, 2013 10:46 am
by yonghui
contrast is the vee pin. adjust the votalge value by changing resistor value.